-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(** This "fixes" [Atomic] of OCaml 5 in two ways: | ||
* [Atomic.get] is incorrectly subject to CSE optimization in OCaml 5. | ||
* OCaml 5 generates inefficient accesses of ['a Atomic.t array]s assuming | ||
that the array might be a double array. *) | ||
|
||
include Atomic | ||
|
||
type 'a t = private 'a ref | ||
|
||
open struct | ||
external as_atomic : 'a t -> 'a Atomic.t = "%identity" | ||
external of_atomic : 'a Atomic.t -> 'a t = "%identity" | ||
end | ||
|
||
let[@inline] make x = of_atomic (make x) | ||
let[@inline] get x = get (Sys.opaque_identity (as_atomic x)) | ||
let[@inline] compare_and_set x b a = compare_and_set (as_atomic x) b a | ||
let[@inline] exchange x v = exchange (as_atomic x) v | ||
let[@inline] set x v = set (as_atomic x) v | ||
let[@inline] fetch_and_add x v = fetch_and_add (as_atomic x) v | ||
let[@inline] incr x = incr (as_atomic x) | ||
let[@inline] decr x = decr (as_atomic x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters