| ... | @@ -329,6 +329,8 @@ pub const TIOCGPKT = 0x80045438; | ... | @@ -329,6 +329,8 @@ pub const TIOCGPKT = 0x80045438; |
| 329 | pub const TIOCGPTLCK = 0x80045439; | 329 | pub const TIOCGPTLCK = 0x80045439; |
| 330 | pub const TIOCGEXCL = 0x80045440; | 330 | pub const TIOCGEXCL = 0x80045440; |
| 331 | | 331 | |
| | 332 | pub const EPOLL_CLOEXEC = O_CLOEXEC; |
| | 333 | |
| 332 | pub const EPOLL_CTL_ADD = 1; | 334 | pub const EPOLL_CTL_ADD = 1; |
| 333 | pub const EPOLL_CTL_DEL = 2; | 335 | pub const EPOLL_CTL_DEL = 2; |
| 334 | pub const EPOLL_CTL_MOD = 3; | 336 | pub const EPOLL_CTL_MOD = 3; |
| ... | @@ -751,22 +753,31 @@ pub fn fstat(fd: i32, stat_buf: &Stat) usize { | ... | @@ -751,22 +753,31 @@ pub fn fstat(fd: i32, stat_buf: &Stat) usize { |
| 751 | return arch.syscall2(arch.SYS_fstat, usize(fd), @ptrToInt(stat_buf)); | 753 | return arch.syscall2(arch.SYS_fstat, usize(fd), @ptrToInt(stat_buf)); |
| 752 | } | 754 | } |
| 753 | | 755 | |
| 754 | pub const epoll_data = u64; | 756 | pub const epoll_data = extern union { |
| | 757 | ptr: usize, |
| | 758 | fd: i32, |
| | 759 | @"u32": u32, |
| | 760 | @"u64": u64, |
| | 761 | }; |
| 755 | | 762 | |
| 756 | pub const epoll_event = extern struct { | 763 | pub const epoll_event = extern struct { |
| 757 | events: u32, | 764 | events: u32, |
| 758 | data: epoll_data | 765 | data: epoll_data, |
| 759 | }; | 766 | }; |
| 760 | | 767 | |
| 761 | pub fn epoll_create() usize { | 768 | pub fn epoll_create() usize { |
| 762 | return arch.syscall1(arch.SYS_epoll_create, usize(1)); | 769 | return epoll_create1(0); |
| | 770 | } |
| | 771 | |
| | 772 | pub fn epoll_create1(flags: usize) usize { |
| | 773 | return arch.syscall1(arch.SYS_epoll_create1, flags); |
| 763 | } | 774 | } |
| 764 | | 775 | |
| 765 | pub fn epoll_ctl(epoll_fd: i32, op: i32, fd: i32, ev: &epoll_event) usize { | 776 | pub fn epoll_ctl(epoll_fd: i32, op: i32, fd: i32, ev: &epoll_event) usize { |
| 766 | return arch.syscall4(arch.SYS_epoll_ctl, usize(epoll_fd), usize(op), usize(fd), @ptrToInt(ev)); | 777 | return arch.syscall4(arch.SYS_epoll_ctl, usize(epoll_fd), usize(op), usize(fd), @ptrToInt(ev)); |
| 767 | } | 778 | } |
| 768 | | 779 | |
| 769 | pub fn epoll_wait(epoll_fd: i32, events: &epoll_event, maxevents: i32, timeout: i32) usize { | 780 | pub fn epoll_wait(epoll_fd: i32, events: &epoll_event, maxevents: u32, timeout: i32) usize { |
| 770 | return arch.syscall4(arch.SYS_epoll_wait, usize(epoll_fd), @ptrToInt(events), usize(maxevents), usize(timeout)); | 781 | return arch.syscall4(arch.SYS_epoll_wait, usize(epoll_fd), @ptrToInt(events), usize(maxevents), usize(timeout)); |
| 771 | } | 782 | } |
| 772 | | 783 | |