| ... | @@ -222,27 +222,27 @@ pub const Loop = struct { | ... | @@ -222,27 +222,27 @@ pub const Loop = struct { |
| 222 | .handle = undefined, | 222 | .handle = undefined, |
| 223 | .overlapped = ResumeNode.overlapped_init, | 223 | .overlapped = ResumeNode.overlapped_init, |
| 224 | }, | 224 | }, |
| 225 | .eventfd = try os.eventfd(1, os.EFD_CLOEXEC | os.EFD_NONBLOCK), | 225 | .eventfd = try os.eventfd(1, os.linux.EFD.CLOEXEC | os.linux.EFD.NONBLOCK), |
| 226 | .epoll_op = os.EPOLL_CTL_ADD, | 226 | .epoll_op = os.linux.EPOLL.CTL_ADD, |
| 227 | }, | 227 | }, |
| 228 | .next = undefined, | 228 | .next = undefined, |
| 229 | }; | 229 | }; |
| 230 | self.available_eventfd_resume_nodes.push(eventfd_node); | 230 | self.available_eventfd_resume_nodes.push(eventfd_node); |
| 231 | } | 231 | } |
| 232 | | 232 | |
| 233 | self.os_data.epollfd = try os.epoll_create1(os.EPOLL_CLOEXEC); | 233 | self.os_data.epollfd = try os.epoll_create1(os.linux.EPOLL.CLOEXEC); |
| 234 | errdefer os.close(self.os_data.epollfd); | 234 | errdefer os.close(self.os_data.epollfd); |
| 235 | | 235 | |
| 236 | self.os_data.final_eventfd = try os.eventfd(0, os.EFD_CLOEXEC | os.EFD_NONBLOCK); | 236 | self.os_data.final_eventfd = try os.eventfd(0, os.linux.EFD.CLOEXEC | os.linux.EFD.NONBLOCK); |
| 237 | errdefer os.close(self.os_data.final_eventfd); | 237 | errdefer os.close(self.os_data.final_eventfd); |
| 238 | | 238 | |
| 239 | self.os_data.final_eventfd_event = os.epoll_event{ | 239 | self.os_data.final_eventfd_event = os.linux.epoll_event{ |
| 240 | .events = os.EPOLLIN, | 240 | .events = os.linux.EPOLL.IN, |
| 241 | .data = os.epoll_data{ .ptr = @ptrToInt(&self.final_resume_node) }, | 241 | .data = os.linux.epoll_data{ .ptr = @ptrToInt(&self.final_resume_node) }, |
| 242 | }; | 242 | }; |
| 243 | try os.epoll_ctl( | 243 | try os.epoll_ctl( |
| 244 | self.os_data.epollfd, | 244 | self.os_data.epollfd, |
| 245 | os.EPOLL_CTL_ADD, | 245 | os.linux.EPOLL.CTL_ADD, |
| 246 | self.os_data.final_eventfd, | 246 | self.os_data.final_eventfd, |
| 247 | &self.os_data.final_eventfd_event, | 247 | &self.os_data.final_eventfd_event, |
| 248 | ); | 248 | ); |
| ... | @@ -283,8 +283,8 @@ pub const Loop = struct { | ... | @@ -283,8 +283,8 @@ pub const Loop = struct { |
| 283 | // this one is for sending events | 283 | // this one is for sending events |
| 284 | .kevent = os.Kevent{ | 284 | .kevent = os.Kevent{ |
| 285 | .ident = i, | 285 | .ident = i, |
| 286 | .filter = os.EVFILT_USER, | 286 | .filter = os.system.EVFILT_USER, |
| 287 | .flags = os.EV_CLEAR | os.EV_ADD | os.EV_DISABLE, | 287 | .flags = os.system.EV_CLEAR | os.system.EV_ADD | os.system.EV_DISABLE, |
| 288 | .fflags = 0, | 288 | .fflags = 0, |
| 289 | .data = 0, | 289 | .data = 0, |
| 290 | .udata = @ptrToInt(&eventfd_node.data.base), | 290 | .udata = @ptrToInt(&eventfd_node.data.base), |
| ... | @@ -295,24 +295,24 @@ pub const Loop = struct { | ... | @@ -295,24 +295,24 @@ pub const Loop = struct { |
| 295 | self.available_eventfd_resume_nodes.push(eventfd_node); | 295 | self.available_eventfd_resume_nodes.push(eventfd_node); |
| 296 | const kevent_array = @as(*const [1]os.Kevent, &eventfd_node.data.kevent); | 296 | const kevent_array = @as(*const [1]os.Kevent, &eventfd_node.data.kevent); |
| 297 | _ = try os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null); | 297 | _ = try os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null); |
| 298 | eventfd_node.data.kevent.flags = os.EV_CLEAR | os.EV_ENABLE; | 298 | eventfd_node.data.kevent.flags = os.system.EV_CLEAR | os.system.EV_ENABLE; |
| 299 | eventfd_node.data.kevent.fflags = os.NOTE_TRIGGER; | 299 | eventfd_node.data.kevent.fflags = os.system.NOTE_TRIGGER; |
| 300 | } | 300 | } |
| 301 | | 301 | |
| 302 | // Pre-add so that we cannot get error.SystemResources | 302 | // Pre-add so that we cannot get error.SystemResources |
| 303 | // later when we try to activate it. | 303 | // later when we try to activate it. |
| 304 | self.os_data.final_kevent = os.Kevent{ | 304 | self.os_data.final_kevent = os.Kevent{ |
| 305 | .ident = extra_thread_count, | 305 | .ident = extra_thread_count, |
| 306 | .filter = os.EVFILT_USER, | 306 | .filter = os.system.EVFILT_USER, |
| 307 | .flags = os.EV_ADD | os.EV_DISABLE, | 307 | .flags = os.system.EV_ADD | os.system.EV_DISABLE, |
| 308 | .fflags = 0, | 308 | .fflags = 0, |
| 309 | .data = 0, | 309 | .data = 0, |
| 310 | .udata = @ptrToInt(&self.final_resume_node), | 310 | .udata = @ptrToInt(&self.final_resume_node), |
| 311 | }; | 311 | }; |
| 312 | const final_kev_arr = @as(*const [1]os.Kevent, &self.os_data.final_kevent); | 312 | const final_kev_arr = @as(*const [1]os.Kevent, &self.os_data.final_kevent); |
| 313 | _ = try os.kevent(self.os_data.kqfd, final_kev_arr, empty_kevs, null); | 313 | _ = try os.kevent(self.os_data.kqfd, final_kev_arr, empty_kevs, null); |
| 314 | self.os_data.final_kevent.flags = os.EV_ENABLE; | 314 | self.os_data.final_kevent.flags = os.system.EV_ENABLE; |
| 315 | self.os_data.final_kevent.fflags = os.NOTE_TRIGGER; | 315 | self.os_data.final_kevent.fflags = os.system.NOTE_TRIGGER; |
| 316 | | 316 | |
| 317 | if (builtin.single_threaded) { | 317 | if (builtin.single_threaded) { |
| 318 | assert(extra_thread_count == 0); | 318 | assert(extra_thread_count == 0); |
| ... | @@ -404,19 +404,19 @@ pub const Loop = struct { | ... | @@ -404,19 +404,19 @@ pub const Loop = struct { |
| 404 | /// resume_node must live longer than the anyframe that it holds a reference to. | 404 | /// resume_node must live longer than the anyframe that it holds a reference to. |
| 405 | /// flags must contain EPOLLET | 405 | /// flags must contain EPOLLET |
| 406 | pub fn linuxAddFd(self: *Loop, fd: i32, resume_node: *ResumeNode, flags: u32) !void { | 406 | pub fn linuxAddFd(self: *Loop, fd: i32, resume_node: *ResumeNode, flags: u32) !void { |
| 407 | assert(flags & os.EPOLLET == os.EPOLLET); | 407 | assert(flags & os.linux.EPOLL.ET == os.linux.EPOLL.ET); |
| 408 | self.beginOneEvent(); | 408 | self.beginOneEvent(); |
| 409 | errdefer self.finishOneEvent(); | 409 | errdefer self.finishOneEvent(); |
| 410 | try self.linuxModFd( | 410 | try self.linuxModFd( |
| 411 | fd, | 411 | fd, |
| 412 | os.EPOLL_CTL_ADD, | 412 | os.linux.EPOLL.CTL_ADD, |
| 413 | flags, | 413 | flags, |
| 414 | resume_node, | 414 | resume_node, |
| 415 | ); | 415 | ); |
| 416 | } | 416 | } |
| 417 | | 417 | |
| 418 | pub fn linuxModFd(self: *Loop, fd: i32, op: u32, flags: u32, resume_node: *ResumeNode) !void { | 418 | pub fn linuxModFd(self: *Loop, fd: i32, op: u32, flags: u32, resume_node: *ResumeNode) !void { |
| 419 | assert(flags & os.EPOLLET == os.EPOLLET); | 419 | assert(flags & os.linux.EPOLL.ET == os.linux.EPOLL.ET); |
| 420 | var ev = os.linux.epoll_event{ | 420 | var ev = os.linux.epoll_event{ |
| 421 | .events = flags, | 421 | .events = flags, |
| 422 | .data = os.linux.epoll_data{ .ptr = @ptrToInt(resume_node) }, | 422 | .data = os.linux.epoll_data{ .ptr = @ptrToInt(resume_node) }, |
| ... | @@ -425,13 +425,13 @@ pub const Loop = struct { | ... | @@ -425,13 +425,13 @@ pub const Loop = struct { |
| 425 | } | 425 | } |
| 426 | | 426 | |
| 427 | pub fn linuxRemoveFd(self: *Loop, fd: i32) void { | 427 | pub fn linuxRemoveFd(self: *Loop, fd: i32) void { |
| 428 | os.epoll_ctl(self.os_data.epollfd, os.linux.EPOLL_CTL_DEL, fd, null) catch {}; | 428 | os.epoll_ctl(self.os_data.epollfd, os.linux.EPOLL.CTL_DEL, fd, null) catch {}; |
| 429 | self.finishOneEvent(); | 429 | self.finishOneEvent(); |
| 430 | } | 430 | } |
| 431 | | 431 | |
| 432 | pub fn linuxWaitFd(self: *Loop, fd: i32, flags: u32) void { | 432 | pub fn linuxWaitFd(self: *Loop, fd: i32, flags: u32) void { |
| 433 | assert(flags & os.EPOLLET == os.EPOLLET); | 433 | assert(flags & os.linux.EPOLL.ET == os.linux.EPOLL.ET); |
| 434 | assert(flags & os.EPOLLONESHOT == os.EPOLLONESHOT); | 434 | assert(flags & os.linux.EPOLL.ONESHOT == os.linux.EPOLL.ONESHOT); |
| 435 | var resume_node = ResumeNode.Basic{ | 435 | var resume_node = ResumeNode.Basic{ |
| 436 | .base = ResumeNode{ | 436 | .base = ResumeNode{ |
| 437 | .id = .Basic, | 437 | .id = .Basic, |
| ... | @@ -457,8 +457,8 @@ pub const Loop = struct { | ... | @@ -457,8 +457,8 @@ pub const Loop = struct { |
| 457 | // Fall back to a blocking poll(). Ideally this codepath is never hit, since | 457 | // Fall back to a blocking poll(). Ideally this codepath is never hit, since |
| 458 | // epoll should be just fine. But this is better than incorrect behavior. | 458 | // epoll should be just fine. But this is better than incorrect behavior. |
| 459 | var poll_flags: i16 = 0; | 459 | var poll_flags: i16 = 0; |
| 460 | if ((flags & os.EPOLLIN) != 0) poll_flags |= os.POLL.IN; | 460 | if ((flags & os.linux.EPOLL.IN) != 0) poll_flags |= os.POLL.IN; |
| 461 | if ((flags & os.EPOLLOUT) != 0) poll_flags |= os.POLL.OUT; | 461 | if ((flags & os.linux.EPOLL.OUT) != 0) poll_flags |= os.POLL.OUT; |
| 462 | var pfd = [1]os.pollfd{os.pollfd{ | 462 | var pfd = [1]os.pollfd{os.pollfd{ |
| 463 | .fd = fd, | 463 | .fd = fd, |
| 464 | .events = poll_flags, | 464 | .events = poll_flags, |
| ... | @@ -484,10 +484,10 @@ pub const Loop = struct { | ... | @@ -484,10 +484,10 @@ pub const Loop = struct { |
| 484 | pub fn waitUntilFdReadable(self: *Loop, fd: os.fd_t) void { | 484 | pub fn waitUntilFdReadable(self: *Loop, fd: os.fd_t) void { |
| 485 | switch (builtin.os.tag) { | 485 | switch (builtin.os.tag) { |
| 486 | .linux => { | 486 | .linux => { |
| 487 | self.linuxWaitFd(fd, os.EPOLLET | os.EPOLLONESHOT | os.EPOLLIN); | 487 | self.linuxWaitFd(fd, os.linux.EPOLL.ET | os.linux.EPOLL.ONESHOT | os.linux.EPOLL.IN); |
| 488 | }, | 488 | }, |
| 489 | .macos, .freebsd, .netbsd, .dragonfly, .openbsd => { | 489 | .macos, .freebsd, .netbsd, .dragonfly, .openbsd => { |
| 490 | self.bsdWaitKev(@intCast(usize, fd), os.EVFILT_READ, os.EV_ONESHOT); | 490 | self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_READ, os.system.EV_ONESHOT); |
| 491 | }, | 491 | }, |
| 492 | else => @compileError("Unsupported OS"), | 492 | else => @compileError("Unsupported OS"), |
| 493 | } | 493 | } |
| ... | @@ -496,10 +496,10 @@ pub const Loop = struct { | ... | @@ -496,10 +496,10 @@ pub const Loop = struct { |
| 496 | pub fn waitUntilFdWritable(self: *Loop, fd: os.fd_t) void { | 496 | pub fn waitUntilFdWritable(self: *Loop, fd: os.fd_t) void { |
| 497 | switch (builtin.os.tag) { | 497 | switch (builtin.os.tag) { |
| 498 | .linux => { | 498 | .linux => { |
| 499 | self.linuxWaitFd(fd, os.EPOLLET | os.EPOLLONESHOT | os.EPOLLOUT); | 499 | self.linuxWaitFd(fd, os.linux.EPOLL.ET | os.linux.EPOLL.ONESHOT | os.linux.EPOLL.OUT); |
| 500 | }, | 500 | }, |
| 501 | .macos, .freebsd, .netbsd, .dragonfly, .openbsd => { | 501 | .macos, .freebsd, .netbsd, .dragonfly, .openbsd => { |
| 502 | self.bsdWaitKev(@intCast(usize, fd), os.EVFILT_WRITE, os.EV_ONESHOT); | 502 | self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_WRITE, os.system.EV_ONESHOT); |
| 503 | }, | 503 | }, |
| 504 | else => @compileError("Unsupported OS"), | 504 | else => @compileError("Unsupported OS"), |
| 505 | } | 505 | } |
| ... | @@ -508,11 +508,11 @@ pub const Loop = struct { | ... | @@ -508,11 +508,11 @@ pub const Loop = struct { |
| 508 | pub fn waitUntilFdWritableOrReadable(self: *Loop, fd: os.fd_t) void { | 508 | pub fn waitUntilFdWritableOrReadable(self: *Loop, fd: os.fd_t) void { |
| 509 | switch (builtin.os.tag) { | 509 | switch (builtin.os.tag) { |
| 510 | .linux => { | 510 | .linux => { |
| 511 | self.linuxWaitFd(fd, os.EPOLLET | os.EPOLLONESHOT | os.EPOLLOUT | os.EPOLLIN); | 511 | self.linuxWaitFd(fd, os.linux.EPOLL.ET | os.linux.EPOLL.ONESHOT | os.linux.EPOLL.OUT | os.linux.EPOLL.IN); |
| 512 | }, | 512 | }, |
| 513 | .macos, .freebsd, .netbsd, .dragonfly, .openbsd => { | 513 | .macos, .freebsd, .netbsd, .dragonfly, .openbsd => { |
| 514 | self.bsdWaitKev(@intCast(usize, fd), os.EVFILT_READ, os.EV_ONESHOT); | 514 | self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_READ, os.system.EV_ONESHOT); |
| 515 | self.bsdWaitKev(@intCast(usize, fd), os.EVFILT_WRITE, os.EV_ONESHOT); | 515 | self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_WRITE, os.system.EV_ONESHOT); |
| 516 | }, | 516 | }, |
| 517 | else => @compileError("Unsupported OS"), | 517 | else => @compileError("Unsupported OS"), |
| 518 | } | 518 | } |
| ... | @@ -530,7 +530,7 @@ pub const Loop = struct { | ... | @@ -530,7 +530,7 @@ pub const Loop = struct { |
| 530 | | 530 | |
| 531 | defer { | 531 | defer { |
| 532 | // If the kevent was set to be ONESHOT, it doesn't need to be deleted manually. | 532 | // If the kevent was set to be ONESHOT, it doesn't need to be deleted manually. |
| 533 | if (flags & os.EV_ONESHOT != 0) { | 533 | if (flags & os.system.EV_ONESHOT != 0) { |
| 534 | self.bsdRemoveKev(ident, filter); | 534 | self.bsdRemoveKev(ident, filter); |
| 535 | } | 535 | } |
| 536 | } | 536 | } |
| ... | @@ -547,7 +547,7 @@ pub const Loop = struct { | ... | @@ -547,7 +547,7 @@ pub const Loop = struct { |
| 547 | var kev = [1]os.Kevent{os.Kevent{ | 547 | var kev = [1]os.Kevent{os.Kevent{ |
| 548 | .ident = ident, | 548 | .ident = ident, |
| 549 | .filter = filter, | 549 | .filter = filter, |
| 550 | .flags = os.EV_ADD | os.EV_ENABLE | os.EV_CLEAR | flags, | 550 | .flags = os.system.EV_ADD | os.system.EV_ENABLE | os.system.EV_CLEAR | flags, |
| 551 | .fflags = 0, | 551 | .fflags = 0, |
| 552 | .data = 0, | 552 | .data = 0, |
| 553 | .udata = @ptrToInt(&resume_node.base), | 553 | .udata = @ptrToInt(&resume_node.base), |
| ... | @@ -560,7 +560,7 @@ pub const Loop = struct { | ... | @@ -560,7 +560,7 @@ pub const Loop = struct { |
| 560 | var kev = [1]os.Kevent{os.Kevent{ | 560 | var kev = [1]os.Kevent{os.Kevent{ |
| 561 | .ident = ident, | 561 | .ident = ident, |
| 562 | .filter = filter, | 562 | .filter = filter, |
| 563 | .flags = os.EV_DELETE, | 563 | .flags = os.system.EV_DELETE, |
| 564 | .fflags = 0, | 564 | .fflags = 0, |
| 565 | .data = 0, | 565 | .data = 0, |
| 566 | .udata = 0, | 566 | .udata = 0, |
| ... | @@ -590,8 +590,8 @@ pub const Loop = struct { | ... | @@ -590,8 +590,8 @@ pub const Loop = struct { |
| 590 | }, | 590 | }, |
| 591 | .linux => { | 591 | .linux => { |
| 592 | // the pending count is already accounted for | 592 | // the pending count is already accounted for |
| 593 | const epoll_events = os.EPOLLONESHOT | os.linux.EPOLLIN | os.linux.EPOLLOUT | | 593 | const epoll_events = os.linux.EPOLL.ONESHOT | os.linux.EPOLL.IN | os.linux.EPOLL.OUT | |
| 594 | os.linux.EPOLLET; | 594 | os.linux.EPOLL.ET; |
| 595 | self.linuxModFd( | 595 | self.linuxModFd( |
| 596 | eventfd_node.eventfd, | 596 | eventfd_node.eventfd, |
| 597 | eventfd_node.epoll_op, | 597 | eventfd_node.epoll_op, |
| ... | @@ -1344,7 +1344,7 @@ pub const Loop = struct { | ... | @@ -1344,7 +1344,7 @@ pub const Loop = struct { |
| 1344 | .Stop => return, | 1344 | .Stop => return, |
| 1345 | .EventFd => { | 1345 | .EventFd => { |
| 1346 | const event_fd_node = @fieldParentPtr(ResumeNode.EventFd, "base", resume_node); | 1346 | const event_fd_node = @fieldParentPtr(ResumeNode.EventFd, "base", resume_node); |
| 1347 | event_fd_node.epoll_op = os.EPOLL_CTL_MOD; | 1347 | event_fd_node.epoll_op = os.linux.EPOLL.CTL_MOD; |
| 1348 | const stack_node = @fieldParentPtr(std.atomic.Stack(ResumeNode.EventFd).Node, "data", event_fd_node); | 1348 | const stack_node = @fieldParentPtr(std.atomic.Stack(ResumeNode.EventFd).Node, "data", event_fd_node); |
| 1349 | self.available_eventfd_resume_nodes.push(stack_node); | 1349 | self.available_eventfd_resume_nodes.push(stack_node); |
| 1350 | }, | 1350 | }, |