package core

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Core.SysSource

include module type of struct include Base.Sys end
Sourceval get_argv : unit -> string array

The command line arguments given to the process. The first element is the command name used to invoke the program. The following elements are the command-line arguments given to the program.

When running in JavaScript in the browser, it is [| "a.out" |].

get_argv is a function because the external function caml_sys_modify_argv can replace the array starting in OCaml 4.09.

Sourceval argv : string array

A single result from get_argv (). This value is indefinitely deprecated. It is kept for compatibility with Stdlib.Sys.

  • deprecated [since 2019-08] Use [Sys.get_argv] instead, which has the correct behavior when [caml_sys_modify_argv] is called.
Sourceval interactive : bool ref

interactive is set to true when being executed in the ocaml REPL, and false otherwise.

Sourceval os_type : string

os_type describes the operating system that the OCaml program is running on.

Its value is one of:

  • "Unix" (for all Unix versions, including Linux and macOS);
  • "Win32" (for MS-Windows, OCaml compiled with MSVC++ or MinGW); or
  • "Cygwin" (for MS-Windows, OCaml compiled with Cygwin)

When running in JavaScript, it is "Unix".

Sourceval unix : bool

unix is true if os_type = "Unix".

Sourceval win32 : bool

win32 is true if os_type = "Win32".

Sourceval cygwin : bool

cygwin is true if os_type = "Cygwin".

Sourcetype backend_type = Sys.backend_type =
  1. | Native
  2. | Bytecode
  3. | Other of string

Currently, the official distribution only supports Native and Bytecode, but it can be other backends with alternative compilers, for example, JavaScript.

Sourceval backend_type : backend_type

Backend type currently executing the OCaml program.

Sourceval word_size_in_bits : int

word_size_in_bits is the number of bits in one word on the machine currently executing the OCaml program. Generally speaking it will be either 32 or 64. When running in JavaScript, it will be 32.

Sourceval int_size_in_bits : int

int_size_in_bits is the number of bits in the int type. Generally, on 32-bit platforms, its value will be 31, and on 64 bit platforms its value will be 63. When running in JavaScript, it will be 32. Int.num_bits is the same as this value.

Sourceval big_endian : bool

big_endian is true when the program is running on a big-endian architecture. When running in JavaScript, it will be false.

Sourceval max_string_length : int

max_string_length is the maximum allowed length of a string or Bytes.t. String.max_length is the same as this value.

Sourceval max_array_length : int

max_array_length is the maximum allowed length of an 'a array. Array.max_length is the same as this value.

Sourceval runtime_variant : unit -> string

Returns the name of the runtime variant the program is running on. This is normally the argument given to -runtime-variant at compile time, but for byte-code it can be changed after compilation.

When running in JavaScript or utop it will be "", while if compiled with DEBUG (debugging of the runtime) it will be "d", and if compiled with CAML_INSTR (instrumentation of the runtime) it will be "i".

Sourceval runtime_parameters : unit -> string

Returns the value of the runtime parameters, in the same format as the contents of the OCAMLRUNPARAM environment variable. When running in JavaScript, it will be "".

Sourceval ocaml_version : string

ocaml_version is the OCaml version with which the program was compiled. It is a string of the form "major.minor[.patchlevel][+additional-info]", where major, minor, and patchlevel are integers, and additional-info is an arbitrary string. The [.patchlevel] and [+additional-info] parts may be absent.

Sourceval enable_runtime_warnings : bool -> unit

Controls whether the OCaml runtime system can emit warnings on stderr. Currently, the only supported warning is triggered when a channel created by open_* functions is finalized without being closed. Runtime warnings are enabled by default.

Sourceval runtime_warnings_enabled : unit -> bool

Returns whether runtime warnings are currently enabled.

Sourceval getenv : string -> string option

Return the value associated to a variable in the process environment. Return None if the variable is unbound or the process has special privileges, as determined by secure_getenv(3) on Linux.

Sourceval getenv_exn : string -> string
Sourceval opaque_identity : 'a -> 'a

For the purposes of optimization, opaque_identity behaves like an unknown (and thus possibly side-effecting) function. At runtime, opaque_identity disappears altogether. A typical use of this function is to prevent pure computations from being optimized away in benchmarking loops. For example:

  for _round = 1 to 100_000 do
    ignore (Sys.opaque_identity (my_pure_computation ()))
  done
Sourceval opaque_identity_global : 'a -> 'a

Like opaque_identity. Forces its argument to be globally allocated.

quote s quotes the string in a format suitable for the shell of the current system (e.g. suitable for command). On Unix, this function only quotes as necessary, which makes its output more legible than Filename.quote.

WARNING: This may not work with some shells, but should work with sh, bash, and zsh.

Converts a list of tokens to a command line fragment that can be passed to the shell of the current system. Each token is escaped as appropriate using quote.

Sourceval c_int_size : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval catch_break : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval chdir : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval command : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval command_exn : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval executable_name : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval execution_mode : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval file_exists : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval file_exists_exn : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval fold_dir : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval getcwd : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval home_directory : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval is_directory : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval is_directory_exn : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval is_file : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval is_file_exn : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval ls_dir : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval override_argv : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval readdir : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval remove : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval rename : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval unsafe_getenv : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceval unsafe_getenv_exn : [ `Use_Sys_unix ]
  • deprecated [since 2021-04] Use [Sys_unix]
Sourceexception Break
  • deprecated [since 2021-04] Use [Sys_unix]
OCaml

Innovation. Community. Security.