Skip to content

Commit

Permalink
Implement Linux POSIX compliance for poll, sched, sys/select. Fix enu…
Browse files Browse the repository at this point in the history
…m in fcntl.
  • Loading branch information
andradei committed Sep 15, 2024
1 parent aa91479 commit 8616842
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions core/sys/posix/fcntl.odin
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ O_Flag_Bits :: enum c.int {
// RSYNC = O_RSYNC,

// Execute only.
EXEC = log2(O_EXEC),
EXEC = O_EXEC when ODIN_OS == .Linux else log2(O_EXEC),
// Reading and writing.
RDWR = log2(O_RDWR),
// Writing only.
Expand Down Expand Up @@ -177,7 +177,7 @@ when ODIN_OS == .Darwin {
O_DIRECTORY :: 0x00100000
O_EXCL :: 0x00000800
O_NOCTTY :: 0x00020000
O_NOFOLLOW :: 0x00000100
O_NOFOLLOW :: 0x00000100
O_TRUNC :: 0x00000400

_O_TTY_INIT :: 0
Expand Down Expand Up @@ -242,7 +242,7 @@ when ODIN_OS == .Darwin {
O_DIRECTORY :: 0x00020000
O_EXCL :: 0x0800
O_NOCTTY :: 0x8000
O_NOFOLLOW :: 0x0100
O_NOFOLLOW :: 0x0100
O_TRUNC :: 0x0400

_O_TTY_INIT :: 0x00080000
Expand Down Expand Up @@ -307,7 +307,7 @@ when ODIN_OS == .Darwin {
O_DIRECTORY :: 0x0020000
O_EXCL :: 0x0800
O_NOCTTY :: 0x8000
O_NOFOLLOW :: 0x0100
O_NOFOLLOW :: 0x0100
O_TRUNC :: 0x0400

_O_TTY_INIT :: 0
Expand Down Expand Up @@ -372,7 +372,7 @@ when ODIN_OS == .Darwin {
O_DIRECTORY :: 0x20000
O_EXCL :: 0x0800
O_NOCTTY :: 0x8000
O_NOFOLLOW :: 0x0100
O_NOFOLLOW :: 0x0100
O_TRUNC :: 0x0400

_O_TTY_INIT :: 0
Expand Down
6 changes: 3 additions & 3 deletions core/sys/posix/poll.odin
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ foreign lib {
nfds_t :: c.uint

Poll_Error :: enum c.int {
EAGAIN = Errno.EAGAIN,
EINTR = Errno.EINTR,
EINVAL = Errno.EINVAL,
EAGAIN = cast(c.int)Errno.EAGAIN,
EINTR = cast(c.int)Errno.EINTR,
EINVAL = cast(c.int)Errno.EINVAL,
}

Poll_Event_Bits :: enum c.short {
Expand Down
2 changes: 1 addition & 1 deletion core/sys/posix/sched.odin
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ when ODIN_OS == .Darwin {
SCHED_RR :: 3
SCHED_OTHER :: 2

} else when ODIN_OS == .NetBSD {
} else when ODIN_OS == .NetBSD || ODIN_OS == .Linux {

SCHED_OTHER :: 0
SCHED_FIFO :: 1
Expand Down
2 changes: 1 addition & 1 deletion core/sys/posix/sys_select.odin
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ when ODIN_OS == .NetBSD {
LSELECT :: "select"
}

when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD {
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {

suseconds_t :: distinct (c.int32_t when ODIN_OS == .Darwin || ODIN_OS == .NetBSD else c.long)

Expand Down

0 comments on commit 8616842

Please sign in to comment.