removed: Wait_Notify_Available global
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 27 Jun 2023 16:40:19 +0000 (11:40 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 27 Jun 2023 16:40:19 +0000 (11:40 -0500)
compiler/src/builtins.c
core/intrinsics/atomics.onyx
core/sync/semaphore.onyx
core/threads/thread.onyx

index 8f256c5de3955879ceb28e50d4fe293f735edb07..ef30beec9aaeecbc828e50cd7985daf082c79696 100644 (file)
@@ -600,10 +600,6 @@ void introduce_build_options(bh_allocator a) {
     multi_threaded->type_node = (AstType *) &basic_type_bool;
     symbol_builtin_introduce(p->scope, "Multi_Threading_Enabled", (AstNode *) multi_threaded);
 
-    AstNumLit* wait_notify_available = make_int_literal(a, context.options->use_multi_threading && context.options->runtime == Runtime_Js);
-    wait_notify_available->type_node = (AstType *) &basic_type_bool;
-    symbol_builtin_introduce(p->scope, "Wait_Notify_Available", (AstNode *) wait_notify_available);
-
     AstNumLit* debug_mode = make_int_literal(a, context.options->debug_info_enabled);
     debug_mode->type_node = (AstType *) &basic_type_bool;
     symbol_builtin_introduce(p->scope, "Debug_Mode_Enabled", (AstNode *) debug_mode);
index 0fea7817f886d922c1270891b272487bdb067f5e..131015f36f695e8798bc5ce4c91820667ba69ca5 100644 (file)
@@ -9,10 +9,8 @@ package core.intrinsics.atomics
 }
 
 // __atomic_wait is only valid for i32 and i64
-#if runtime.Wait_Notify_Available {
-    __atomic_wait   :: (addr: &$T, value: T, timeout: i64 = -1) -> i32 #intrinsic ---
-    __atomic_notify :: (addr: rawptr, maximum: i32 = 1) -> i32 #intrinsic ---
-}
+__atomic_wait   :: (addr: &$T, value: T, timeout: i64 = -1) -> i32 #intrinsic ---
+__atomic_notify :: (addr: rawptr, maximum: i32 = 1) -> i32 #intrinsic ---
 
 __atomic_fence  :: () -> void #intrinsic ---
 
index 100454f7cb38f87660cfab57ce64a6ff990693bf..d389f57f0a7682af3f567d2339bad005588dff96 100644 (file)
@@ -3,10 +3,6 @@ package core.sync
 use runtime
 use core
 
-#if runtime.Wait_Notify_Available {
-    use core.intrinsics.atomics {__atomic_wait, __atomic_notify}
-}
-
 #doc """
     A semaphore represents a counter that can only be incremented
     and decremented by one thread at a time. "Waiting" on a semaphore
index caefd3e5702f1f40b83872f9a182ce8a2f2e24e3..c9a5e11496d8178d3927f77ea72b0fdd68689a18 100644 (file)
@@ -54,8 +54,8 @@ spawn :: (t: &Thread, data: &$T, func: (&T) -> void) {
 """
 join :: (t: &Thread) {
     while t.alive {
-        #if runtime.Wait_Notify_Available {
-            __atomic_wait(&t.id, t.id);
+        #if runtime.platform.Supports_Futexes {
+            runtime.platform.__futex_wait(&t.id, t.id, -1);
         } else {
             // To not completely kill the CPU.
             runtime.platform.__sleep(1);
@@ -94,8 +94,8 @@ __exited :: (id: i32) {
     thread := thread_map->get(id)?;
     if thread != null {
         thread.alive = false;
-        #if runtime.Wait_Notify_Available {
-            __atomic_notify(&thread.id);
+        #if runtime.platform.Supports_Futexes {
+            runtime.platform.__futex_wake(&thread.id, 1);
         }
 
         thread_map->delete(id);