1 (***********************************************************************)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
7 (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 (* en Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the GNU Library General Public License, with *)
10 (* the special exception on linking described in file ../LICENSE. *)
12 (* Portions (C) Edgar Friendly <thelema314@gmail.com> *)
13 (***********************************************************************)
17 (* WARNING: sys.ml is generated from sys.mlp. DO NOT EDIT sys.ml or
18 your changes will be lost.
21 (* System interface *)
23 external get_config: unit -> string * int = "caml_sys_get_config"
24 external get_argv: unit -> string * string array = "caml_sys_get_argv"
26 let (executable_name, argv) = get_argv()
27 let (os_type, word_size) = get_config()
28 let max_array_length = (1 lsl (word_size - 10)) - 1;;
29 let max_string_length = word_size / 8 * max_array_length - 1;;
31 external file_exists: string -> bool = "caml_sys_file_exists"
32 external is_directory : string -> bool = "caml_sys_is_directory"
33 external remove: string -> unit = "caml_sys_remove"
34 external rename : string -> string -> unit = "caml_sys_rename"
35 external getenv: string -> string = "caml_sys_getenv"
36 external command: string -> int = "caml_sys_system_command"
37 external time: unit -> float = "caml_sys_time"
44 external chdir: string -> unit = "caml_sys_chdir"
45 external getcwd: unit -> string = "caml_sys_getcwd"
46 external readdir : string -> string array = "caml_sys_read_directory"
48 let interactive = ref false
50 type signal_behavior =
53 | Signal_handle of (int -> unit)
55 external signal : int -> signal_behavior -> signal_behavior
56 = "caml_install_signal_handler"
58 let set_signal sig_num sig_beh = ignore(signal sig_num sig_beh)
82 module Signal = struct
83 type t = SIGABRT | SIGALRM | SIGFPE | SIGHUP | SIGILL | SIGINT | SIGKILL | SIGPIPE | SIGQUIT | SIGSEGV | SIGTERM | SIGUSR1 | SIGUSR2 | SIGCHLD | SIGCONT | SIGSTOP | SIGTSTP | SIGTTIN | SIGTTOU | SIGVTALRM | SIGPROF | SIGOther of int
85 let of_int = function -1 -> SIGABRT | -2 -> SIGALRM | -3 -> SIGFPE | -4 -> SIGHUP | -5 -> SIGILL | -6 -> SIGINT | -7 -> SIGKILL | -8 -> SIGPIPE | -9 -> SIGQUIT | -10 -> SIGSEGV | -11 -> SIGTERM | -12 -> SIGUSR1 | -13 -> SIGUSR2 | -14 -> SIGCHLD | -15 -> SIGCONT | -16 -> SIGSTOP | -17 -> SIGTSTP | -18 -> SIGTTIN | -19 -> SIGTTOU | -20 -> SIGVTALRM | -21 -> SIGPROF | x -> SIGOther x
87 let to_int = function SIGABRT -> -1 | SIGALRM -> -2 | SIGFPE -> -3 | SIGHUP -> -4 | SIGILL -> -5 | SIGINT -> -6 | SIGKILL -> -7 | SIGPIPE -> -8 | SIGQUIT -> -9 | SIGSEGV -> -10 | SIGTERM -> -11 | SIGUSR1 -> -12 | SIGUSR2 -> -13 | SIGCHLD -> -14 | SIGCONT -> -15 | SIGSTOP -> -16 | SIGTSTP -> -17 | SIGTTIN -> -18 | SIGTTOU -> -19 | SIGVTALRM -> -20 | SIGPROF -> -21 | SIGOther x -> x
89 let set_signal sig_var sig_beh = ignore(signal (to_int sig_var) sig_beh)
96 set_signal sigint (Signal_handle(fun _ -> raise Break))
98 set_signal sigint Signal_default
101 (* The version string is found in file ../VERSION *)
103 let ocaml_version = "%%VERSION%%";;