summaryrefslogtreecommitdiff
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
parentd6bb4daa64d300d72a68b63e014076d7095ba65d (diff)
parent2d03974c1223bbd3f1535fde1be2f03148bbed82 (diff)
downloadocaml-f78128a7d723fa6002a08f5379a565da5022006a.tar.gz
merge 4.05 into trunk
-rw-r--r--.gitattributes2
-rw-r--r--Changes91
-rw-r--r--appveyor.yml1
-rw-r--r--bytecomp/typeopt.ml2
-rw-r--r--config/Makefile.mingw12
-rw-r--r--config/Makefile.mingw644
-rwxr-xr-xconfigure10
-rw-r--r--manual/manual/cmds/ocamldoc.etex11
-rw-r--r--manual/manual/cmds/unified-options.etex6
-rw-r--r--manual/manual/library/stdlib.etex5
-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
-rw-r--r--stdlib/.depend4
-rw-r--r--stdlib/Makefile2
-rw-r--r--stdlib/camlinternalBigarray.ml54
-rw-r--r--stdlib/format.mli2
-rw-r--r--testsuite/makefiles/Makefile.common1
-rw-r--r--testsuite/tests/lib-bigarray-file/mapfile.ml10
-rw-r--r--testsuite/tests/lib-bigarray/bigarrays.ml55
-rw-r--r--testsuite/tests/lib-bigarray/bigarrays.reference2
-rw-r--r--testsuite/tests/lib-dynlink-csharp/Makefile2
-rw-r--r--testsuite/tests/lib-dynlink-csharp/bytecode.reference1
-rwxr-xr-xtestsuite/tests/lib-dynlink-csharp/main.ml16
-rw-r--r--testsuite/tests/lib-dynlink-csharp/native.reference1
-rw-r--r--testsuite/tests/lib-unix/cmdline_prog.c10
-rw-r--r--testsuite/tests/lib-unix/common/Makefile10
-rw-r--r--testsuite/tests/lib-unix/common/cloexec.ml9
-rw-r--r--testsuite/tests/lib-unix/common/fdstatus.c4
-rw-r--r--testsuite/tests/lib-unix/test_unix_cmdline.ml28
-rw-r--r--testsuite/tests/lib-unix/test_unix_cmdline.reference13
-rw-r--r--testsuite/tests/tool-command-line/Makefile2
33 files changed, 367 insertions, 148 deletions
diff --git a/.gitattributes b/.gitattributes
index f78a284521..f4bdc362e6 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -157,10 +157,12 @@ testsuite/tests/typing-typeparam/newtype.ml text eol=lf
testsuite/tests/typing-unboxed/test.ml text eol=lf
testsuite/tests/typing-unboxed-types/test.ml text eol=lf
testsuite/tests/typing-warnings/ambiguous_guarded_disjunction.ml text eol=lf
+testsuite/tests/typing-warnings/application.ml text eol=lf
testsuite/tests/typing-warnings/coercions.ml text eol=lf
testsuite/tests/typing-warnings/exhaustiveness.ml text eol=lf
testsuite/tests/typing-warnings/pr6872.ml text eol=lf
testsuite/tests/typing-warnings/pr7085.ml text eol=lf
testsuite/tests/typing-warnings/pr7115.ml text eol=lf
+testsuite/tests/typing-warnings/pr7297.ml text eol=lf
testsuite/tests/typing-warnings/records.ml text eol=lf
testsuite/tests/typing-warnings/unused_types.ml text eol=lf
diff --git a/Changes b/Changes
index 6fba72850d..5e40e3b3ac 100644
--- a/Changes
+++ b/Changes
@@ -293,6 +293,8 @@ Working version
Next major version (4.05.0):
----------------------------
+OCaml 4.05.0 (TBD):
+----------------------------
(Changes that can break existing programs are marked with a "*")
@@ -321,6 +323,17 @@ Next major version (4.05.0):
- PR#7533, GPR#1173: Correctly perform side effects for certain
cases of "/" and "mod"
(Mark Shinwell, report by Jan Mitgaard)
+- GPR#863, GPR#1068, GPR#1069: Optimise matches with constant
+ results to lookup tables.
+ (Stephen Dolan, review by Gabriel Scherer, Pierre Chambart,
+ Mark Shinwell, and bug report by Gabriel Scherer)
+
+- GPR#1150: Fix typo in arm64 assembler directives
+ (KC Sivaramakrishnan)
+
+- PR#7533, GPR#1173: Correctly perform side effects for certain
+ cases of "/" and "mod"
+ (Mark Shinwell, report by Jan Mitgaard)
### Runtime system:
@@ -331,6 +344,9 @@ Next major version (4.05.0):
- MPR#385, GPR#953: Add caml_startup_exn
(Mark Shinwell)
+- MPR#385, GPR#953: Add caml_startup_exn
+ (Mark Shinwell)
+
- PR#7423, GPR#946: expose new exception-raising functions
`void caml_{failwith,invalid_argument}_value(value msg)`
in addition to
@@ -343,6 +359,13 @@ Next major version (4.05.0):
- GPR#795: remove 256-character limitation on Sys.executable_name
(Xavier Leroy)
+- PR#7557, GPR#1213: More security for getenv
+ (Damien Doligez, reports by Seth Arnold and Eric Milliken, review by
+ Xavier Leroy, David Allsopp, Stephen Dolan, Hannes Mehnert)
+
+- GPR#795: remove 256-character limitation on Sys.executable_name
+ (Xavier Leroy)
+
- GPR#891: Use -fno-builtin-memcmp when building runtime with gcc.
(Leo White)
@@ -357,6 +380,9 @@ Next major version (4.05.0):
* PR#7414, GPR#929: Soundness bug with non-generalized type variables and functors.
(Jacques Garrigue, report by Leo White)
+* PR#7414, GPR#929: Soundness bug with non-generalized type variables and
+ functors.
+ (Jacques Garrigue, report by Leo White)
### Compiler user-interface and warnings:
@@ -414,6 +440,8 @@ Next major version (4.05.0):
- GPR#1015: add option "-plugin PLUGIN" to ocamldep too. Use compilerlibs
to build ocamldep. Add option "-depend" to ocamlc/ocamlopt to behave
as ocamldep. Remove any use of ocamldep to build the distribution.
+- GPR#1015: add option "-plugin PLUGIN" to ocamldep too. Use compilerlibs
+ to build ocamldep.
(Fabrice Le Fessant)
- GPR#1027: various improvements to -dtimings, mostly including time
@@ -439,6 +467,14 @@ Next major version (4.05.0):
* PR#7500, GPR#1081: Remove Uchar.dump
(Daniel Bünzli)
+- PR#7279 GPR#710: `Weak.get_copy` `Ephemeron.*_copy` doesn't copy
+ custom blocks anymore
+ (François Bobot, Alain Frisch, bug reported by Martin R. Neuhäußer,
+ review by Thomas Braibant and Damien Doligez)
+
+* PR#7500, GPR#1081: Remove Uchar.dump
+ (Daniel Bünzli)
+
- GPR#760: Add a functions List.compare_lengths and
List.compare_length_with to avoid full list length computations
(Fabrice Le Fessant)
@@ -501,6 +537,20 @@ Next major version (4.05.0):
(Edwin Török, review by Gabriel Scherer, discussion with Alain Frisch,
David Allsopp, Sébastien Hinderer, Damien Doligez and Xavier Leroy)
+- PR#7497, GPR#1095: manual, enable numbering for table of contents
+ (Florian Angeletti, request by Daniel Bünzli)
+
+- PR#7539, GPR#1181: manual, update dead links in ocamldoc chapter
+ (Florian Angeletti)
+
+- GPR#633: manpage and manual documentation for the `-opaque` option
+ (Konstantin Romanov, Gabriel Scherer, review by Mark Shinwell)
+
+- GPR#916: new tool lintapidiff, use it to update the manual with
+ @since annotations for API changes introduced between 4.00-4.05.
+ (Edwin Török, review by Gabriel Scherer, discussion with Alain Frisch,
+ David Allsopp, Sébastien Hinderer, Damien Doligez and Xavier Leroy)
+
- GPR#939: activate the caml_example environment in the language
extensions section of the manual. Convert some existing code
examples to this format.
@@ -554,11 +604,14 @@ Next major version (4.05.0):
- GPR#997, GPR#1077: Deprecate Bigarray.*.map_file and add Unix.map_file as a
first step towards moving Bigarray to the stdlib
(Jérémie Dimino and Xavier Leroy)
+### Toplevel:
### Toplevel:
- PR#7060, GPR#1035: Print exceptions in installed custom printers
(Tadeu Zagallo, review by David Allsopp)
+- PR#7060, GPR#1035: Print exceptions in installed custom printers
+ (Tadeu Zagallo, review by David Allsopp)
### Tools:
@@ -593,9 +646,15 @@ Next major version (4.05.0):
### Compiler distribution build system:
+### Compiler distribution build system:
+
- PR#7377: remove -std=gnu99 for newer gcc versions
(Damien Doligez, report by ygrek)
+- PR#7452, GPR#1228: tweak GCC options to try to avoid the
+ Skylake/Kaby lake bug
+ (Damien Doligez, review by David Allsopp, Xavier Leroy and Mark Shinwell)
+
- GPR#693: fail on unexpected errors or warnings within caml_example
environment.
(Florian Angeletti)
@@ -760,6 +819,18 @@ The complete list of changes is listed below.
(Mark Shinwell, review by Xavier Leroy, testing by David Allsopp and
Olivier Andrieu)
+- PR#6136, GPR#967: Fix Closure so that overapplication evaluation order
+ matches the bytecode compiler and Flambda.
+ (Mark Shinwell, report by Jeremy Yallop, review by Frédéric Bour)
+
+- PR#6550, GPR#1094: Allow creation of empty .cmxa files on macOS
+ (Mark Shinwell)
+
+- PR#6594, GPR#955: Remove "Istore_symbol" specific operation on x86-64.
+ This is more robust and in particular avoids assembly failures on Win64.
+ (Mark Shinwell, review by Xavier Leroy, testing by David Allsopp and
+ Olivier Andrieu)
+
- PR#6903: Unix.execvpe doesn't change environment on Cygwin
(Xavier Leroy)
@@ -823,6 +894,12 @@ The complete list of changes is listed below.
- PR#7456, GPR#1092: fix slow compilation on source files containing a lot
of similar debugging information location entries
(Mark Shinwell)
+- PR#7504: fix warning 8 with unconstrained records
+ (Florian Angeletti, report by John Whitington)
+
+- PR#7456, GPR#1092: fix slow compilation on source files containing a lot
+ of similar debugging information location entries
+ (Mark Shinwell)
- GPR#805, GPR#815, GPR#833: check for integer overflow in String.concat
(Jeremy Yallop,
@@ -890,6 +967,20 @@ OCaml 4.04.1 (14 Apr 2017):
- PR#7501, GPR#1089: Consider arrays of length zero as constants
when using Flambda.
(Pierre Chambart, review by Mark Shinwell and Leo White)
+OCaml 4.04.2 (23 Jun 2017):
+---------------------------
+
+### Security fix:
+
+- PR#7557: Local privilege escalation issue with ocaml binaries.
+ (Damien Doligez, report by Eric Milliken, review by Xavier Leroy)
+
+OCaml 4.04.1 (14 Apr 2017):
+---------------------------
+
+- PR#7501, GPR#1089: Consider arrays of length zero as constants
+ when using Flambda.
+ (Pierre Chambart, review by Mark Shinwell and Leo White)
### Standard library:
diff --git a/appveyor.yml b/appveyor.yml
index 1c770f20bd..fbdb79ad7b 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -21,6 +21,7 @@ image: Visual Studio 2015
branches:
only:
- trunk
+ - 4.05
# Do a shallow clone of the repo to speed up the build
clone_depth: 1
diff --git a/bytecomp/typeopt.ml b/bytecomp/typeopt.ml
index 4416cf92b6..93b7ec6559 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 = "CamlinternalBigarray" ->
+ when Ident.name mod_id = "Bigarray" ->
begin try List.assoc type_name tbl with Not_found -> dfl end
| _ ->
dfl
diff --git a/config/Makefile.mingw b/config/Makefile.mingw
index b8b0e5cae3..b38479a13e 100644
--- a/config/Makefile.mingw
+++ b/config/Makefile.mingw
@@ -109,9 +109,19 @@ AFL_INSTRUMENT=false
### Which C compiler to use for the bytecode interpreter.
CC = $(TOOLPREF)gcc
-CFLAGS = -O -mms-bitfields -Wall -Wno-unused
+CFLAGS = -O -mms-bitfields -Wall -Wno-unused -fno-tree-vrp
+# -fno-tree-vrp is here to try to work around the Skylake/Kaby lake bug,
+# and only works on GCC 4.2 and later.
CPPFLAGS = -DCAML_NAME_SPACE
OCAMLC_CFLAGS = -O -mms-bitfields
+||||||| merged common ancestors
+BYTECC=$(TOOLPREF)gcc -O -mms-bitfields
+BYTECODE_C_COMPILER=$(BYTECC)
+
+### Additional compile-time options for $(BYTECC). (For static linking.)
+BYTECCCOMPOPTS=-DCAML_NAME_SPACE -Wall -Wno-unused
+
+### Additional compile-time options for $(BYTECC). (For debug version.)
BYTECCDBGCOMPOPTS=-g
LDFLAGS=
diff --git a/config/Makefile.mingw64 b/config/Makefile.mingw64
index 86418180a7..bed9a88338 100644
--- a/config/Makefile.mingw64
+++ b/config/Makefile.mingw64
@@ -109,7 +109,9 @@ AFL_INSTRUMENT=false
### Which C compiler to use for the bytecode interpreter.
CC = $(TOOLPREF)gcc
-CFLAGS = -O -mms-bitfields -Wall -Wno-unused
+CFLAGS = -O -mms-bitfields -Wall -Wno-unused -fno-tree-vrp
+# -fno-tree-vrp is here to try to work around the Skylake/Kaby lake bug,
+# and only works on GCC 4.2 and later.
CPPFLAGS = -DCAML_NAME_SPACE
OCAMLC_CFLAGS = -O -mms-bitfields
diff --git a/configure b/configure
index 44a7b099b4..abc0e83a2a 100755
--- a/configure
+++ b/configure
@@ -877,6 +877,16 @@ else
fi
+# Try to work around the Skylake/Kaby Lake processor bug.
+case "$bytecc,$target" in
+ *gcc*,x86_64-*|*gcc*,i686-*)
+ if sh ./hasgot -Werror -fno-tree-vrp; then
+ byteccprivatecompopts="$byteccprivatecompopts -fno-tree-vrp"
+ inf "Adding -fno-tree-vrp option to work around PR#7452"
+ fi;;
+esac
+
+
# Configure the native-code compiler
arch=none
diff --git a/manual/manual/cmds/ocamldoc.etex b/manual/manual/cmds/ocamldoc.etex
index dcea59711e..e2fc527f71 100644
--- a/manual/manual/cmds/ocamldoc.etex
+++ b/manual/manual/cmds/ocamldoc.etex
@@ -1027,12 +1027,13 @@ let _ = Odoc_args.extend_html_generator (module Generator : Odoc_gen.Html_functo
To know which methods to override and/or which methods are available,
have a look at the different base implementations, depending on the
kind of generator you are extending~:
+\newcommand\ocamldocsrc[2]{\href{https://github.com/ocaml/ocaml/blob/{\ocamlversion}/ocamldoc/odoc_#1.ml}{#2}}
\begin{itemize}
-\item for HTML~: \href{http://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/version/\ocamlversion/ocamldoc/odoc_html.ml?view=markup}{"odoc_html.ml"},
-\item for \LaTeX~: \href{http://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/version/\ocamlversion/ocamldoc/odoc_latex.ml?view=markup}{"odoc_latex.ml"},
-\item for TeXinfo~: \href{http://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/version/\ocamlversion/ocamldoc/odoc_texi.ml?view=markup}{"odoc_texi.ml"},
-\item for man pages~: \href{http://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/version/\ocamlversion/ocamldoc/odoc_man.ml?view=markup}{"odoc_man.ml"},
-\item for graphviz (dot)~: \href{http://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/version/\ocamlversion/ocamldoc/odoc_dot.ml?view=markup}{"odoc_dot.ml"}.
+\item for HTML~: \ocamldocsrc{html}{"odoc_html.ml"},
+\item for \LaTeX~: \ocamldocsrc{latex}{"odoc_latex.ml"},
+\item for TeXinfo~: \ocamldocsrc{texi}{"odoc_texi.ml"},
+\item for man pages~: \ocamldocsrc{man}{"odoc_man.ml"},
+\item for graphviz (dot)~: \ocamldocsrc{dot}{"odoc_dot.ml"}.
\end{itemize}
%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/manual/manual/cmds/unified-options.etex b/manual/manual/cmds/unified-options.etex
index 8b35a5850d..12498d6716 100644
--- a/manual/manual/cmds/unified-options.etex
+++ b/manual/manual/cmds/unified-options.etex
@@ -547,8 +547,10 @@ errors, the intermediate file is deleted afterwards.
\item["-ppx" \var{command}]
After parsing, pipe the abstract syntax tree through the preprocessor
\var{command}. The module "Ast_mapper", described in
-chapter~\ref{Ast-underscoremapper}, implements the external interface
-of a preprocessor.
+\ifouthtml
+chapter~\ref{c:parsinglib}: \ahref{libref/Ast\_mapper.html}{ \texttt{Ast_mapper} }
+\else section~\ref{Ast-underscoremapper}\fi,
+implements the external interface of a preprocessor.
\item["-principal"]
Check information path during type-checking, to make sure that all
diff --git a/manual/manual/library/stdlib.etex b/manual/manual/library/stdlib.etex
index d8c4074470..f159cf99cc 100644
--- a/manual/manual/library/stdlib.etex
+++ b/manual/manual/library/stdlib.etex
@@ -103,6 +103,7 @@ be called from C \\
\item \ahref{libref/ArrayLabels.html}{Module \texttt{ArrayLabels}: array operations (with labels)}
\item \ahref{libref/Buffer.html}{Module \texttt{Buffer}: extensible buffers}
\item \ahref{libref/Bytes.html}{Module \texttt{Bytes}: byte sequences}
+\item \ahref{libref/BytesLabels.html}{Module \texttt{BytesLabels}: byte sequences (with labels)}
\item \ahref{libref/Callback.html}{Module \texttt{Callback}: registering OCaml values with the C runtime}
\item \ahref{libref/Char.html}{Module \texttt{Char}: character operations}
\item \ahref{libref/Complex.html}{Module \texttt{Complex}: Complex numbers}
@@ -145,8 +146,10 @@ be called from C \\
\else
\input{Arg.tex}
\input{Array.tex}
+\input{ArrayLabels.tex}
\input{Buffer.tex}
\input{Bytes.tex}
+\input{BytesLabels.tex}
\input{Callback.tex}
\input{Char.tex}
\input{Complex.tex}
@@ -162,6 +165,7 @@ be called from C \\
\input{Lazy.tex}
\input{Lexing.tex}
\input{List.tex}
+\input{ListLabels.tex}
\input{Map.tex}
\input{Marshal.tex}
\input{MoreLabels.tex}
@@ -180,6 +184,7 @@ be called from C \\
\input{StdLabels.tex}
\input{Stream.tex}
\input{String.tex}
+\input{StringLabels.tex}
\input{Sys.tex}
\input{Uchar.tex}
\input{Weak.tex}
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. *)
-
diff --git a/stdlib/.depend b/stdlib/.depend
index 4ac015ad66..1ed2bedad0 100644
--- a/stdlib/.depend
+++ b/stdlib/.depend
@@ -21,8 +21,6 @@ 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 \
@@ -202,8 +200,6 @@ 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 5f7bde13e3..6a863bc77f 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 camlinternalBigarray.cmo
+ spacetime.cmo
.PHONY: all
all: stdlib.cma std_exit.cmo camlheader target_camlheader camlheader_ur
diff --git a/stdlib/camlinternalBigarray.ml b/stdlib/camlinternalBigarray.ml
deleted file mode 100644
index 9f1639ed96..0000000000
--- a/stdlib/camlinternalBigarray.ml
+++ /dev/null
@@ -1,54 +0,0 @@
-(**************************************************************************)
-(* *)
-(* 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/stdlib/format.mli b/stdlib/format.mli
index 03866b088b..511e69ed3a 100644
--- a/stdlib/format.mli
+++ b/stdlib/format.mli
@@ -616,6 +616,7 @@ type formatter_out_functions = {
- field [out_newline] is equivalent to [out_string "\n" 0 1];
- field [out_spaces] is equivalent to [out_string (String.make n ' ') 0 n];
- field [out_indent] is the same as field [out_spaces].
+ @since 4.01.0
*)
val set_formatter_out_functions : formatter_out_functions -> unit
@@ -916,6 +917,7 @@ val pp_get_formatter_out_functions :
operating on the standard formatter are defined via partial
evaluation of these primitives. For instance,
{!print_string} is equal to {!pp_print_string} {!std_formatter}.
+ @since 4.01.0
*)
diff --git a/testsuite/makefiles/Makefile.common b/testsuite/makefiles/Makefile.common
index 7e395b6800..43c232d6c7 100644
--- a/testsuite/makefiles/Makefile.common
+++ b/testsuite/makefiles/Makefile.common
@@ -71,6 +71,7 @@ defaultclean:
.S.o:
@$(ASPP) $(ASPPFLAGS) -DSYS_$(SYSTEM) -DMODEL_$(MODEL) -o $*.o $*.S
+.PRECIOUS: %.s
.s.o:
@$(ASPP) $(ASPPFLAGS) -DSYS_$(SYSTEM) -o $*.o $*.s
diff --git a/testsuite/tests/lib-bigarray-file/mapfile.ml b/testsuite/tests/lib-bigarray-file/mapfile.ml
index aeed7258f9..3c814a2721 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 (Unix.map_file fd float64 c_layout true [|10000|])
+ array1_of_genarray (Genarray.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
- (Unix.map_file fd float64 fortran_layout false [|100; -1|])
+ (Genarray.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 (Unix.map_file fd float64 c_layout false [|-1; 100|])
+ array2_of_genarray (Genarray.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
- (Unix.map_file fd ~pos:800L float64 c_layout false [|-1; 100|])
+ (Genarray.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
- (Unix.map_file fd ~pos:79200L float64 c_layout false [|-1; 100|])
+ (Genarray.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 31a90bca8d..d229ae09c6 100644
--- a/testsuite/tests/lib-bigarray/bigarrays.ml
+++ b/testsuite/tests/lib-bigarray/bigarrays.ml
@@ -976,6 +976,61 @@ 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 1c80e50e28..e96d0114ca 100644
--- a/testsuite/tests/lib-bigarray/bigarrays.reference
+++ b/testsuite/tests/lib-bigarray/bigarrays.reference
@@ -75,3 +75,5 @@ 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 a385d1caf1..ae98ca0bb5 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/win32unix:$(TOPDIR)/otherlibs/bigarray:$(TOPDIR)/otherlibs/dynlink
+LD_PATH=$(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 1c61c156e7..8be606c4bd 100644
--- a/testsuite/tests/lib-dynlink-csharp/bytecode.reference
+++ b/testsuite/tests/lib-dynlink-csharp/bytecode.reference
@@ -1,6 +1,5 @@
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 7c8030a18b..d30c150e1d 100755
--- a/testsuite/tests/lib-dynlink-csharp/main.ml
+++ b/testsuite/tests/lib-dynlink-csharp/main.ml
@@ -5,21 +5,19 @@ 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,s3 =
- Dynlink.adapt_filename "../../../otherlibs/win32unix/unix.cma",
- Dynlink.adapt_filename "../../../otherlibs/bigarray/bigarray.cma",
- Dynlink.adapt_filename "plugin.cmo"
+ let s1,s2 =
+ if Dynlink.is_native then
+ "../../../otherlibs/bigarray/bigarray.cmxs",
+ "plugin.cmxs"
+ else
+ "../../../otherlibs/bigarray/bigarray.cma",
+ "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 cfb612da6d..ff18be96c3 100644
--- a/testsuite/tests/lib-dynlink-csharp/native.reference
+++ b/testsuite/tests/lib-dynlink-csharp/native.reference
@@ -1,6 +1,5 @@
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.
diff --git a/testsuite/tests/lib-unix/cmdline_prog.c b/testsuite/tests/lib-unix/cmdline_prog.c
new file mode 100644
index 0000000000..c67a75633b
--- /dev/null
+++ b/testsuite/tests/lib-unix/cmdline_prog.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+
+int main (int argc, char *argv[])
+{
+ int i;
+ for (i = 1; i < argc; i ++) {
+ printf ("%s\n", argv[i]);
+ }
+ return 0;
+}
diff --git a/testsuite/tests/lib-unix/common/Makefile b/testsuite/tests/lib-unix/common/Makefile
index 2883a8aeb4..706137bead 100644
--- a/testsuite/tests/lib-unix/common/Makefile
+++ b/testsuite/tests/lib-unix/common/Makefile
@@ -23,11 +23,15 @@ ADD_BYTERUN_FLAGS="-I $(OTOPDIR)/otherlibs/win32unix"
endif
default: reflector.exe fdstatus.exe cmdline_prog.exe
- $(MAKE) check
+ @$(MAKE) check
include $(BASEDIR)/makefiles/Makefile.several
include $(BASEDIR)/makefiles/Makefile.common
%.exe: %.c
- @$(CC) $(CFLAGS) $(CPPFLAGS) $(if $(filter msvc,$(CCOMPTYPE)),/Fe$*.exe,-o $*.exe) $*.c
-
+ifeq ($(CCOMPTYPE),msvc)
+ @set -o pipefail ; \
+ $(CC) $(CFLAGS) $(CPPFLAGS) /Fe$*.exe $*.c | tail -n +2
+else
+ @$(CC) $(CFLAGS) $(CPPFLAGS) -o $*.exe $*.c
+endif
diff --git a/testsuite/tests/lib-unix/common/cloexec.ml b/testsuite/tests/lib-unix/common/cloexec.ml
index 462882b1be..d7e1e29245 100644
--- a/testsuite/tests/lib-unix/common/cloexec.ml
+++ b/testsuite/tests/lib-unix/common/cloexec.ml
@@ -6,7 +6,11 @@
let string_of_fd (fd: Unix.file_descr) : string =
match Sys.os_type with
| "Unix" | "Cygwin" -> string_of_int (Obj.magic fd : int)
- | "Win32" -> Int32.to_string (Obj.magic fd : int32)
+ | "Win32" ->
+ if Sys.word_size = 32 then
+ Int32.to_string (Obj.magic fd : int32)
+ else
+ Int64.to_string (Obj.magic fd : int64)
| _ -> assert false
let _ =
@@ -33,7 +37,7 @@ let _ =
try Unix.(socketpair ~cloexec:true PF_UNIX SOCK_STREAM 0)
with Invalid_argument _ -> (p2, p2') in
- let fds = [| f0;f1;f2; d0;d1;d2;
+ let fds = [| f0;f1;f2; d0;d1;d2;
p0;p0';p1;p1';p2;p2';
s0;s1;s2;
x0;x0';x1;x1';x2;x2' |] in
@@ -45,4 +49,3 @@ let _ =
ignore (Unix.waitpid [] pid);
Array.iter (fun fd -> try Unix.close fd with Unix.Unix_error _ -> ()) fds;
Sys.remove "tmp.txt"
-
diff --git a/testsuite/tests/lib-unix/common/fdstatus.c b/testsuite/tests/lib-unix/common/fdstatus.c
index c2171e1852..b87704188d 100644
--- a/testsuite/tests/lib-unix/common/fdstatus.c
+++ b/testsuite/tests/lib-unix/common/fdstatus.c
@@ -16,7 +16,11 @@ void process_fd(char * s)
HANDLE h;
DWORD flags;
+#ifdef _WIN64
+ h = (HANDLE) _atoi64(s);
+#else
h = (HANDLE) atoi(s);
+#endif
if (GetHandleInformation(h, &flags)) {
printf("open\n");
} else if (GetLastError() == ERROR_INVALID_HANDLE) {
diff --git a/testsuite/tests/lib-unix/test_unix_cmdline.ml b/testsuite/tests/lib-unix/test_unix_cmdline.ml
new file mode 100644
index 0000000000..f0f7679b08
--- /dev/null
+++ b/testsuite/tests/lib-unix/test_unix_cmdline.ml
@@ -0,0 +1,28 @@
+open Unix
+
+let prog_name = "cmdline_prog.exe"
+
+let run args =
+ let out, inp = pipe () in
+ let in_chan = in_channel_of_descr out in
+ set_binary_mode_in in_chan false;
+ let pid = create_process ("./" ^ prog_name) (Array.of_list (prog_name :: args)) Unix.stdin inp Unix.stderr in
+ List.iter (fun arg ->
+ let s = input_line in_chan in
+ Printf.printf "%S -> %S [%s]\n" arg s (if s = arg then "OK" else "FAIL")
+ ) args;
+ close_in in_chan;
+ let _, exit = waitpid [] pid in
+ assert (exit = WEXITED 0)
+
+let () =
+ List.iter run
+ [
+ [""; ""; "\t \011"];
+ ["a"; "b"; "c.txt@!"];
+ ["\""];
+ [" "; " a "; " \" \\\" "];
+ [" \\ \\ \\\\\\"];
+ [" \"hola \""];
+ ["a\tb"];
+ ]
diff --git a/testsuite/tests/lib-unix/test_unix_cmdline.reference b/testsuite/tests/lib-unix/test_unix_cmdline.reference
new file mode 100644
index 0000000000..7d2f2c2a91
--- /dev/null
+++ b/testsuite/tests/lib-unix/test_unix_cmdline.reference
@@ -0,0 +1,13 @@
+"" -> "" [OK]
+"" -> "" [OK]
+"\t \011" -> "\t \011" [OK]
+"a" -> "a" [OK]
+"b" -> "b" [OK]
+"c.txt@!" -> "c.txt@!" [OK]
+"\"" -> "\"" [OK]
+" " -> " " [OK]
+" a " -> " a " [OK]
+" \" \\\" " -> " \" \\\" " [OK]
+" \\ \\ \\\\\\" -> " \\ \\ \\\\\\" [OK]
+" \"hola \"" -> " \"hola \"" [OK]
+"a\tb" -> "a\tb" [OK]
diff --git a/testsuite/tests/tool-command-line/Makefile b/testsuite/tests/tool-command-line/Makefile
index b2200c6b3f..148dafa202 100644
--- a/testsuite/tests/tool-command-line/Makefile
+++ b/testsuite/tests/tool-command-line/Makefile
@@ -17,7 +17,7 @@ BASEDIR=../..
default:
- $(MAKE) byte
+ @$(MAKE) byte
@if $(BYTECODE_ONLY); then $(MAKE) opt-skipped ; else \
$(MAKE) opt; \
fi