summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Munch-Maccagnoni <Guillaume.Munch-Maccagnoni@Inria.fr>2020-06-09 23:51:58 +0200
committerGuillaume Munch-Maccagnoni <Guillaume.Munch-Maccagnoni@Inria.fr>2020-06-10 14:29:21 +0200
commit3a1901d87336e6e003a2e053fdf9ec274dd3007b (patch)
tree44b8a68e43cd8c1b2798725fbd518b4c13ccefea
parenta1e3b966ea34faaf67104f2bfe6f90bc42758225 (diff)
downloadocaml-3a1901d87336e6e003a2e053fdf9ec274dd3007b.tar.gz
Fix dune build
Introduce CamlinternalAtomic since Stdlib cannot refer to Stdlib__-prefixed modules without breaking the dune build. No change entry needed.
-rw-r--r--stdlib/.depend9
-rwxr-xr-xstdlib/Compflags2
-rw-r--r--stdlib/Makefile2
-rw-r--r--stdlib/StdlibModules5
-rw-r--r--stdlib/atomic.ml37
-rw-r--r--stdlib/camlinternalAtomic.ml49
-rw-r--r--stdlib/camlinternalAtomic.mli30
-rw-r--r--stdlib/dune2
-rw-r--r--stdlib/stdlib.ml6
9 files changed, 99 insertions, 43 deletions
diff --git a/stdlib/.depend b/stdlib/.depend
index 74f9692a4e..258d4e38d7 100644
--- a/stdlib/.depend
+++ b/stdlib/.depend
@@ -32,8 +32,10 @@ stdlib__arrayLabels.cmx : \
stdlib__arrayLabels.cmi : \
stdlib__seq.cmi
stdlib__atomic.cmo : \
+ camlinternalAtomic.cmi \
stdlib__atomic.cmi
stdlib__atomic.cmx : \
+ camlinternalAtomic.cmx \
stdlib__atomic.cmi
stdlib__atomic.cmi :
stdlib__bigarray.cmo : \
@@ -103,6 +105,11 @@ stdlib__callback.cmx : \
stdlib__obj.cmx \
stdlib__callback.cmi
stdlib__callback.cmi :
+camlinternalAtomic.cmo : \
+ camlinternalAtomic.cmi
+camlinternalAtomic.cmx : \
+ camlinternalAtomic.cmi
+camlinternalAtomic.cmi :
camlinternalFormat.cmo : \
stdlib__sys.cmi \
stdlib__string.cmi \
@@ -687,9 +694,11 @@ stdlib__weak.cmi : \
stdlib__hashtbl.cmi
stdlib.cmo : \
camlinternalFormatBasics.cmi \
+ camlinternalAtomic.cmi \
stdlib.cmi
stdlib.cmx : \
camlinternalFormatBasics.cmx \
+ camlinternalAtomic.cmx \
stdlib.cmi
stdlib.cmi : \
camlinternalFormatBasics.cmi
diff --git a/stdlib/Compflags b/stdlib/Compflags
index 7382ec932b..3fa37a3651 100755
--- a/stdlib/Compflags
+++ b/stdlib/Compflags
@@ -20,7 +20,7 @@ case $1 in
' -pp "$AWK -f ./expand_module_aliases.awk"';;
# stdlib dependencies
camlinternalFormatBasics*.cm[iox]) echo ' -nopervasives';;
- stdlib__atomic*.cm[iox]) echo ' -nopervasives';;
+ camlinternalAtomic.cm[iox]) echo ' -nopervasives';;
# end stdlib dependencies
camlinternalOO.cmx) echo ' -inline 0 -afl-inst-ratio 0';;
camlinternalLazy.cmx) echo ' -afl-inst-ratio 0';;
diff --git a/stdlib/Makefile b/stdlib/Makefile
index b76bd551bb..83c2976595 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -34,7 +34,7 @@ OC_CPPFLAGS += -I$(ROOTDIR)/runtime
include StdlibModules
OBJS=$(addsuffix .cmo,$(STDLIB_MODULES))
-NOSTDLIB= camlinternalFormatBasics.cmo stdlib__atomic.cmo stdlib.cmo
+NOSTDLIB= camlinternalFormatBasics.cmo camlinternalAtomic.cmo stdlib.cmo
OTHERS=$(filter-out $(NOSTDLIB),$(OBJS))
PREFIXED_OBJS=$(filter stdlib__%.cmo,$(OBJS))
diff --git a/stdlib/StdlibModules b/stdlib/StdlibModules
index 83d7936e8a..d21befe9d1 100644
--- a/stdlib/StdlibModules
+++ b/stdlib/StdlibModules
@@ -30,11 +30,12 @@ endef
# Modules should be listed in dependency order.
STDLIB_MODS=\
- camlinternalFormatBasics atomic \
+ camlinternalFormatBasics camlinternalAtomic \
stdlib pervasives seq option result bool char uchar \
sys list bytes string unit marshal obj array float int int32 int64 nativeint \
lexing parsing set map stack queue camlinternalLazy lazy stream buffer \
- camlinternalFormat printf arg printexc fun gc digest random hashtbl weak \
+ camlinternalFormat printf arg atomic \
+ printexc fun gc digest random hashtbl weak \
format scanf callback camlinternalOO oo camlinternalMod genlex ephemeron \
filename complex arrayLabels listLabels bytesLabels stringLabels moreLabels \
stdLabels spacetime bigarray
diff --git a/stdlib/atomic.ml b/stdlib/atomic.ml
index b47b50e622..a60a2451f2 100644
--- a/stdlib/atomic.ml
+++ b/stdlib/atomic.ml
@@ -2,7 +2,7 @@
(* *)
(* OCaml *)
(* *)
-(* Gabriel Scherer, projet Partout, INRIA Paris-Saclay *)
+(* Guillaume Munch-Maccagnoni, projet Gallinette, INRIA *)
(* *)
(* Copyright 2020 Institut National de Recherche en Informatique et *)
(* en Automatique. *)
@@ -13,37 +13,4 @@
(* *)
(**************************************************************************)
-(* Atomic is a dependency of Stdlib, so it is compiled with
- -nopervasives. *)
-external ( == ) : 'a -> 'a -> bool = "%eq"
-external ( + ) : int -> int -> int = "%addint"
-external ignore : 'a -> unit = "%ignore"
-
-(* We are not reusing ('a ref) directly to make it easier to reason
- about atomicity if we wish to: even in a sequential implementation,
- signals and other asynchronous callbacks might break atomicity. *)
-type 'a t = {mutable v: 'a}
-
-let make v = {v}
-let get r = r.v
-let set r v = r.v <- v
-
-let exchange r v =
- let cur = r.v in
- r.v <- v;
- cur
-
-let compare_and_set r seen v =
- let cur = r.v in
- if cur == seen then
- (r.v <- v; true)
- else
- false
-
-let fetch_and_add r n =
- let cur = r.v in
- r.v <- (cur + n);
- cur
-
-let incr r = ignore (fetch_and_add r 1)
-let decr r = ignore (fetch_and_add r (-1))
+include CamlinternalAtomic
diff --git a/stdlib/camlinternalAtomic.ml b/stdlib/camlinternalAtomic.ml
new file mode 100644
index 0000000000..c738453301
--- /dev/null
+++ b/stdlib/camlinternalAtomic.ml
@@ -0,0 +1,49 @@
+(**************************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Gabriel Scherer, projet Partout, INRIA Paris-Saclay *)
+(* *)
+(* Copyright 2020 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. *)
+(* *)
+(**************************************************************************)
+
+(* CamlinternalAtomic is a dependency of Stdlib, so it is compiled with
+ -nopervasives. *)
+external ( == ) : 'a -> 'a -> bool = "%eq"
+external ( + ) : int -> int -> int = "%addint"
+external ignore : 'a -> unit = "%ignore"
+
+(* We are not reusing ('a ref) directly to make it easier to reason
+ about atomicity if we wish to: even in a sequential implementation,
+ signals and other asynchronous callbacks might break atomicity. *)
+type 'a t = {mutable v: 'a}
+
+let make v = {v}
+let get r = r.v
+let set r v = r.v <- v
+
+let exchange r v =
+ let cur = r.v in
+ r.v <- v;
+ cur
+
+let compare_and_set r seen v =
+ let cur = r.v in
+ if cur == seen then
+ (r.v <- v; true)
+ else
+ false
+
+let fetch_and_add r n =
+ let cur = r.v in
+ r.v <- (cur + n);
+ cur
+
+let incr r = ignore (fetch_and_add r 1)
+let decr r = ignore (fetch_and_add r (-1))
diff --git a/stdlib/camlinternalAtomic.mli b/stdlib/camlinternalAtomic.mli
new file mode 100644
index 0000000000..f5eb36c42d
--- /dev/null
+++ b/stdlib/camlinternalAtomic.mli
@@ -0,0 +1,30 @@
+(**************************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Stephen Dolan, University of Cambridge *)
+(* Guillaume Munch-Maccagnoni, projet Gallinette, INRIA *)
+(* *)
+(* Copyright 2020 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. *)
+(* *)
+(**************************************************************************)
+
+(* The documentation is in atomic.mli. CamlinternalAtomic exists in
+ order to be a dependency of Stdlib. More precisely, the option
+ modules_before_stdlib used in stdlib/dune does not support the
+ Stdlib__ prefix trick. *)
+
+type 'a t
+val make : 'a -> 'a t
+val get : 'a t -> 'a
+val set : 'a t -> 'a -> unit
+val exchange : 'a t -> 'a -> 'a
+val compare_and_set : 'a t -> 'a -> 'a -> bool
+val fetch_and_add : int t -> int -> int
+val incr : int t -> unit
+val decr : int t -> unit
diff --git a/stdlib/dune b/stdlib/dune
index ac57286db9..cd2ff217aa 100644
--- a/stdlib/dune
+++ b/stdlib/dune
@@ -19,7 +19,7 @@
(internal_modules Camlinternal*)
(modules_before_stdlib
camlinternalFormatBasics
- stdlib__atomic))
+ camlinternalAtomic))
(flags (:standard -w -9 -nolabels))
(preprocess
(per_module
diff --git a/stdlib/stdlib.ml b/stdlib/stdlib.ml
index eec461bd19..a3c58a080a 100644
--- a/stdlib/stdlib.ml
+++ b/stdlib/stdlib.ml
@@ -543,10 +543,10 @@ let ( ^^ ) (Format (fmt1, str1)) (Format (fmt2, str2)) =
external sys_exit : int -> 'a = "caml_sys_exit"
-let exit_function = Stdlib__atomic.make flush_all
+let exit_function = CamlinternalAtomic.make flush_all
let rec at_exit f =
- let module Atomic = Stdlib__atomic in
+ let module Atomic = CamlinternalAtomic in
(* MPR#7253, MPR#7796: make sure "f" is executed only once *)
let f_yet_to_run = Atomic.make true in
let old_exit = Atomic.get exit_function in
@@ -557,7 +557,7 @@ let rec at_exit f =
let success = Atomic.compare_and_set exit_function old_exit new_exit in
if not success then at_exit f
-let do_at_exit () = (Stdlib__atomic.get exit_function) ()
+let do_at_exit () = (CamlinternalAtomic.get exit_function) ()
let exit retcode =
do_at_exit ();