diff --git a/dune-project b/dune-project index 4070162..66ab1bc 100644 --- a/dune-project +++ b/dune-project @@ -50,8 +50,5 @@ (depends (ocaml (>= 4.12.0)) - ;; Test dependencies - (multicore-magic - (>= 2.2.0)) (dscheck - (= dev)))) + (>= 0.5.0)))) diff --git a/multicore-magic-dscheck.opam b/multicore-magic-dscheck.opam index 2b2727d..32bc643 100644 --- a/multicore-magic-dscheck.opam +++ b/multicore-magic-dscheck.opam @@ -10,8 +10,7 @@ bug-reports: "https://github.com/ocaml-multicore/multicore-magic/issues" depends: [ "dune" {>= "3.14"} "ocaml" {>= "4.12.0"} - "multicore-magic" {>= "2.2.0"} - "dscheck" {= "dev"} + "dscheck" {>= "0.5.0"} "odoc" {with-doc} ] build: [ diff --git a/src/dscheck/dune b/src/dscheck/dune index ca2144d..b4de21a 100644 --- a/src/dscheck/dune +++ b/src/dscheck/dune @@ -1,6 +1,6 @@ (library (name multicore_magic_dscheck) (public_name multicore-magic-dscheck) - (libraries multicore-magic dscheck) + (libraries dscheck) (enabled_if (>= %{ocaml_version} 5))) diff --git a/src/dscheck/multicore_magic.ml b/src/dscheck/multicore_magic.ml index b47354a..0af3718 100644 --- a/src/dscheck/multicore_magic.ml +++ b/src/dscheck/multicore_magic.ml @@ -1,6 +1,7 @@ module Atomic = Dscheck.TracedAtomic let copy_as_padded = Fun.id +let copy_as ?padded:_ x = x let make_padded_array = Array.make let length_of_padded_array = Array.length let length_of_padded_array_minus_1 xs = Array.length xs - 1 @@ -13,29 +14,22 @@ module Transparent_atomic = struct let fenceless_set = set end -let[@inline] fenceless_get (atomic : 'a Atomic.t) = - !(Sys.opaque_identity (Obj.magic atomic : 'a ref)) - -let[@inline] fenceless_set (atomic : 'a Atomic.t) value = - (Obj.magic atomic : 'a ref) := value - +let fenceless_get = Atomic.get +let fenceless_set = Atomic.set let[@inline] fence atomic = Atomic.fetch_and_add atomic 0 |> ignore module Atomic_array = struct type 'a t = 'a Atomic.t array - let[@inline] at (type a) (xs : a t) i : a Atomic.t = - (* ['a t] does not contain [float]s. *) - Obj.magic (Array.unsafe_get (Obj.magic xs : a ref array) i) - + let[@inline] at (xs : 'a t) i : 'a Atomic.t = Array.get xs i let[@inline] make n v = Array.init n @@ fun _ -> Atomic.make v let[@inline] init n fn = Array.init n @@ fun i -> Atomic.make (fn i) - let[@inline] of_array xs = init (Array.length xs) (Array.unsafe_get xs) + let[@inline] of_array xs = init (Array.length xs) (Array.get xs) external length : 'a array -> int = "%array_length" - let[@inline] unsafe_fenceless_set xs i v = Obj.magic (at xs i) := v - let[@inline] unsafe_fenceless_get xs i = !(Obj.magic (at xs i)) + let unsafe_fenceless_set xs i v = Atomic.set xs.(i) v + let unsafe_fenceless_get xs i = Atomic.get xs.(i) let[@inline] unsafe_compare_and_set xs i b a = Atomic.compare_and_set (at xs i) b a diff --git a/src/dscheck/multicore_magic.mli b/src/dscheck/multicore_magic.mli index faa3163..fc7e9b2 100644 --- a/src/dscheck/multicore_magic.mli +++ b/src/dscheck/multicore_magic.mli @@ -1,6 +1,7 @@ module Atomic = Dscheck.TracedAtomic val copy_as_padded : 'a -> 'a +val copy_as : ?padded:bool -> 'a -> 'a val make_padded_array : int -> 'a -> 'a array val length_of_padded_array : 'a array -> int val length_of_padded_array_minus_1 : 'a array -> int