mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 04:50:29 +00:00
fix(poll): make interface more odinary
We take `fds` as a normal slice and get the length from it instead of bothering with a second parameter.
This commit is contained in:
@@ -433,13 +433,11 @@ AT_REMOVEDIR :: uintptr(0x200)
|
||||
AT_SYMLINK_NOFOLLOW :: uintptr(0x100)
|
||||
|
||||
pollfd :: struct {
|
||||
fd: c.int,
|
||||
events: c.short,
|
||||
revents: c.short,
|
||||
fd: c.int,
|
||||
events: c.short,
|
||||
revents: c.short,
|
||||
}
|
||||
|
||||
nfds_t :: distinct c.uint
|
||||
|
||||
sigset_t :: distinct u64
|
||||
|
||||
foreign libc {
|
||||
@@ -1098,16 +1096,16 @@ fcntl :: proc(fd: int, cmd: int, arg: int) -> (int, Errno) {
|
||||
return result, ERROR_NONE
|
||||
}
|
||||
|
||||
poll :: proc(fds: [^]pollfd, nfds: nfds_t, timeout: int) -> (int, Errno) {
|
||||
result := unix.sys_poll(fds, uint(nfds), timeout)
|
||||
poll :: proc(fds: []pollfd, timeout: int) -> (int, Errno) {
|
||||
result := unix.sys_poll(raw_data(fds), uint(len(fds)), timeout)
|
||||
if result < 0 {
|
||||
return 0, _get_errno(result)
|
||||
}
|
||||
return result, ERROR_NONE
|
||||
}
|
||||
|
||||
ppoll :: proc(fds: [^]pollfd, nfds: nfds_t, timeout: ^unix.timespec, sigmask: ^sigset_t) -> (int, Errno) {
|
||||
result := unix.sys_ppoll(fds, uint(nfds), timeout, sigmask, size_of(sigset_t))
|
||||
ppoll :: proc(fds: []pollfd, timeout: ^unix.timespec, sigmask: ^sigset_t) -> (int, Errno) {
|
||||
result := unix.sys_ppoll(raw_data(fds), uint(len(fds)), timeout, sigmask, size_of(sigset_t))
|
||||
if result < 0 {
|
||||
return 0, _get_errno(result)
|
||||
}
|
||||
|
||||
@@ -2088,7 +2088,7 @@ sys_poll :: proc "contextless" (fds: rawptr, nfds: uint, timeout: int) -> int {
|
||||
}
|
||||
|
||||
sys_ppoll :: proc "contextless" (fds: rawptr, nfds: uint, timeout: rawptr, sigmask: rawptr, sigsetsize: uint) -> int {
|
||||
return int(intrinsics.syscall(SYS_ppoll, uintptr(fds), uintptr(nfds), uintptr(timeout), uintptr(sigmask), uintptr(sigsetsize)))
|
||||
return int(intrinsics.syscall(SYS_ppoll, uintptr(fds), uintptr(nfds), uintptr(timeout), uintptr(sigmask), uintptr(sigsetsize)))
|
||||
}
|
||||
|
||||
get_errno :: proc "contextless" (res: int) -> i32 {
|
||||
|
||||
Reference in New Issue
Block a user