| ... | @@ -3968,7 +3968,7 @@ pub const EpollCtlError = error{ | ... | @@ -3968,7 +3968,7 @@ pub const EpollCtlError = error{ |
| 3968 | FileDescriptorIncompatibleWithEpoll, | 3968 | FileDescriptorIncompatibleWithEpoll, |
| 3969 | } || UnexpectedError; | 3969 | } || UnexpectedError; |
| 3970 | | 3970 | |
| 3971 | pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*linux.epoll_event) EpollCtlError!void { | 3971 | pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*system.epoll_event) EpollCtlError!void { |
| 3972 | const rc = system.epoll_ctl(epfd, op, fd, event); | 3972 | const rc = system.epoll_ctl(epfd, op, fd, event); |
| 3973 | switch (errno(rc)) { | 3973 | switch (errno(rc)) { |
| 3974 | .SUCCESS => return, | 3974 | .SUCCESS => return, |
| ... | @@ -3988,7 +3988,7 @@ pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*linux.epoll_event) EpollC | ... | @@ -3988,7 +3988,7 @@ pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*linux.epoll_event) EpollC |
| 3988 | /// Waits for an I/O event on an epoll file descriptor. | 3988 | /// Waits for an I/O event on an epoll file descriptor. |
| 3989 | /// Returns the number of file descriptors ready for the requested I/O, | 3989 | /// Returns the number of file descriptors ready for the requested I/O, |
| 3990 | /// or zero if no file descriptor became ready during the requested timeout milliseconds. | 3990 | /// or zero if no file descriptor became ready during the requested timeout milliseconds. |
| 3991 | pub fn epoll_wait(epfd: i32, events: []linux.epoll_event, timeout: i32) usize { | 3991 | pub fn epoll_wait(epfd: i32, events: []system.epoll_event, timeout: i32) usize { |
| 3992 | while (true) { | 3992 | while (true) { |
| 3993 | // TODO get rid of the @intCast | 3993 | // TODO get rid of the @intCast |
| 3994 | const rc = system.epoll_wait(epfd, events.ptr, @intCast(events.len), timeout); | 3994 | const rc = system.epoll_wait(epfd, events.ptr, @intCast(events.len), timeout); |
| ... | @@ -7142,32 +7142,35 @@ pub const PerfEventOpenError = error{ | ... | @@ -7142,32 +7142,35 @@ pub const PerfEventOpenError = error{ |
| 7142 | } || UnexpectedError; | 7142 | } || UnexpectedError; |
| 7143 | | 7143 | |
| 7144 | pub fn perf_event_open( | 7144 | pub fn perf_event_open( |
| 7145 | attr: *linux.perf_event_attr, | 7145 | attr: *system.perf_event_attr, |
| 7146 | pid: pid_t, | 7146 | pid: pid_t, |
| 7147 | cpu: i32, | 7147 | cpu: i32, |
| 7148 | group_fd: fd_t, | 7148 | group_fd: fd_t, |
| 7149 | flags: usize, | 7149 | flags: usize, |
| 7150 | ) PerfEventOpenError!fd_t { | 7150 | ) PerfEventOpenError!fd_t { |
| 7151 | const rc = linux.perf_event_open(attr, pid, cpu, group_fd, flags); | 7151 | if (native_os == .linux) { |
| 7152 | switch (errno(rc)) { | 7152 | // There is no syscall wrapper for this function exposed by libcs |
| 7153 | .SUCCESS => return @intCast(rc), | 7153 | const rc = linux.perf_event_open(attr, pid, cpu, group_fd, flags); |
| 7154 | .@"2BIG" => return error.TooBig, | 7154 | switch (errno(rc)) { |
| 7155 | .ACCES => return error.PermissionDenied, | 7155 | .SUCCESS => return @intCast(rc), |
| 7156 | .BADF => unreachable, // group_fd file descriptor is not valid. | 7156 | .@"2BIG" => return error.TooBig, |
| 7157 | .BUSY => return error.DeviceBusy, | 7157 | .ACCES => return error.PermissionDenied, |
| 7158 | .FAULT => unreachable, // Segmentation fault. | 7158 | .BADF => unreachable, // group_fd file descriptor is not valid. |
| 7159 | .INVAL => unreachable, // Bad attr settings. | 7159 | .BUSY => return error.DeviceBusy, |
| 7160 | .INTR => unreachable, // Mixed perf and ftrace handling for a uprobe. | 7160 | .FAULT => unreachable, // Segmentation fault. |
| 7161 | .MFILE => return error.ProcessResources, | 7161 | .INVAL => unreachable, // Bad attr settings. |
| 7162 | .NODEV => return error.EventRequiresUnsupportedCpuFeature, | 7162 | .INTR => unreachable, // Mixed perf and ftrace handling for a uprobe. |
| 7163 | .NOENT => unreachable, // Invalid type setting. | 7163 | .MFILE => return error.ProcessResources, |
| 7164 | .NOSPC => return error.TooManyBreakpoints, | 7164 | .NODEV => return error.EventRequiresUnsupportedCpuFeature, |
| 7165 | .NOSYS => return error.SampleStackNotSupported, | 7165 | .NOENT => unreachable, // Invalid type setting. |
| 7166 | .OPNOTSUPP => return error.EventNotSupported, | 7166 | .NOSPC => return error.TooManyBreakpoints, |
| 7167 | .OVERFLOW => return error.SampleMaxStackOverflow, | 7167 | .NOSYS => return error.SampleStackNotSupported, |
| 7168 | .PERM => return error.PermissionDenied, | 7168 | .OPNOTSUPP => return error.EventNotSupported, |
| 7169 | .SRCH => return error.ProcessNotFound, | 7169 | .OVERFLOW => return error.SampleMaxStackOverflow, |
| 7170 | else => |err| return unexpectedErrno(err), | 7170 | .PERM => return error.PermissionDenied, |
| | 7171 | .SRCH => return error.ProcessNotFound, |
| | 7172 | else => |err| return unexpectedErrno(err), |
| | 7173 | } |
| 7171 | } | 7174 | } |
| 7172 | } | 7175 | } |
| 7173 | | 7176 | |
| ... | @@ -7182,8 +7185,8 @@ pub const TimerFdCreateError = error{ | ... | @@ -7182,8 +7185,8 @@ pub const TimerFdCreateError = error{ |
| 7182 | pub const TimerFdGetError = error{InvalidHandle} || UnexpectedError; | 7185 | pub const TimerFdGetError = error{InvalidHandle} || UnexpectedError; |
| 7183 | pub const TimerFdSetError = TimerFdGetError || error{Canceled}; | 7186 | pub const TimerFdSetError = TimerFdGetError || error{Canceled}; |
| 7184 | | 7187 | |
| 7185 | pub fn timerfd_create(clokid: i32, flags: linux.TFD) TimerFdCreateError!fd_t { | 7188 | pub fn timerfd_create(clokid: i32, flags: system.TFD) TimerFdCreateError!fd_t { |
| 7186 | const rc = linux.timerfd_create(clokid, flags); | 7189 | const rc = system.timerfd_create(clokid, @bitCast(flags)); |
| 7187 | return switch (errno(rc)) { | 7190 | return switch (errno(rc)) { |
| 7188 | .SUCCESS => @intCast(rc), | 7191 | .SUCCESS => @intCast(rc), |
| 7189 | .INVAL => unreachable, | 7192 | .INVAL => unreachable, |
| ... | @@ -7198,11 +7201,11 @@ pub fn timerfd_create(clokid: i32, flags: linux.TFD) TimerFdCreateError!fd_t { | ... | @@ -7198,11 +7201,11 @@ pub fn timerfd_create(clokid: i32, flags: linux.TFD) TimerFdCreateError!fd_t { |
| 7198 | | 7201 | |
| 7199 | pub fn timerfd_settime( | 7202 | pub fn timerfd_settime( |
| 7200 | fd: i32, | 7203 | fd: i32, |
| 7201 | flags: linux.TFD.TIMER, | 7204 | flags: system.TFD.TIMER, |
| 7202 | new_value: *const linux.itimerspec, | 7205 | new_value: *const system.itimerspec, |
| 7203 | old_value: ?*linux.itimerspec, | 7206 | old_value: ?*system.itimerspec, |
| 7204 | ) TimerFdSetError!void { | 7207 | ) TimerFdSetError!void { |
| 7205 | const rc = linux.timerfd_settime(fd, flags, new_value, old_value); | 7208 | const rc = system.timerfd_settime(fd, @bitCast(flags), new_value, old_value); |
| 7206 | return switch (errno(rc)) { | 7209 | return switch (errno(rc)) { |
| 7207 | .SUCCESS => {}, | 7210 | .SUCCESS => {}, |
| 7208 | .BADF => error.InvalidHandle, | 7211 | .BADF => error.InvalidHandle, |
| ... | @@ -7213,9 +7216,9 @@ pub fn timerfd_settime( | ... | @@ -7213,9 +7216,9 @@ pub fn timerfd_settime( |
| 7213 | }; | 7216 | }; |
| 7214 | } | 7217 | } |
| 7215 | | 7218 | |
| 7216 | pub fn timerfd_gettime(fd: i32) TimerFdGetError!linux.itimerspec { | 7219 | pub fn timerfd_gettime(fd: i32) TimerFdGetError!system.itimerspec { |
| 7217 | var curr_value: linux.itimerspec = undefined; | 7220 | var curr_value: system.itimerspec = undefined; |
| 7218 | const rc = linux.timerfd_gettime(fd, &curr_value); | 7221 | const rc = system.timerfd_gettime(fd, &curr_value); |
| 7219 | return switch (errno(rc)) { | 7222 | return switch (errno(rc)) { |
| 7220 | .SUCCESS => return curr_value, | 7223 | .SUCCESS => return curr_value, |
| 7221 | .BADF => error.InvalidHandle, | 7224 | .BADF => error.InvalidHandle, |