| ... | ... | @@ -4880,10 +4880,7 @@ fn futexWait(t: *Threaded, ptr: *const std.atomic.Value(u32), expect: u32) Io.Ca |
| 4880 | 4880 | .FAULT => unreachable, // ptr was invalid |
| 4881 | 4881 | else => unreachable, |
| 4882 | 4882 | }; |
| 4883 | | return; |
| 4884 | | } |
| 4885 | | |
| 4886 | | if (native_os.isDarwin()) { |
| 4883 | } else if (native_os.isDarwin()) { |
| 4887 | 4884 | const c = std.c; |
| 4888 | 4885 | const flags: c.UL = .{ |
| 4889 | 4886 | .op = .COMPARE_AND_WAIT, |
| ... | ... | @@ -4907,10 +4904,7 @@ fn futexWait(t: *Threaded, ptr: *const std.atomic.Value(u32), expect: u32) Io.Ca |
| 4907 | 4904 | .TIMEDOUT => unreachable, |
| 4908 | 4905 | else => unreachable, |
| 4909 | 4906 | }; |
| 4910 | | return; |
| 4911 | | } |
| 4912 | | |
| 4913 | | if (builtin.cpu.arch.isWasm()) { |
| 4907 | } else if (builtin.cpu.arch.isWasm()) { |
| 4914 | 4908 | comptime assert(builtin.cpu.has(.wasm, .atomics)); |
| 4915 | 4909 | try t.checkCancel(); |
| 4916 | 4910 | const timeout: i64 = -1; |
| ... | ... | @@ -4933,10 +4927,16 @@ fn futexWait(t: *Threaded, ptr: *const std.atomic.Value(u32), expect: u32) Io.Ca |
| 4933 | 4927 | 2 => assert(!is_debug), // timeout |
| 4934 | 4928 | else => assert(!is_debug), |
| 4935 | 4929 | } |
| 4936 | | return; |
| 4930 | } else if (is_windows) { |
| 4931 | try t.checkCancel(); |
| 4932 | switch (windows.ntdll.RtlWaitOnAddress(ptr, &expect, @sizeOf(@TypeOf(expect)), null)) { |
| 4933 | .SUCCESS => {}, |
| 4934 | .CANCELLED => return error.Canceled, |
| 4935 | else => recoverableOsBugDetected(), |
| 4936 | } |
| 4937 | } else { |
| 4938 | @compileError("TODO"); |
| 4937 | 4939 | } |
| 4938 | | |
| 4939 | | @compileError("TODO"); |
| 4940 | 4940 | } |
| 4941 | 4941 | |
| 4942 | 4942 | pub fn futexWaitUncancelable(ptr: *const std.atomic.Value(u32), expect: u32) void { |
| ... | ... | @@ -4954,10 +4954,7 @@ pub fn futexWaitUncancelable(ptr: *const std.atomic.Value(u32), expect: u32) voi |
| 4954 | 4954 | .FAULT => unreachable, // ptr was invalid |
| 4955 | 4955 | else => unreachable, |
| 4956 | 4956 | }; |
| 4957 | | return; |
| 4958 | | } |
| 4959 | | |
| 4960 | | if (native_os.isDarwin()) { |
| 4957 | } else if (native_os.isDarwin()) { |
| 4961 | 4958 | const c = std.c; |
| 4962 | 4959 | const flags: c.UL = .{ |
| 4963 | 4960 | .op = .COMPARE_AND_WAIT, |
| ... | ... | @@ -4980,10 +4977,7 @@ pub fn futexWaitUncancelable(ptr: *const std.atomic.Value(u32), expect: u32) voi |
| 4980 | 4977 | .TIMEDOUT => unreachable, |
| 4981 | 4978 | else => unreachable, |
| 4982 | 4979 | }; |
| 4983 | | return; |
| 4984 | | } |
| 4985 | | |
| 4986 | | if (builtin.cpu.arch.isWasm()) { |
| 4980 | } else if (builtin.cpu.arch.isWasm()) { |
| 4987 | 4981 | comptime assert(builtin.cpu.has(.wasm, .atomics)); |
| 4988 | 4982 | const timeout: i64 = -1; |
| 4989 | 4983 | const signed_expect: i32 = @bitCast(expect); |
| ... | ... | @@ -5005,10 +4999,14 @@ pub fn futexWaitUncancelable(ptr: *const std.atomic.Value(u32), expect: u32) voi |
| 5005 | 4999 | 2 => assert(!is_debug), // timeout |
| 5006 | 5000 | else => assert(!is_debug), |
| 5007 | 5001 | } |
| 5008 | | return; |
| 5002 | } else if (is_windows) { |
| 5003 | switch (windows.ntdll.RtlWaitOnAddress(ptr, &expect, @sizeOf(@TypeOf(expect)), null)) { |
| 5004 | .SUCCESS, .CANCELLED => {}, |
| 5005 | else => recoverableOsBugDetected(), |
| 5006 | } |
| 5007 | } else { |
| 5008 | @compileError("TODO"); |
| 5009 | 5009 | } |
| 5010 | | |
| 5011 | | @compileError("TODO"); |
| 5012 | 5010 | } |
| 5013 | 5011 | |
| 5014 | 5012 | pub fn futexWaitDurationUncancelable(ptr: *const std.atomic.Value(u32), expect: u32, timeout: Io.Duration) void { |
| ... | ... | @@ -5028,9 +5026,9 @@ pub fn futexWaitDurationUncancelable(ptr: *const std.atomic.Value(u32), expect: |
| 5028 | 5026 | else => unreachable, |
| 5029 | 5027 | }; |
| 5030 | 5028 | return; |
| 5029 | } else { |
| 5030 | @compileError("TODO"); |
| 5031 | 5031 | } |
| 5032 | | |
| 5033 | | @compileError("TODO"); |
| 5034 | 5032 | } |
| 5035 | 5033 | |
| 5036 | 5034 | pub fn futexWake(ptr: *const std.atomic.Value(u32), max_waiters: u32) void { |
| ... | ... | @@ -5049,10 +5047,7 @@ pub fn futexWake(ptr: *const std.atomic.Value(u32), max_waiters: u32) void { |
| 5049 | 5047 | .FAULT => {}, // pointer became invalid while doing the wake |
| 5050 | 5048 | else => unreachable, |
| 5051 | 5049 | }; |
| 5052 | | return; |
| 5053 | | } |
| 5054 | | |
| 5055 | | if (native_os.isDarwin()) { |
| 5050 | } else if (native_os.isDarwin()) { |
| 5056 | 5051 | const c = std.c; |
| 5057 | 5052 | const flags: c.UL = .{ |
| 5058 | 5053 | .op = .COMPARE_AND_WAIT, |
| ... | ... | @@ -5071,9 +5066,7 @@ pub fn futexWake(ptr: *const std.atomic.Value(u32), max_waiters: u32) void { |
| 5071 | 5066 | else => assert(!is_debug), |
| 5072 | 5067 | } |
| 5073 | 5068 | } |
| 5074 | | } |
| 5075 | | |
| 5076 | | if (builtin.cpu.arch.isWasm()) { |
| 5069 | } else if (builtin.cpu.arch.isWasm()) { |
| 5077 | 5070 | comptime assert(builtin.cpu.has(.wasm, .atomics)); |
| 5078 | 5071 | assert(max_waiters != 0); |
| 5079 | 5072 | const woken_count = asm volatile ( |
| ... | ... | @@ -5086,10 +5079,15 @@ pub fn futexWake(ptr: *const std.atomic.Value(u32), max_waiters: u32) void { |
| 5086 | 5079 | [waiters] "r" (max_waiters), |
| 5087 | 5080 | ); |
| 5088 | 5081 | _ = woken_count; // can be 0 when linker flag 'shared-memory' is not enabled |
| 5089 | | return; |
| 5082 | } else if (is_windows) { |
| 5083 | assert(max_waiters != 0); |
| 5084 | switch (max_waiters) { |
| 5085 | 1 => windows.ntdll.RtlWakeAddressSingle(ptr), |
| 5086 | else => windows.ntdll.RtlWakeAddressAll(ptr), |
| 5087 | } |
| 5088 | } else { |
| 5089 | @compileError("TODO"); |
| 5090 | 5090 | } |
| 5091 | | |
| 5092 | | @compileError("TODO"); |
| 5093 | 5091 | } |
| 5094 | 5092 | |
| 5095 | 5093 | /// A thread-safe logical boolean value which can be `set` and `unset`. |