aboutsummaryrefslogtreecommitdiff
path: root/core/sys/posix
diff options
context:
space:
mode:
authorColin Davidson <colrdavidson@gmail.com>2025-04-26 18:22:21 -0700
committerColin Davidson <colrdavidson@gmail.com>2025-04-26 18:22:21 -0700
commitf1fdd1a8b9a53d34b59f8bac86ebba5f35189f28 (patch)
tree5d8e0f200c25ae3451f666e7292f9cc9ad3db743 /core/sys/posix
parent78d8ed2d391e8def6b303445c82f7d143897c251 (diff)
parent7d4c3d23e6156c1b4be1f91e6d18e51a8e9814f0 (diff)
Merge branch 'master' into macharena
Diffstat (limited to 'core/sys/posix')
-rw-r--r--core/sys/posix/arpa_inet.odin4
-rw-r--r--core/sys/posix/dirent.odin27
-rw-r--r--core/sys/posix/errno.odin89
-rw-r--r--core/sys/posix/fcntl.odin69
-rw-r--r--core/sys/posix/fnmatch.odin4
-rw-r--r--core/sys/posix/glob.odin6
-rw-r--r--core/sys/posix/grp.odin4
-rw-r--r--core/sys/posix/langinfo.odin6
-rw-r--r--core/sys/posix/libgen.odin2
-rw-r--r--core/sys/posix/locale.odin2
-rw-r--r--core/sys/posix/monetary.odin2
-rw-r--r--core/sys/posix/netdb.odin52
-rw-r--r--core/sys/posix/netinet_in.odin61
-rw-r--r--core/sys/posix/poll.odin49
-rw-r--r--core/sys/posix/pthread.odin52
-rw-r--r--core/sys/posix/pwd.odin14
-rw-r--r--core/sys/posix/sched.odin9
-rw-r--r--core/sys/posix/signal.odin151
-rw-r--r--core/sys/posix/signal_libc.odin2
-rw-r--r--core/sys/posix/stdio_libc.odin2
-rw-r--r--core/sys/posix/stdlib.odin2
-rw-r--r--core/sys/posix/stdlib_libc.odin2
-rw-r--r--core/sys/posix/string.odin2
-rw-r--r--core/sys/posix/string_libc.odin2
-rw-r--r--core/sys/posix/sys_ipc.odin25
-rw-r--r--core/sys/posix/sys_msg.odin20
-rw-r--r--core/sys/posix/sys_resource.odin53
-rw-r--r--core/sys/posix/sys_select.odin16
-rw-r--r--core/sys/posix/sys_sem.odin28
-rw-r--r--core/sys/posix/sys_socket.odin66
-rw-r--r--core/sys/posix/sys_stat.odin32
-rw-r--r--core/sys/posix/sys_time.odin13
-rw-r--r--core/sys/posix/sys_times.odin4
-rw-r--r--core/sys/posix/sys_uio.odin4
-rw-r--r--core/sys/posix/sys_un.odin10
-rw-r--r--core/sys/posix/sys_utsname.odin6
-rw-r--r--core/sys/posix/sys_wait.odin54
-rw-r--r--core/sys/posix/termios.odin184
-rw-r--r--core/sys/posix/time.odin13
-rw-r--r--core/sys/posix/unistd.odin560
-rw-r--r--core/sys/posix/unistd_libc.odin2
-rw-r--r--core/sys/posix/utime.odin4
42 files changed, 1398 insertions, 311 deletions
diff --git a/core/sys/posix/arpa_inet.odin b/core/sys/posix/arpa_inet.odin
index d3592dd80..ac850ed49 100644
--- a/core/sys/posix/arpa_inet.odin
+++ b/core/sys/posix/arpa_inet.odin
@@ -1,10 +1,12 @@
-#+build darwin, linux, freebsd, openbsd, netbsd
+#+build darwin, linux, freebsd, openbsd, netbsd, haiku
package posix
import "core:c"
when ODIN_OS == .Darwin {
foreign import lib "system:System.framework"
+} else when ODIN_OS == .Haiku {
+ foreign import lib "system:network"
} else {
foreign import lib "system:c"
}
diff --git a/core/sys/posix/dirent.odin b/core/sys/posix/dirent.odin
index bf32be8cf..1394f6b9e 100644
--- a/core/sys/posix/dirent.odin
+++ b/core/sys/posix/dirent.odin
@@ -1,4 +1,4 @@
-#+build darwin, linux, freebsd, openbsd, netbsd
+#+build darwin, linux, freebsd, openbsd, netbsd, haiku
package posix
import "core:c"
@@ -219,12 +219,23 @@ when ODIN_OS == .Darwin {
} else when ODIN_OS == .Linux {
- dirent :: struct {
- d_ino: u64, /* [PSX] file number of entry */
- d_off: i64, /* directory offset of the next entry */
- d_reclen: u16, /* length of this record */
- d_type: D_Type, /* file type */
- d_name: [256]c.char `fmt:"s,0"`, /* [PSX] entry name */
- }
+ dirent :: struct {
+ d_ino: u64, /* [PSX] file number of entry */
+ d_off: i64, /* directory offset of the next entry */
+ d_reclen: u16, /* length of this record */
+ d_type: D_Type, /* file type */
+ d_name: [256]c.char `fmt:"s,0"`, /* [PSX] entry name */
+ }
+
+} else when ODIN_OS == .Haiku {
+
+ dirent :: struct {
+ d_dev: dev_t, /* device */
+ d_pdev: dev_t, /* parent device (only for queries) */
+ d_ino: ino_t, /* inode number */
+ d_pino: ino_t, /* parent inode (only for queries) */
+ d_reclen: c.ushort, /* length of this record, not the name */
+ d_name: [0]c.char `fmt:"s,0"`, /* name of the entry (null byte terminated) */
+ }
}
diff --git a/core/sys/posix/errno.odin b/core/sys/posix/errno.odin
index 9bc77f12e..bb4e9e045 100644
--- a/core/sys/posix/errno.odin
+++ b/core/sys/posix/errno.odin
@@ -1,4 +1,4 @@
-#+build windows, darwin, linux, freebsd, openbsd, netbsd
+#+build windows, darwin, linux, freebsd, openbsd, netbsd, haiku
package posix
import "core:c"
@@ -536,5 +536,92 @@ when ODIN_OS == .Darwin {
ETXTBSY :: 139
EWOULDBLOCK :: 140
EXDEV :: 18
+} else when ODIN_OS == .Haiku {
+ _HAIKU_USE_POSITIVE_POSIX_ERRORS :: libc._HAIKU_USE_POSITIVE_POSIX_ERRORS
+ _POSIX_ERROR_FACTOR :: libc._POSIX_ERROR_FACTOR
+
+ _GENERAL_ERROR_BASE :: min(c.int)
+ _OS_ERROR_BASE :: _GENERAL_ERROR_BASE + 0x1000
+ _STORAGE_ERROR_BASE :: _GENERAL_ERROR_BASE + 0x6000
+ _POSIX_ERROR_BASE :: _GENERAL_ERROR_BASE + 0x7000
+
+ EIO :: _POSIX_ERROR_FACTOR * (_GENERAL_ERROR_BASE + 1) // B_IO_ERROR
+ EACCES :: _POSIX_ERROR_FACTOR * (_GENERAL_ERROR_BASE + 2) // B_PERMISSION_DENIED
+ EINVAL :: _POSIX_ERROR_FACTOR * (_GENERAL_ERROR_BASE + 5) // B_BAD_VALUE
+ ETIMEDOUT :: _POSIX_ERROR_FACTOR * (_GENERAL_ERROR_BASE + 9) // B_TIMED_OUT
+ EINTR :: _POSIX_ERROR_FACTOR * (_GENERAL_ERROR_BASE + 10) // B_INTERRUPTED
+ EAGAIN :: _POSIX_ERROR_FACTOR * (_GENERAL_ERROR_BASE + 11) // B_WOULD_BLOCK /* SysV compatibility */
+ EWOULDBLOCK :: _POSIX_ERROR_FACTOR * (_GENERAL_ERROR_BASE + 11) // B_WOULD_BLOCK /* BSD compatibility */
+ EBUSY :: _POSIX_ERROR_FACTOR * (_GENERAL_ERROR_BASE + 14) // B_BUSY
+ EPERM :: _POSIX_ERROR_FACTOR * (_GENERAL_ERROR_BASE + 15) // B_NOT_ALLOWED
+ EFAULT :: _POSIX_ERROR_FACTOR * (_OS_ERROR_BASE + 0x301) // B_BAD_ADDRESS
+ ENOEXEC :: _POSIX_ERROR_FACTOR * (_OS_ERROR_BASE + 0x302) // B_NOT_AN_EXECUTABLE
+ EBADF :: _POSIX_ERROR_FACTOR * (_STORAGE_ERROR_BASE + 0) // B_FILE_ERROR
+ EEXIST :: _POSIX_ERROR_FACTOR * (_STORAGE_ERROR_BASE + 2) // B_FILE_EXISTS
+ ENOENT :: _POSIX_ERROR_FACTOR * (_STORAGE_ERROR_BASE + 3) // B_ENTRY_NOT_FOUND
+ ENAMETOOLONG :: _POSIX_ERROR_FACTOR * (_STORAGE_ERROR_BASE + 4) // B_NAME_TOO_LONG
+ ENOTDIR :: _POSIX_ERROR_FACTOR * (_STORAGE_ERROR_BASE + 5) // B_NOT_A_DIRECTORY
+ ENOTEMPTY :: _POSIX_ERROR_FACTOR * (_STORAGE_ERROR_BASE + 6) // B_DIRECTORY_NOT_EMPTY
+ ENOSPC :: _POSIX_ERROR_FACTOR * (_STORAGE_ERROR_BASE + 7) // B_DEVICE_FULL
+ EROFS :: _POSIX_ERROR_FACTOR * (_STORAGE_ERROR_BASE + 8) // B_READ_ONLY_DEVICE
+ EISDIR :: _POSIX_ERROR_FACTOR * (_STORAGE_ERROR_BASE + 9) // B_IS_A_DIRECTORY
+ EMFILE :: _POSIX_ERROR_FACTOR * (_STORAGE_ERROR_BASE + 10) // B_NO_MORE_FDS
+ EXDEV :: _POSIX_ERROR_FACTOR * (_STORAGE_ERROR_BASE + 11) // B_CROSS_DEVICE_LINK
+ ELOOP :: _POSIX_ERROR_FACTOR * (_STORAGE_ERROR_BASE + 12) // B_LINK_LIMIT
+ EPIPE :: _POSIX_ERROR_FACTOR * (_STORAGE_ERROR_BASE + 13) // B_BUSTED_PIPE
+ ENOMEM :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 0) when _HAIKU_USE_POSITIVE_POSIX_ERRORS else (_GENERAL_ERROR_BASE + 0) // B_NO_MEMORY
+ E2BIG :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 1)
+ ECHILD :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 2)
+ EDEADLK :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 3)
+ EFBIG :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 4)
+ EMLINK :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 5)
+ ENFILE :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 6)
+ ENODEV :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 7)
+ ENOLCK :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 8)
+ ENOSYS :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 9)
+ ENOTTY :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 10)
+ ENXIO :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 11)
+ ESPIPE :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 12)
+ ESRCH :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 13)
+ EPROTOTYPE :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 18)
+ EPROTONOSUPPORT :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 19)
+ EAFNOSUPPORT :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 21)
+ EADDRINUSE :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 22)
+ EADDRNOTAVAIL :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 23)
+ ENETDOWN :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 24)
+ ENETUNREACH :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 25)
+ ENETRESET :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 26)
+ ECONNABORTED :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 27)
+ ECONNRESET :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 28)
+ EISCONN :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 29)
+ ENOTCONN :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 30)
+ ECONNREFUSED :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 32)
+ EHOSTUNREACH :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 33)
+ ENOPROTOOPT :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 34)
+ ENOBUFS :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 35)
+ EINPROGRESS :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 36)
+ EALREADY :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 37)
+ ENOMSG :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 39)
+ ESTALE :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 40)
+ EOVERFLOW :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 41)
+ EMSGSIZE :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 42)
+ EOPNOTSUPP :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 43)
+ ENOTSOCK :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 44)
+ EBADMSG :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 46)
+ ECANCELED :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 47)
+ EDESTADDRREQ :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 48)
+ EDQUOT :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 49)
+ EIDRM :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 50)
+ EMULTIHOP :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 51)
+ ENODATA :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 52)
+ ENOLINK :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 53)
+ ENOSR :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 54)
+ ENOSTR :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 55)
+ ENOTSUP :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 56)
+ EPROTO :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 57)
+ ETIME :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 58)
+ ETXTBSY :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 59)
+ ENOTRECOVERABLE :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 61)
+ EOWNERDEAD :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 62)
}
diff --git a/core/sys/posix/fcntl.odin b/core/sys/posix/fcntl.odin
index d948af600..bc0b5b5ba 100644
--- a/core/sys/posix/fcntl.odin
+++ b/core/sys/posix/fcntl.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, openbsd, freebsd, netbsd
+#+build linux, darwin, openbsd, freebsd, netbsd, haiku
package posix
import "core:c"
@@ -343,6 +343,7 @@ when ODIN_OS == .Darwin {
l_type: Lock_Type, /* [PSX] type of lock */
l_whence: c.short, /* [PSX] flag (Whence) of starting offset */
}
+
} else when ODIN_OS == .OpenBSD {
off_t :: distinct c.int64_t
@@ -408,6 +409,72 @@ when ODIN_OS == .Darwin {
l_whence: c.short, /* [PSX] flag (Whence) of starting offset */
}
+} else when ODIN_OS == .Haiku {
+
+ off_t :: distinct c.int64_t
+ pid_t :: distinct c.int32_t
+
+ /* commands that can be passed to fcntl() */
+ F_DUPFD :: 0x0001 /* duplicate fd */
+ F_GETFD :: 0x0002 /* get fd flags */
+ F_SETFD :: 0x0004 /* set fd flags */
+ F_GETFL :: 0x0008 /* get file status flags and access mode */
+ F_SETFL :: 0x0010 /* set file status flags */
+ F_GETLK :: 0x0020 /* get locking information */
+ F_SETLK :: 0x0080 /* set locking information */
+ F_SETLKW :: 0x0100 /* as above, but waits if blocked */
+ F_DUPFD_CLOEXEC :: 0x0200 /* duplicate fd with close on exec set */
+ F_GETOWN :: -1 // NOTE: Not supported.
+ F_SETOWN :: -1 // NOTE: Not supported.
+
+ /* advisory locking types */
+ F_RDLCK :: 0x0040 /* read or shared lock */
+ F_UNLCK :: 0x0200 /* unlock */
+ F_WRLCK :: 0x0400 /* write or exclusive lock */
+
+ /* file descriptor flags for fcntl() */
+ FD_CLOEXEC :: 1
+
+ O_CLOEXEC :: 0x00000040
+ O_CREAT :: 0x0200
+ O_DIRECTORY :: 0x00200000
+ O_EXCL :: 0x0100
+ O_NOCTTY :: 0x1000
+ O_NOFOLLOW :: 0x00080000
+ O_TRUNC :: 0x0400
+
+ _O_TTY_INIT :: 0
+ O_TTY_INIT :: O_Flags{} // NOTE: not defined in the headers
+
+ O_APPEND :: 0x0800
+ O_DSYNC :: 0x040000
+ O_NONBLOCK :: 0x0080
+ O_SYNC :: 0x010000
+ O_RSYNC :: 0x020000
+
+ O_EXEC :: 0x04000000 // NOTE: not defined in the headers
+ O_RDONLY :: 0
+ O_RDWR :: 0x0002
+ O_WRONLY :: 0x0001
+
+ _O_SEARCH :: 0
+ O_SEARCH :: O_Flags{} // NOTE: not defined in the headers
+
+ AT_FDCWD: FD: -100
+
+ AT_EACCESS :: 0x08
+ AT_SYMLINK_NOFOLLOW :: 0x01
+ AT_SYMLINK_FOLLOW :: 0x02
+ AT_REMOVEDIR :: 0x04
+
+ flock :: struct {
+ l_type: Lock_Type, /* [PSX] type of lock */
+ l_whence: c.short, /* [PSX] flag (Whence) of starting offset */
+ l_start: off_t, /* [PSX] relative offset in bytes */
+ l_len: off_t, /* [PSX] size; if 0 then until EOF */
+ l_pid: pid_t, /* [PSX] process ID of the process holding the lock */
+ }
+
} else when ODIN_OS == .Linux {
off_t :: distinct c.int64_t
diff --git a/core/sys/posix/fnmatch.odin b/core/sys/posix/fnmatch.odin
index 2d582705c..04c3d2888 100644
--- a/core/sys/posix/fnmatch.odin
+++ b/core/sys/posix/fnmatch.odin
@@ -1,4 +1,4 @@
-#+build darwin, linux, openbsd, freebsd, netbsd
+#+build darwin, linux, openbsd, freebsd, netbsd, haiku
package posix
import "core:c"
@@ -46,7 +46,7 @@ FNM_Flag_Bits :: enum c.int {
}
FNM_Flags :: bit_set[FNM_Flag_Bits; c.int]
-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 == .Haiku {
FNM_NOMATCH :: 1
diff --git a/core/sys/posix/glob.odin b/core/sys/posix/glob.odin
index 7c8009a59..fb90b7546 100644
--- a/core/sys/posix/glob.odin
+++ b/core/sys/posix/glob.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -109,7 +109,7 @@ when ODIN_OS == .Darwin {
GLOB_NOMATCH :: -3
GLOB_NOSPACE :: -1
-} else when ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD {
+} else when ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .Haiku {
glob_t :: struct {
gl_pathc: c.size_t, /* [PSX] count of paths matched by pattern */
@@ -134,7 +134,7 @@ when ODIN_OS == .Darwin {
GLOB_ERR :: 0x0004
GLOB_MARK :: 0x0008
GLOB_NOCHECK :: 0x0010
- GLOB_NOESCAPE :: 0x2000 when ODIN_OS == .FreeBSD else 0x0100
+ GLOB_NOESCAPE :: 0x2000 when ODIN_OS == .FreeBSD || ODIN_OS == .Haiku else 0x0100
GLOB_NOSORT :: 0x0020
GLOB_ABORTED :: -2
diff --git a/core/sys/posix/grp.odin b/core/sys/posix/grp.odin
index 956ed148b..3694308a0 100644
--- a/core/sys/posix/grp.odin
+++ b/core/sys/posix/grp.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -115,7 +115,7 @@ foreign lib {
getgrnam_r :: proc(name: cstring, grp: ^group, buffer: [^]byte, bufsize: c.size_t, result: ^^group) -> Errno ---
}
-when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
+when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Haiku || ODIN_OS == .Linux {
gid_t :: distinct c.uint32_t
diff --git a/core/sys/posix/langinfo.odin b/core/sys/posix/langinfo.odin
index 3c001aee0..1fddfe280 100644
--- a/core/sys/posix/langinfo.odin
+++ b/core/sys/posix/langinfo.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -143,7 +143,7 @@ nl_item :: enum nl_item_t {
CRNCYSTR = CRNCYSTR,
}
-when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD {
+when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .Haiku {
// NOTE: declared with `_t` so we can enumerate the real `nl_info`.
nl_item_t :: distinct c.int
@@ -210,7 +210,7 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD {
YESEXPR :: 52
NOEXPR :: 53
- CRNCYSTR :: 56
+ CRNCYSTR :: 54 when ODIN_OS == .Haiku else 56
} else when ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD {
diff --git a/core/sys/posix/libgen.odin b/core/sys/posix/libgen.odin
index 69176a557..2354bf70d 100644
--- a/core/sys/posix/libgen.odin
+++ b/core/sys/posix/libgen.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
when ODIN_OS == .Darwin {
diff --git a/core/sys/posix/locale.odin b/core/sys/posix/locale.odin
index 5b8d7c216..bbe10e803 100644
--- a/core/sys/posix/locale.odin
+++ b/core/sys/posix/locale.odin
@@ -1,4 +1,4 @@
-#+build windows, linux, darwin, netbsd, openbsd, freebsd
+#+build windows, linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c/libc"
diff --git a/core/sys/posix/monetary.odin b/core/sys/posix/monetary.odin
index ee342e211..a444bff09 100644
--- a/core/sys/posix/monetary.odin
+++ b/core/sys/posix/monetary.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
diff --git a/core/sys/posix/netdb.odin b/core/sys/posix/netdb.odin
index 79e13a140..ff1cb9d4c 100644
--- a/core/sys/posix/netdb.odin
+++ b/core/sys/posix/netdb.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -319,7 +319,7 @@ Info_Errno :: enum c.int {
OVERFLOW = EAI_OVERFLOW,
}
-when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
+when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux || ODIN_OS == .Haiku {
hostent :: struct {
h_name: cstring, /* [PSX] official name of host */
@@ -352,15 +352,28 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
// The highest reserved port number.
IPPORT_RESERVED :: 1024
- addrinfo :: struct {
- ai_flags: Addrinfo_Flags, /* [PSX] input flags */
- ai_family: AF, /* [PSX] address family of socket */
- ai_socktype: Sock, /* [PSX] socket type */
- ai_protocol: Protocol, /* [PSX] protocol of socket */
- ai_addrlen: socklen_t, /* [PSX] length of socket address */
- ai_canonname: cstring, /* [PSX] canonical name of service location */
- ai_addr: ^sockaddr, /* [PSX] binary address */
- ai_next: ^addrinfo, /* [PSX] pointer to next in list */
+ when ODIN_OS == .Linux || ODIN_OS == .OpenBSD {
+ addrinfo :: struct {
+ ai_flags: Addrinfo_Flags, /* [PSX] input flags */
+ ai_family: AF, /* [PSX] address family of socket */
+ ai_socktype: Sock, /* [PSX] socket type */
+ ai_protocol: Protocol, /* [PSX] protocol of socket */
+ ai_addrlen: socklen_t, /* [PSX] length of socket address */
+ ai_addr: ^sockaddr, /* [PSX] binary address */
+ ai_canonname: cstring, /* [PSX] canonical name of service location */
+ ai_next: ^addrinfo, /* [PSX] pointer to next in list */
+ }
+ } else {
+ addrinfo :: struct {
+ ai_flags: Addrinfo_Flags, /* [PSX] input flags */
+ ai_family: AF, /* [PSX] address family of socket */
+ ai_socktype: Sock, /* [PSX] socket type */
+ ai_protocol: Protocol, /* [PSX] protocol of socket */
+ ai_addrlen: socklen_t, /* [PSX] length of socket address */
+ ai_canonname: cstring, /* [PSX] canonical name of service location */
+ ai_addr: ^sockaddr, /* [PSX] binary address */
+ ai_next: ^addrinfo, /* [PSX] pointer to next in list */
+ }
}
when ODIN_OS == .Darwin {
@@ -431,6 +444,23 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
NI_NUMERICSCOPE :: 0x100
NI_DGRAM :: 16
+ } else when ODIN_OS == .Haiku {
+
+ AI_PASSIVE :: 0x001
+ AI_CANONNAME :: 0x002
+ AI_NUMERICHOST :: 0x004
+ AI_NUMERICSERV :: 0x008
+ AI_V4MAPPED :: 0x800
+ AI_ALL :: 0x100
+ AI_ADDRCONFIG :: 0x400
+
+ NI_NOFQDN :: 0x01
+ NI_NUMERICHOST :: 0x02
+ NI_NAMEREQD :: 0x04
+ NI_NUMERICSERV :: 0x08
+ NI_DGRAM :: 0x10
+ NI_NUMERICSCOPE :: 0x40
+
}
when ODIN_OS == .OpenBSD {
diff --git a/core/sys/posix/netinet_in.odin b/core/sys/posix/netinet_in.odin
index a2cf904ce..ec05915de 100644
--- a/core/sys/posix/netinet_in.odin
+++ b/core/sys/posix/netinet_in.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -31,20 +31,31 @@ Protocol :: enum c.int {
UDP = IPPROTO_UDP,
}
-when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
+when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux || ODIN_OS == .Haiku {
in_addr :: struct {
s_addr: in_addr_t, /* [PSX] big endian address */
}
- in6_addr :: struct {
- using _: struct #raw_union {
- s6_addr: [16]c.uint8_t, /* [PSX] big endian address */
- __u6_addr16: [8]c.uint16_t,
- __u6_addr32: [4]c.uint32_t,
- },
+ when ODIN_OS == .Haiku {
+ in6_addr :: struct #packed {
+ using _: struct #raw_union {
+ s6_addr: [16]c.uint8_t, /* [PSX] big endian address */
+ __u6_addr16: [8]c.uint16_t,
+ __u6_addr32: [4]c.uint32_t,
+ },
+ }
+ } else {
+ in6_addr :: struct {
+ using _: struct #raw_union {
+ s6_addr: [16]c.uint8_t, /* [PSX] big endian address */
+ __u6_addr16: [8]c.uint16_t,
+ __u6_addr32: [4]c.uint32_t,
+ },
+ }
}
+
when ODIN_OS == .Linux {
sockaddr_in :: struct {
@@ -77,12 +88,20 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
} else {
+ when ODIN_OS == .Haiku {
+ @(private)
+ _SIN_ZEROSIZE :: 24
+ } else {
+ @(private)
+ _SIN_ZEROSIZE :: 8
+ }
+
sockaddr_in :: struct {
sin_len: c.uint8_t,
sin_family: sa_family_t, /* [PSX] AF_INET (but a smaller size) */
sin_port: in_port_t, /* [PSX] port number */
sin_addr: in_addr, /* [PSX] IP address */
- sin_zero: [8]c.char,
+ sin_zero: [_SIN_ZEROSIZE]c.char,
}
sockaddr_in6 :: struct {
@@ -99,13 +118,23 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
ipv6mr_interface: c.uint, /* [PSX] interface index */
}
- IPV6_JOIN_GROUP :: 12
- IPV6_LEAVE_GROUP :: 13
- IPV6_MULTICAST_HOPS :: 10
- IPV6_MULTICAST_IF :: 9
- IPV6_MULTICAST_LOOP :: 11
- IPV6_UNICAST_HOPS :: 4
- IPV6_V6ONLY :: 27
+ when ODIN_OS == .Haiku {
+ IPV6_JOIN_GROUP :: 28
+ IPV6_LEAVE_GROUP :: 29
+ IPV6_MULTICAST_HOPS :: 25
+ IPV6_MULTICAST_IF :: 24
+ IPV6_MULTICAST_LOOP :: 26
+ IPV6_UNICAST_HOPS :: 27
+ IPV6_V6ONLY :: 30
+ } else {
+ IPV6_JOIN_GROUP :: 12
+ IPV6_LEAVE_GROUP :: 13
+ IPV6_MULTICAST_HOPS :: 10
+ IPV6_MULTICAST_IF :: 9
+ IPV6_MULTICAST_LOOP :: 11
+ IPV6_UNICAST_HOPS :: 4
+ IPV6_V6ONLY :: 27
+ }
}
diff --git a/core/sys/posix/poll.odin b/core/sys/posix/poll.odin
index 9c3b8b081..44ec767a6 100644
--- a/core/sys/posix/poll.odin
+++ b/core/sys/posix/poll.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "base:intrinsics"
@@ -25,7 +25,11 @@ foreign lib {
poll :: proc(fds: [^]pollfd, nfds: nfds_t, timeout: c.int) -> c.int ---
}
-nfds_t :: c.uint
+when ODIN_OS == .Haiku {
+ nfds_t :: c.ulong
+} else {
+ nfds_t :: c.uint
+}
Poll_Event_Bits :: enum c.short {
// Data other than high-priority data may be read without blocking.
@@ -53,7 +57,7 @@ Poll_Event_Bits :: enum c.short {
}
Poll_Event :: bit_set[Poll_Event_Bits; c.short]
-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 == .Haiku {
pollfd :: struct {
fd: FD, /* [PSX] the following descriptor being polled */
@@ -61,17 +65,36 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
revents: Poll_Event, /* [PSX] the output event flags */
}
- POLLIN :: 0x0001
- POLLRDNORM :: 0x0040
- POLLRDBAND :: 0x0080
- POLLPRI :: 0x0002
- POLLOUT :: 0x0004
- POLLWRNORM :: POLLOUT
- POLLWRBAND :: 0x0100
+ when ODIN_OS == .Haiku {
+
+ POLLIN :: 0x0001 /* any readable data available */
+ POLLOUT :: 0x0002 /* file descriptor is writeable */
+ POLLRDNORM :: POLLIN
+ POLLWRNORM :: POLLOUT
+ POLLRDBAND :: 0x0008 /* priority readable data */
+ POLLWRBAND :: 0x0010 /* priority data can be written */
+ POLLPRI :: 0x0020 /* high priority readable data */
+
+ POLLERR :: 0x0004 /* errors pending */
+ POLLHUP :: 0x0080 /* disconnected */
+ POLLNVAL :: 0x1000 /* invalid file descriptor */
+
+ } else {
+
+ POLLIN :: 0x0001
+ POLLRDNORM :: 0x0040
+ POLLRDBAND :: 0x0080
+ POLLPRI :: 0x0002
+ POLLOUT :: 0x0004
+ POLLWRNORM :: POLLOUT
+ POLLWRBAND :: 0x0100
+
+ POLLERR :: 0x0008
+ POLLHUP :: 0x0010
+ POLLNVAL :: 0x0020
+
+ }
- POLLERR :: 0x0008
- POLLHUP :: 0x0010
- POLLNVAL :: 0x0020
} else when ODIN_OS == .Linux {
diff --git a/core/sys/posix/pthread.odin b/core/sys/posix/pthread.odin
index 490064da6..36a3cd7b3 100644
--- a/core/sys/posix/pthread.odin
+++ b/core/sys/posix/pthread.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -554,6 +554,56 @@ when ODIN_OS == .Darwin {
sched_priority: c.int, /* [PSX] process or thread execution scheduling priority */
}
+} else when ODIN_OS == .Haiku {
+
+ PTHREAD_CANCEL_ASYNCHRONOUS :: 2
+ PTHREAD_CANCEL_DEFERRED :: 0
+
+ PTHREAD_CANCEL_DISABLE :: 1
+ PTHREAD_CANCEL_ENABLE :: 0
+
+ PTHREAD_CANCELED :: rawptr(uintptr(1))
+
+ PTHREAD_CREATE_DETACHED :: 0x1
+ PTHREAD_CREATE_JOINABLE :: 0
+
+ PTHREAD_EXPLICIT_SCHED :: 0
+ PTHREAD_INHERIT_SCHED :: 0x4
+
+ PTHREAD_PRIO_INHERIT :: 1
+ PTHREAD_PRIO_NONE :: 0
+ PTHREAD_PRIO_PROTECT :: 2
+
+ PTHREAD_PROCESS_SHARED :: 1
+ PTHREAD_PROCESS_PRIVATE :: 0
+
+ PTHREAD_SCOPE_PROCESS :: 0
+ PTHREAD_SCOPE_SYSTEM :: 0x2
+
+ pthread_t :: distinct rawptr
+ pthread_attr_t :: distinct rawptr
+ pthread_key_t :: distinct c.int
+
+ pthread_mutex_t :: struct {
+ flags: u32,
+ lock: i32,
+ unused: i32,
+ owner: i32,
+ owner_count: i32,
+ }
+
+ pthread_cond_t :: struct {
+ flags: u32,
+ unused: i32,
+ mutex: ^pthread_mutex_t,
+ waiter_count: i32,
+ lock: i32,
+ }
+
+ sched_param :: struct {
+ sched_priority: c.int, /* [PSX] process or thread execution scheduling priority */
+ }
+
} else when ODIN_OS == .Linux {
PTHREAD_CANCEL_DEFERRED :: 0
diff --git a/core/sys/posix/pwd.odin b/core/sys/posix/pwd.odin
index 33cbcd7c5..75d15c899 100644
--- a/core/sys/posix/pwd.odin
+++ b/core/sys/posix/pwd.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -176,4 +176,16 @@ when ODIN_OS == .Darwin || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD {
pw_shell: cstring, /* Shell program. */
}
+} else when ODIN_OS == .Haiku {
+
+ passwd :: struct {
+ pw_name: cstring, /* [PSX] user name */
+ pw_passwd: cstring, /* encrypted password */
+ pw_uid: uid_t, /* [PSX] user uid */
+ pw_gid: gid_t, /* [PSX] user gid */
+ pw_dir: cstring, /* Home directory. */
+ pw_shell: cstring, /* Shell program. */
+ pw_gecos: cstring, /* Real name. */
+ }
+
}
diff --git a/core/sys/posix/sched.odin b/core/sys/posix/sched.odin
index e91178b09..82b335653 100644
--- a/core/sys/posix/sched.odin
+++ b/core/sys/posix/sched.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -101,4 +101,11 @@ when ODIN_OS == .Darwin {
SCHED_FIFO :: 1
SCHED_RR :: 2
+} else when ODIN_OS == .Haiku {
+
+ SCHED_FIFO :: 1
+ SCHED_RR :: 2
+ // SCHED_SPORADIC :: 3 NOTE: not a thing on freebsd, netbsd and probably others, leaving it out
+ SCHED_OTHER :: 4
+
}
diff --git a/core/sys/posix/signal.odin b/core/sys/posix/signal.odin
index 4ba4e9943..d2f737946 100644
--- a/core/sys/posix/signal.odin
+++ b/core/sys/posix/signal.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "base:intrinsics"
@@ -565,7 +565,7 @@ when ODIN_OS == .Darwin {
SS_ONSTACK :: 0x0001
SS_DISABLE :: 0x0004
- when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm32 {
+ when ODIN_ARCH == .arm64 || ODIN_ARCH == .arm32 {
MINSIGSTKSZ :: 1024 * 4
} else when ODIN_ARCH == .amd64 || ODIN_ARCH == .i386 {
MINSIGSTKSZ :: 512 * 4
@@ -1180,4 +1180,151 @@ when ODIN_OS == .Darwin {
SI_TIMER :: -2
SI_MESGQ :: -3
SI_ASYNCIO :: -4
+
+} else when ODIN_OS == .Haiku {
+
+ // Request that signal be held
+ SIG_HOLD :: rawptr(uintptr(3))
+
+ uid_t :: distinct c.uint32_t
+ sigset_t :: distinct u64
+
+ SIGHUP :: 1 // hangup -- tty is gone!
+ //SIGINT :: 2 // interrupt
+ SIGQUIT :: 3 // `quit' special character typed in tty
+ //SIGILL :: 4 // illegal instruction
+ SIGCHLD :: 5 // child process exited
+ //SIGABRT :: 6 // abort() called, dont' catch
+ SIGPIPE :: 7 // write to a pipe w/no readers
+ //SIGFPE :: 8 // floating point exception
+ SIGKILL :: 9 // kill a team (not catchable)
+ SIGSTOP :: 10 // suspend a thread (not catchable)
+ //SIGSEGV :: 11 // segmentation violation (read: invalid pointer)
+ SIGCONT :: 12 // continue execution if suspended
+ SIGTSTP :: 13 // `stop' special character typed in tty
+ SIGALRM :: 14 // an alarm has gone off (see alarm())
+ //SIGTERM :: 15 // termination requested
+ SIGTTIN :: 16 // read of tty from bg process
+ SIGTTOU :: 17 // write to tty from bg process
+ SIGUSR1 :: 18 // app defined signal 1
+ SIGUSR2 :: 19 // app defined signal 2
+ SIGWINCH :: 20 // tty window size changed
+ SIGKILLTHR :: 21 // be specific: kill just the thread, not team
+ SIGTRAP :: 22 // Trace/breakpoint trap
+ SIGPOLL :: 23 // Pollable event
+ SIGPROF :: 24 // Profiling timer expired
+ SIGSYS :: 25 // Bad system call
+ SIGURG :: 26 // High bandwidth data is available at socket
+ SIGVTALRM :: 27 // Virtual timer expired
+ SIGXCPU :: 28 // CPU time limit exceeded
+ SIGXFSZ :: 29 // File size limit exceeded
+ SIGBUS :: 30 // access to undefined portion of a memory object
+
+ // NOTE: this is actually defined as `sigaction`, but due to the function with the same name
+ // `_t` has been added.
+
+ sigaction_t :: struct {
+ using _: struct #raw_union {
+ sa_handler: proc "c" (Signal), /* [PSX] signal-catching function or one of the SIG_IGN or SIG_DFL */
+ sa_sigaction: proc "c" (Signal, ^siginfo_t, rawptr), /* [PSX] signal-catching function */
+ },
+ sa_mask: sigset_t, /* [PSX] set of signals to be blocked during execution of the signal handling function */
+ sa_flags: SA_Flags, /* [PSX] special flags */
+ sa_userdata: rawptr, /* will be passed to the signal handler, BeOS extension */
+ }
+
+ SIG_BLOCK :: 1
+ SIG_UNBLOCK :: 2
+ SIG_SETMASK :: 3
+
+ SA_NOCLDSTOP :: 0x01
+ SA_NOCLDWAIT :: 0x02
+ SA_RESETHAND :: 0x04
+ SA_NODEFER :: 0x08
+ SA_RESTART :: 0x10
+ SA_ONSTACK :: 0x20
+ SA_SIGINFO :: 0x40
+
+ SS_ONSTACK :: 1
+ SS_DISABLE :: 2
+
+ MINSIGSTKSZ :: 8192
+ SIGSTKSZ :: 16384
+
+ stack_t :: struct {
+ ss_sp: rawptr, /* [PSX] stack base or pointer */
+ ss_size: c.size_t, /* [PSX] stack size */
+ ss_flags: SS_Flags, /* [PSX] flags */
+ }
+
+ siginfo_t :: struct {
+ si_signo: Signal, /* [PSX] signal number */
+ si_code: struct #raw_union { /* [PSX] specific more detailed codes per signal */
+ ill: ILL_Code,
+ fpe: FPE_Code,
+ segv: SEGV_Code,
+ bus: BUS_Code,
+ trap: TRAP_Code,
+ chld: CLD_Code,
+ poll: POLL_Code,
+ any: Any_Code,
+ },
+ si_errno: Errno, /* [PSX] errno value associated with this signal */
+ si_pid: pid_t, /* sending process ID */
+ si_uid: uid_t, /* real user ID of sending process */
+ si_addr: rawptr, /* address of faulting instruction */
+ si_status: c.int, /* exit value or signal */
+ si_band: c.long, /* band event for SIGPOLL */
+ si_value: sigval, /* signal value */
+ }
+
+ /* any signal */
+ SI_USER :: 0 /* signal sent by user */
+ SI_QUEUE :: 1 /* signal sent by sigqueue() */
+ SI_TIMER :: 2 /* signal sent on timer_settime() timeout */
+ SI_ASYNCIO :: 3 /* signal sent on asynchronous I/O completion */
+ SI_MESGQ :: 4 /* signal sent on arrival of message on empty message queue */
+ /* SIGILL */
+ ILL_ILLOPC :: 10 /* illegal opcode */
+ ILL_ILLOPN :: 11 /* illegal operand */
+ ILL_ILLADR :: 12 /* illegal addressing mode */
+ ILL_ILLTRP :: 13 /* illegal trap */
+ ILL_PRVOPC :: 14 /* privileged opcode */
+ ILL_PRVREG :: 15 /* privileged register */
+ ILL_COPROC :: 16 /* coprocessor error */
+ ILL_BADSTK :: 17 /* internal stack error */
+ /* SIGFPE */
+ FPE_INTDIV :: 20 /* integer division by zero */
+ FPE_INTOVF :: 21 /* integer overflow */
+ FPE_FLTDIV :: 22 /* floating-point division by zero */
+ FPE_FLTOVF :: 23 /* floating-point overflow */
+ FPE_FLTUND :: 24 /* floating-point underflow */
+ FPE_FLTRES :: 25 /* floating-point inexact result */
+ FPE_FLTINV :: 26 /* invalid floating-point operation */
+ FPE_FLTSUB :: 27 /* subscript out of range */
+ /* SIGSEGV */
+ SEGV_MAPERR :: 30 /* address not mapped to object */
+ SEGV_ACCERR :: 31 /* invalid permissions for mapped object */
+ /* SIGBUS */
+ BUS_ADRALN :: 40 /* invalid address alignment */
+ BUS_ADRERR :: 41 /* nonexistent physical address */
+ BUS_OBJERR :: 42 /* object-specific hardware error */
+ /* SIGTRAP */
+ TRAP_BRKPT :: 50 /* process breakpoint */
+ TRAP_TRACE :: 51 /* process trace trap. */
+ /* SIGCHLD */
+ CLD_EXITED :: 60 /* child exited */
+ CLD_KILLED :: 61 /* child terminated abnormally without core dump */
+ CLD_DUMPED :: 62 /* child terminated abnormally with core dump */
+ CLD_TRAPPED :: 63 /* traced child trapped */
+ CLD_STOPPED :: 64 /* child stopped */
+ CLD_CONTINUED :: 65 /* stopped child continued */
+ /* SIGPOLL */
+ POLL_IN :: 70 /* input available */
+ POLL_OUT :: 71 /* output available */
+ POLL_MSG :: 72 /* input message available */
+ POLL_ERR :: 73 /* I/O error */
+ POLL_PRI :: 74 /* high priority input available */
+ POLL_HUP :: 75 /* device disconnected */
+
}
diff --git a/core/sys/posix/signal_libc.odin b/core/sys/posix/signal_libc.odin
index aef22da29..7a054ddd7 100644
--- a/core/sys/posix/signal_libc.odin
+++ b/core/sys/posix/signal_libc.odin
@@ -1,4 +1,4 @@
-#+build linux, windows, darwin, netbsd, openbsd, freebsd
+#+build linux, windows, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "base:intrinsics"
diff --git a/core/sys/posix/stdio_libc.odin b/core/sys/posix/stdio_libc.odin
index fbd949b2c..12706970d 100644
--- a/core/sys/posix/stdio_libc.odin
+++ b/core/sys/posix/stdio_libc.odin
@@ -1,4 +1,4 @@
-#+build linux, windows, linux, darwin, netbsd, openbsd, freebsd
+#+build linux, windows, linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
diff --git a/core/sys/posix/stdlib.odin b/core/sys/posix/stdlib.odin
index 640c70b5a..5f1ae1908 100644
--- a/core/sys/posix/stdlib.odin
+++ b/core/sys/posix/stdlib.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "base:intrinsics"
diff --git a/core/sys/posix/stdlib_libc.odin b/core/sys/posix/stdlib_libc.odin
index fa4d925b2..6574026f4 100644
--- a/core/sys/posix/stdlib_libc.odin
+++ b/core/sys/posix/stdlib_libc.odin
@@ -1,4 +1,4 @@
-#+build linux, windows, darwin, netbsd, openbsd, freebsd
+#+build linux, windows, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "base:intrinsics"
diff --git a/core/sys/posix/string.odin b/core/sys/posix/string.odin
index 96b6a9007..3f9dbb43e 100644
--- a/core/sys/posix/string.odin
+++ b/core/sys/posix/string.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
diff --git a/core/sys/posix/string_libc.odin b/core/sys/posix/string_libc.odin
index 336352cbc..72164cc4c 100644
--- a/core/sys/posix/string_libc.odin
+++ b/core/sys/posix/string_libc.odin
@@ -1,4 +1,4 @@
-#+build linux, windows, darwin, netbsd, openbsd, freebsd
+#+build linux, windows, darwin, netbsd, openbsd, freebsd, haiku
package posix
when ODIN_OS == .Windows {
diff --git a/core/sys/posix/sys_ipc.odin b/core/sys/posix/sys_ipc.odin
index 0f7ec06c5..bf5938ce1 100644
--- a/core/sys/posix/sys_ipc.odin
+++ b/core/sys/posix/sys_ipc.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -111,4 +111,27 @@ when ODIN_OS == .Darwin {
IPC_SET :: 1
IPC_STAT :: 2
+} else when ODIN_OS == .Haiku {
+
+ key_t :: distinct c.int32_t
+
+ ipc_perm :: struct {
+ key: key_t,
+ uid: uid_t, /* [PSX] owner's user ID */
+ gid: gid_t, /* [PSX] owner's group ID */
+ cuid: uid_t, /* [PSX] creator's user ID */
+ cgid: gid_t, /* [PSX] creator's group ID */
+ mode: mode_t, /* [PSX] read/write perms */
+ }
+
+ IPC_CREAT :: 0o01000
+ IPC_EXCL :: 0o02000
+ IPC_NOWAIT :: 0o04000
+
+ IPC_PRIVATE :: key_t(0)
+
+ IPC_RMID :: 0
+ IPC_SET :: 1
+ IPC_STAT :: 2
+
}
diff --git a/core/sys/posix/sys_msg.odin b/core/sys/posix/sys_msg.odin
index 0e78777f9..c578b1fc6 100644
--- a/core/sys/posix/sys_msg.odin
+++ b/core/sys/posix/sys_msg.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -171,4 +171,22 @@ when ODIN_OS == .Darwin {
__unused: [2]c.ulong,
}
+} else when ODIN_OS == .Haiku {
+
+ msgqnum_t :: distinct c.uint32_t
+ msglen_t :: distinct c.uint32_t
+
+ MSG_NOERROR :: 0o10000
+
+ msqid_ds :: struct {
+ msg_perm: ipc_perm, /* [PSX] operation permission structure */
+ msg_qnum: msgqnum_t, /* [PSX] number of messages currently on queue */
+ msg_qbytes: msglen_t, /* [PSX] maximum number of bytes allowed on queue */
+ msg_lspid: pid_t, /* [PSX] process ID of last msgsnd() */
+ msg_lrpid: pid_t, /* [PSX] process ID of last msgrcv() */
+ msg_stime: time_t, /* [PSX] time of last msgsnd() */
+ msg_rtime: time_t, /* [PSX] time of last msgrcv() */
+ msg_ctime: time_t, /* [PSX] time of last change */
+ }
+
}
diff --git a/core/sys/posix/sys_resource.odin b/core/sys/posix/sys_resource.odin
index 9af2a929b..ae478382a 100644
--- a/core/sys/posix/sys_resource.odin
+++ b/core/sys/posix/sys_resource.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -96,15 +96,26 @@ when ODIN_OS == .NetBSD {
@(private) LGETRUSAGE :: "getrusage"
}
-when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
+when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux || ODIN_OS == .Haiku {
PRIO_PROCESS :: 0
PRIO_PGRP :: 1
PRIO_USER :: 2
- rlim_t :: distinct c.uint64_t
+ when ODIN_OS == .Haiku {
+ rlim_t :: distinct c.ulong
+ } else {
+ rlim_t :: distinct c.uint64_t
+ }
- RLIM_INFINITY :: ~rlim_t(0) when ODIN_OS == .Linux else (rlim_t(1) << 63) - 1
+ when ODIN_OS == .Haiku {
+ RLIM_INFINITY :: rlim_t(0xFFFFFFFF)
+ } else when ODIN_OS == .Linux {
+ RLIM_INFINITY :: ~rlim_t(0)
+ } else {
+ RLIM_INFINITY :: (rlim_t(1) << 63) - 1
+ }
+
RLIM_SAVED_MAX :: RLIM_INFINITY
RLIM_SAVED_CUR :: RLIM_INFINITY
@@ -140,19 +151,29 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
ru_nivcsw: c.long, /* involuntary " */
}
- RLIMIT_CORE :: 4
- RLIMIT_CPU :: 0
- RLIMIT_DATA :: 2
- RLIMIT_FSIZE :: 1
- RLIMIT_NOFILE :: 7 when ODIN_OS == .Linux else 8
- RLIMIT_STACK :: 3
-
- when ODIN_OS == .Linux {
- RLIMIT_AS :: 9
- } else when ODIN_OS == .Darwin || ODIN_OS == .OpenBSD {
- RLIMIT_AS :: 5
+ when ODIN_OS == .Haiku {
+ RLIMIT_CORE :: 0
+ RLIMIT_CPU :: 1
+ RLIMIT_DATA :: 2
+ RLIMIT_FSIZE :: 3
+ RLIMIT_NOFILE :: 4
+ RLIMIT_STACK :: 5
+ RLIMIT_AS :: 6
} else {
- RLIMIT_AS :: 10
+ RLIMIT_CORE :: 4
+ RLIMIT_CPU :: 0
+ RLIMIT_DATA :: 2
+ RLIMIT_FSIZE :: 1
+ RLIMIT_NOFILE :: 7 when ODIN_OS == .Linux else 8
+ RLIMIT_STACK :: 3
+
+ when ODIN_OS == .Linux {
+ RLIMIT_AS :: 9
+ } else when ODIN_OS == .Darwin || ODIN_OS == .OpenBSD {
+ RLIMIT_AS :: 5
+ } else {
+ RLIMIT_AS :: 10
+ }
}
}
diff --git a/core/sys/posix/sys_select.odin b/core/sys/posix/sys_select.odin
index 2058ee777..a75e58de6 100644
--- a/core/sys/posix/sys_select.odin
+++ b/core/sys/posix/sys_select.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "base:intrinsics"
@@ -56,9 +56,9 @@ when ODIN_OS == .NetBSD {
LSELECT :: "select"
}
-when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
+when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux || ODIN_OS == .Haiku {
- suseconds_t :: distinct (c.int32_t when ODIN_OS == .Darwin || ODIN_OS == .NetBSD else c.long)
+ suseconds_t :: distinct (c.int32_t when ODIN_OS == .Darwin || ODIN_OS == .NetBSD || ODIN_OS == .Haiku else c.long)
timeval :: struct {
tv_sec: time_t, /* [PSX] seconds */
@@ -75,8 +75,14 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
@(private)
ALIGN :: align_of(c.long) when ODIN_OS == .FreeBSD || ODIN_OS == .Linux else align_of(c.int32_t)
- fd_set :: struct #align(ALIGN) {
- fds_bits: [(FD_SETSIZE / __NFDBITS) when (FD_SETSIZE % __NFDBITS) == 0 else (FD_SETSIZE / __NFDBITS) + 1]c.int32_t,
+ when ODIN_OS == .Haiku {
+ fd_set :: struct #align(ALIGN) {
+ fds_bits: [(FD_SETSIZE + (__NFDBITS - 1)) / __NFDBITS]c.int32_t,
+ }
+ } else {
+ fd_set :: struct #align(ALIGN) {
+ fds_bits: [(FD_SETSIZE / __NFDBITS) when (FD_SETSIZE % __NFDBITS) == 0 else (FD_SETSIZE / __NFDBITS) + 1]c.int32_t,
+ }
}
@(private)
diff --git a/core/sys/posix/sys_sem.odin b/core/sys/posix/sys_sem.odin
index 6b695e766..069315f87 100644
--- a/core/sys/posix/sys_sem.odin
+++ b/core/sys/posix/sys_sem.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -154,4 +154,30 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
sem_flg: c.short, /* [PSX] operation flags */
}
+} else when ODIN_OS == .Haiku {
+
+ SEM_UNDO :: 10 // undo the operation on exit
+
+ // Commands for `semctl'.
+ GETPID :: 3
+ GETVAL :: 4
+ GETALL :: 5
+ GETNCNT :: 6
+ GETZCNT :: 7
+ SETVAL :: 8
+ SETALL :: 9
+
+ semid_ds :: struct {
+ sem_perm: ipc_perm, // [PSX] operation permission structure
+ sem_nsems: c.ushort, // [PSX] number of semaphores in set
+ sem_otime: time_t, // [PSX] last semop()
+ sem_ctime: time_t, // [PSX] last time changed by semctl()
+ }
+
+ sembuf :: struct {
+ sem_num: c.ushort, /* [PSX] semaphore number */
+ sem_op: c.short, /* [PSX] semaphore operation */
+ sem_flg: c.short, /* [PSX] operation flags */
+ }
+
}
diff --git a/core/sys/posix/sys_socket.odin b/core/sys/posix/sys_socket.odin
index 4dd6074a3..0645893d0 100644
--- a/core/sys/posix/sys_socket.odin
+++ b/core/sys/posix/sys_socket.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -328,24 +328,32 @@ when ODIN_OS == .NetBSD {
@(private) LSOCKET :: "socket"
}
-when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
+when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux || ODIN_OS == .Haiku {
socklen_t :: distinct c.uint
+ when ODIN_OS == .Haiku {
+ @(private)
+ _SA_DATASIZE :: 30
+ } else {
+ @(private)
+ _SA_DATASIZE :: 14
+ }
+
when ODIN_OS == .Linux {
_sa_family_t :: distinct c.ushort
sockaddr :: struct {
- sa_family: sa_family_t, /* [PSX] address family */
- sa_data: [14]c.char, /* [PSX] socket address */
+ sa_family: sa_family_t, /* [PSX] address family */
+ sa_data: [_SA_DATASIZE]c.char, /* [PSX] socket address */
}
} else {
_sa_family_t :: distinct c.uint8_t
sockaddr :: struct {
- sa_len: c.uint8_t, /* total length */
- sa_family: sa_family_t, /* [PSX] address family */
- sa_data: [14]c.char, /* [PSX] socket address */
+ sa_len: c.uint8_t, /* total length */
+ sa_family: sa_family_t, /* [PSX] address family */
+ sa_data: [_SA_DATASIZE]c.char, /* [PSX] socket address */
}
}
@@ -355,6 +363,11 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
_SS_PAD1SIZE :: 6
@(private)
_SS_PAD2SIZE :: 240
+ } else when ODIN_OS == .Haiku {
+ @(private)
+ _SS_PAD1SIZE :: 6
+ @(private)
+ _SS_PAD2SIZE :: 112
} else when ODIN_OS == .Linux {
@(private)
_SS_SIZE :: 128
@@ -486,6 +499,26 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
SO_RCVTIMEO :: 66
SO_SNDTIMEO :: 67
+ } else when ODIN_OS == .Haiku {
+ SOL_SOCKET :: -1
+
+ SO_ACCEPTCONN :: 0x00000001
+ SO_BROADCAST :: 0x00000002
+ SO_DEBUG :: 0x00000004
+ SO_DONTROUTE :: 0x00000008
+ SO_ERROR :: 0x40000007
+ SO_KEEPALIVE :: 0x00000010
+ SO_OOBINLINE :: 0x00000020
+ SO_RCVBUF :: 0x40000004
+ SO_RCVLOWAT :: 0x40000005
+ SO_REUSEADDR :: 0x00000040
+ SO_SNDBUF :: 0x40000001
+ SO_SNDLOWAT :: 0x40000002
+ SO_TYPE :: 0x40000008
+
+ SO_LINGER :: 0x00000200
+ SO_RCVTIMEO :: 0x40000006
+ SO_SNDTIMEO :: 0x40000003
} else {
SOL_SOCKET :: 0xffff
@@ -523,7 +556,11 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
}
// The maximum backlog queue length for listen().
- SOMAXCONN :: 128
+ when ODIN_OS == .Haiku {
+ SOMAXCONN :: 32
+ } else {
+ SOMAXCONN :: 128
+ }
when ODIN_OS == .Linux {
MSG_CTRUNC :: 0x008
@@ -549,11 +586,18 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
MSG_NOSIGNAL :: 0x00020000
} else when ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD {
MSG_NOSIGNAL :: 0x0400
+ } else when ODIN_OS == .Haiku {
+ MSG_NOSIGNAL :: 0x800
}
}
- AF_INET :: 2
- AF_UNIX :: 1
+ when ODIN_OS == .Haiku {
+ AF_INET :: 1
+ AF_UNIX :: 9
+ } else {
+ AF_INET :: 2
+ AF_UNIX :: 1
+ }
when ODIN_OS == .Darwin {
AF_INET6 :: 30
@@ -563,6 +607,8 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
AF_INET6 :: 24
} else when ODIN_OS == .Linux {
AF_INET6 :: 10
+ } else when ODIN_OS == .Haiku {
+ AF_INET6 :: 5
}
SHUT_RD :: 0
diff --git a/core/sys/posix/sys_stat.odin b/core/sys/posix/sys_stat.odin
index 61b98ef35..265356e54 100644
--- a/core/sys/posix/sys_stat.odin
+++ b/core/sys/posix/sys_stat.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -428,6 +428,36 @@ when ODIN_OS == .Darwin {
UTIME_NOW :: -2
UTIME_OMIT :: -1
+} else when ODIN_OS == .Haiku {
+
+ dev_t :: distinct c.int32_t
+ nlink_t :: distinct c.int32_t
+ _mode_t :: distinct c.uint32_t
+ blkcnt_t :: distinct c.int64_t
+ blksize_t :: distinct c.int32_t
+ ino_t :: distinct c.int64_t
+
+ stat_t :: struct {
+ st_dev: dev_t, /* [PSX] ID of device containing file */
+ st_ino: ino_t, /* [PSX] file serial number */
+ st_mode: mode_t, /* [PSX] mode of file */
+ st_nlink: nlink_t, /* [PSX] number of hard links */
+ st_uid: uid_t, /* [PSX] user ID of the file */
+ st_gid: gid_t, /* [PSX] group ID of the file */
+ st_size: off_t, /* [PSX] file size, in bytes */
+ st_rdev: dev_t, /* [PSX] device ID */
+ st_blksize: blksize_t, /* [PSX] optimal blocksize for I/O */
+ st_atim: timespec, /* [PSX] time of last access */
+ st_mtim: timespec, /* [PSX] time of last data modification */
+ st_ctim: timespec, /* [PSX] time of last status change */
+ st_crtim: timespec, /* [PSX] time of last status change */
+ st_type: c.uint32_t,
+ st_blocks: blkcnt_t, /* [PSX] blocks allocated for file */
+ }
+
+ UTIME_NOW :: 1000000000
+ UTIME_OMIT :: 1000000001
+
} else when ODIN_OS == .Linux {
dev_t :: distinct u64
diff --git a/core/sys/posix/sys_time.odin b/core/sys/posix/sys_time.odin
index 3036352aa..94eafec85 100644
--- a/core/sys/posix/sys_time.odin
+++ b/core/sys/posix/sys_time.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -78,4 +78,15 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
ITIMER_VIRTUAL :: 1
ITIMER_PROF :: 2
+} else when ODIN_OS == .Haiku {
+
+ itimerval :: struct {
+ it_interval: timeval, /* [PSX] timer interval */
+ it_value: timeval, /* [PSX] current value */
+ }
+
+ ITIMER_REAL :: 1
+ ITIMER_VIRTUAL :: 2
+ ITIMER_PROF :: 3
+
}
diff --git a/core/sys/posix/sys_times.odin b/core/sys/posix/sys_times.odin
index 113e3f963..73db489a7 100644
--- a/core/sys/posix/sys_times.odin
+++ b/core/sys/posix/sys_times.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
when ODIN_OS == .Darwin {
@@ -25,7 +25,7 @@ when ODIN_OS == .NetBSD {
@(private) LTIMES :: "times"
}
-when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
+when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux || ODIN_OS == .Haiku {
tms :: struct {
tms_utime: clock_t, /* [PSX] user CPU time */
diff --git a/core/sys/posix/sys_uio.odin b/core/sys/posix/sys_uio.odin
index a0ad2934e..5770f8058 100644
--- a/core/sys/posix/sys_uio.odin
+++ b/core/sys/posix/sys_uio.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -31,7 +31,7 @@ foreign libc {
writev :: proc(fildes: FD, iov: [^]iovec, iovcnt: c.int) -> c.ssize_t ---
}
-when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
+when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux || ODIN_OS == .Haiku {
iovec :: struct {
iov_base: rawptr, /* [PSX] base address of I/O memory region */
diff --git a/core/sys/posix/sys_un.odin b/core/sys/posix/sys_un.odin
index ca5c4ee31..167bf3ce1 100644
--- a/core/sys/posix/sys_un.odin
+++ b/core/sys/posix/sys_un.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -20,4 +20,12 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
sun_path: [108]c.char, /* [PSX] socket pathname */
}
+} else when ODIN_OS == .Haiku {
+
+ sockaddr_un :: struct {
+ sun_len: c.uint8_t,
+ sun_family: sa_family_t, /* [PSX] address family */
+ sun_path: [126]c.char, /* [PSX] socket pathname */
+ }
+
}
diff --git a/core/sys/posix/sys_utsname.odin b/core/sys/posix/sys_utsname.odin
index 64930160f..5ea8807a7 100644
--- a/core/sys/posix/sys_utsname.odin
+++ b/core/sys/posix/sys_utsname.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -38,10 +38,10 @@ foreign lib {
uname :: proc(uname: ^utsname) -> c.int ---
}
-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 == .Haiku {
@(private)
- _SYS_NAMELEN :: 256
+ _SYS_NAMELEN :: 32 when ODIN_OS == .Haiku else 256
utsname :: struct {
sysname: [_SYS_NAMELEN]c.char `fmt:"s,0"`, /* [PSX] name of OS */
diff --git a/core/sys/posix/sys_wait.odin b/core/sys/posix/sys_wait.odin
index 812bd8c62..d3bcdfddd 100644
--- a/core/sys/posix/sys_wait.odin
+++ b/core/sys/posix/sys_wait.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -442,4 +442,56 @@ when ODIN_OS == .Darwin {
_WIFCONTINUED :: #force_inline proc "contextless" (x: c.int) -> bool {
return x == 0xffff
}
+
+} else when ODIN_OS == .Haiku {
+
+ id_t :: distinct c.int32_t
+
+ WCONTINUED :: 0x04
+ WNOHANG :: 0x01
+ WUNTRACED :: 0x02
+
+ WEXITED :: 0x08
+ WNOWAIT :: 0x20
+ WSTOPPED :: 0x10
+
+ _P_ALL :: 0
+ _P_PID :: 1
+ _P_PGID :: 2
+
+ @(private)
+ _WIFEXITED :: #force_inline proc "contextless" (x: c.int) -> bool {
+ return (x & ~(c.int)(0xff)) == 0
+ }
+
+ @(private)
+ _WEXITSTATUS :: #force_inline proc "contextless" (x: c.int) -> c.int {
+ return x & 0xff
+ }
+
+ @(private)
+ _WIFSIGNALED :: #force_inline proc "contextless" (x: c.int) -> bool {
+ return ((x >> 8) & 0xff) != 0
+ }
+
+ @(private)
+ _WTERMSIG :: #force_inline proc "contextless" (x: c.int) -> Signal {
+ return Signal((x >> 8) & 0xff)
+ }
+
+ @(private)
+ _WIFSTOPPED :: #force_inline proc "contextless" (x: c.int) -> bool {
+ return ((x >> 16) & 0xff) != 0
+ }
+
+ @(private)
+ _WSTOPSIG :: #force_inline proc "contextless" (x: c.int) -> Signal {
+ return Signal((x >> 16) & 0xff)
+ }
+
+ @(private)
+ _WIFCONTINUED :: #force_inline proc "contextless" (x: c.int) -> bool {
+ return (x & 0x20000) != 0
+ }
+
}
diff --git a/core/sys/posix/termios.odin b/core/sys/posix/termios.odin
index 0c07eceb9..4ca884e87 100644
--- a/core/sys/posix/termios.odin
+++ b/core/sys/posix/termios.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -138,17 +138,30 @@ CLocal_Flag_Bits :: enum tcflag_t {
}
CLocal_Flags :: bit_set[CLocal_Flag_Bits; tcflag_t]
-CControl_Flag_Bits :: enum tcflag_t {
- // CS5 = log2(CS5), /* 5 bits (pseudo) (default) */
- CS6 = log2(CS6), /* 6 bits */
- CS7 = log2(CS7), /* 7 bits */
- CS8 = log2(CS8), /* 8 bits */
- CSTOPB = log2(CSTOPB), /* send 2 stop bits */
- CREAD = log2(CREAD), /* enable receiver */
- PARENB = log2(PARENB), /* parity enable */
- PARODD = log2(PARODD), /* odd parity, else even */
- HUPCL = log2(HUPCL), /* hang up on last close */
- CLOCAL = log2(CLOCAL), /* ignore modem status lines */
+when ODIN_OS == .Haiku {
+ CControl_Flag_Bits :: enum tcflag_t {
+ // CS7 = log2(CS7), /* 7 bits (default) */
+ CS8 = log2(CS8), /* 8 bits */
+ CSTOPB = log2(CSTOPB), /* send 2 stop bits */
+ CREAD = log2(CREAD), /* enable receiver */
+ PARENB = log2(PARENB), /* parity enable */
+ PARODD = log2(PARODD), /* odd parity, else even */
+ HUPCL = log2(HUPCL), /* hang up on last close */
+ CLOCAL = log2(CLOCAL), /* ignore modem status lines */
+ }
+} else {
+ CControl_Flag_Bits :: enum tcflag_t {
+ // CS5 = log2(CS5), /* 5 bits (pseudo) (default) */
+ CS6 = log2(CS6), /* 6 bits */
+ CS7 = log2(CS7), /* 7 bits */
+ CS8 = log2(CS8), /* 8 bits */
+ CSTOPB = log2(CSTOPB), /* send 2 stop bits */
+ CREAD = log2(CREAD), /* enable receiver */
+ PARENB = log2(PARENB), /* parity enable */
+ PARODD = log2(PARODD), /* odd parity, else even */
+ HUPCL = log2(HUPCL), /* hang up on last close */
+ CLOCAL = log2(CLOCAL), /* ignore modem status lines */
+ }
}
CControl_Flags :: bit_set[CControl_Flag_Bits; tcflag_t]
@@ -597,4 +610,151 @@ when ODIN_OS == .Darwin {
TCOOFF :: 0
TCOON :: 1
+} else when ODIN_OS == .Haiku {
+
+ cc_t :: distinct c.uchar
+ _speed_t :: distinct c.uint32_t
+ tcflag_t :: distinct c.uint16_t
+
+ // Same as speed_t, but 16-bit.
+ CSpeed :: enum tcflag_t {
+ B0 = B0,
+ B50 = B50,
+ B75 = B75,
+ B110 = B110,
+ B134 = B134,
+ B150 = B150,
+ B200 = B200,
+ B300 = B300,
+ B600 = B600,
+ B1200 = B1200,
+ B1800 = B1800,
+ B2400 = B2400,
+ B4800 = B4800,
+ B9600 = B9600,
+ B19200 = B19200,
+ B38400 = B38400,
+ }
+
+ termios :: struct {
+ c_iflag: CInput_Flags, /* [XBD] input flags */
+ c_ispeed: CSpeed, /* input speed */
+ c_oflag: COutput_Flags, /* [XBD] output flags */
+ c_ospeed: CSpeed, /* output speed */
+ c_cflag: CControl_Flags, /* [XBD] control flags */
+ c_ispeed_high: tcflag_t, /* high word of input baudrate */
+ c_lflag: CLocal_Flags, /* [XBD] local flag */
+ c_ospeed_high: tcflag_t, /* high word of output baudrate */
+ c_line: c.char,
+ _padding: c.uchar,
+ _padding2: c.uchar,
+ c_cc: [NCCS]cc_t,
+ }
+
+ NCCS :: 11
+
+ VINTR :: 0
+ VQUIT :: 1
+ VERASE :: 2
+ VKILL :: 3
+ VEOF :: 4
+ VEOL :: 5
+ VMIN :: 4
+ VTIME :: 5
+ VEOL2 :: 6
+ VSWTCH :: 7
+ VSTART :: 8
+ VSTOP :: 9
+ VSUSP :: 10
+
+ IGNBRK :: 0x01 /* ignore break condition */
+ BRKINT :: 0x02 /* break sends interrupt */
+ IGNPAR :: 0x04 /* ignore characters with parity errors */
+ PARMRK :: 0x08 /* mark parity errors */
+ INPCK :: 0x10 /* enable input parity checking */
+ ISTRIP :: 0x20 /* strip high bit from characters */
+ INLCR :: 0x40 /* maps newline to CR on input */
+ IGNCR :: 0x80 /* ignore carriage returns */
+ ICRNL :: 0x100 /* map CR to newline on input */
+ IXON :: 0x400 /* enable input SW flow control */
+ IXANY :: 0x800 /* any character will restart input */
+ IXOFF :: 0x1000 /* enable output SW flow control */
+
+ OPOST :: 0x01 /* enable postprocessing of output */
+ ONLCR :: 0x04 /* map NL to CR-NL on output */
+ OCRNL :: 0x08 /* map CR to NL on output */
+ ONOCR :: 0x10 /* no CR output when at column 0 */
+ ONLRET :: 0x20 /* newline performs CR function */
+ OFILL :: 0x40 /* use fill characters for delays */
+ OFDEL :: 0x80 /* Fills are DEL, otherwise NUL */
+ _NLDLY :: 0x100 /* Newline delays: */
+ NL0 :: 0x000
+ NL1 :: 0x100
+ _CRDLY :: 0x600 /* Carriage return delays: */
+ CR0 :: 0x000
+ CR1 :: 0x200
+ CR2 :: 0x400
+ CR3 :: 0x600
+ _TABDLY :: 0x1800 /* Tab delays: */
+ TAB0 :: 0x0000
+ TAB1 :: 0x0800
+ TAB3 :: 0x1800
+ _BSDLY :: 0x2000 /* Backspace delays: */
+ BS0 :: 0x0000
+ BS1 :: 0x2000
+ _VTDLY :: 0x4000 /* Vertical tab delays: */
+ VT0 :: 0x0000
+ VT1 :: 0x4000
+ _FFDLY :: 0x8000 /* Form feed delays: */
+ FF0 :: 0x0000
+ FF1 :: 0x8000
+
+ B0 :: 0x00 /* hang up */
+ B50 :: 0x01 /* 50 baud */
+ B75 :: 0x02
+ B110 :: 0x03
+ B134 :: 0x04
+ B150 :: 0x05
+ B200 :: 0x06
+ B300 :: 0x07
+ B600 :: 0x08
+ B1200 :: 0x09
+ B1800 :: 0x0A
+ B2400 :: 0x0B
+ B4800 :: 0x0C
+ B9600 :: 0x0D
+ B19200 :: 0x0E
+ B38400 :: 0x0F
+
+ _CSIZE :: 0x20 /* character size */
+ //CS5 :: 0x00 /* only 7 and 8 bits supported */
+ //CS6 :: 0x00 /* Note, it was not very wise to set all of these */
+ //CS7 :: 0x00 /* to zero, but there is not much we can do about it*/
+ CS8 :: 0x20
+ CSTOPB :: 0x40 /* send 2 stop bits, not 1 */
+ CREAD :: 0x80 /* enable receiver */
+ PARENB :: 0x100 /* parity enable */
+ PARODD :: 0x200 /* odd parity, else even */
+ HUPCL :: 0x400 /* hangs up on last close */
+ CLOCAL :: 0x800 /* indicates local line */
+
+ ISIG :: 0x01 /* enable signals */
+ ICANON :: 0x02 /* Canonical input */
+ ECHO :: 0x08 /* Enable echo */
+ ECHOE :: 0x10 /* Echo erase as bs-sp-bs */
+ ECHOK :: 0x20 /* Echo nl after kill */
+ ECHONL :: 0x40 /* Echo nl */
+ NOFLSH :: 0x80 /* Disable flush after int or quit */
+ TOSTOP :: 0x100 /* stop bg processes that write to tty */
+ IEXTEN :: 0x200 /* implementation defined extensions */
+
+ TCIFLUSH :: 1
+ TCOFLUSH :: 2
+ TCIOFLUSH :: 3
+
+ TCIOFF :: 0x04
+ TCION :: 0x08
+ TCOOFF :: 0x01
+ TCOON :: 0x02
+
}
diff --git a/core/sys/posix/time.odin b/core/sys/posix/time.odin
index f9c51c63c..88f0153f4 100644
--- a/core/sys/posix/time.odin
+++ b/core/sys/posix/time.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -230,6 +230,17 @@ when ODIN_OS == .Darwin {
getdate_err: Errno = .ENOSYS // NOTE: looks like it's not a thing on OpenBSD.
+} else when ODIN_OS == .Haiku {
+
+ clockid_t :: distinct c.int32_t
+
+ CLOCK_MONOTONIC :: 0
+ CLOCK_PROCESS_CPUTIME_ID :: -2
+ CLOCK_REALTIME :: -1
+ CLOCK_THREAD_CPUTIME_ID :: -3
+
+ getdate_err: Errno = .ENOSYS // NOTE: looks like it's not a thing on Haiku.
+
} else when ODIN_OS == .Linux {
clockid_t :: distinct c.int
diff --git a/core/sys/posix/unistd.odin b/core/sys/posix/unistd.odin
index 0526b3235..b8020317c 100644
--- a/core/sys/posix/unistd.odin
+++ b/core/sys/posix/unistd.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
@@ -899,7 +899,7 @@ CS :: enum c.int {
}
PC :: enum c.int {
- _2_SYMLINK = _PC_2_SYMLINK,
+ _2_SYMLINKS = _PC_2_SYMLINKS,
_ALLOC_SIZE_MIN = _PC_ALLOC_SIZE_MIN,
_ASYNC_IO = _PC_ASYNC_IO,
_CHOWN_RESTRICTED = _PC_CHOWN_RESTRICTED,
@@ -1099,7 +1099,7 @@ when ODIN_OS == .Darwin {
_PC_CHOWN_RESTRICTED :: 7
_PC_NO_TRUNC :: 8
_PC_VDISABLE :: 9
- _PC_2_SYMLINK :: 15
+ _PC_2_SYMLINKS :: 15
_PC_ALLOC_SIZE_MIN :: 16
_PC_ASYNC_IO :: 17
_PC_FILESIZEBITS :: 18
@@ -1280,7 +1280,7 @@ when ODIN_OS == .Darwin {
_PC_CHOWN_RESTRICTED :: 7
_PC_NO_TRUNC :: 8
_PC_VDISABLE :: 9
- _PC_2_SYMLINK :: 13 // NOTE: not in headers (freebsd)
+ _PC_2_SYMLINKS :: 13 // NOTE: not in headers (freebsd)
_PC_ALLOC_SIZE_MIN :: 10
_PC_ASYNC_IO :: 53
_PC_FILESIZEBITS :: 12
@@ -1461,7 +1461,7 @@ when ODIN_OS == .Darwin {
_PC_CHOWN_RESTRICTED :: 7
_PC_NO_TRUNC :: 8
_PC_VDISABLE :: 9
- _PC_2_SYMLINK :: 13 // NOTE: not in headers
+ _PC_2_SYMLINKS :: 13 // NOTE: not in headers
_PC_ALLOC_SIZE_MIN :: 10 // NOTE: not in headers
_PC_ASYNC_IO :: 53 // NOTE: not in headers
_PC_FILESIZEBITS :: 11
@@ -1646,7 +1646,7 @@ when ODIN_OS == .Darwin {
_PC_CHOWN_RESTRICTED :: 7
_PC_NO_TRUNC :: 8
_PC_VDISABLE :: 9
- _PC_2_SYMLINK :: 10
+ _PC_2_SYMLINKS :: 10
_PC_ALLOC_SIZE_MIN :: 11
_PC_ASYNC_IO :: 12
_PC_FILESIZEBITS :: 13
@@ -1816,180 +1816,390 @@ when ODIN_OS == .Darwin {
F_TLOCK :: 2
F_ULOCK :: 0
- _CS_PATH :: 1
- _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS :: 2
-
- _CS_POSIX_V6_ILP32_OFF32_CFLAGS :: 1116
- _CS_POSIX_V6_ILP32_OFF32_LDFLAGS :: 1117
- _CS_POSIX_V6_ILP32_OFF32_LIBS :: 1118
- _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS :: 1120
- _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS :: 1121
- _CS_POSIX_V6_ILP32_OFFBIG_LIBS :: 1122
- _CS_POSIX_V6_LP64_OFF64_CFLAGS :: 1124
- _CS_POSIX_V6_LP64_OFF64_LDFLAGS :: 1125
- _CS_POSIX_V6_LP64_OFF64_LIBS :: 1126
- _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS :: 1128
- _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS :: 1129
- _CS_POSIX_V6_LPBIG_OFFBIG_LIBS :: 1130
-
- _PC_LINK_MAX :: 1
- _PC_MAX_CANON :: 2
- _PC_MAX_INPUT :: 3
- _PC_NAME_MAX :: 4
- _PC_PATH_MAX :: 5
- _PC_PIPE_BUF :: 6
- _PC_CHOWN_RESTRICTED :: 7
- _PC_NO_TRUNC :: 8
- _PC_VDISABLE :: 9
- _PC_SYNC_IO :: 10
- _PC_ASYNC_IO :: 11
- _PC_PRIO_IO :: 12
- _PC_FILESIZEBITS :: 14
- _PC_REC_INCR_XFER_SIZE :: 15
- _PC_REC_MAX_XFER_SIZE :: 16
- _PC_REC_MIN_XFER_SIZE :: 17
- _PC_REC_XFER_ALIGN :: 18
- _PC_ALLOC_SIZE_MIN :: 19
- _PC_SYMLINK_MAX :: 20
- _PC_2_SYMLINK :: 21
-
- _SC_ARG_MAX :: 1
- _SC_CHILD_MAX :: 2
- _SC_CLK_TCK :: 3
- _SC_NGROUPS_MAX :: 4
- _SC_OPEN_MAX :: 5
- _SC_STREAM_MAX :: 6
- _SC_TZNAME_MAX :: 7
- _SC_JOB_CONTROL :: 8
- _SC_SAVED_IDS :: 9
- _SC_REALTIME_SIGNALS :: 10
- _SC_PRIORITY_SCHEDULING :: 11
- _SC_TIMERS :: 12
- _SC_ASYNCHRONOUS_IO :: 13
- _SC_PRIORITIZED_IO :: 14
- _SC_SYNCHRONIZED_IO :: 15
- _SC_FSYNC :: 16
- _SC_MAPPED_FILES :: 17
- _SC_MEMLOCK :: 18
- _SC_MEMLOCK_RANGE :: 19
- _SC_MEMORY_PROTECTION :: 20
- _SC_MESSAGE_PASSING :: 21
- _SC_SEMAPHORES :: 22
- _SC_SHARED_MEMORY_OBJECTS :: 23
- _SC_AIO_LISTIO_MAX :: 24
- _SC_AIO_MAX :: 25
- _SC_AIO_PRIO_DELTA_MAX :: 26
- _SC_DELAYTIMER_MAX :: 27
- _SC_MQ_OPEN_MAX :: 28
- _SC_MQ_PRIO_MAX :: 29
- _SC_VERSION :: 30
- _SC_PAGESIZE :: 31
- _SC_PAGE_SIZE :: _SC_PAGESIZE
- _SC_RTSIG_MAX :: 32
- _SC_SEM_NSEMS_MAX :: 33
- _SC_SEM_VALUE_MAX :: 34
- _SC_SIGQUEUE_MAX :: 35
- _SC_TIMER_MAX :: 36
- _SC_BC_BASE_MAX :: 37
- _SC_BC_DIM_MAX :: 38
- _SC_BC_SCALE_MAX :: 39
- _SC_BC_STRING_MAX :: 40
- _SC_COLL_WEIGHTS_MAX :: 41
- _SC_EXPR_NEST_MAX :: 43
- _SC_LINE_MAX :: 44
- _SC_RE_DUP_MAX :: 45
- _SC_2_VERSION :: 47
- _SC_2_C_BIND :: 48
- _SC_2_C_DEV :: 49
- _SC_2_FORT_DEV :: 50
- _SC_2_FORT_RUN :: 51
- _SC_2_SW_DEV :: 52
- _SC_2_LOCALEDEF :: 53
-
- _SC_IOV_MAX :: 62
- _SC_THREADS :: 69
- _SC_THREAD_SAFE_FUNCTIONS :: 70
- _SC_GETGR_R_SIZE_MAX :: 71
- _SC_GETPW_R_SIZE_MAX :: 72
- _SC_LOGIN_NAME_MAX :: 73
- _SC_TTY_NAME_MAX :: 74
- _SC_THREAD_DESTRUCTOR_ITERATIONS :: 75
- _SC_THREAD_KEYS_MAX :: 76
- _SC_THREAD_STACK_MIN :: 77
- _SC_THREAD_THREADS_MAX :: 78
- _SC_THREAD_ATTR_STACKADDR :: 79
- _SC_THREAD_ATTR_STACKSIZE :: 80
- _SC_THREAD_PRIORITY_SCHEDULING :: 81
- _SC_THREAD_PRIO_INHERIT :: 82
- _SC_THREAD_PRIO_PROTECT :: 83
- _SC_THREAD_PROCESS_SHARED :: 84
- _SC_NPROCESSORS_CONF :: 85
- _SC_NPROCESSORS_ONLN :: 86
- _SC_PHYS_PAGES :: 87
- _SC_AVPHYS_PAGES :: 88
- _SC_ATEXIT_MAX :: 89
- _SC_PASS_MAX :: 90
- _SC_XOPEN_VERSION :: 91
- _SC_XOPEN_UNIX :: 92
- _SC_XOPEN_CRYPT :: 93
- _SC_XOPEN_ENH_I18N :: 94
- _SC_XOPEN_SHM :: 95
- _SC_2_CHAR_TERM :: 96
+ _CS_PATH :: 0
+ _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS :: 1
+ _CS_GNU_LIBC_VERSION :: 2
+ _CS_GNU_LIBPTHREAD_VERSION :: 3
+ _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS :: 4
+ _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS :: 5
+
+ _CS_POSIX_V6_ILP32_OFF32_CFLAGS :: 1116
+ _CS_POSIX_V6_ILP32_OFF32_LDFLAGS :: 1117
+ _CS_POSIX_V6_ILP32_OFF32_LIBS :: 1118
+ _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS :: 1119
+ _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS :: 1120
+ _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS :: 1121
+ _CS_POSIX_V6_ILP32_OFFBIG_LIBS :: 1122
+ _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS :: 1123
+ _CS_POSIX_V6_LP64_OFF64_CFLAGS :: 1124
+ _CS_POSIX_V6_LP64_OFF64_LDFLAGS :: 1125
+ _CS_POSIX_V6_LP64_OFF64_LIBS :: 1126
+ _CS_POSIX_V6_LP64_OFF64_LINTFLAGS :: 1127
+ _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS :: 1128
+ _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS :: 1129
+ _CS_POSIX_V6_LPBIG_OFFBIG_LIBS :: 1130
+ _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS :: 1131
+ _CS_POSIX_V7_ILP32_OFF32_CFLAGS :: 1132
+ _CS_POSIX_V7_ILP32_OFF32_LDFLAGS :: 1133
+ _CS_POSIX_V7_ILP32_OFF32_LIBS :: 1134
+ _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS :: 1135
+ _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS :: 1136
+ _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS :: 1137
+ _CS_POSIX_V7_ILP32_OFFBIG_LIBS :: 1138
+ _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS :: 1139
+ _CS_POSIX_V7_LP64_OFF64_CFLAGS :: 1140
+ _CS_POSIX_V7_LP64_OFF64_LDFLAGS :: 1141
+ _CS_POSIX_V7_LP64_OFF64_LIBS :: 1142
+ _CS_POSIX_V7_LP64_OFF64_LINTFLAGS :: 1143
+ _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS :: 1144
+ _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS :: 1145
+ _CS_POSIX_V7_LPBIG_OFFBIG_LIBS :: 1146
+ _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS :: 1147
+ _CS_V6_ENV :: 1148
+ _CS_V7_ENV :: 1149
+ _CS_POSIX_V7_THREADS_CFLAGS :: 1150
+ _CS_POSIX_V7_THREADS_LDFLAGS :: 1151
+
+ _PC_LINK_MAX :: 0
+ _PC_MAX_CANON :: 1
+ _PC_MAX_INPUT :: 2
+ _PC_NAME_MAX :: 3
+ _PC_PATH_MAX :: 4
+ _PC_PIPE_BUF :: 5
+ _PC_CHOWN_RESTRICTED :: 6
+ _PC_NO_TRUNC :: 7
+ _PC_VDISABLE :: 8
+ _PC_SYNC_IO :: 9
+ _PC_ASYNC_IO :: 10
+ _PC_PRIO_IO :: 11
+ _PC_SOCK_MAXBUF :: 12
+ _PC_FILESIZEBITS :: 13
+ _PC_REC_INCR_XFER_SIZE :: 14
+ _PC_REC_MAX_XFER_SIZE :: 15
+ _PC_REC_MIN_XFER_SIZE :: 16
+ _PC_REC_XFER_ALIGN :: 17
+ _PC_ALLOC_SIZE_MIN :: 18
+ _PC_SYMLINK_MAX :: 19
+ _PC_2_SYMLINKS :: 20
+
+ _SC_ARG_MAX :: 0
+ _SC_CHILD_MAX :: 1
+ _SC_CLK_TCK :: 2
+ _SC_NGROUPS_MAX :: 3
+ _SC_OPEN_MAX :: 4
+ _SC_STREAM_MAX :: 5
+ _SC_TZNAME_MAX :: 6
+ _SC_JOB_CONTROL :: 7
+ _SC_SAVED_IDS :: 8
+ _SC_REALTIME_SIGNALS :: 9
+ _SC_PRIORITY_SCHEDULING :: 10
+ _SC_TIMERS :: 11
+ _SC_ASYNCHRONOUS_IO :: 12
+ _SC_PRIORITIZED_IO :: 13
+ _SC_SYNCHRONIZED_IO :: 14
+ _SC_FSYNC :: 15
+ _SC_MAPPED_FILES :: 16
+ _SC_MEMLOCK :: 17
+ _SC_MEMLOCK_RANGE :: 18
+ _SC_MEMORY_PROTECTION :: 19
+ _SC_MESSAGE_PASSING :: 20
+ _SC_SEMAPHORES :: 21
+ _SC_SHARED_MEMORY_OBJECTS :: 22
+ _SC_AIO_LISTIO_MAX :: 23
+ _SC_AIO_MAX :: 24
+ _SC_AIO_PRIO_DELTA_MAX :: 25
+ _SC_DELAYTIMER_MAX :: 26
+ _SC_MQ_OPEN_MAX :: 27
+ _SC_MQ_PRIO_MAX :: 28
+ _SC_VERSION :: 29
+ _SC_PAGE_SIZE :: 30
+ _SC_PAGESIZE :: _SC_PAGE_SIZE
+ _SC_RTSIG_MAX :: 31
+ _SC_SEM_NSEMS_MAX :: 32
+ _SC_SEM_VALUE_MAX :: 33
+ _SC_SIGQUEUE_MAX :: 34
+ _SC_TIMER_MAX :: 35
+ _SC_BC_BASE_MAX :: 36
+ _SC_BC_DIM_MAX :: 37
+ _SC_BC_SCALE_MAX :: 38
+ _SC_BC_STRING_MAX :: 39
+ _SC_COLL_WEIGHTS_MAX :: 40
+ _SC_EXPR_NEST_MAX :: 42
+ _SC_LINE_MAX :: 43
+ _SC_RE_DUP_MAX :: 44
+ _SC_2_VERSION :: 46
+ _SC_2_C_BIND :: 47
+ _SC_2_C_DEV :: 48
+ _SC_2_FORT_DEV :: 49
+ _SC_2_FORT_RUN :: 50
+ _SC_2_SW_DEV :: 51
+ _SC_2_LOCALEDEF :: 52
+ _SC_UIO_MAXIOV :: 60
+ _SC_IOV_MAX :: _SC_UIO_MAXIOV
+ _SC_THREADS :: 67
+ _SC_THREAD_SAFE_FUNCTIONS :: 68
+ _SC_GETGR_R_SIZE_MAX :: 69
+ _SC_GETPW_R_SIZE_MAX :: 70
+ _SC_LOGIN_NAME_MAX :: 71
+ _SC_TTY_NAME_MAX :: 72
+ _SC_THREAD_DESTRUCTOR_ITERATIONS :: 73
+ _SC_THREAD_KEYS_MAX :: 74
+ _SC_THREAD_STACK_MIN :: 75
+ _SC_THREAD_THREADS_MAX :: 76
+ _SC_THREAD_ATTR_STACKADDR :: 77
+ _SC_THREAD_ATTR_STACKSIZE :: 78
+ _SC_THREAD_PRIORITY_SCHEDULING :: 79
+ _SC_THREAD_PRIO_INHERIT :: 80
+ _SC_THREAD_PRIO_PROTECT :: 81
+ _SC_THREAD_PROCESS_SHARED :: 82
+ _SC_NPROCESSORS_CONF :: 83
+ _SC_NPROCESSORS_ONLN :: 84
+ _SC_PHYS_PAGES :: 85
+ _SC_AVPHYS_PAGES :: 86
+ _SC_ATEXIT_MAX :: 87
+ _SC_PASS_MAX :: 88
+ _SC_XOPEN_VERSION :: 89
+ _SC_XOPEN_XCU_VERSION :: 90
+ _SC_XOPEN_UNIX :: 91
+ _SC_XOPEN_CRYPT :: 92
+ _SC_XOPEN_ENH_I18N :: 93
+ _SC_XOPEN_SHM :: 94
+ _SC_2_CHAR_TERM :: 95
_SC_2_UPE :: 97
-
- _SC_XOPEN_LEGACY :: 129
- _SC_XOPEN_REALTIME :: 130
- _SC_XOPEN_REALTIME_THREADS :: 131
- _SC_ADVISORY_INFO :: 132
- _SC_BARRIERS :: 133
- _SC_CLOCK_SELECTION :: 137
- _SC_CPUTIME :: 138
- _SC_THREAD_CPUTIME :: 139
- _SC_MONOTONIC_CLOCK :: 149
- _SC_READER_WRITER_LOCKS :: 153
- _SC_SPIN_LOCKS :: 154
- _SC_REGEXP :: 155
- _SC_SHELL :: 157
- _SC_SPAWN :: 159
- _SC_SPORADIC_SERVER :: 160
- _SC_THREAD_SPORADIC_SERVER :: 161
- _SC_TIMEOUTS :: 164
- _SC_TYPED_MEMORY_OBJECTS :: 165
- _SC_2_PBS :: 168
- _SC_2_PBS_ACCOUNTING :: 169
- _SC_2_PBS_LOCATE :: 170
- _SC_2_PBS_MESSAGE :: 171
- _SC_2_PBS_TRACK :: 172
- _SC_SYMLOOP_MAX :: 173
- _SC_2_PBS_CHECKPOINT :: 174
- _SC_V6_ILP32_OFF32 :: 175
- _SC_V6_ILP32_OFFBIG :: 176
- _SC_V6_LP64_OFF64 :: 177
- _SC_V6_LPBIG_OFFBIG :: 178
- _SC_HOST_NAME_MAX :: 179
- _SC_TRACE :: 180
- _SC_TRACE_EVENT_FILTER :: 181
- _SC_TRACE_INHERIT :: 182
- _SC_TRACE_LOG :: 183
-
- _SC_IPV6 :: 234
- _SC_RAW_SOCKETS :: 235
- _SC_V7_ILP32_OFF32 :: 236
- _SC_V7_ILP32_OFFBIG :: 237
- _SC_V7_LP64_OFF64 :: 238
- _SC_V7_LPBIG_OFFBIG :: 239
- _SC_SS_REPL_MAX :: 240
- _SC_TRACE_EVENT_NAME_MAX :: 241
- _SC_TRACE_NAME_MAX :: 242
- _SC_TRACE_SYS_MAX :: 243
- _SC_TRACE_USER_EVENT_MAX :: 244
- _SC_XOPEN_STREAMS :: 245
- _SC_THREAD_ROBUST_PRIO_INHERIT :: 246
- _SC_THREAD_ROBUST_PRIO_PROTECT :: 247
+ _SC_XOPEN_XPG2 :: 98
+ _SC_XOPEN_XPG3 :: 99
+ _SC_XOPEN_XPG4 :: 100
+ _SC_NZERO :: 109
+ _SC_XBS5_ILP32_OFF32 :: 125
+ _SC_XBS5_ILP32_OFFBIG :: 126
+ _SC_XBS5_LP64_OFF64 :: 127
+ _SC_XBS5_LPBIG_OFFBIG :: 128
+ _SC_XOPEN_LEGACY :: 129
+ _SC_XOPEN_REALTIME :: 130
+ _SC_XOPEN_REALTIME_THREADS :: 131
+ _SC_ADVISORY_INFO :: 132
+ _SC_BARRIERS :: 133
+ _SC_CLOCK_SELECTION :: 137
+ _SC_CPUTIME :: 138
+ _SC_THREAD_CPUTIME :: 139
+ _SC_MONOTONIC_CLOCK :: 149
+ _SC_READER_WRITER_LOCKS :: 153
+ _SC_SPIN_LOCKS :: 154
+ _SC_REGEXP :: 155
+ _SC_SHELL :: 157
+ _SC_SPAWN :: 159
+ _SC_SPORADIC_SERVER :: 160
+ _SC_THREAD_SPORADIC_SERVER :: 161
+ _SC_TIMEOUTS :: 164
+ _SC_TYPED_MEMORY_OBJECTS :: 165
+ _SC_2_PBS :: 168
+ _SC_2_PBS_ACCOUNTING :: 169
+ _SC_2_PBS_LOCATE :: 170
+ _SC_2_PBS_MESSAGE :: 171
+ _SC_2_PBS_TRACK :: 172
+ _SC_SYMLOOP_MAX :: 173
+ _SC_STREAMS :: 174
+ _SC_2_PBS_CHECKPOINT :: 175
+ _SC_V6_ILP32_OFF32 :: 176
+ _SC_V6_ILP32_OFFBIG :: 177
+ _SC_V6_LP64_OFF64 :: 178
+ _SC_V6_LPBIG_OFFBIG :: 179
+ _SC_HOST_NAME_MAX :: 180
+ _SC_TRACE :: 181
+ _SC_TRACE_EVENT_FILTER :: 182
+ _SC_TRACE_INHERIT :: 183
+ _SC_TRACE_LOG :: 184
+
+ _SC_IPV6 :: 235
+ _SC_RAW_SOCKETS :: 236
+ _SC_V7_ILP32_OFF32 :: 237
+ _SC_V7_ILP32_OFFBIG :: 238
+ _SC_V7_LP64_OFF64 :: 239
+ _SC_V7_LPBIG_OFFBIG :: 240
+ _SC_SS_REPL_MAX :: 241
+ _SC_TRACE_EVENT_NAME_MAX :: 242
+ _SC_TRACE_NAME_MAX :: 243
+ _SC_TRACE_SYS_MAX :: 244
+ _SC_TRACE_USER_EVENT_MAX :: 245
+ _SC_XOPEN_STREAMS :: 246
+ _SC_THREAD_ROBUST_PRIO_INHERIT :: 247
+ _SC_THREAD_ROBUST_PRIO_PROTECT :: 248
+ _SC_MINSIGSTKSZ :: 249
+ _SC_SIGSTKSZ :: 250
// NOTE: Not implemented.
_SC_XOPEN_UUCP :: 0
// NOTE: Not implemented.
_POSIX_VDISABLE :: 0
+} else when ODIN_OS == .Haiku {
+
+ _F_OK :: 0
+ X_OK :: 1
+ W_OK :: 2
+ R_OK :: 4
+
+ F_LOCK :: 1
+ F_TEST :: 3
+ F_TLOCK :: 2
+ F_ULOCK :: 0
+
+ _CS_PATH :: 1
+ _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS :: 0 // Undefined.
+ _CS_POSIX_V6_ILP32_OFF32_CFLAGS :: 0 // Undefined.
+ _CS_POSIX_V6_ILP32_OFF32_LDFLAGS :: 0 // Undefined.
+ _CS_POSIX_V6_ILP32_OFF32_LIBS :: 0 // Undefined.
+ _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS :: 0 // Undefined.
+ _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS :: 0 // Undefined.
+ _CS_POSIX_V6_ILP32_OFFBIG_LIBS :: 0 // Undefined.
+ _CS_POSIX_V6_LP64_OFF64_CFLAGS :: 0 // Undefined.
+ _CS_POSIX_V6_LP64_OFF64_LDFLAGS :: 0 // Undefined.
+ _CS_POSIX_V6_LP64_OFF64_LIBS :: 0 // Undefined.
+ _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS :: 0 // Undefined.
+ _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS :: 0 // Undefined.
+ _CS_POSIX_V6_LPBIG_OFFBIG_LIBS :: 0 // Undefined.
+
+ _SC_ASYNCHRONOUS_IO :: 0 // Undefined.
+ _SC_RAW_SOCKETS :: 0 // Undefined.
+ _SC_SS_REPL_MAX :: 0 // Undefined.
+ _SC_TRACE_EVENT_NAME_MAX :: 0 // Undefined.
+ _SC_TRACE_NAME_MAX :: 0 // Undefined.
+ _SC_TRACE_SYS_MAX :: 0 // Undefined.
+ _SC_TRACE_USER_EVENT_MAX :: 0 // Undefined.
+
+ _PC_CHOWN_RESTRICTED :: 1
+ _PC_MAX_CANON :: 2
+ _PC_MAX_INPUT :: 3
+ _PC_NAME_MAX :: 4
+ _PC_NO_TRUNC :: 5
+ _PC_PATH_MAX :: 6
+ _PC_PIPE_BUF :: 7
+ _PC_VDISABLE :: 8
+ _PC_LINK_MAX :: 25
+ _PC_SYNC_IO :: 26
+ _PC_ASYNC_IO :: 27
+ _PC_PRIO_IO :: 28
+ _PC_FILESIZEBITS :: 30
+ _PC_REC_INCR_XFER_SIZE :: 31
+ _PC_REC_MAX_XFER_SIZE :: 32
+ _PC_REC_MIN_XFER_SIZE :: 33
+ _PC_REC_XFER_ALIGN :: 34
+ _PC_ALLOC_SIZE_MIN :: 35
+ _PC_SYMLINK_MAX :: 36
+ _PC_2_SYMLINKS :: 37
+
+ _SC_ARG_MAX :: 15
+ _SC_CHILD_MAX :: 16
+ _SC_CLK_TCK :: 17
+ _SC_JOB_CONTROL :: 18
+ _SC_NGROUPS_MAX :: 19
+ _SC_OPEN_MAX :: 20
+ _SC_SAVED_IDS :: 21
+ _SC_STREAM_MAX :: 22
+ _SC_TZNAME_MAX :: 23
+ _SC_VERSION :: 24
+ _SC_GETGR_R_SIZE_MAX :: 25
+ _SC_GETPW_R_SIZE_MAX :: 26
+ _SC_PAGE_SIZE :: 27
+ _SC_PAGESIZE :: _SC_PAGE_SIZE
+ _SC_SEM_NSEMS_MAX :: 28
+ _SC_SEM_VALUE_MAX :: 29
+ _SC_SEMAPHORES :: 30
+ _SC_THREADS :: 31
+ _SC_IOV_MAX :: 32
+ _SC_NPROCESSORS_CONF :: 34
+ _SC_NPROCESSORS_ONLN :: 35
+ _SC_ATEXIT_MAX :: 37
+ _SC_MAPPED_FILES :: 45
+ _SC_THREAD_PROCESS_SHARED :: 46
+ _SC_THREAD_STACK_MIN :: 47
+ _SC_THREAD_ATTR_STACKADDR :: 48
+ _SC_THREAD_ATTR_STACKSIZE :: 49
+ _SC_THREAD_PRIORITY_SCHEDULING :: 50
+ _SC_REALTIME_SIGNALS :: 51
+ _SC_MEMORY_PROTECTION :: 52
+ _SC_SIGQUEUE_MAX :: 53
+ _SC_RTSIG_MAX :: 54
+ _SC_MONOTONIC_CLOCK :: 55
+ _SC_DELAYTIMER_MAX :: 56
+ _SC_TIMER_MAX :: 57
+ _SC_TIMERS :: 58
+ _SC_CPUTIME :: 59
+ _SC_THREAD_CPUTIME :: 60
+ _SC_HOST_NAME_MAX :: 61
+ _SC_REGEXP :: 62
+ _SC_SYMLOOP_MAX :: 63
+ _SC_SHELL :: 64
+ _SC_TTY_NAME_MAX :: 65
+ _SC_ADVISORY_INFO :: 66
+ _SC_BARRIERS :: 67
+ _SC_CLOCK_SELECTION :: 68
+ _SC_FSYNC :: 69
+ _SC_IPV6 :: 70
+ _SC_MEMLOCK :: 71
+ _SC_MEMLOCK_RANGE :: 72
+ _SC_MESSAGE_PASSING :: 73
+ _SC_PRIORITIZED_IO :: 74
+ _SC_PRIORITY_SCHEDULING :: 75
+ _SC_READER_WRITER_LOCKS :: 76
+ _SC_SHARED_MEMORY_OBJECTS :: 77
+ _SC_SPAWN :: 78
+ _SC_SPIN_LOCKS :: 79
+ _SC_SPORADIC_SERVER :: 80
+ _SC_SYNCHRONIZED_IO :: 81
+ _SC_THREAD_PRIO_INHERIT :: 82
+ _SC_THREAD_PRIO_PROTECT :: 83
+ _SC_THREAD_SAFE_FUNCTIONS :: 86
+ _SC_THREAD_SPORADIC_SERVER :: 87
+ _SC_TIMEOUTS :: 88
+ _SC_TRACE :: 89
+ _SC_TRACE_EVENT_FILTER :: 90
+ _SC_TRACE_INHERIT :: 91
+ _SC_TRACE_LOG :: 92
+ _SC_TYPED_MEMORY_OBJECTS :: 93
+ _SC_V6_ILP32_OFF32 :: 94
+ _SC_V6_ILP32_OFFBIG :: 95
+ _SC_V6_LP64_OFF64 :: 96
+ _SC_V6_LPBIG_OFFBIG :: 97
+ _SC_2_C_BIND :: 102
+ _SC_2_C_DEV :: 103
+ _SC_2_CHAR_TERM :: 104
+ _SC_2_FORT_DEV :: 105
+ _SC_2_FORT_RUN :: 106
+ _SC_2_LOCALEDEF :: 107
+ _SC_2_PBS :: 108
+ _SC_2_PBS_ACCOUNTING :: 109
+ _SC_2_PBS_CHECKPOINT :: 110
+ _SC_2_PBS_LOCATE :: 111
+ _SC_2_PBS_MESSAGE :: 112
+ _SC_2_PBS_TRACK :: 113
+ _SC_2_SW_DEV :: 114
+ _SC_2_UPE :: 115
+ _SC_2_VERSION :: 116
+ _SC_XOPEN_CRYPT :: 117
+ _SC_XOPEN_ENH_I18N :: 118
+ _SC_XOPEN_REALTIME :: 119
+ _SC_XOPEN_REALTIME_THREADS :: 120
+ _SC_XOPEN_SHM :: 121
+ _SC_XOPEN_STREAMS :: 122
+ _SC_XOPEN_UNIX :: 123
+ _SC_XOPEN_VERSION :: 125
+ _SC_AIO_LISTIO_MAX :: 126
+ _SC_AIO_MAX :: 127
+ _SC_AIO_PRIO_DELTA_MAX :: 128
+ _SC_BC_BASE_MAX :: 129
+ _SC_BC_DIM_MAX :: 130
+ _SC_BC_SCALE_MAX :: 131
+ _SC_BC_STRING_MAX :: 132
+ _SC_COLL_WEIGHTS_MAX :: 133
+ _SC_EXPR_NEST_MAX :: 134
+ _SC_LINE_MAX :: 135
+ _SC_LOGIN_NAME_MAX :: 136
+ _SC_MQ_OPEN_MAX :: 137
+ _SC_MQ_PRIO_MAX :: 138
+ _SC_THREAD_DESTRUCTOR_ITERATIONS :: 139
+ _SC_THREAD_KEYS_MAX :: 140
+ _SC_THREAD_THREADS_MAX :: 141
+ _SC_RE_DUP_MAX :: 142
+
}
diff --git a/core/sys/posix/unistd_libc.odin b/core/sys/posix/unistd_libc.odin
index bbfe3d59d..74edb6862 100644
--- a/core/sys/posix/unistd_libc.odin
+++ b/core/sys/posix/unistd_libc.odin
@@ -1,4 +1,4 @@
-#+build linux, windows, darwin, netbsd, openbsd, freebsd
+#+build linux, windows, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "core:c"
diff --git a/core/sys/posix/utime.odin b/core/sys/posix/utime.odin
index e884eb1a3..98c8166d6 100644
--- a/core/sys/posix/utime.odin
+++ b/core/sys/posix/utime.odin
@@ -1,4 +1,4 @@
-#+build linux, darwin, netbsd, openbsd, freebsd
+#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
when ODIN_OS == .Darwin {
@@ -25,7 +25,7 @@ when ODIN_OS == .NetBSD {
@(private) LUTIME :: "utime"
}
-when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
+when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux || ODIN_OS == .Haiku {
utimbuf :: struct {
actime: time_t, /* [PSX] access time (seconds since epoch) */