@@ -47,7 +47,7 @@ pub const Loop = struct {
47
47
/// Values in the completion queue must not be in the kqueue.
48
48
completions : queue .Intrusive (Completion ) = .{},
49
49
50
- /// Heap of timers. We use heaps instead of the EVFILT_TIMER because
50
+ /// Heap of timers. We use heaps instead of the EVFILT.TIMER because
51
51
/// it avoids a lot of syscalls in the case where there are a LOT of
52
52
/// timers.
53
53
timers : TimerHeap = .{ .context = {} },
@@ -169,7 +169,7 @@ pub const Loop = struct {
169
169
self .completions .push (c );
170
170
171
171
events [events_len ] = ev ;
172
- events [events_len ].flags = posix .system .EV_DELETE ;
172
+ events [events_len ].flags = posix .system .EV . DELETE ;
173
173
events_len += 1 ;
174
174
if (events_len >= events .len ) break :queue_pop ;
175
175
},
@@ -209,12 +209,12 @@ pub const Loop = struct {
209
209
const c : * Completion = @ptrFromInt (@as (usize , @intCast (ev .udata )));
210
210
211
211
// We handle deletions separately.
212
- if (ev .flags & posix .system .EV_DELETE != 0 ) continue ;
212
+ if (ev .flags & posix .system .EV . DELETE != 0 ) continue ;
213
213
214
- // If EV_ERROR is set, then submission failed for this
214
+ // If EV.ERROR is set, then submission failed for this
215
215
// completion. We get the syscall errorcode from data and
216
216
// store it.
217
- if (ev .flags & posix .system .EV_ERROR != 0 ) {
217
+ if (ev .flags & posix .system .EV . ERROR != 0 ) {
218
218
c .result = c .syscall_result (- @as (i32 , @intCast (ev .data )));
219
219
} else {
220
220
// No error, means that this completion is ready to work.
@@ -288,9 +288,9 @@ pub const Loop = struct {
288
288
// event. We have to add here because we need a stable self pointer.
289
289
const events = [_ ]Kevent {.{
290
290
.ident = @as (usize , @intCast (self .mach_port .port )),
291
- .filter = posix .system .EVFILT_MACHPORT ,
292
- .flags = posix .system .EV_ADD | posix .system .EV_ENABLE ,
293
- .fflags = posix .system .MACH_RCV_MSG ,
291
+ .filter = posix .system .EVFILT . MACHPORT ,
292
+ .flags = posix .system .EV . ADD | posix .system .EV . ENABLE ,
293
+ .fflags = posix .system .MACH_PORT_RIGHT . RECEIVE ,
294
294
.data = 0 ,
295
295
.udata = 0 ,
296
296
.ext = .{
@@ -425,7 +425,7 @@ pub const Loop = struct {
425
425
.disarm = > {
426
426
if (disarm_ev ) | ev | {
427
427
events [changes ] = ev ;
428
- events [changes ].flags = posix .system .EV_DELETE ;
428
+ events [changes ].flags = posix .system .EV . DELETE ;
429
429
events [changes ].udata = 0 ;
430
430
changes += 1 ;
431
431
assert (changes <= events .len );
@@ -448,16 +448,16 @@ pub const Loop = struct {
448
448
const t = self .timers .peek () orelse break :timeout null ;
449
449
450
450
// Determine the time in milliseconds.
451
- const ms_now = @as (u64 , @intCast (self .cached_now .tv_sec )) * std .time .ms_per_s +
452
- @as (u64 , @intCast (self .cached_now .tv_nsec )) / std .time .ns_per_ms ;
453
- const ms_next = @as (u64 , @intCast (t .next .tv_sec )) * std .time .ms_per_s +
454
- @as (u64 , @intCast (t .next .tv_nsec )) / std .time .ns_per_ms ;
451
+ const ms_now = @as (u64 , @intCast (self .cached_now .sec )) * std .time .ms_per_s +
452
+ @as (u64 , @intCast (self .cached_now .nsec )) / std .time .ns_per_ms ;
453
+ const ms_next = @as (u64 , @intCast (t .next .sec )) * std .time .ms_per_s +
454
+ @as (u64 , @intCast (t .next .nsec )) / std .time .ns_per_ms ;
455
455
const ms = ms_next - | ms_now ;
456
456
457
457
// Convert to s/ns for the timespec
458
458
const sec = ms / std .time .ms_per_s ;
459
459
const nsec = (ms % std .time .ms_per_s ) * std .time .ns_per_ms ;
460
- break :timeout .{ .tv_sec = @intCast (sec ), .tv_nsec = @intCast (nsec ) };
460
+ break :timeout .{ .sec = @intCast (sec ), .nsec = @intCast (nsec ) };
461
461
};
462
462
463
463
// Wait for changes. Note that we ALWAYS attempt to get completions
@@ -495,13 +495,13 @@ pub const Loop = struct {
495
495
// Ignore any successful deletions. This can only happen
496
496
// from disarms below and in that case we already processed
497
497
// their callback.
498
- if (ev .flags & posix .system .EV_DELETE != 0 ) continue ;
498
+ if (ev .flags & posix .system .EV . DELETE != 0 ) continue ;
499
499
500
500
// This can only be set during changelist processing so
501
501
// that means that this event was never actually active.
502
502
// Therefore, we only decrement the waiters by 1 if we
503
503
// processed an active change.
504
- if (ev .flags & posix .system .EV_ERROR != 0 ) {
504
+ if (ev .flags & posix .system .EV . ERROR != 0 ) {
505
505
// We cannot use c here because c is already dead
506
506
// at this point for this event.
507
507
continue ;
@@ -521,7 +521,7 @@ pub const Loop = struct {
521
521
// Mark this event for deletion, it'll happen
522
522
// on the next tick.
523
523
events [changes ] = ev ;
524
- events [changes ].flags = posix .system .EV_DELETE ;
524
+ events [changes ].flags = posix .system .EV . DELETE ;
525
525
events [changes ].udata = 0 ;
526
526
changes += 1 ;
527
527
assert (changes <= events .len );
@@ -559,8 +559,8 @@ pub const Loop = struct {
559
559
560
560
// Calculate all the values, being careful about overflows in order
561
561
// to just return the maximum value.
562
- const sec = std .math .mul (isize , self .cached_now .tv_sec , std .time .ms_per_s ) catch return max ;
563
- const nsec = @divFloor (self .cached_now .tv_nsec , std .time .ns_per_ms );
562
+ const sec = std .math .mul (isize , self .cached_now .sec , std .time .ms_per_s ) catch return max ;
563
+ const nsec = @divFloor (self .cached_now .nsec , std .time .ns_per_ms );
564
564
return std .math .lossyCast (i64 , sec + | nsec );
565
565
}
566
566
@@ -638,8 +638,8 @@ pub const Loop = struct {
638
638
// There are lots of failure scenarios here in math. If we see any
639
639
// of them we just use the maximum value.
640
640
const max : posix.timespec = .{
641
- .tv_sec = std .math .maxInt (isize ),
642
- .tv_nsec = std .math .maxInt (isize ),
641
+ .sec = std .math .maxInt (isize ),
642
+ .nsec = std .math .maxInt (isize ),
643
643
};
644
644
645
645
const next_s = std .math .cast (isize , next_ms / std .time .ms_per_s ) orelse
@@ -650,9 +650,9 @@ pub const Loop = struct {
650
650
) orelse return max ;
651
651
652
652
return .{
653
- .tv_sec = std .math .add (isize , self .cached_now .tv_sec , next_s ) catch
653
+ .sec = std .math .add (isize , self .cached_now .sec , next_s ) catch
654
654
return max ,
655
- .tv_nsec = std .math .add (isize , self .cached_now .tv_nsec , next_ns ) catch
655
+ .nsec = std .math .add (isize , self .cached_now .nsec , next_ns ) catch
656
656
return max ,
657
657
};
658
658
}
@@ -1026,17 +1026,17 @@ pub const Completion = struct {
1026
1026
1027
1027
.accept = > | v | kevent_init (.{
1028
1028
.ident = @intCast (v .socket ),
1029
- .filter = posix .system .EVFILT_READ ,
1030
- .flags = posix .system .EV_ADD | posix .system .EV_ENABLE ,
1029
+ .filter = posix .system .EVFILT . READ ,
1030
+ .flags = posix .system .EV . ADD | posix .system .EV . ENABLE ,
1031
1031
.fflags = 0 ,
1032
1032
.data = 0 ,
1033
1033
.udata = @intFromPtr (self ),
1034
1034
}),
1035
1035
1036
1036
.connect = > | v | kevent_init (.{
1037
1037
.ident = @intCast (v .socket ),
1038
- .filter = posix .system .EVFILT_WRITE ,
1039
- .flags = posix .system .EV_ADD | posix .system .EV_ENABLE ,
1038
+ .filter = posix .system .EVFILT . WRITE ,
1039
+ .flags = posix .system .EV . ADD | posix .system .EV . ENABLE ,
1040
1040
.fflags = 0 ,
1041
1041
.data = 0 ,
1042
1042
.udata = @intFromPtr (self ),
@@ -1053,12 +1053,12 @@ pub const Completion = struct {
1053
1053
1054
1054
// The kevent below waits for a machport to have a message
1055
1055
// available AND automatically reads the message into the
1056
- // buffer since MACH_RCV_MSG is set.
1056
+ // buffer since MACH_PORT_RIGHT.RECEIVE is set.
1057
1057
break :kevent .{
1058
1058
.ident = @intCast (v .port ),
1059
- .filter = posix .system .EVFILT_MACHPORT ,
1060
- .flags = posix .system .EV_ADD | posix .system .EV_ENABLE ,
1061
- .fflags = posix .system .MACH_RCV_MSG ,
1059
+ .filter = posix .system .EVFILT . MACHPORT ,
1060
+ .flags = posix .system .EV . ADD | posix .system .EV . ENABLE ,
1061
+ .fflags = posix .system .MACH_PORT_RIGHT . RECEIVE ,
1062
1062
.data = 0 ,
1063
1063
.udata = @intFromPtr (self ),
1064
1064
.ext = .{ @intFromPtr (slice .ptr ), slice .len },
@@ -1067,26 +1067,26 @@ pub const Completion = struct {
1067
1067
1068
1068
.proc = > | v | kevent_init (.{
1069
1069
.ident = @intCast (v .pid ),
1070
- .filter = posix .system .EVFILT_PROC ,
1071
- .flags = posix .system .EV_ADD | posix .system .EV_ENABLE ,
1070
+ .filter = posix .system .EVFILT . PROC ,
1071
+ .flags = posix .system .EV . ADD | posix .system .EV . ENABLE ,
1072
1072
.fflags = v .flags ,
1073
1073
.data = 0 ,
1074
1074
.udata = @intFromPtr (self ),
1075
1075
}),
1076
1076
1077
1077
inline .write , .pwrite , .send , .sendto = > | v | kevent_init (.{
1078
1078
.ident = @intCast (v .fd ),
1079
- .filter = posix .system .EVFILT_WRITE ,
1080
- .flags = posix .system .EV_ADD | posix .system .EV_ENABLE ,
1079
+ .filter = posix .system .EVFILT . WRITE ,
1080
+ .flags = posix .system .EV . ADD | posix .system .EV . ENABLE ,
1081
1081
.fflags = 0 ,
1082
1082
.data = 0 ,
1083
1083
.udata = @intFromPtr (self ),
1084
1084
}),
1085
1085
1086
1086
inline .read , .pread , .recv , .recvfrom = > | v | kevent_init (.{
1087
1087
.ident = @intCast (v .fd ),
1088
- .filter = posix .system .EVFILT_READ ,
1089
- .flags = posix .system .EV_ADD | posix .system .EV_ENABLE ,
1088
+ .filter = posix .system .EVFILT . READ ,
1089
+ .flags = posix .system .EV . ADD | posix .system .EV . ENABLE ,
1090
1090
.fflags = 0 ,
1091
1091
.data = 0 ,
1092
1092
.udata = @intFromPtr (self ),
@@ -1220,7 +1220,7 @@ pub const Completion = struct {
1220
1220
const ev = ev_ orelse break :res .{ .proc = ProcError .MissingKevent };
1221
1221
1222
1222
// If we have the exit status, we read it.
1223
- if (ev .fflags & (posix .system .NOTE_EXIT | posix .system .NOTE_EXITSTATUS ) > 0 ) {
1223
+ if (ev .fflags & (posix .system .NOTE . EXIT | posix .system .NOTE . EXITSTATUS ) > 0 ) {
1224
1224
const data : u32 = @intCast (ev .data );
1225
1225
if (posix .W .IFEXITED (data )) break :res .{
1226
1226
.proc = posix .W .EXITSTATUS (data ),
@@ -1653,16 +1653,16 @@ const Timer = struct {
1653
1653
/// any software is running in 584 years waiting on this timer...
1654
1654
/// shame on me I guess... but I'll be dead.
1655
1655
fn ns (self : * const Timer ) u64 {
1656
- assert (self .next .tv_sec >= 0 );
1657
- assert (self .next .tv_nsec >= 0 );
1656
+ assert (self .next .sec >= 0 );
1657
+ assert (self .next .nsec >= 0 );
1658
1658
1659
1659
const max = std .math .maxInt (u64 );
1660
1660
const s_ns = std .math .mul (
1661
1661
u64 ,
1662
- @as (u64 , @intCast (self .next .tv_sec )),
1662
+ @as (u64 , @intCast (self .next .sec )),
1663
1663
std .time .ns_per_s ,
1664
1664
) catch return max ;
1665
- return std .math .add (u64 , s_ns , @as (u64 , @intCast (self .next .tv_nsec ))) catch
1665
+ return std .math .add (u64 , s_ns , @as (u64 , @intCast (self .next .nsec ))) catch
1666
1666
return max ;
1667
1667
}
1668
1668
};
0 commit comments