From: Brendan Hansen Date: Tue, 27 Jun 2023 16:40:19 +0000 (-0500) Subject: removed: Wait_Notify_Available global X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=158187ee6d56dddec45fc50f96b0495542c449bf;p=onyx.git removed: Wait_Notify_Available global --- diff --git a/compiler/src/builtins.c b/compiler/src/builtins.c index 8f256c5d..ef30beec 100644 --- a/compiler/src/builtins.c +++ b/compiler/src/builtins.c @@ -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); diff --git a/core/intrinsics/atomics.onyx b/core/intrinsics/atomics.onyx index 0fea7817..131015f3 100644 --- a/core/intrinsics/atomics.onyx +++ b/core/intrinsics/atomics.onyx @@ -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 --- diff --git a/core/sync/semaphore.onyx b/core/sync/semaphore.onyx index 100454f7..d389f57f 100644 --- a/core/sync/semaphore.onyx +++ b/core/sync/semaphore.onyx @@ -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 diff --git a/core/threads/thread.onyx b/core/threads/thread.onyx index caefd3e5..c9a5e114 100644 --- a/core/threads/thread.onyx +++ b/core/threads/thread.onyx @@ -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);