@@ -196,7 +196,10 @@ const DarwinImpl = struct {
196196 var timeout_overflowed = false ;
197197
198198 const addr : * const anyopaque = ptr ;
199- const flags = c .UL_COMPARE_AND_WAIT | c .ULF_NO_ERRNO ;
199+ const flags : c.UL = .{
200+ .op = .COMPARE_AND_WAIT ,
201+ .NO_ERRNO = true ,
202+ };
200203 const status = blk : {
201204 if (supports_ulock_wait2 ) {
202205 break :blk c .__ulock_wait2 (flags , addr , expect , timeout_ns , 0 );
@@ -228,10 +231,11 @@ const DarwinImpl = struct {
228231 }
229232
230233 fn wake (ptr : * const atomic .Value (u32 ), max_waiters : u32 ) void {
231- var flags : u32 = c .UL_COMPARE_AND_WAIT | c .ULF_NO_ERRNO ;
232- if (max_waiters > 1 ) {
233- flags |= c .ULF_WAKE_ALL ;
234- }
234+ const flags : c.UL = .{
235+ .op = .COMPARE_AND_WAIT ,
236+ .NO_ERRNO = true ,
237+ .WAKE_ALL = max_waiters > 1 ,
238+ };
235239
236240 while (true ) {
237241 const addr : * const anyopaque = ptr ;
@@ -242,7 +246,7 @@ const DarwinImpl = struct {
242246 .INTR = > continue , // spurious wake()
243247 .FAULT = > unreachable , // __ulock_wake doesn't generate EFAULT according to darwin pthread_cond_t
244248 .NOENT = > return , // nothing was woken up
245- .ALREADY = > unreachable , // only for ULF_WAKE_THREAD
249+ .ALREADY = > unreachable , // only for UL.Op.WAKE_THREAD
246250 else = > unreachable ,
247251 }
248252 }
@@ -254,8 +258,8 @@ const LinuxImpl = struct {
254258 fn wait (ptr : * const atomic .Value (u32 ), expect : u32 , timeout : ? u64 ) error {Timeout }! void {
255259 var ts : linux.timespec = undefined ;
256260 if (timeout ) | timeout_ns | {
257- ts .tv_sec = @as (@TypeOf (ts .tv_sec ), @intCast (timeout_ns / std .time .ns_per_s ));
258- ts .tv_nsec = @as (@TypeOf (ts .tv_nsec ), @intCast (timeout_ns % std .time .ns_per_s ));
261+ ts .sec = @as (@TypeOf (ts .sec ), @intCast (timeout_ns / std .time .ns_per_s ));
262+ ts .nsec = @as (@TypeOf (ts .nsec ), @intCast (timeout_ns % std .time .ns_per_s ));
259263 }
260264
261265 const rc = linux .futex_wait (
@@ -306,10 +310,10 @@ const FreebsdImpl = struct {
306310 tm_ptr = & tm ;
307311 tm_size = @sizeOf (@TypeOf (tm ));
308312
309- tm ._flags = 0 ; // use relative time not UMTX_ABSTIME
310- tm ._clockid = c . CLOCK .MONOTONIC ;
311- tm ._timeout . tv_sec = @as (@TypeOf (tm ._timeout . tv_sec ), @intCast (timeout_ns / std .time .ns_per_s ));
312- tm ._timeout . tv_nsec = @as (@TypeOf (tm ._timeout . tv_nsec ), @intCast (timeout_ns % std .time .ns_per_s ));
313+ tm .flags = 0 ; // use relative time not UMTX_ABSTIME
314+ tm .clockid = .MONOTONIC ;
315+ tm .timeout . sec = @as (@TypeOf (tm .timeout . sec ), @intCast (timeout_ns / std .time .ns_per_s ));
316+ tm .timeout . nsec = @as (@TypeOf (tm .timeout . nsec ), @intCast (timeout_ns % std .time .ns_per_s ));
313317 }
314318
315319 const rc = c ._umtx_op (
@@ -356,16 +360,16 @@ const OpenbsdImpl = struct {
356360 fn wait (ptr : * const atomic .Value (u32 ), expect : u32 , timeout : ? u64 ) error {Timeout }! void {
357361 var ts : c.timespec = undefined ;
358362 if (timeout ) | timeout_ns | {
359- ts .tv_sec = @as (@TypeOf (ts .tv_sec ), @intCast (timeout_ns / std .time .ns_per_s ));
360- ts .tv_nsec = @as (@TypeOf (ts .tv_nsec ), @intCast (timeout_ns % std .time .ns_per_s ));
363+ ts .sec = @as (@TypeOf (ts .sec ), @intCast (timeout_ns / std .time .ns_per_s ));
364+ ts .nsec = @as (@TypeOf (ts .nsec ), @intCast (timeout_ns % std .time .ns_per_s ));
361365 }
362366
363367 const rc = c .futex (
364368 @as (* const volatile u32 , @ptrCast (& ptr .raw )),
365- c .FUTEX_WAIT | c .FUTEX_PRIVATE_FLAG ,
369+ c .FUTEX . WAIT | c .FUTEX . PRIVATE_FLAG ,
366370 @as (c_int , @bitCast (expect )),
367371 if (timeout != null ) & ts else null ,
368- null , // FUTEX_WAIT takes no requeue address
372+ null , // FUTEX.WAIT takes no requeue address
369373 );
370374
371375 switch (std .posix .errno (rc )) {
@@ -387,10 +391,10 @@ const OpenbsdImpl = struct {
387391 fn wake (ptr : * const atomic .Value (u32 ), max_waiters : u32 ) void {
388392 const rc = c .futex (
389393 @as (* const volatile u32 , @ptrCast (& ptr .raw )),
390- c .FUTEX_WAKE | c .FUTEX_PRIVATE_FLAG ,
394+ c .FUTEX . WAKE | c .FUTEX . PRIVATE_FLAG ,
391395 std .math .cast (c_int , max_waiters ) orelse std .math .maxInt (c_int ),
392- null , // FUTEX_WAKE takes no timeout ptr
393- null , // FUTEX_WAKE takes no requeue address
396+ null , // FUTEX.WAKE takes no timeout ptr
397+ null , // FUTEX.WAKE takes no requeue address
394398 );
395399
396400 // returns number of threads woken up.
@@ -540,12 +544,12 @@ const PosixImpl = struct {
540544 var ts : c.timespec = undefined ;
541545 if (timeout ) | timeout_ns | {
542546 std .posix .clock_gettime (c .CLOCK .REALTIME , & ts ) catch unreachable ;
543- ts .tv_sec + |= @as (@TypeOf (ts .tv_sec ), @intCast (timeout_ns / std .time .ns_per_s ));
544- ts .tv_nsec += @as (@TypeOf (ts .tv_nsec ), @intCast (timeout_ns % std .time .ns_per_s ));
547+ ts .sec + |= @as (@TypeOf (ts .sec ), @intCast (timeout_ns / std .time .ns_per_s ));
548+ ts .nsec += @as (@TypeOf (ts .nsec ), @intCast (timeout_ns % std .time .ns_per_s ));
545549
546- if (ts .tv_nsec >= std .time .ns_per_s ) {
547- ts .tv_sec + |= 1 ;
548- ts .tv_nsec -= std .time .ns_per_s ;
550+ if (ts .nsec >= std .time .ns_per_s ) {
551+ ts .sec + |= 1 ;
552+ ts .nsec -= std .time .ns_per_s ;
549553 }
550554 }
551555
0 commit comments