|
@@ -432,6 +432,18 @@ AT_FDCWD :: ~uintptr(99) /* -100 */
|
|
AT_REMOVEDIR :: uintptr(0x200)
|
|
AT_REMOVEDIR :: uintptr(0x200)
|
|
AT_SYMLINK_NOFOLLOW :: uintptr(0x100)
|
|
AT_SYMLINK_NOFOLLOW :: uintptr(0x100)
|
|
|
|
|
|
|
|
+pollfd :: struct {
|
|
|
|
+ fd: c.int,
|
|
|
|
+ events: c.short,
|
|
|
|
+ revents: c.short,
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+nfds_t :: distinct c.uint
|
|
|
|
+
|
|
|
|
+sigset_t :: struct {
|
|
|
|
+ __val: [16]c.ulong,
|
|
|
|
+}
|
|
|
|
+
|
|
foreign libc {
|
|
foreign libc {
|
|
@(link_name="__errno_location") __errno_location :: proc() -> ^int ---
|
|
@(link_name="__errno_location") __errno_location :: proc() -> ^int ---
|
|
|
|
|
|
@@ -1087,3 +1099,27 @@ fcntl :: proc(fd: int, cmd: int, arg: int) -> (int, Errno) {
|
|
}
|
|
}
|
|
return result, ERROR_NONE
|
|
return result, ERROR_NONE
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// select :: proc(nfds: int, readfds: ^fd_set, writefds: ^fd_set, exceptfds: ^fd_set, timeout: ^timeval) -> (int, Errno) {
|
|
|
|
+// result := unix.sys_select(nfds, readfds, writefds, exceptfds, timeout)
|
|
|
|
+// if result < 0 {
|
|
|
|
+// return 0, _get_errno(result)
|
|
|
|
+// }
|
|
|
|
+// return result, ERROR_NONE
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+poll :: proc(fds: [^]pollfd, nfds: nfds_t, timeout: int) -> (int, Errno) {
|
|
|
|
+ result := unix.sys_poll(fds, uint(nfds), 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))
|
|
|
|
+ if result < 0 {
|
|
|
|
+ return 0, _get_errno(result)
|
|
|
|
+ }
|
|
|
|
+ return result, ERROR_NONE
|
|
|
|
+}
|