Implement POSIX linux support for poll and netinet_tcp. Incomplete support for netinet/in.

This commit is contained in:
Isaac Andrade
2024-09-02 21:59:03 -06:00
parent 35f961d80f
commit f072136c04
3 changed files with 196 additions and 2 deletions
+27 -1
View File
@@ -21,11 +21,17 @@ foreign lib {
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html ]]
*/
poll :: proc(fds: [^]pollfd, nfds: nfds_t, timeout: c.int) -> c.int ---
poll :: proc(fds: [^]pollfd, nfds: nfds_t, timeout: c.int) -> Poll_Error ---
}
nfds_t :: c.uint
Poll_Error :: enum c.int {
EAGAIN = Errno.EAGAIN,
EINTR = Errno.EINTR,
EINVAL = Errno.EINVAL,
}
Poll_Event_Bits :: enum c.short {
// Data other than high-priority data may be read without blocking.
IN = log2(POLLIN),
@@ -72,6 +78,26 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
POLLHUP :: 0x0010
POLLNVAL :: 0x0020
} else when ODIN_OS == .Linux {
pollfd :: struct {
fd: FD, /* [PSX] the following descriptor being polled */
events: Poll_Event, /* [PSX] the input event flags */
revents: Poll_Event, /* [PSX] the output event flags */
}
POLLIN :: 0x0001
POLLRDNORM :: 0x0040
POLLRDBAND :: 0x0080
POLLPRI :: 0x0002
POLLOUT :: 0x0004
POLLWRNORM :: 0x0100
POLLWRBAND :: 0x0200
POLLERR :: 0x0008
POLLHUP :: 0x0010
POLLNVAL :: 0x0020
} else {
#panic("posix is unimplemented for the current target")
}