mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 05:08:14 +00:00
Implement POSIX linux support for poll and netinet_tcp. Incomplete support for netinet/in.
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user