diff options
author | Damien Doligez <damien.doligez@inria.fr> | 2017-07-13 20:00:39 +0200 |
---|---|---|
committer | Damien Doligez <damien.doligez@inria.fr> | 2017-07-18 13:11:36 +0200 |
commit | c05a851e041d74578ed2ef964a0a96bfd9d1b5db (patch) | |
tree | 0c8482c6ccd60a18f3acd3cedf4c0f4749bbffb0 | |
parent | f78128a7d723fa6002a08f5379a565da5022006a (diff) | |
download | ocaml-c05a851e041d74578ed2ef964a0a96bfd9d1b5db.tar.gz |
fix up the merge of 4.05 into trunk
-rw-r--r-- | Changes | 4 | ||||
-rw-r--r-- | bytecomp/typeopt.ml | 2 | ||||
-rw-r--r-- | otherlibs/bigarray/bigarray.mli | 109 | ||||
-rw-r--r-- | otherlibs/threads/unix.ml | 15 | ||||
-rw-r--r-- | stdlib/.depend | 4 | ||||
-rw-r--r-- | stdlib/Makefile | 2 | ||||
-rw-r--r-- | stdlib/camlinternalBigarray.ml | 54 | ||||
-rw-r--r-- | testsuite/tests/lib-bigarray-file/mapfile.ml | 10 | ||||
-rw-r--r-- | testsuite/tests/lib-bigarray/bigarrays.ml | 55 | ||||
-rw-r--r-- | testsuite/tests/lib-bigarray/bigarrays.reference | 2 | ||||
-rw-r--r-- | testsuite/tests/lib-dynlink-csharp/Makefile | 2 | ||||
-rw-r--r-- | testsuite/tests/lib-dynlink-csharp/bytecode.reference | 1 | ||||
-rwxr-xr-x | testsuite/tests/lib-dynlink-csharp/main.ml | 16 | ||||
-rw-r--r-- | testsuite/tests/lib-dynlink-csharp/native.reference | 1 |
14 files changed, 133 insertions, 144 deletions
@@ -42,7 +42,7 @@ Working version Mark Shinwell and Leo White) - MPR#7531, GPR#1162: Erroneous code transformation at partial applications - (Mark Shinwell) + (Mark Shinwell) ### Standard library: @@ -295,6 +295,8 @@ Next major version (4.05.0): ---------------------------- OCaml 4.05.0 (TBD): ---------------------------- +OCaml 4.05.0 (13 Jul 2017): +--------------------------- (Changes that can break existing programs are marked with a "*") diff --git a/bytecomp/typeopt.ml b/bytecomp/typeopt.ml index 93b7ec6559..4416cf92b6 100644 --- a/bytecomp/typeopt.ml +++ b/bytecomp/typeopt.ml @@ -118,7 +118,7 @@ let array_pattern_kind pat = array_type_kind pat.pat_env pat.pat_type let bigarray_decode_type env ty tbl dfl = match scrape env ty with | Tconstr(Pdot(Pident mod_id, type_name, _), [], _) - when Ident.name mod_id = "Bigarray" -> + when Ident.name mod_id = "CamlinternalBigarray" -> begin try List.assoc type_name tbl with Not_found -> dfl end | _ -> dfl diff --git a/otherlibs/bigarray/bigarray.mli b/otherlibs/bigarray/bigarray.mli index 1234093aae..39d5bbb030 100644 --- a/otherlibs/bigarray/bigarray.mli +++ b/otherlibs/bigarray/bigarray.mli @@ -59,20 +59,23 @@ of abstract types for technical injectivity reasons). *) -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 = +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 = Float32 : (float, float32_elt) kind | Float64 : (float, float64_elt) kind | Int8_signed : (int, int8_signed_elt) kind @@ -178,10 +181,11 @@ val kind_size_in_bytes : ('a, 'b) kind -> int (** {6 Array layouts} *) -type c_layout = C_layout_typ (**) +type c_layout = CamlinternalBigarray.c_layout = C_layout_typ (**) (** See {!Bigarray.fortran_layout}.*) -type fortran_layout = Fortran_layout_typ (**) +type fortran_layout = CamlinternalBigarray.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, @@ -212,7 +216,7 @@ type fortran_layout = Fortran_layout_typ (**) re-exported as values below for backward-compatibility reasons. *) -type 'a layout = +type 'a layout = 'a CamlinternalBigarray.layout = C_layout: c_layout layout | Fortran_layout: fortran_layout layout @@ -224,7 +228,7 @@ val fortran_layout : fortran_layout layout module Genarray : sig - type ('a, 'b, 'c) t + type ('a, 'b, 'c) t = ('a, 'b, 'c) CamlinternalBigarray.genarray (** 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. @@ -437,53 +441,10 @@ module Genarray : val map_file: Unix.file_descr -> ?pos:int64 -> ('a, 'b) kind -> 'c layout -> bool -> int array -> ('a, 'b, 'c) t - (** 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. *) - + [@@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."] end (** {6 Zero-dimensional arrays} *) @@ -631,8 +592,10 @@ module Array1 : sig val map_file: Unix.file_descr -> ?pos:int64 -> ('a, 'b) kind -> 'c layout -> bool -> int -> ('a, 'b, 'c) t - (** Memory mapping of a file as a one-dimensional big array. - See {!Bigarray.Genarray.map_file} for more details. *) + [@@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."] 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. @@ -754,8 +717,10 @@ module Array2 : val map_file: Unix.file_descr -> ?pos:int64 -> ('a, 'b) kind -> 'c layout -> bool -> int -> int -> ('a, 'b, 'c) t - (** Memory mapping of a file as a two-dimensional big array. - See {!Bigarray.Genarray.map_file} for more details. *) + [@@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."] external unsafe_get: ('a, 'b, 'c) t -> int -> int -> 'a = "%caml_ba_unsafe_ref_2" @@ -900,8 +865,10 @@ module Array3 : val map_file: Unix.file_descr -> ?pos:int64 -> ('a, 'b) kind -> 'c layout -> bool -> int -> int -> int -> ('a, 'b, 'c) t - (** Memory mapping of a file as a three-dimensional big array. - See {!Bigarray.Genarray.map_file} for more details. *) + [@@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."] external unsafe_get: ('a, 'b, 'c) t -> int -> int -> int -> 'a = "%caml_ba_unsafe_ref_3" diff --git a/otherlibs/threads/unix.ml b/otherlibs/threads/unix.ml index 143100eb2a..261b87fc39 100644 --- a/otherlibs/threads/unix.ml +++ b/otherlibs/threads/unix.ml @@ -320,6 +320,21 @@ 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/stdlib/.depend b/stdlib/.depend index 1ed2bedad0..4ac015ad66 100644 --- a/stdlib/.depend +++ b/stdlib/.depend @@ -21,6 +21,8 @@ bytesLabels.cmi : callback.cmo : obj.cmi callback.cmi callback.cmx : obj.cmx callback.cmi callback.cmi : +camlinternalBigarray.cmo : complex.cmi +camlinternalBigarray.cmx : complex.cmx camlinternalFormat.cmo : sys.cmi string.cmi char.cmi \ camlinternalFormatBasics.cmi bytes.cmi buffer.cmi camlinternalFormat.cmi camlinternalFormat.cmx : sys.cmx string.cmx char.cmx \ @@ -200,6 +202,8 @@ bytesLabels.cmo : bytes.cmi bytesLabels.cmi bytesLabels.p.cmx : bytes.cmx bytesLabels.cmi callback.cmo : obj.cmi callback.cmi callback.p.cmx : obj.cmx callback.cmi +camlinternalBigarray.cmo : complex.cmi +camlinternalBigarray.p.cmx : complex.cmx camlinternalFormat.cmo : sys.cmi string.cmi char.cmi \ camlinternalFormatBasics.cmi bytes.cmi buffer.cmi camlinternalFormat.cmi camlinternalFormat.p.cmx : sys.cmx string.cmx char.cmx \ diff --git a/stdlib/Makefile b/stdlib/Makefile index 6a863bc77f..5f7bde13e3 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -48,7 +48,7 @@ OTHERS=list.cmo char.cmo uchar.cmo bytes.cmo string.cmo sys.cmo \ filename.cmo complex.cmo \ arrayLabels.cmo listLabels.cmo bytesLabels.cmo \ stringLabels.cmo moreLabels.cmo stdLabels.cmo \ - spacetime.cmo + spacetime.cmo camlinternalBigarray.cmo .PHONY: all all: stdlib.cma std_exit.cmo camlheader target_camlheader camlheader_ur diff --git a/stdlib/camlinternalBigarray.ml b/stdlib/camlinternalBigarray.ml new file mode 100644 index 0000000000..9f1639ed96 --- /dev/null +++ b/stdlib/camlinternalBigarray.ml @@ -0,0 +1,54 @@ +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Manuel Serrano and Xavier Leroy, INRIA Rocquencourt *) +(* *) +(* Copyright 2000 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +(* Bigarray types. These must be kept in sync with the tables in + ../bytecomp/typeopt.ml *) + +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 + | Int8_unsigned : (int, int8_unsigned_elt) kind + | Int16_signed : (int, int16_signed_elt) kind + | Int16_unsigned : (int, int16_unsigned_elt) kind + | Int32 : (int32, int32_elt) kind + | Int64 : (int64, int64_elt) kind + | Int : (int, int_elt) kind + | Nativeint : (nativeint, nativeint_elt) kind + | Complex32 : (Complex.t, complex32_elt) kind + | Complex64 : (Complex.t, complex64_elt) kind + | Char : (char, int8_unsigned_elt) kind + +type c_layout = C_layout_typ +type fortran_layout = Fortran_layout_typ + +type 'a layout = + C_layout: c_layout layout + | Fortran_layout: fortran_layout layout + +type ('a, 'b, 'c) genarray diff --git a/testsuite/tests/lib-bigarray-file/mapfile.ml b/testsuite/tests/lib-bigarray-file/mapfile.ml index 3c814a2721..aeed7258f9 100644 --- a/testsuite/tests/lib-bigarray-file/mapfile.ml +++ b/testsuite/tests/lib-bigarray-file/mapfile.ml @@ -33,14 +33,14 @@ let tests () = Unix.openfile mapped_file [Unix.O_RDWR; Unix.O_TRUNC; Unix.O_CREAT] 0o666 in let a = - array1_of_genarray (Genarray.map_file fd float64 c_layout true [|10000|]) + array1_of_genarray (Unix.map_file fd float64 c_layout true [|10000|]) in Unix.close fd; for i = 0 to 9999 do a.{i} <- float i done; let fd = Unix.openfile mapped_file [Unix.O_RDONLY] 0 in let b = array2_of_genarray - (Genarray.map_file fd float64 fortran_layout false [|100; -1|]) + (Unix.map_file fd float64 fortran_layout false [|100; -1|]) in Unix.close fd; let ok = ref true in @@ -53,7 +53,7 @@ let tests () = b.{50,50} <- (-1.0); let fd = Unix.openfile mapped_file [Unix.O_RDONLY] 0 in let c = - array2_of_genarray (Genarray.map_file fd float64 c_layout false [|-1; 100|]) + array2_of_genarray (Unix.map_file fd float64 c_layout false [|-1; 100|]) in Unix.close fd; let ok = ref true in @@ -66,7 +66,7 @@ let tests () = let fd = Unix.openfile mapped_file [Unix.O_RDONLY] 0 in let c = array2_of_genarray - (Genarray.map_file fd ~pos:800L float64 c_layout false [|-1; 100|]) + (Unix.map_file fd ~pos:800L float64 c_layout false [|-1; 100|]) in Unix.close fd; let ok = ref true in @@ -79,7 +79,7 @@ let tests () = let fd = Unix.openfile mapped_file [Unix.O_RDONLY] 0 in let c = array2_of_genarray - (Genarray.map_file fd ~pos:79200L float64 c_layout false [|-1; 100|]) + (Unix.map_file fd ~pos:79200L float64 c_layout false [|-1; 100|]) in Unix.close fd; let ok = ref true in diff --git a/testsuite/tests/lib-bigarray/bigarrays.ml b/testsuite/tests/lib-bigarray/bigarrays.ml index d229ae09c6..31a90bca8d 100644 --- a/testsuite/tests/lib-bigarray/bigarrays.ml +++ b/testsuite/tests/lib-bigarray/bigarrays.ml @@ -976,61 +976,6 @@ let tests () = test_structured_io 14 (make_array3 complex64 fortran_layout 1 10 20 30 makecomplex); - testing_function "map_file"; - let mapped_file = Filename.temp_file "bigarray" ".data" in - begin - let fd = - Unix.openfile mapped_file - [Unix.O_RDWR; Unix.O_TRUNC; Unix.O_CREAT] 0o666 in - let a = Array1.map_file fd float64 c_layout true 10000 in - Unix.close fd; - for i = 0 to 9999 do a.{i} <- float i done; - let fd = Unix.openfile mapped_file [Unix.O_RDONLY] 0 in - let b = Array2.map_file fd float64 fortran_layout false 100 (-1) in - Unix.close fd; - let ok = ref true in - for i = 0 to 99 do - for j = 0 to 99 do - if b.{j+1,i+1} <> float (100 * i + j) then ok := false - done - done; - test 1 !ok true; - b.{50,50} <- (-1.0); - let fd = Unix.openfile mapped_file [Unix.O_RDONLY] 0 in - let c = Array2.map_file fd float64 c_layout false (-1) 100 in - Unix.close fd; - let ok = ref true in - for i = 0 to 99 do - for j = 0 to 99 do - if c.{i,j} <> float (100 * i + j) then ok := false - done - done; - test 2 !ok true; - let fd = Unix.openfile mapped_file [Unix.O_RDONLY] 0 in - let c = Array2.map_file fd ~pos:800L float64 c_layout false (-1) 100 in - Unix.close fd; - let ok = ref true in - for i = 1 to 99 do - for j = 0 to 99 do - if c.{i-1,j} <> float (100 * i + j) then ok := false - done - done; - test 3 !ok true; - let fd = Unix.openfile mapped_file [Unix.O_RDONLY] 0 in - let c = Array2.map_file fd ~pos:79200L float64 c_layout false (-1) 100 in - Unix.close fd; - let ok = ref true in - for j = 0 to 99 do - if c.{0,j} <> float (100 * 99 + j) then ok := false - done; - test 4 !ok true - end; - (* Force garbage collection of the mapped bigarrays above, otherwise - Win32 doesn't let us erase the file. Notice the begin...end above - so that the VM doesn't keep stack references to the mapped bigarrays. *) - Gc.full_major(); - Sys.remove mapped_file; - () [@@inline never] diff --git a/testsuite/tests/lib-bigarray/bigarrays.reference b/testsuite/tests/lib-bigarray/bigarrays.reference index e96d0114ca..1c80e50e28 100644 --- a/testsuite/tests/lib-bigarray/bigarrays.reference +++ b/testsuite/tests/lib-bigarray/bigarrays.reference @@ -75,5 +75,3 @@ reshape output_value/input_value 1... 2... 3... 4... 5... 6... 7... 8... 9... 10... 11... 12... 13... 14... -map_file - 1... 2... 3... 4... diff --git a/testsuite/tests/lib-dynlink-csharp/Makefile b/testsuite/tests/lib-dynlink-csharp/Makefile index ae98ca0bb5..a385d1caf1 100644 --- a/testsuite/tests/lib-dynlink-csharp/Makefile +++ b/testsuite/tests/lib-dynlink-csharp/Makefile @@ -20,7 +20,7 @@ CSC=$(CSC_COMMAND) $(CSC_FLAGS) COMPFLAGS=-I $(OTOPDIR)/otherlibs/bigarray -I $(OTOPDIR)/otherlibs/dynlink \ -I $(OTOPDIR)/byterun -LD_PATH=$(TOPDIR)/otherlibs/bigarray:$(TOPDIR)/otherlibs/dynlink +LD_PATH=$(TOPDIR)/otherlibs/win32unix:$(TOPDIR)/otherlibs/bigarray:$(TOPDIR)/otherlibs/dynlink default: @$(SET_LD_PATH) $(MAKE) all diff --git a/testsuite/tests/lib-dynlink-csharp/bytecode.reference b/testsuite/tests/lib-dynlink-csharp/bytecode.reference index 8be606c4bd..1c61c156e7 100644 --- a/testsuite/tests/lib-dynlink-csharp/bytecode.reference +++ b/testsuite/tests/lib-dynlink-csharp/bytecode.reference @@ -1,5 +1,6 @@ Now starting the OCaml engine. Main is running. +Loading ../../../otherlibs/win32unix/unix.cma Loading ../../../otherlibs/bigarray/bigarray.cma Loading plugin.cmo I'm the plugin. diff --git a/testsuite/tests/lib-dynlink-csharp/main.ml b/testsuite/tests/lib-dynlink-csharp/main.ml index d30c150e1d..7c8030a18b 100755 --- a/testsuite/tests/lib-dynlink-csharp/main.ml +++ b/testsuite/tests/lib-dynlink-csharp/main.ml @@ -5,19 +5,21 @@ let load s = with Dynlink.Error e -> print_endline (Dynlink.error_message e) +(* Callback must be linked to load Unix dynamically *) +let _ = Callback.register +module CamlinternalBigarray = CamlinternalBigarray + let () = ignore (Hashtbl.hash 42.0); print_endline "Main is running."; Dynlink.init (); Dynlink.allow_unsafe_modules true; - let s1,s2 = - if Dynlink.is_native then - "../../../otherlibs/bigarray/bigarray.cmxs", - "plugin.cmxs" - else - "../../../otherlibs/bigarray/bigarray.cma", - "plugin.cmo" + let s1,s2,s3 = + Dynlink.adapt_filename "../../../otherlibs/win32unix/unix.cma", + Dynlink.adapt_filename "../../../otherlibs/bigarray/bigarray.cma", + Dynlink.adapt_filename "plugin.cmo" in load s1; load s2; + load s3; print_endline "OK." diff --git a/testsuite/tests/lib-dynlink-csharp/native.reference b/testsuite/tests/lib-dynlink-csharp/native.reference index ff18be96c3..cfb612da6d 100644 --- a/testsuite/tests/lib-dynlink-csharp/native.reference +++ b/testsuite/tests/lib-dynlink-csharp/native.reference @@ -1,5 +1,6 @@ Now starting the OCaml engine. Main is running. +Loading ../../../otherlibs/win32unix/unix.cmxs Loading ../../../otherlibs/bigarray/bigarray.cmxs Loading plugin.cmxs I'm the plugin. |