Skip to content

Commit

Permalink
Add {Sys,Unix,UnixLabels}.io_buffer_size functions
Browse files Browse the repository at this point in the history
  • Loading branch information
EruEri committed Nov 4, 2024
1 parent 9ddc048 commit 8388a24
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions otherlibs/unix/read_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ CAMLprim value caml_unix_read_bigarray(value vfd, value vbuf,
if (ret == -1) caml_uerror("read_bigarray", Nothing);
CAMLreturn(Val_long(ret));
}

CAMLprim value caml_unix_io_buffer_size(value unit)
{
return Val_long(UNIX_BUFFER_SIZE);
}
5 changes: 5 additions & 0 deletions otherlibs/unix/read_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,8 @@ CAMLprim value caml_unix_read_bigarray(value fd, value vbuf,
}
CAMLreturn(Val_int(numread));
}

CAMLprim value caml_unix_io_buffer_size(value unit)
{
return Val_long(UNIX_BUFFER_SIZE);
}
6 changes: 6 additions & 0 deletions otherlibs/unix/unix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ val stdout : file_descr
val stderr : file_descr
(** File descriptor for standard error. *)

val io_buffer_size: int
(** Size of the unix io buffers
@since 5.4
*)

type open_flag =
O_RDONLY (** Open for reading *)
| O_WRONLY (** Open for writing *)
Expand Down
6 changes: 6 additions & 0 deletions otherlibs/unix/unixLabels.mli
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ val stdout : file_descr
val stderr : file_descr
(** File descriptor for standard error. *)

val io_buffer_size: int
(** Size of the unix io buffers
@since 5.4
*)

type open_flag = Unix.open_flag =
O_RDONLY (** Open for reading *)
| O_WRONLY (** Open for writing *)
Expand Down
3 changes: 3 additions & 0 deletions otherlibs/unix/unix_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ let stdin = 0
let stdout = 1
let stderr = 2

external io_buffer_size : unit -> int = "caml_unix_io_buffer_size"
let io_buffer_size = io_buffer_size ()

type open_flag =
O_RDONLY
| O_WRONLY
Expand Down
3 changes: 3 additions & 0 deletions otherlibs/unix/unix_win32.ml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ let stdin = filedescr_of_unix_fd_num 0
let stdout = filedescr_of_unix_fd_num 1
let stderr = filedescr_of_unix_fd_num 2

external io_buffer_size : unit -> int = "caml_unix_io_buffer_size"
let io_buffer_size = io_buffer_size ()

type open_flag =
O_RDONLY
| O_WRONLY
Expand Down
5 changes: 5 additions & 0 deletions runtime/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,11 @@ CAMLprim value caml_sys_const_max_wosize(value unit)
return Val_long(Max_wosize) ;
}

CAMLprim value caml_sys_io_buffer_size(value unit)
{
return Val_long(IO_BUFFER_SIZE);
}

CAMLprim value caml_sys_const_ostype_unix(value unit)
{
return Val_bool(0 == strcmp(OCAML_OS_TYPE,"Unix"));
Expand Down
3 changes: 3 additions & 0 deletions stdlib/sys.ml.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ external rmdir: string -> unit = "caml_sys_rmdir"
external getcwd: unit -> string = "caml_sys_getcwd"
external readdir : string -> string array = "caml_sys_read_directory"

external io_buffer_size: unit -> int = "caml_sys_io_buffer_size"
let io_buffer_size = io_buffer_size ()

let interactive = ref false

type signal_behavior =
Expand Down
6 changes: 6 additions & 0 deletions stdlib/sys.mli
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ external readdir : string -> string array = "caml_sys_read_directory"
in any specific order; they are not, in particular, guaranteed to
appear in alphabetical order. *)

val io_buffer_size: int
(** Size of the buffer channels
@since 5.4
*)

val interactive : bool ref
[@@alert unsynchronized_access
"The interactive status is a mutable global state."
Expand Down

0 comments on commit 8388a24

Please sign in to comment.