-
Notifications
You must be signed in to change notification settings - Fork 76
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
10 changed files
with
109 additions
and
13 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
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
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
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,28 @@ | ||
(* TEST | ||
modules = "aligned_alloc_stubs.c" | ||
* runtime4 | ||
** skip | ||
* runtime5 | ||
** native | ||
*) | ||
|
||
external is_aligned : 'a Atomic.t -> bool = "caml_atomic_is_aligned" | ||
let test_is_aligned () = | ||
let l = List.init 100 Atomic.make in | ||
let all_aligned = | ||
List.for_all is_aligned l | ||
in | ||
assert (not all_aligned) | ||
;; | ||
|
||
let test_make_contended () = | ||
let l = List.init 100 Atomic.make_contended in | ||
List.iteri (fun i atomic -> | ||
assert (Atomic.get atomic == i); | ||
assert (is_aligned atomic)) l | ||
;; | ||
|
||
let () = | ||
test_is_aligned (); | ||
test_make_contended (); | ||
;; |
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,12 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "caml/alloc.h" | ||
|
||
CAMLprim value caml_atomic_is_aligned(value val) | ||
{ | ||
if ((uintptr_t)Hp_val(val) % Cache_line_bsize == 0) { | ||
return Val_true; | ||
} else { | ||
return Val_false; | ||
} | ||
} |
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