fix haiku

This commit is contained in:
avanspector
2024-12-20 17:19:04 +01:00
parent 597fba7c31
commit 5376d2a20b
19 changed files with 840 additions and 225 deletions
+88 -1
View File
@@ -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)
}
+68 -1
View File
@@ -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
+2 -2
View File
@@ -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
+51 -1
View File
@@ -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
+8 -1
View File
@@ -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
}
+158 -1
View File
@@ -1,4 +1,4 @@
#+build linux, darwin, netbsd, openbsd, freebsd
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "base:intrinsics"
@@ -185,6 +185,16 @@ foreign lib {
*/
sigwait :: proc(set: ^sigset_t, sig: ^Signal) -> Errno ---
when ODIN_OS != .Darwin {
/*
Wait for queued signals.
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigtimedwait.html ]]
*/
sigtimedwait :: proc(set: ^sigset_t, info: ^siginfo_t, timeout: ^timespec) -> result ---
}
/* NOTE: unimplemented on darwin.
void psiginfo(const siginfo_t *, const char *);
@@ -1180,4 +1190,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 */
}
+1 -1
View File
@@ -1,4 +1,4 @@
#+build linux, windows, darwin, netbsd, openbsd, freebsd
#+build linux, windows, darwin, netbsd, openbsd, freebsd, haiku
package posix
import "base:intrinsics"
+31 -1
View File
@@ -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
+12 -1
View File
@@ -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