diff options
author | Gabriel Scherer <gabriel.scherer@gmail.com> | 2014-11-17 12:21:46 +0000 |
---|---|---|
committer | Gabriel Scherer <gabriel.scherer@gmail.com> | 2014-11-17 12:21:46 +0000 |
commit | 8b59f8faef194a4385fa70be46acaed07abef4a0 (patch) | |
tree | 8996b07e05599247042d65e486a82afda470ff00 /stdlib | |
parent | 82df1b9fb9dc9f3b937e9965fd807f23eabe1584 (diff) |
Sys: Use constant for some runtime limitations. After bootstrap
From: Hugo Heuzard <hugo.heuzard@gmail.com>
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15590 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/sys.mli | 3 | ||||
-rw-r--r-- | stdlib/sys.mlp | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/stdlib/sys.mli b/stdlib/sys.mli index ae175c2e8..57c77608a 100644 --- a/stdlib/sys.mli +++ b/stdlib/sys.mli @@ -99,6 +99,9 @@ val word_size : int (** Size of one word on the machine currently executing the OCaml program, in bits: 32 or 64. *) +val int_size : int +(** Size of one int, in bits: 31 or 63. *) + val big_endian : bool (** Whether the machine currently executing the Caml program is big-endian. @since 4.00.0 *) diff --git a/stdlib/sys.mlp b/stdlib/sys.mlp index c54fcb821..c7b9e9cd1 100644 --- a/stdlib/sys.mlp +++ b/stdlib/sys.mlp @@ -21,6 +21,8 @@ external get_config: unit -> string * int * bool = "caml_sys_get_config" external get_argv: unit -> string * string array = "caml_sys_get_argv" external big_endian : unit -> bool = "%big_endian" external word_size : unit -> int = "%word_size" +external int_size : unit -> int = "%int_size" +external max_wosize : unit -> int = "%max_wosize" external unix : unit -> bool = "%ostype_unix" external win32 : unit -> bool = "%ostype_win32" external cygwin : unit -> bool = "%ostype_cygwin" @@ -29,10 +31,11 @@ let (executable_name, argv) = get_argv() let (os_type, _, _) = get_config() let big_endian = big_endian () let word_size = word_size () +let int_size = int_size () let unix = unix () let win32 = win32 () let cygwin = cygwin () -let max_array_length = (1 lsl (word_size - 10)) - 1;; +let max_array_length = max_wosize () let max_string_length = word_size / 8 * max_array_length - 1;; external file_exists: string -> bool = "caml_sys_file_exists" |