summaryrefslogtreecommitdiff
path: root/otherlibs
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez@inria.fr>2017-07-18 13:03:54 +0200
committerDamien Doligez <damien.doligez@inria.fr>2017-07-18 13:03:54 +0200
commitf78128a7d723fa6002a08f5379a565da5022006a (patch)
treec4eec7c3cfd1f5a93a41e2223b525292ecd3f003 /otherlibs
parentd6bb4daa64d300d72a68b63e014076d7095ba65d (diff)
parent2d03974c1223bbd3f1535fde1be2f03148bbed82 (diff)
downloadocaml-f78128a7d723fa6002a08f5379a565da5022006a.tar.gz
merge 4.05 into trunk
Diffstat (limited to 'otherlibs')
-rw-r--r--otherlibs/bigarray/bigarray.mli109
-rw-r--r--otherlibs/raw_spacetime_lib/.depend18
-rw-r--r--otherlibs/threads/unix.ml15
-rw-r--r--otherlibs/unix/unix.mli3
4 files changed, 90 insertions, 55 deletions
diff --git a/otherlibs/bigarray/bigarray.mli b/otherlibs/bigarray/bigarray.mli
index 39d5bbb030..1234093aae 100644
--- a/otherlibs/bigarray/bigarray.mli
+++ b/otherlibs/bigarray/bigarray.mli
@@ -59,23 +59,20 @@
of abstract types for technical injectivity reasons).
*)
-type float32_elt = CamlinternalBigarray.float32_elt = Float32_elt
-type float64_elt = CamlinternalBigarray.float64_elt = Float64_elt
-type int8_signed_elt = CamlinternalBigarray.int8_signed_elt = Int8_signed_elt
-type int8_unsigned_elt = CamlinternalBigarray.int8_unsigned_elt =
- Int8_unsigned_elt
-type int16_signed_elt = CamlinternalBigarray.int16_signed_elt =
- Int16_signed_elt
-type int16_unsigned_elt = CamlinternalBigarray.int16_unsigned_elt =
- Int16_unsigned_elt
-type int32_elt = CamlinternalBigarray.int32_elt = Int32_elt
-type int64_elt = CamlinternalBigarray.int64_elt = Int64_elt
-type int_elt = CamlinternalBigarray.int_elt = Int_elt
-type nativeint_elt = CamlinternalBigarray.nativeint_elt = Nativeint_elt
-type complex32_elt = CamlinternalBigarray.complex32_elt = Complex32_elt
-type complex64_elt = CamlinternalBigarray.complex64_elt = Complex64_elt
-
-type ('a, 'b) kind = ('a, 'b) CamlinternalBigarray.kind =
+type float32_elt = Float32_elt
+type float64_elt = Float64_elt
+type int8_signed_elt = Int8_signed_elt
+type int8_unsigned_elt = Int8_unsigned_elt
+type int16_signed_elt = Int16_signed_elt
+type int16_unsigned_elt = Int16_unsigned_elt
+type int32_elt = Int32_elt
+type int64_elt = Int64_elt
+type int_elt = Int_elt
+type nativeint_elt = Nativeint_elt
+type complex32_elt = Complex32_elt
+type complex64_elt = Complex64_elt
+
+type ('a, 'b) kind =
Float32 : (float, float32_elt) kind
| Float64 : (float, float64_elt) kind
| Int8_signed : (int, int8_signed_elt) kind
@@ -181,11 +178,10 @@ val kind_size_in_bytes : ('a, 'b) kind -> int
(** {6 Array layouts} *)
-type c_layout = CamlinternalBigarray.c_layout = C_layout_typ (**)
+type c_layout = C_layout_typ (**)
(** See {!Bigarray.fortran_layout}.*)
-type fortran_layout = CamlinternalBigarray.fortran_layout =
- Fortran_layout_typ (**)
+type fortran_layout = Fortran_layout_typ (**)
(** To facilitate interoperability with existing C and Fortran code,
this library supports two different memory layouts for big arrays,
one compatible with the C conventions,
@@ -216,7 +212,7 @@ type fortran_layout = CamlinternalBigarray.fortran_layout =
re-exported as values below for backward-compatibility reasons.
*)
-type 'a layout = 'a CamlinternalBigarray.layout =
+type 'a layout =
C_layout: c_layout layout
| Fortran_layout: fortran_layout layout
@@ -228,7 +224,7 @@ val fortran_layout : fortran_layout layout
module Genarray :
sig
- type ('a, 'b, 'c) t = ('a, 'b, 'c) CamlinternalBigarray.genarray
+ type ('a, 'b, 'c) t
(** The type [Genarray.t] is the type of big arrays with variable
numbers of dimensions. Any number of dimensions between 0 and 16
is supported.
@@ -441,10 +437,53 @@ module Genarray :
val map_file:
Unix.file_descr -> ?pos:int64 -> ('a, 'b) kind -> 'c layout ->
bool -> int array -> ('a, 'b, 'c) t
- [@@ocaml.deprecated "\
-Use Unix.map_file instead.\n\
-Note that Bigarray.Genarray.map_file raises Sys_error while\n\
-Unix.map_file raises Unix_error."]
+ (** Memory mapping of a file as a big array.
+ [Genarray.map_file fd kind layout shared dims]
+ returns a big array of kind [kind], layout [layout],
+ and dimensions as specified in [dims]. The data contained in
+ this big array are the contents of the file referred to by
+ the file descriptor [fd] (as opened previously with
+ [Unix.openfile], for example). The optional [pos] parameter
+ is the byte offset in the file of the data being mapped;
+ it defaults to 0 (map from the beginning of the file).
+
+ If [shared] is [true], all modifications performed on the array
+ are reflected in the file. This requires that [fd] be opened
+ with write permissions. If [shared] is [false], modifications
+ performed on the array are done in memory only, using
+ copy-on-write of the modified pages; the underlying file is not
+ affected.
+
+ [Genarray.map_file] is much more efficient than reading
+ the whole file in a big array, modifying that big array,
+ and writing it afterwards.
+
+ To adjust automatically the dimensions of the big array to
+ the actual size of the file, the major dimension (that is,
+ the first dimension for an array with C layout, and the last
+ dimension for an array with Fortran layout) can be given as
+ [-1]. [Genarray.map_file] then determines the major dimension
+ from the size of the file. The file must contain an integral
+ number of sub-arrays as determined by the non-major dimensions,
+ otherwise [Failure] is raised.
+
+ If all dimensions of the big array are given, the file size is
+ matched against the size of the big array. If the file is larger
+ than the big array, only the initial portion of the file is
+ mapped to the big array. If the file is smaller than the big
+ array, the file is automatically grown to the size of the big array.
+ This requires write permissions on [fd].
+
+ Array accesses are bounds-checked, but the bounds are determined by
+ the initial call to [map_file]. Therefore, you should make sure no
+ other process modifies the mapped file while you're accessing it,
+ or a SIGBUS signal may be raised. This happens, for instance, if the
+ file is shrunk.
+
+ This function raises [Sys_error] in the case of any errors from the
+ underlying system calls. [Invalid_argument] or [Failure] may be
+ raised in cases where argument validation fails. *)
+
end
(** {6 Zero-dimensional arrays} *)
@@ -592,10 +631,8 @@ module Array1 : sig
val map_file: Unix.file_descr -> ?pos:int64 -> ('a, 'b) kind -> 'c layout ->
bool -> int -> ('a, 'b, 'c) t
- [@@ocaml.deprecated "\
-Use [array1_of_genarray (Unix.map_file ...)] instead.\n\
-Note that Bigarray.Array1.map_file raises Sys_error while\n\
-Unix.map_file raises Unix_error."]
+ (** Memory mapping of a file as a one-dimensional big array.
+ See {!Bigarray.Genarray.map_file} for more details. *)
external unsafe_get: ('a, 'b, 'c) t -> int -> 'a = "%caml_ba_unsafe_ref_1"
(** Like {!Bigarray.Array1.get}, but bounds checking is not always performed.
@@ -717,10 +754,8 @@ module Array2 :
val map_file: Unix.file_descr -> ?pos:int64 -> ('a, 'b) kind -> 'c layout ->
bool -> int -> int -> ('a, 'b, 'c) t
- [@@ocaml.deprecated "\
-Use [array2_of_genarray (Unix.map_file ...)] instead.\n\
-Note that Bigarray.Array2.map_file raises Sys_error while\n\
-Unix.map_file raises Unix_error."]
+ (** Memory mapping of a file as a two-dimensional big array.
+ See {!Bigarray.Genarray.map_file} for more details. *)
external unsafe_get: ('a, 'b, 'c) t -> int -> int -> 'a
= "%caml_ba_unsafe_ref_2"
@@ -865,10 +900,8 @@ module Array3 :
val map_file: Unix.file_descr -> ?pos:int64 -> ('a, 'b) kind -> 'c layout ->
bool -> int -> int -> int -> ('a, 'b, 'c) t
- [@@ocaml.deprecated "\
-Use [array3_of_genarray (Unix.map_file ...)] instead.\n\
-Note that Bigarray.Array3.map_file raises Sys_error while\n\
-Unix.map_file raises Unix_error."]
+ (** Memory mapping of a file as a three-dimensional big array.
+ See {!Bigarray.Genarray.map_file} for more details. *)
external unsafe_get: ('a, 'b, 'c) t -> int -> int -> int -> 'a
= "%caml_ba_unsafe_ref_3"
diff --git a/otherlibs/raw_spacetime_lib/.depend b/otherlibs/raw_spacetime_lib/.depend
index 18fc1804b2..515304f035 100644
--- a/otherlibs/raw_spacetime_lib/.depend
+++ b/otherlibs/raw_spacetime_lib/.depend
@@ -1,3 +1,21 @@
raw_spacetime_lib.cmo : raw_spacetime_lib.cmi
raw_spacetime_lib.cmx : raw_spacetime_lib.cmi
raw_spacetime_lib.cmi :
+raw_spacetime_lib.cmo : raw_spacetime_lib.cmi
+raw_spacetime_lib.cmx : raw_spacetime_lib.cmi
+raw_spacetime_lib.cmi :
+raw_spacetime_lib.cmo : raw_spacetime_lib.cmi
+raw_spacetime_lib.cmx : raw_spacetime_lib.cmi
+raw_spacetime_lib.cmi :
+raw_spacetime_lib.cmo : raw_spacetime_lib.cmi
+raw_spacetime_lib.cmx : raw_spacetime_lib.cmi
+raw_spacetime_lib.cmi :
+raw_spacetime_lib.cmo : raw_spacetime_lib.cmi
+raw_spacetime_lib.cmx : raw_spacetime_lib.cmi
+raw_spacetime_lib.cmi :
+raw_spacetime_lib.cmo : raw_spacetime_lib.cmi
+raw_spacetime_lib.cmx : raw_spacetime_lib.cmi
+raw_spacetime_lib.cmi :
+raw_spacetime_lib.cmo : raw_spacetime_lib.cmi
+raw_spacetime_lib.cmx : raw_spacetime_lib.cmi
+raw_spacetime_lib.cmi :
diff --git a/otherlibs/threads/unix.ml b/otherlibs/threads/unix.ml
index 261b87fc39..143100eb2a 100644
--- a/otherlibs/threads/unix.ml
+++ b/otherlibs/threads/unix.ml
@@ -320,21 +320,6 @@ module LargeFile =
external fstat : file_descr -> stats = "unix_fstat_64"
end
-type map_file_impl =
- { map_file_impl
- : 'a 'b 'c. file_descr
- -> ('a, 'b) CamlinternalBigarray.kind
- -> 'c CamlinternalBigarray.layout
- -> bool
- -> int array
- -> int64
- -> ('a, 'b, 'c) CamlinternalBigarray.genarray
- }
-let map_file_impl =
- ref { map_file_impl = fun _ _ _ _ _ _ -> failwith "Bigarray not initialized!" }
-let map_file fd ?(pos=0L) kind layout shared dims =
- !map_file_impl.map_file_impl fd kind layout shared dims pos
-
type access_permission =
R_OK
| W_OK
diff --git a/otherlibs/unix/unix.mli b/otherlibs/unix/unix.mli
index 318a5b086c..d134157061 100644
--- a/otherlibs/unix/unix.mli
+++ b/otherlibs/unix/unix.mli
@@ -541,7 +541,7 @@ val map_file :
[Invalid_argument] or [Failure] may be raised in cases where argument
validation fails.
- @since 4.05.0 *)
+ @since 4.06.0 *)
(** {6 Operations on file names} *)
@@ -1671,4 +1671,3 @@ val setsid : unit -> int
its controlling terminal.
On Windows, not implemented. *)
-