forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ocaml#11272 from gadmm/caml_try_get_caml_state3
Make `Caml_state` `NULL` while the domain lock is not held (cherry picked from commit bc36f00)
- Loading branch information
Showing
11 changed files
with
135 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(* TEST | ||
modules = "test_c_thread_has_lock_cstubs.c" | ||
* bytecode | ||
* native | ||
*) | ||
|
||
external test_with_lock : unit -> bool = "with_lock" | ||
external test_without_lock : unit -> bool = "without_lock" | ||
|
||
let passed b = Printf.printf (if b then "passed\n" else "failed\n") | ||
|
||
let f () = | ||
passed (not (test_without_lock ())) ; | ||
passed (test_with_lock ()) | ||
|
||
let _ = | ||
f (); |
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,2 @@ | ||
passed | ||
passed |
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,17 @@ | ||
#include "caml/mlvalues.h" | ||
#include "caml/domain_state.h" | ||
#include "caml/signals.h" | ||
|
||
value with_lock(value unit) | ||
{ | ||
return Val_bool(Caml_state != NULL); | ||
} | ||
|
||
value without_lock(value unit) | ||
{ | ||
int res; | ||
caml_enter_blocking_section(); | ||
res = (Caml_state != NULL); | ||
caml_leave_blocking_section(); | ||
return Val_bool(res); | ||
} |
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,21 @@ | ||
(* TEST | ||
modules = "test_c_thread_has_lock_cstubs.c" | ||
* hassysthreads | ||
include systhreads | ||
** bytecode | ||
** native | ||
*) | ||
|
||
external test_with_lock : unit -> bool = "with_lock" | ||
external test_without_lock : unit -> bool = "without_lock" | ||
|
||
let passed b = Printf.printf (if b then "passed\n" else "failed\n") | ||
|
||
let f () = | ||
passed (not (test_without_lock ())) ; | ||
passed (test_with_lock ()) | ||
|
||
let _ = | ||
f (); | ||
let t = Thread.create f () in | ||
Thread.join t |
4 changes: 4 additions & 0 deletions
4
testsuite/tests/c-api/test_c_thread_has_lock_systhread.reference
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,4 @@ | ||
passed | ||
passed | ||
passed | ||
passed |