mirror of
https://github.com/odin-lang/Odin.git
synced 2026-05-26 05:38:14 +00:00
Merge pull request #6631 from heavyrain266/deprecate-haiku
removed Haiku from supported targets
This commit is contained in:
@@ -512,7 +512,6 @@ Raw_Quaternion256_Vector_Scalar :: struct {vector: [3]f64, scalar: f64}
|
||||
FreeBSD,
|
||||
OpenBSD,
|
||||
NetBSD,
|
||||
Haiku,
|
||||
WASI,
|
||||
JS,
|
||||
Orca,
|
||||
@@ -579,7 +578,6 @@ ALL_ODIN_OS_TYPES :: Odin_OS_Types{
|
||||
.FreeBSD,
|
||||
.OpenBSD,
|
||||
.NetBSD,
|
||||
.Haiku,
|
||||
.WASI,
|
||||
.JS,
|
||||
.Orca,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#+private
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
#+no-instrumentation
|
||||
package runtime
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
#+private
|
||||
package runtime
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
#+build haiku
|
||||
#+private
|
||||
package runtime
|
||||
|
||||
foreign import libc "system:c"
|
||||
|
||||
_HAS_RAND_BYTES :: true
|
||||
|
||||
foreign libc {
|
||||
@(link_name="write")
|
||||
_unix_write :: proc(fd: i32, buf: rawptr, size: int) -> int ---
|
||||
|
||||
_errnop :: proc() -> ^i32 ---
|
||||
|
||||
arc4random_buf :: proc(buf: [^]byte, nbytes: uint) ---
|
||||
}
|
||||
|
||||
_stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
|
||||
ret := _unix_write(2, raw_data(data), len(data))
|
||||
if ret < len(data) {
|
||||
err := _errnop()
|
||||
return int(ret), _OS_Errno(err^ if err != nil else 0)
|
||||
}
|
||||
return int(ret), 0
|
||||
}
|
||||
|
||||
_rand_bytes :: proc "contextless" (dst: []byte) {
|
||||
arc4random_buf(raw_data(dst), len(dst))
|
||||
}
|
||||
|
||||
_exit :: proc "contextless" (code: int) -> ! {
|
||||
trap()
|
||||
}
|
||||
@@ -117,11 +117,6 @@ OpenBSD)
|
||||
LDFLAGS="$LDFLAGS -lstdc++ -L/usr/local/lib -liconv"
|
||||
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs)"
|
||||
;;
|
||||
Haiku)
|
||||
CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE $($LLVM_CONFIG --cxxflags --ldflags) -I/system/develop/headers/private/shared -I/system/develop/headers/private/kernel"
|
||||
LDFLAGS="$LDFLAGS -lstdc++ -liconv"
|
||||
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs)"
|
||||
;;
|
||||
*)
|
||||
error "Platform \"$OS_NAME\" unsupported"
|
||||
;;
|
||||
|
||||
@@ -51,8 +51,6 @@ if "%1" == "freestanding" (
|
||||
if "%1" == "rare" (
|
||||
echo Checking freebsd_i386
|
||||
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_i386
|
||||
echo Checking haiku_amd64
|
||||
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:haiku_amd64
|
||||
)
|
||||
|
||||
if "%1" == "wasm" (
|
||||
|
||||
@@ -21,8 +21,6 @@ freestanding)
|
||||
rare)
|
||||
echo Checking freebsd_i386
|
||||
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_i386
|
||||
echo Checking haiku_amd64
|
||||
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:haiku_amd64
|
||||
;;
|
||||
|
||||
wasm)
|
||||
|
||||
@@ -80,25 +80,6 @@ when ODIN_OS == .Darwin {
|
||||
ERANGE :: 34
|
||||
}
|
||||
|
||||
when ODIN_OS == .Haiku {
|
||||
@(private="file")
|
||||
@(default_calling_convention="c")
|
||||
foreign libc {
|
||||
@(link_name="_errnop")
|
||||
_get_errno :: proc() -> ^int ---
|
||||
}
|
||||
|
||||
_HAIKU_USE_POSITIVE_POSIX_ERRORS :: #config(HAIKU_USE_POSITIVE_POSIX_ERRORS, false)
|
||||
_POSIX_ERROR_FACTOR :: -1 when _HAIKU_USE_POSITIVE_POSIX_ERRORS else 1
|
||||
|
||||
@(private="file") _GENERAL_ERROR_BASE :: min(int)
|
||||
@(private="file") _POSIX_ERROR_BASE :: _GENERAL_ERROR_BASE + 0x7000
|
||||
|
||||
EDOM :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 16)
|
||||
EILSEQ :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 38)
|
||||
ERANGE :: _POSIX_ERROR_FACTOR * (_POSIX_ERROR_BASE + 17)
|
||||
}
|
||||
|
||||
when ODIN_OS == .JS {
|
||||
_ :: libc
|
||||
_get_errno :: proc "c" () -> ^int {
|
||||
|
||||
@@ -110,7 +110,7 @@ when ODIN_OS == .Windows {
|
||||
}
|
||||
}
|
||||
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Haiku || ODIN_OS == .Windows {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Windows {
|
||||
|
||||
LC_ALL :: 0
|
||||
LC_COLLATE :: 1
|
||||
|
||||
@@ -34,7 +34,7 @@ when ODIN_OS == .Windows {
|
||||
SIGTERM :: 15
|
||||
}
|
||||
|
||||
when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .Haiku || ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD || ODIN_OS == .Darwin {
|
||||
when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD || ODIN_OS == .Darwin {
|
||||
SIG_ERR :: rawptr(~uintptr(0))
|
||||
SIG_DFL :: rawptr(uintptr(0))
|
||||
SIG_IGN :: rawptr(uintptr(1))
|
||||
|
||||
@@ -200,36 +200,6 @@ when ODIN_OS == .Darwin {
|
||||
}
|
||||
}
|
||||
|
||||
when ODIN_OS == .Haiku {
|
||||
fpos_t :: distinct i64
|
||||
|
||||
_IOFBF :: 0
|
||||
_IOLBF :: 1
|
||||
_IONBF :: 2
|
||||
|
||||
BUFSIZ :: 8192
|
||||
|
||||
EOF :: int(-1)
|
||||
|
||||
FOPEN_MAX :: 128
|
||||
|
||||
FILENAME_MAX :: 256
|
||||
|
||||
L_tmpnam :: 512
|
||||
|
||||
SEEK_SET :: 0
|
||||
SEEK_CUR :: 1
|
||||
SEEK_END :: 2
|
||||
|
||||
TMP_MAX :: 32768
|
||||
|
||||
foreign libc {
|
||||
stderr: ^FILE
|
||||
stdin: ^FILE
|
||||
stdout: ^FILE
|
||||
}
|
||||
}
|
||||
|
||||
when ODIN_OS == .NetBSD {
|
||||
@(private) LRENAME :: "__posix_rename"
|
||||
@(private) LFGETPOS :: "__fgetpos50"
|
||||
|
||||
@@ -42,22 +42,6 @@ when ODIN_OS == .Linux {
|
||||
}
|
||||
}
|
||||
|
||||
when ODIN_OS == .Haiku {
|
||||
RAND_MAX :: 0x7fffffff
|
||||
|
||||
// GLIBC and MUSL only
|
||||
@(private="file")
|
||||
@(default_calling_convention="c")
|
||||
foreign libc {
|
||||
__ctype_get_mb_cur_max :: proc() -> ushort ---
|
||||
}
|
||||
|
||||
MB_CUR_MAX :: #force_inline proc() -> size_t {
|
||||
return size_t(__ctype_get_mb_cur_max())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .OpenBSD {
|
||||
RAND_MAX :: 0x7fffffff
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ when ODIN_OS == .Windows {
|
||||
}
|
||||
}
|
||||
|
||||
when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .Darwin || ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD || ODIN_OS == .Haiku || ODIN_OS == .JS {
|
||||
when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .Darwin || ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD || ODIN_OS == .JS {
|
||||
@(default_calling_convention="c")
|
||||
foreign libc {
|
||||
// 7.27.2 Time manipulation functions
|
||||
@@ -95,7 +95,7 @@ when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .Darwin || ODIN_OS =
|
||||
|
||||
time_t :: distinct i64
|
||||
|
||||
when ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .Haiku {
|
||||
when ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD {
|
||||
clock_t :: distinct int32_t
|
||||
} else {
|
||||
clock_t :: distinct long
|
||||
|
||||
@@ -30,10 +30,6 @@ when ODIN_OS == .Windows {
|
||||
wctrans_t :: distinct int
|
||||
wctype_t :: distinct ulong
|
||||
|
||||
} else when ODIN_OS == .Haiku {
|
||||
wctrans_t :: distinct i32
|
||||
wctype_t :: distinct i32
|
||||
|
||||
}
|
||||
|
||||
@(default_calling_convention="c")
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#+build haiku
|
||||
#+private
|
||||
package dynlib
|
||||
|
||||
import "base:runtime"
|
||||
|
||||
_LIBRARY_FILE_EXTENSION :: ""
|
||||
|
||||
_load_library :: proc(path: string, global_symbols: bool, allocator: runtime.Allocator) -> (Library, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
_unload_library :: proc(library: Library) -> bool {
|
||||
return false
|
||||
}
|
||||
|
||||
_symbol_address :: proc(library: Library, symbol: string, allocator: runtime.Allocator) -> (ptr: rawptr, found: bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
_last_error :: proc() -> string {
|
||||
return ""
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build darwin, linux, netbsd, freebsd, openbsd, haiku
|
||||
#+build darwin, linux, netbsd, freebsd, openbsd
|
||||
package os_old
|
||||
|
||||
import "core:strings"
|
||||
|
||||
@@ -1,544 +0,0 @@
|
||||
package os_old
|
||||
|
||||
foreign import lib "system:c"
|
||||
|
||||
import "base:runtime"
|
||||
import "core:c"
|
||||
import "core:c/libc"
|
||||
import "core:strings"
|
||||
import "core:sys/haiku"
|
||||
import "core:sys/posix"
|
||||
|
||||
Handle :: i32
|
||||
Pid :: i32
|
||||
File_Time :: i64
|
||||
_Platform_Error :: haiku.Errno
|
||||
|
||||
MAX_PATH :: haiku.PATH_MAX
|
||||
|
||||
ENOSYS :: _Platform_Error(haiku.Errno.ENOSYS)
|
||||
|
||||
INVALID_HANDLE :: ~Handle(0)
|
||||
|
||||
stdin: Handle = 0
|
||||
stdout: Handle = 1
|
||||
stderr: Handle = 2
|
||||
|
||||
pid_t :: haiku.pid_t
|
||||
off_t :: haiku.off_t
|
||||
dev_t :: haiku.dev_t
|
||||
ino_t :: haiku.ino_t
|
||||
mode_t :: haiku.mode_t
|
||||
nlink_t :: haiku.nlink_t
|
||||
uid_t :: haiku.uid_t
|
||||
gid_t :: haiku.gid_t
|
||||
blksize_t :: haiku.blksize_t
|
||||
blkcnt_t :: haiku.blkcnt_t
|
||||
time_t :: haiku.time_t
|
||||
|
||||
|
||||
Unix_File_Time :: struct {
|
||||
seconds: time_t,
|
||||
nanoseconds: c.long,
|
||||
}
|
||||
|
||||
OS_Stat :: struct {
|
||||
device_id: dev_t, // device ID that this file resides on
|
||||
serial: ino_t, // this file's serial inode ID
|
||||
mode: mode_t, // file mode (rwx for user, group, etc)
|
||||
nlink: nlink_t, // number of hard links to this file
|
||||
uid: uid_t, // user ID of the file's owner
|
||||
gid: gid_t, // group ID of the file's group
|
||||
size: off_t, // file size, in bytes
|
||||
rdev: dev_t, // device type (not used)
|
||||
block_size: blksize_t, // optimal blocksize for I/O
|
||||
|
||||
last_access: Unix_File_Time, // time of last access
|
||||
modified: Unix_File_Time, // time of last data modification
|
||||
status_change: Unix_File_Time, // time of last file status change
|
||||
birthtime: Unix_File_Time, // time of file creation
|
||||
|
||||
type: u32, // attribute/index type
|
||||
|
||||
blocks: blkcnt_t, // blocks allocated for file
|
||||
}
|
||||
|
||||
/* file access modes for open() */
|
||||
O_RDONLY :: 0x0000 /* read only */
|
||||
O_WRONLY :: 0x0001 /* write only */
|
||||
O_RDWR :: 0x0002 /* read and write */
|
||||
O_ACCMODE :: 0x0003 /* mask to get the access modes above */
|
||||
O_RWMASK :: O_ACCMODE
|
||||
|
||||
/* flags for open() */
|
||||
O_EXCL :: 0x0100 /* exclusive creat */
|
||||
O_CREATE :: 0x0200 /* create and open file */
|
||||
O_TRUNC :: 0x0400 /* open with truncation */
|
||||
O_NOCTTY :: 0x1000 /* don't make tty the controlling tty */
|
||||
O_NOTRAVERSE :: 0x2000 /* do not traverse leaf link */
|
||||
|
||||
// File type
|
||||
S_IFMT :: 0o170000 // Type of file mask
|
||||
S_IFIFO :: 0o010000 // Named pipe (fifo)
|
||||
S_IFCHR :: 0o020000 // Character special
|
||||
S_IFDIR :: 0o040000 // Directory
|
||||
S_IFBLK :: 0o060000 // Block special
|
||||
S_IFREG :: 0o100000 // Regular
|
||||
S_IFLNK :: 0o120000 // Symbolic link
|
||||
S_IFSOCK :: 0o140000 // Socket
|
||||
S_ISVTX :: 0o001000 // Save swapped text even after use
|
||||
|
||||
// File mode
|
||||
// Read, write, execute/search by owner
|
||||
S_IRWXU :: 0o0700 // RWX mask for owner
|
||||
S_IRUSR :: 0o0400 // R for owner
|
||||
S_IWUSR :: 0o0200 // W for owner
|
||||
S_IXUSR :: 0o0100 // X for owner
|
||||
|
||||
// Read, write, execute/search by group
|
||||
S_IRWXG :: 0o0070 // RWX mask for group
|
||||
S_IRGRP :: 0o0040 // R for group
|
||||
S_IWGRP :: 0o0020 // W for group
|
||||
S_IXGRP :: 0o0010 // X for group
|
||||
|
||||
// Read, write, execute/search by others
|
||||
S_IRWXO :: 0o0007 // RWX mask for other
|
||||
S_IROTH :: 0o0004 // R for other
|
||||
S_IWOTH :: 0o0002 // W for other
|
||||
S_IXOTH :: 0o0001 // X for other
|
||||
|
||||
S_ISUID :: 0o4000 // Set user id on execution
|
||||
S_ISGID :: 0o2000 // Set group id on execution
|
||||
S_ISTXT :: 0o1000 // Sticky bit
|
||||
|
||||
S_ISLNK :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFLNK }
|
||||
S_ISREG :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFREG }
|
||||
S_ISDIR :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFDIR }
|
||||
S_ISCHR :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFCHR }
|
||||
S_ISBLK :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFBLK }
|
||||
S_ISFIFO :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFIFO }
|
||||
S_ISSOCK :: #force_inline proc(m: u32) -> bool { return (m & S_IFMT) == S_IFSOCK }
|
||||
|
||||
__error :: libc.errno
|
||||
_unix_open :: posix.open
|
||||
|
||||
foreign lib {
|
||||
@(link_name="fork") _unix_fork :: proc() -> pid_t ---
|
||||
@(link_name="getthrid") _unix_getthrid :: proc() -> int ---
|
||||
|
||||
@(link_name="close") _unix_close :: proc(fd: Handle) -> c.int ---
|
||||
@(link_name="read") _unix_read :: proc(fd: Handle, buf: rawptr, size: c.size_t) -> c.ssize_t ---
|
||||
@(link_name="pread") _unix_pread :: proc(fd: Handle, buf: rawptr, size: c.size_t, offset: i64) -> c.ssize_t ---
|
||||
@(link_name="write") _unix_write :: proc(fd: Handle, buf: rawptr, size: c.size_t) -> c.ssize_t ---
|
||||
@(link_name="pwrite") _unix_pwrite :: proc(fd: Handle, buf: rawptr, size: c.size_t, offset: i64) -> c.ssize_t ---
|
||||
@(link_name="lseek") _unix_seek :: proc(fd: Handle, offset: off_t, whence: c.int) -> off_t ---
|
||||
@(link_name="stat") _unix_stat :: proc(path: cstring, sb: ^OS_Stat) -> c.int ---
|
||||
@(link_name="fstat") _unix_fstat :: proc(fd: Handle, sb: ^OS_Stat) -> c.int ---
|
||||
@(link_name="lstat") _unix_lstat :: proc(path: cstring, sb: ^OS_Stat) -> c.int ---
|
||||
@(link_name="readlink") _unix_readlink :: proc(path: cstring, buf: ^byte, bufsiz: c.size_t) -> c.ssize_t ---
|
||||
@(link_name="access") _unix_access :: proc(path: cstring, mask: c.int) -> c.int ---
|
||||
@(link_name="getcwd") _unix_getcwd :: proc(buf: cstring, len: c.size_t) -> cstring ---
|
||||
@(link_name="chdir") _unix_chdir :: proc(path: cstring) -> c.int ---
|
||||
@(link_name="rename") _unix_rename :: proc(old, new: cstring) -> c.int ---
|
||||
@(link_name="unlink") _unix_unlink :: proc(path: cstring) -> c.int ---
|
||||
@(link_name="rmdir") _unix_rmdir :: proc(path: cstring) -> c.int ---
|
||||
@(link_name="mkdir") _unix_mkdir :: proc(path: cstring, mode: mode_t) -> c.int ---
|
||||
@(link_name="fsync") _unix_fsync :: proc(fd: Handle) -> c.int ---
|
||||
|
||||
@(link_name="getpagesize") _unix_getpagesize :: proc() -> c.int ---
|
||||
@(link_name="sysconf") _sysconf :: proc(name: c.int) -> c.long ---
|
||||
@(link_name="fdopendir") _unix_fdopendir :: proc(fd: Handle) -> Dir ---
|
||||
@(link_name="closedir") _unix_closedir :: proc(dirp: Dir) -> c.int ---
|
||||
@(link_name="rewinddir") _unix_rewinddir :: proc(dirp: Dir) ---
|
||||
@(link_name="readdir_r") _unix_readdir_r :: proc(dirp: Dir, entry: ^Dirent, result: ^^Dirent) -> c.int ---
|
||||
@(link_name="dup") _unix_dup :: proc(fd: Handle) -> Handle ---
|
||||
|
||||
@(link_name="malloc") _unix_malloc :: proc(size: c.size_t) -> rawptr ---
|
||||
@(link_name="calloc") _unix_calloc :: proc(num, size: c.size_t) -> rawptr ---
|
||||
@(link_name="free") _unix_free :: proc(ptr: rawptr) ---
|
||||
@(link_name="realloc") _unix_realloc :: proc(ptr: rawptr, size: c.size_t) -> rawptr ---
|
||||
|
||||
@(link_name="getenv") _unix_getenv :: proc(cstring) -> cstring ---
|
||||
@(link_name="realpath") _unix_realpath :: proc(path: cstring, resolved_path: [^]byte = nil) -> cstring ---
|
||||
|
||||
@(link_name="exit") _unix_exit :: proc(status: c.int) -> ! ---
|
||||
|
||||
@(link_name="dlopen") _unix_dlopen :: proc(filename: cstring, flags: c.int) -> rawptr ---
|
||||
@(link_name="dlsym") _unix_dlsym :: proc(handle: rawptr, symbol: cstring) -> rawptr ---
|
||||
@(link_name="dlclose") _unix_dlclose :: proc(handle: rawptr) -> c.int ---
|
||||
@(link_name="dlerror") _unix_dlerror :: proc() -> cstring ---
|
||||
}
|
||||
|
||||
MAXNAMLEN :: haiku.NAME_MAX
|
||||
|
||||
Dirent :: struct {
|
||||
dev: dev_t,
|
||||
pdef: dev_t,
|
||||
ino: ino_t,
|
||||
pino: ino_t,
|
||||
reclen: u16,
|
||||
name: [MAXNAMLEN + 1]byte, // name
|
||||
}
|
||||
|
||||
Dir :: distinct rawptr // DIR*
|
||||
|
||||
@(require_results)
|
||||
is_path_separator :: proc(r: rune) -> bool {
|
||||
return r == '/'
|
||||
}
|
||||
|
||||
@(require_results, no_instrumentation)
|
||||
get_last_error :: proc "contextless" () -> Error {
|
||||
return Platform_Error(__error()^)
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
fork :: proc() -> (Pid, Error) {
|
||||
pid := _unix_fork()
|
||||
if pid == -1 {
|
||||
return Pid(-1), get_last_error()
|
||||
}
|
||||
return Pid(pid), nil
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Error) {
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||
cstr := strings.clone_to_cstring(path, context.temp_allocator)
|
||||
handle := cast(Handle)_unix_open(cstr, transmute(posix.O_Flags)i32(flags), transmute(posix.mode_t)i32(mode))
|
||||
if handle == -1 {
|
||||
return INVALID_HANDLE, get_last_error()
|
||||
}
|
||||
return handle, nil
|
||||
}
|
||||
|
||||
close :: proc(fd: Handle) -> Error {
|
||||
result := _unix_close(fd)
|
||||
if result == -1 {
|
||||
return get_last_error()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
flush :: proc(fd: Handle) -> Error {
|
||||
result := _unix_fsync(fd)
|
||||
if result == -1 {
|
||||
return get_last_error()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// In practice a read/write call would probably never read/write these big buffers all at once,
|
||||
// which is why the number of bytes is returned and why there are procs that will call this in a
|
||||
// loop for you.
|
||||
// We set a max of 1GB to keep alignment and to be safe.
|
||||
@(private)
|
||||
MAX_RW :: 1 << 30
|
||||
|
||||
read :: proc(fd: Handle, data: []byte) -> (int, Error) {
|
||||
to_read := min(c.size_t(len(data)), MAX_RW)
|
||||
bytes_read := _unix_read(fd, &data[0], to_read)
|
||||
if bytes_read == -1 {
|
||||
return -1, get_last_error()
|
||||
}
|
||||
return int(bytes_read), nil
|
||||
}
|
||||
|
||||
write :: proc(fd: Handle, data: []byte) -> (int, Error) {
|
||||
if len(data) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
to_write := min(c.size_t(len(data)), MAX_RW)
|
||||
bytes_written := _unix_write(fd, &data[0], to_write)
|
||||
if bytes_written == -1 {
|
||||
return -1, get_last_error()
|
||||
}
|
||||
return int(bytes_written), nil
|
||||
}
|
||||
|
||||
read_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Error) {
|
||||
if len(data) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
to_read := min(uint(len(data)), MAX_RW)
|
||||
|
||||
bytes_read := _unix_pread(fd, raw_data(data), to_read, offset)
|
||||
if bytes_read < 0 {
|
||||
return -1, get_last_error()
|
||||
}
|
||||
return bytes_read, nil
|
||||
}
|
||||
|
||||
write_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Error) {
|
||||
if len(data) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
to_write := min(uint(len(data)), MAX_RW)
|
||||
|
||||
bytes_written := _unix_pwrite(fd, raw_data(data), to_write, offset)
|
||||
if bytes_written < 0 {
|
||||
return -1, get_last_error()
|
||||
}
|
||||
return bytes_written, nil
|
||||
}
|
||||
|
||||
seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Error) {
|
||||
switch whence {
|
||||
case SEEK_SET, SEEK_CUR, SEEK_END:
|
||||
break
|
||||
case:
|
||||
return 0, .Invalid_Whence
|
||||
}
|
||||
res := _unix_seek(fd, offset, c.int(whence))
|
||||
if res == -1 {
|
||||
errno := get_last_error()
|
||||
switch errno {
|
||||
case .BAD_VALUE:
|
||||
return 0, .Invalid_Offset
|
||||
}
|
||||
return 0, errno
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
file_size :: proc(fd: Handle) -> (i64, Error) {
|
||||
s, err := _fstat(fd)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
return s.size, nil
|
||||
}
|
||||
|
||||
// "Argv" arguments converted to Odin strings
|
||||
args := _alloc_command_line_arguments()
|
||||
|
||||
@(private, require_results)
|
||||
_alloc_command_line_arguments :: proc "contextless" () -> []string {
|
||||
context = runtime.default_context()
|
||||
res := make([]string, len(runtime.args__))
|
||||
for arg, i in runtime.args__ {
|
||||
res[i] = string(arg)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@(private, fini)
|
||||
_delete_command_line_arguments :: proc "contextless" () {
|
||||
context = runtime.default_context()
|
||||
delete(args)
|
||||
}
|
||||
|
||||
@(private, require_results, no_sanitize_memory)
|
||||
_stat :: proc(path: string) -> (OS_Stat, Error) {
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||
cstr := strings.clone_to_cstring(path, context.temp_allocator)
|
||||
|
||||
// deliberately uninitialized
|
||||
s: OS_Stat = ---
|
||||
res := _unix_stat(cstr, &s)
|
||||
if res == -1 {
|
||||
return s, get_last_error()
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
@(private, require_results, no_sanitize_memory)
|
||||
_lstat :: proc(path: string) -> (OS_Stat, Error) {
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||
cstr := strings.clone_to_cstring(path, context.temp_allocator)
|
||||
|
||||
// deliberately uninitialized
|
||||
s: OS_Stat = ---
|
||||
res := _unix_lstat(cstr, &s)
|
||||
if res == -1 {
|
||||
return s, get_last_error()
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
@(private, require_results, no_sanitize_memory)
|
||||
_fstat :: proc(fd: Handle) -> (OS_Stat, Error) {
|
||||
// deliberately uninitialized
|
||||
s: OS_Stat = ---
|
||||
res := _unix_fstat(fd, &s)
|
||||
if res == -1 {
|
||||
return s, get_last_error()
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
@(private)
|
||||
_fdopendir :: proc(fd: Handle) -> (Dir, Error) {
|
||||
dirp := _unix_fdopendir(fd)
|
||||
if dirp == cast(Dir)nil {
|
||||
return nil, get_last_error()
|
||||
}
|
||||
return dirp, nil
|
||||
}
|
||||
|
||||
@(private)
|
||||
_closedir :: proc(dirp: Dir) -> Error {
|
||||
rc := _unix_closedir(dirp)
|
||||
if rc != 0 {
|
||||
return get_last_error()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@(private)
|
||||
_rewinddir :: proc(dirp: Dir) {
|
||||
_unix_rewinddir(dirp)
|
||||
}
|
||||
|
||||
@(private, require_results)
|
||||
_readdir :: proc(dirp: Dir) -> (entry: Dirent, err: Error, end_of_stream: bool) {
|
||||
result: ^Dirent
|
||||
rc := _unix_readdir_r(dirp, &entry, &result)
|
||||
|
||||
if rc != 0 {
|
||||
err = get_last_error()
|
||||
return
|
||||
}
|
||||
|
||||
if result == nil {
|
||||
end_of_stream = true
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@(private, require_results)
|
||||
_readlink :: proc(path: string) -> (string, Error) {
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator)
|
||||
path_cstr := strings.clone_to_cstring(path, context.temp_allocator)
|
||||
|
||||
bufsz : uint = MAX_PATH
|
||||
buf := make([]byte, MAX_PATH)
|
||||
for {
|
||||
rc := _unix_readlink(path_cstr, &(buf[0]), bufsz)
|
||||
if rc == -1 {
|
||||
delete(buf)
|
||||
return "", get_last_error()
|
||||
} else if rc == int(bufsz) {
|
||||
bufsz += MAX_PATH
|
||||
delete(buf)
|
||||
buf = make([]byte, bufsz)
|
||||
} else {
|
||||
return strings.string_from_ptr(&buf[0], rc), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
absolute_path_from_handle :: proc(fd: Handle) -> (string, Error) {
|
||||
return "", Error(ENOSYS)
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
absolute_path_from_relative :: proc(rel: string, allocator := context.allocator) -> (path: string, err: Error) {
|
||||
rel := rel
|
||||
if rel == "" {
|
||||
rel = "."
|
||||
}
|
||||
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator)
|
||||
rel_cstr := strings.clone_to_cstring(rel, context.temp_allocator)
|
||||
|
||||
path_ptr := _unix_realpath(rel_cstr, nil)
|
||||
if path_ptr == nil {
|
||||
return "", get_last_error()
|
||||
}
|
||||
defer _unix_free(rawptr(path_ptr))
|
||||
|
||||
path_cstr := cstring(path_ptr)
|
||||
return strings.clone(string(path_cstr), allocator)
|
||||
}
|
||||
|
||||
access :: proc(path: string, mask: int) -> (bool, Error) {
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||
cstr := strings.clone_to_cstring(path, context.temp_allocator)
|
||||
res := _unix_access(cstr, c.int(mask))
|
||||
if res == -1 {
|
||||
return false, get_last_error()
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
lookup_env_alloc :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) {
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator)
|
||||
path_str := strings.clone_to_cstring(key, context.temp_allocator)
|
||||
// NOTE(tetra): Lifetime of 'cstr' is unclear, but _unix_free(cstr) segfaults.
|
||||
cstr := _unix_getenv(path_str)
|
||||
if cstr == nil {
|
||||
return "", false
|
||||
}
|
||||
return strings.clone(string(cstr), allocator), true
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
lookup_env_buffer :: proc(buf: []u8, key: string) -> (value: string, err: Error) {
|
||||
if len(key) + 1 > len(buf) {
|
||||
return "", .Buffer_Full
|
||||
} else {
|
||||
copy(buf, key)
|
||||
buf[len(key)] = 0
|
||||
}
|
||||
|
||||
if value = string(_unix_getenv(cstring(raw_data(buf)))); value == "" {
|
||||
return "", .Env_Var_Not_Found
|
||||
} else {
|
||||
if len(value) > len(buf) {
|
||||
return "", .Buffer_Full
|
||||
} else {
|
||||
copy(buf, value)
|
||||
return string(buf[:len(value)]), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
lookup_env :: proc{lookup_env_alloc, lookup_env_buffer}
|
||||
|
||||
@(require_results)
|
||||
get_env_alloc :: proc(key: string, allocator := context.allocator) -> (value: string) {
|
||||
value, _ = lookup_env(key, allocator)
|
||||
return
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
get_env_buf :: proc(buf: []u8, key: string) -> (value: string) {
|
||||
value, _ = lookup_env(buf, key)
|
||||
return
|
||||
}
|
||||
get_env :: proc{get_env_alloc, get_env_buf}
|
||||
|
||||
|
||||
@(private, require_results)
|
||||
_processor_core_count :: proc() -> int {
|
||||
info: haiku.system_info
|
||||
haiku.get_system_info(&info)
|
||||
return int(info.cpu_count)
|
||||
}
|
||||
|
||||
exit :: proc "contextless" (code: int) -> ! {
|
||||
runtime._cleanup_runtime_contextless()
|
||||
_unix_exit(i32(code))
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
current_thread_id :: proc "contextless" () -> int {
|
||||
return int(haiku.find_thread(nil))
|
||||
}
|
||||
|
||||
@(private, require_results)
|
||||
_dup :: proc(fd: Handle) -> (Handle, Error) {
|
||||
dup := _unix_dup(fd)
|
||||
if dup == -1 {
|
||||
return INVALID_HANDLE, get_last_error()
|
||||
}
|
||||
return dup, nil
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
package os_old
|
||||
|
||||
import "core:time"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
package filepath
|
||||
|
||||
SEPARATOR :: '/'
|
||||
SEPARATOR_STRING :: `/`
|
||||
LIST_SEPARATOR :: ':'
|
||||
LIST_SEPARATOR :: ':'
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
#+private
|
||||
package sync
|
||||
|
||||
import "core:sys/haiku"
|
||||
import "core:sys/posix"
|
||||
import "core:time"
|
||||
|
||||
@(private="file")
|
||||
Wait_Node :: struct {
|
||||
thread: posix.pthread_t,
|
||||
futex: ^Futex,
|
||||
prev, next: ^Wait_Node,
|
||||
}
|
||||
@(private="file")
|
||||
atomic_flag :: distinct bool
|
||||
@(private="file")
|
||||
Wait_Queue :: struct {
|
||||
lock: atomic_flag,
|
||||
list: Wait_Node,
|
||||
}
|
||||
@(private="file")
|
||||
waitq_lock :: proc "contextless" (waitq: ^Wait_Queue) {
|
||||
for cast(bool)atomic_exchange_explicit(&waitq.lock, atomic_flag(true), .Acquire) {
|
||||
cpu_relax() // spin...
|
||||
}
|
||||
}
|
||||
@(private="file")
|
||||
waitq_unlock :: proc "contextless" (waitq: ^Wait_Queue) {
|
||||
atomic_store_explicit(&waitq.lock, atomic_flag(false), .Release)
|
||||
}
|
||||
|
||||
// FIXME: This approach may scale badly in the future,
|
||||
// possible solution - hash map (leads to deadlocks now).
|
||||
@(private="file")
|
||||
g_waitq: Wait_Queue
|
||||
|
||||
@(init, private="file")
|
||||
g_waitq_init :: proc() {
|
||||
g_waitq = {
|
||||
list = {
|
||||
prev = &g_waitq.list,
|
||||
next = &g_waitq.list,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@(private="file")
|
||||
get_waitq :: #force_inline proc "contextless" (f: ^Futex) -> ^Wait_Queue {
|
||||
_ = f
|
||||
return &g_waitq
|
||||
}
|
||||
|
||||
_futex_wait :: proc "contextless" (f: ^Futex, expect: u32) -> (ok: bool) {
|
||||
waitq := get_waitq(f)
|
||||
waitq_lock(waitq)
|
||||
defer waitq_unlock(waitq)
|
||||
|
||||
head := &waitq.list
|
||||
waiter := Wait_Node{
|
||||
thread = posix.pthread_self(),
|
||||
futex = f,
|
||||
prev = head,
|
||||
next = head.next,
|
||||
}
|
||||
|
||||
waiter.prev.next = &waiter
|
||||
waiter.next.prev = &waiter
|
||||
|
||||
old_mask, mask: posix.sigset_t
|
||||
posix.sigemptyset(&mask)
|
||||
posix.sigaddset(&mask, .SIGCONT)
|
||||
posix.pthread_sigmask(.BLOCK, &mask, &old_mask)
|
||||
|
||||
if u32(atomic_load_explicit(f, .Acquire)) == expect {
|
||||
waitq_unlock(waitq)
|
||||
defer waitq_lock(waitq)
|
||||
|
||||
sig: posix.Signal
|
||||
errno := posix.sigwait(&mask, &sig)
|
||||
ok = errno == nil
|
||||
}
|
||||
|
||||
waiter.prev.next = waiter.next
|
||||
waiter.next.prev = waiter.prev
|
||||
|
||||
_ = posix.pthread_sigmask(.SETMASK, &old_mask, nil)
|
||||
|
||||
// FIXME: Add error handling!
|
||||
return
|
||||
}
|
||||
|
||||
_futex_wait_with_timeout :: proc "contextless" (f: ^Futex, expect: u32, duration: time.Duration) -> (ok: bool) {
|
||||
if duration <= 0 {
|
||||
return false
|
||||
}
|
||||
waitq := get_waitq(f)
|
||||
waitq_lock(waitq)
|
||||
defer waitq_unlock(waitq)
|
||||
|
||||
head := &waitq.list
|
||||
waiter := Wait_Node{
|
||||
thread = posix.pthread_self(),
|
||||
futex = f,
|
||||
prev = head,
|
||||
next = head.next,
|
||||
}
|
||||
|
||||
waiter.prev.next = &waiter
|
||||
waiter.next.prev = &waiter
|
||||
|
||||
old_mask, mask: posix.sigset_t
|
||||
posix.sigemptyset(&mask)
|
||||
posix.sigaddset(&mask, .SIGCONT)
|
||||
posix.pthread_sigmask(.BLOCK, &mask, &old_mask)
|
||||
|
||||
if u32(atomic_load_explicit(f, .Acquire)) == expect {
|
||||
waitq_unlock(waitq)
|
||||
defer waitq_lock(waitq)
|
||||
|
||||
info: posix.siginfo_t
|
||||
ts := posix.timespec{
|
||||
tv_sec = posix.time_t(i64(duration / 1e9)),
|
||||
tv_nsec = i64(duration % 1e9),
|
||||
}
|
||||
haiku.sigtimedwait(&mask, &info, &ts)
|
||||
errno := posix.errno()
|
||||
ok = errno == .EAGAIN || errno == nil
|
||||
}
|
||||
|
||||
waiter.prev.next = waiter.next
|
||||
waiter.next.prev = waiter.prev
|
||||
|
||||
posix.pthread_sigmask(.SETMASK, &old_mask, nil)
|
||||
|
||||
// FIXME: Add error handling!
|
||||
return
|
||||
}
|
||||
|
||||
_futex_signal :: proc "contextless" (f: ^Futex) {
|
||||
waitq := get_waitq(f)
|
||||
waitq_lock(waitq)
|
||||
defer waitq_unlock(waitq)
|
||||
|
||||
head := &waitq.list
|
||||
for waiter := head.next; waiter != head; waiter = waiter.next {
|
||||
if waiter.futex == f {
|
||||
posix.pthread_kill(waiter.thread, .SIGCONT)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_futex_broadcast :: proc "contextless" (f: ^Futex) {
|
||||
waitq := get_waitq(f)
|
||||
waitq_lock(waitq)
|
||||
defer waitq_unlock(waitq)
|
||||
|
||||
head := &waitq.list
|
||||
for waiter := head.next; waiter != head; waiter = waiter.next {
|
||||
if waiter.futex == f {
|
||||
posix.pthread_kill(waiter.thread, .SIGCONT)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#+private
|
||||
package sync
|
||||
|
||||
import "core:sys/haiku"
|
||||
|
||||
_current_thread_id :: proc "contextless" () -> int {
|
||||
return int(haiku.find_thread(nil))
|
||||
}
|
||||
@@ -1,302 +0,0 @@
|
||||
#+build haiku
|
||||
package sys_haiku
|
||||
|
||||
import "core:sys/posix"
|
||||
|
||||
foreign import libroot "system:c"
|
||||
|
||||
USE_POSITIVE_POSIX_ERRORS :: posix._HAIKU_USE_POSITIVE_POSIX_ERRORS
|
||||
POSIX_ERROR_FACTOR :: posix._POSIX_ERROR_FACTOR
|
||||
|
||||
// Error baselines
|
||||
GENERAL_ERROR_BASE :: min(i32)
|
||||
OS_ERROR_BASE :: GENERAL_ERROR_BASE + 0x1000
|
||||
APP_ERROR_BASE :: GENERAL_ERROR_BASE + 0x2000
|
||||
INTERFACE_ERROR_BASE :: GENERAL_ERROR_BASE + 0x3000
|
||||
MEDIA_ERROR_BASE :: GENERAL_ERROR_BASE + 0x4000
|
||||
TRANSLATION_ERROR_BASE :: GENERAL_ERROR_BASE + 0x4800
|
||||
MIDI_ERROR_BASE :: GENERAL_ERROR_BASE + 0x5000
|
||||
STORAGE_ERROR_BASE :: GENERAL_ERROR_BASE + 0x6000
|
||||
POSIX_ERROR_BASE :: GENERAL_ERROR_BASE + 0x7000
|
||||
MAIL_ERROR_BASE :: GENERAL_ERROR_BASE + 0x8000
|
||||
PRINT_ERROR_BASE :: GENERAL_ERROR_BASE + 0x9000
|
||||
DEVICE_ERROR_BASE :: GENERAL_ERROR_BASE + 0xA000
|
||||
|
||||
// Developer-defined errors start at (ERRORS_END+1)
|
||||
ERRORS_END :: GENERAL_ERROR_BASE + 0xFFFF
|
||||
|
||||
Errno :: enum i32 {
|
||||
// General Errors
|
||||
NO_MEMORY = GENERAL_ERROR_BASE + 0,
|
||||
IO_ERROR = GENERAL_ERROR_BASE + 1,
|
||||
PERMISSION_DENIED = GENERAL_ERROR_BASE + 2,
|
||||
BAD_INDEX = GENERAL_ERROR_BASE + 3,
|
||||
BAD_TYPE = GENERAL_ERROR_BASE + 4,
|
||||
BAD_VALUE = GENERAL_ERROR_BASE + 5,
|
||||
MISMATCHED_VALUES = GENERAL_ERROR_BASE + 6,
|
||||
NAME_NOT_FOUND = GENERAL_ERROR_BASE + 7,
|
||||
NAME_IN_USE = GENERAL_ERROR_BASE + 8,
|
||||
TIMED_OUT = GENERAL_ERROR_BASE + 9,
|
||||
INTERRUPTED = GENERAL_ERROR_BASE + 10,
|
||||
WOULD_BLOCK = GENERAL_ERROR_BASE + 11,
|
||||
CANCELED = GENERAL_ERROR_BASE + 12,
|
||||
NO_INIT = GENERAL_ERROR_BASE + 13,
|
||||
NOT_INITIALIZED = GENERAL_ERROR_BASE + 13,
|
||||
BUSY = GENERAL_ERROR_BASE + 14,
|
||||
NOT_ALLOWED = GENERAL_ERROR_BASE + 15,
|
||||
BAD_DATA = GENERAL_ERROR_BASE + 16,
|
||||
DONT_DO_THAT = GENERAL_ERROR_BASE + 17,
|
||||
|
||||
ERROR = -1,
|
||||
OK = 0,
|
||||
NO_ERROR = 0,
|
||||
|
||||
// Kernel Kit Errors
|
||||
BAD_SEM_ID = OS_ERROR_BASE + 0,
|
||||
NO_MORE_SEMS = OS_ERROR_BASE + 1,
|
||||
BAD_THREAD_ID = OS_ERROR_BASE + 0x100,
|
||||
NO_MORE_THREADS = OS_ERROR_BASE + 0x101,
|
||||
BAD_THREAD_STATE = OS_ERROR_BASE + 0x102,
|
||||
BAD_TEAM_ID = OS_ERROR_BASE + 0x103,
|
||||
NO_MORE_TEAMS = OS_ERROR_BASE + 0x104,
|
||||
BAD_PORT_ID = OS_ERROR_BASE + 0x200,
|
||||
NO_MORE_PORTS = OS_ERROR_BASE + 0x201,
|
||||
BAD_IMAGE_ID = OS_ERROR_BASE + 0x300,
|
||||
BAD_ADDRESS = OS_ERROR_BASE + 0x301,
|
||||
NOT_AN_EXECUTABLE = OS_ERROR_BASE + 0x302,
|
||||
MISSING_LIBRARY = OS_ERROR_BASE + 0x303,
|
||||
MISSING_SYMBOL = OS_ERROR_BASE + 0x304,
|
||||
UNKNOWN_EXECUTABLE = OS_ERROR_BASE + 0x305,
|
||||
LEGACY_EXECUTABLE = OS_ERROR_BASE + 0x306,
|
||||
|
||||
DEBUGGER_ALREADY_INSTALLED = OS_ERROR_BASE + 0x400,
|
||||
|
||||
// Application Kit Errors
|
||||
BAD_REPLY = APP_ERROR_BASE + 0,
|
||||
DUPLICATE_REPLY = APP_ERROR_BASE + 1,
|
||||
MESSAGE_TO_SELF = APP_ERROR_BASE + 2,
|
||||
BAD_HANDLER = APP_ERROR_BASE + 3,
|
||||
ALREADY_RUNNING = APP_ERROR_BASE + 4,
|
||||
LAUNCH_FAILED = APP_ERROR_BASE + 5,
|
||||
AMBIGUOUS_APP_LAUNCH = APP_ERROR_BASE + 6,
|
||||
UNKNOWN_MIME_TYPE = APP_ERROR_BASE + 7,
|
||||
BAD_SCRIPT_SYNTAX = APP_ERROR_BASE + 8,
|
||||
LAUNCH_FAILED_NO_RESOLVE_LINK = APP_ERROR_BASE + 9,
|
||||
LAUNCH_FAILED_EXECUTABLE = APP_ERROR_BASE + 10,
|
||||
LAUNCH_FAILED_APP_NOT_FOUND = APP_ERROR_BASE + 11,
|
||||
LAUNCH_FAILED_APP_IN_TRASH = APP_ERROR_BASE + 12,
|
||||
LAUNCH_FAILED_NO_PREFERRED_APP = APP_ERROR_BASE + 13,
|
||||
LAUNCH_FAILED_FILES_APP_NOT_FOUND = APP_ERROR_BASE + 14,
|
||||
BAD_MIME_SNIFFER_RULE = APP_ERROR_BASE + 15,
|
||||
NOT_A_MESSAGE = APP_ERROR_BASE + 16,
|
||||
SHUTDOWN_CANCELLED = APP_ERROR_BASE + 17,
|
||||
SHUTTING_DOWN = APP_ERROR_BASE + 18,
|
||||
|
||||
// Storage Kit/File System Errors
|
||||
FILE_ERROR = STORAGE_ERROR_BASE + 0,
|
||||
// 1 was B_FILE_NOT_FOUND (deprecated)
|
||||
FILE_EXISTS = STORAGE_ERROR_BASE + 2,
|
||||
ENTRY_NOT_FOUND = STORAGE_ERROR_BASE + 3,
|
||||
NAME_TOO_LONG = STORAGE_ERROR_BASE + 4,
|
||||
NOT_A_DIRECTORY = STORAGE_ERROR_BASE + 5,
|
||||
DIRECTORY_NOT_EMPTY = STORAGE_ERROR_BASE + 6,
|
||||
DEVICE_FULL = STORAGE_ERROR_BASE + 7,
|
||||
READ_ONLY_DEVICE = STORAGE_ERROR_BASE + 8,
|
||||
IS_A_DIRECTORY = STORAGE_ERROR_BASE + 9,
|
||||
NO_MORE_FDS = STORAGE_ERROR_BASE + 10,
|
||||
CROSS_DEVICE_LINK = STORAGE_ERROR_BASE + 11,
|
||||
LINK_LIMIT = STORAGE_ERROR_BASE + 12,
|
||||
BUSTED_PIPE = STORAGE_ERROR_BASE + 13,
|
||||
UNSUPPORTED = STORAGE_ERROR_BASE + 14,
|
||||
PARTITION_TOO_SMALL = STORAGE_ERROR_BASE + 15,
|
||||
PARTIAL_READ = STORAGE_ERROR_BASE + 16,
|
||||
PARTIAL_WRITE = STORAGE_ERROR_BASE + 17,
|
||||
|
||||
EIO = posix.EIO,
|
||||
EACCES = posix.EACCES,
|
||||
EINVAL = posix.EINVAL,
|
||||
ETIMEDOUT = posix.ETIMEDOUT,
|
||||
EINTR = posix.EINTR,
|
||||
EAGAIN = posix.EAGAIN,
|
||||
EWOULDBLOCK = posix.EWOULDBLOCK,
|
||||
EBUSY = posix.EBUSY,
|
||||
EPERM = posix.EPERM,
|
||||
EFAULT = posix.EFAULT,
|
||||
ENOEXEC = posix.ENOEXEC,
|
||||
EBADF = posix.EBADF,
|
||||
EEXIST = posix.EEXIST,
|
||||
ENOENT = posix.ENOENT,
|
||||
ENAMETOOLONG = posix.ENAMETOOLONG,
|
||||
ENOTDIR = posix.ENOTDIR,
|
||||
ENOTEMPTY = posix.ENOTEMPTY,
|
||||
ENOSPC = posix.ENOSPC,
|
||||
EROFS = posix.EROFS,
|
||||
EISDIR = posix.EISDIR,
|
||||
EMFILE = posix.EMFILE,
|
||||
EXDEV = posix.EXDEV,
|
||||
ELOOP = posix.ELOOP,
|
||||
EPIPE = posix.EPIPE,
|
||||
ENOMEM = posix.ENOMEM,
|
||||
E2BIG = posix.E2BIG,
|
||||
ECHILD = posix.ECHILD,
|
||||
EDEADLK = posix.EDEADLK,
|
||||
EFBIG = posix.EFBIG,
|
||||
EMLINK = posix.EMLINK,
|
||||
ENFILE = posix.ENFILE,
|
||||
ENODEV = posix.ENODEV,
|
||||
ENOLCK = posix.ENOLCK,
|
||||
ENOSYS = posix.ENOSYS,
|
||||
ENOTTY = posix.ENOTTY,
|
||||
ENXIO = posix.ENXIO,
|
||||
ESPIPE = posix.ESPIPE,
|
||||
ESRCH = posix.ESRCH,
|
||||
EDOM = posix.EDOM,
|
||||
ERANGE = posix.ERANGE,
|
||||
EPROTOTYPE = posix.EPROTOTYPE,
|
||||
EPROTONOSUPPORT = posix.EPROTONOSUPPORT,
|
||||
EAFNOSUPPORT = posix.EAFNOSUPPORT,
|
||||
EADDRINUSE = posix.EADDRINUSE,
|
||||
EADDRNOTAVAIL = posix.EADDRNOTAVAIL,
|
||||
ENETDOWN = posix.ENETDOWN,
|
||||
ENETUNREACH = posix.ENETUNREACH,
|
||||
ENETRESET = posix.ENETRESET,
|
||||
ECONNABORTED = posix.ECONNABORTED,
|
||||
ECONNRESET = posix.ECONNRESET,
|
||||
EISCONN = posix.EISCONN,
|
||||
ENOTCONN = posix.ENOTCONN,
|
||||
ECONNREFUSED = posix.ECONNREFUSED,
|
||||
EHOSTUNREACH = posix.EHOSTUNREACH,
|
||||
ENOPROTOOPT = posix.ENOPROTOOPT,
|
||||
ENOBUFS = posix.ENOBUFS,
|
||||
EINPROGRESS = posix.EINPROGRESS,
|
||||
EALREADY = posix.EALREADY,
|
||||
EILSEQ = posix.EILSEQ,
|
||||
ENOMSG = posix.ENOMSG,
|
||||
ESTALE = posix.ESTALE,
|
||||
EOVERFLOW = posix.EOVERFLOW,
|
||||
EMSGSIZE = posix.EMSGSIZE,
|
||||
EOPNOTSUPP = posix.EOPNOTSUPP,
|
||||
ENOTSOCK = posix.ENOTSOCK,
|
||||
EBADMSG = posix.EBADMSG,
|
||||
ECANCELED = posix.ECANCELED,
|
||||
EDESTADDRREQ = posix.EDESTADDRREQ,
|
||||
EDQUOT = posix.EDQUOT,
|
||||
EIDRM = posix.EIDRM,
|
||||
EMULTIHOP = posix.EMULTIHOP,
|
||||
ENODATA = posix.ENODATA,
|
||||
ENOLINK = posix.ENOLINK,
|
||||
ENOSR = posix.ENOSR,
|
||||
ENOSTR = posix.ENOSTR,
|
||||
ENOTSUP = posix.ENOTSUP,
|
||||
EPROTO = posix.EPROTO,
|
||||
ETIME = posix.ETIME,
|
||||
ETXTBSY = posix.ETXTBSY,
|
||||
ENOTRECOVERABLE = posix.ENOTRECOVERABLE,
|
||||
EOWNERDEAD = posix.EOWNERDEAD,
|
||||
|
||||
// New error codes that can be mapped to POSIX errors
|
||||
TOO_MANY_ARGS = POSIX_ERROR_FACTOR * E2BIG,
|
||||
FILE_TOO_LARGE = POSIX_ERROR_FACTOR * EFBIG,
|
||||
DEVICE_NOT_FOUND = POSIX_ERROR_FACTOR * ENODEV,
|
||||
RESULT_NOT_REPRESENTABLE = POSIX_ERROR_FACTOR * ERANGE,
|
||||
BUFFER_OVERFLOW = POSIX_ERROR_FACTOR * EOVERFLOW,
|
||||
NOT_SUPPORTED = POSIX_ERROR_FACTOR * EOPNOTSUPP,
|
||||
|
||||
// Media Kit Errors
|
||||
STREAM_NOT_FOUND = MEDIA_ERROR_BASE + 0,
|
||||
SERVER_NOT_FOUND = MEDIA_ERROR_BASE + 1,
|
||||
RESOURCE_NOT_FOUND = MEDIA_ERROR_BASE + 2,
|
||||
RESOURCE_UNAVAILABLE = MEDIA_ERROR_BASE + 3,
|
||||
BAD_SUBSCRIBER = MEDIA_ERROR_BASE + 4,
|
||||
SUBSCRIBER_NOT_ENTERED = MEDIA_ERROR_BASE + 5,
|
||||
BUFFER_NOT_AVAILABLE = MEDIA_ERROR_BASE + 6,
|
||||
LAST_BUFFER_ERROR = MEDIA_ERROR_BASE + 7,
|
||||
MEDIA_SYSTEM_FAILURE = MEDIA_ERROR_BASE + 100,
|
||||
MEDIA_BAD_NODE = MEDIA_ERROR_BASE + 101,
|
||||
MEDIA_NODE_BUSY = MEDIA_ERROR_BASE + 102,
|
||||
MEDIA_BAD_FORMAT = MEDIA_ERROR_BASE + 103,
|
||||
MEDIA_BAD_BUFFER = MEDIA_ERROR_BASE + 104,
|
||||
MEDIA_TOO_MANY_NODES = MEDIA_ERROR_BASE + 105,
|
||||
MEDIA_TOO_MANY_BUFFERS = MEDIA_ERROR_BASE + 106,
|
||||
MEDIA_NODE_ALREADY_EXISTS = MEDIA_ERROR_BASE + 107,
|
||||
MEDIA_BUFFER_ALREADY_EXISTS = MEDIA_ERROR_BASE + 108,
|
||||
MEDIA_CANNOT_SEEK = MEDIA_ERROR_BASE + 109,
|
||||
MEDIA_CANNOT_CHANGE_RUN_MODE = MEDIA_ERROR_BASE + 110,
|
||||
MEDIA_APP_ALREADY_REGISTERED = MEDIA_ERROR_BASE + 111,
|
||||
MEDIA_APP_NOT_REGISTERED = MEDIA_ERROR_BASE + 112,
|
||||
MEDIA_CANNOT_RECLAIM_BUFFERS = MEDIA_ERROR_BASE + 113,
|
||||
MEDIA_BUFFERS_NOT_RECLAIMED = MEDIA_ERROR_BASE + 114,
|
||||
MEDIA_TIME_SOURCE_STOPPED = MEDIA_ERROR_BASE + 115,
|
||||
MEDIA_TIME_SOURCE_BUSY = MEDIA_ERROR_BASE + 116,
|
||||
MEDIA_BAD_SOURCE = MEDIA_ERROR_BASE + 117,
|
||||
MEDIA_BAD_DESTINATION = MEDIA_ERROR_BASE + 118,
|
||||
MEDIA_ALREADY_CONNECTED = MEDIA_ERROR_BASE + 119,
|
||||
MEDIA_NOT_CONNECTED = MEDIA_ERROR_BASE + 120,
|
||||
MEDIA_BAD_CLIP_FORMAT = MEDIA_ERROR_BASE + 121,
|
||||
MEDIA_ADDON_FAILED = MEDIA_ERROR_BASE + 122,
|
||||
MEDIA_ADDON_DISABLED = MEDIA_ERROR_BASE + 123,
|
||||
MEDIA_CHANGE_IN_PROGRESS = MEDIA_ERROR_BASE + 124,
|
||||
MEDIA_STALE_CHANGE_COUNT = MEDIA_ERROR_BASE + 125,
|
||||
MEDIA_ADDON_RESTRICTED = MEDIA_ERROR_BASE + 126,
|
||||
MEDIA_NO_HANDLER = MEDIA_ERROR_BASE + 127,
|
||||
MEDIA_DUPLICATE_FORMAT = MEDIA_ERROR_BASE + 128,
|
||||
MEDIA_REALTIME_DISABLED = MEDIA_ERROR_BASE + 129,
|
||||
MEDIA_REALTIME_UNAVAILABLE = MEDIA_ERROR_BASE + 130,
|
||||
|
||||
// Mail Kit Errors
|
||||
MAIL_NO_DAEMON = MAIL_ERROR_BASE + 0,
|
||||
MAIL_UNKNOWN_USER = MAIL_ERROR_BASE + 1,
|
||||
MAIL_WRONG_PASSWORD = MAIL_ERROR_BASE + 2,
|
||||
MAIL_UNKNOWN_HOST = MAIL_ERROR_BASE + 3,
|
||||
MAIL_ACCESS_ERROR = MAIL_ERROR_BASE + 4,
|
||||
MAIL_UNKNOWN_FIELD = MAIL_ERROR_BASE + 5,
|
||||
MAIL_NO_RECIPIENT = MAIL_ERROR_BASE + 6,
|
||||
MAIL_INVALID_MAIL = MAIL_ERROR_BASE + 7,
|
||||
|
||||
// Printing Errors
|
||||
NO_PRINT_SERVER = PRINT_ERROR_BASE + 0,
|
||||
|
||||
// Device Kit Errors
|
||||
DEV_INVALID_IOCTL = DEVICE_ERROR_BASE + 0,
|
||||
DEV_NO_MEMORY = DEVICE_ERROR_BASE + 1,
|
||||
DEV_BAD_DRIVE_NUM = DEVICE_ERROR_BASE + 2,
|
||||
DEV_NO_MEDIA = DEVICE_ERROR_BASE + 3,
|
||||
DEV_UNREADABLE = DEVICE_ERROR_BASE + 4,
|
||||
DEV_FORMAT_ERROR = DEVICE_ERROR_BASE + 5,
|
||||
DEV_TIMEOUT = DEVICE_ERROR_BASE + 6,
|
||||
DEV_RECALIBRATE_ERROR = DEVICE_ERROR_BASE + 7,
|
||||
DEV_SEEK_ERROR = DEVICE_ERROR_BASE + 8,
|
||||
DEV_ID_ERROR = DEVICE_ERROR_BASE + 9,
|
||||
DEV_READ_ERROR = DEVICE_ERROR_BASE + 10,
|
||||
DEV_WRITE_ERROR = DEVICE_ERROR_BASE + 11,
|
||||
DEV_NOT_READY = DEVICE_ERROR_BASE + 12,
|
||||
DEV_MEDIA_CHANGED = DEVICE_ERROR_BASE + 13,
|
||||
DEV_MEDIA_CHANGE_REQUESTED = DEVICE_ERROR_BASE + 14,
|
||||
DEV_RESOURCE_CONFLICT = DEVICE_ERROR_BASE + 15,
|
||||
DEV_CONFIGURATION_ERROR = DEVICE_ERROR_BASE + 16,
|
||||
DEV_DISABLED_BY_USER = DEVICE_ERROR_BASE + 17,
|
||||
DEV_DOOR_OPEN = DEVICE_ERROR_BASE + 18,
|
||||
DEV_INVALID_PIPE = DEVICE_ERROR_BASE + 19,
|
||||
DEV_CRC_ERROR = DEVICE_ERROR_BASE + 20,
|
||||
DEV_STALLED = DEVICE_ERROR_BASE + 21,
|
||||
DEV_BAD_PID = DEVICE_ERROR_BASE + 22,
|
||||
DEV_UNEXPECTED_PID = DEVICE_ERROR_BASE + 23,
|
||||
DEV_DATA_OVERRUN = DEVICE_ERROR_BASE + 24,
|
||||
DEV_DATA_UNDERRUN = DEVICE_ERROR_BASE + 25,
|
||||
DEV_FIFO_OVERRUN = DEVICE_ERROR_BASE + 26,
|
||||
DEV_FIFO_UNDERRUN = DEVICE_ERROR_BASE + 27,
|
||||
DEV_PENDING = DEVICE_ERROR_BASE + 28,
|
||||
DEV_MULTIPLE_ERRORS = DEVICE_ERROR_BASE + 29,
|
||||
DEV_TOO_LATE = DEVICE_ERROR_BASE + 30,
|
||||
|
||||
// Translation Kit Errors
|
||||
TRANSLATION_BASE_ERROR = TRANSLATION_ERROR_BASE + 0,
|
||||
NO_TRANSLATOR = TRANSLATION_ERROR_BASE + 1,
|
||||
ILLEGAL_DATA = TRANSLATION_ERROR_BASE + 2,
|
||||
}
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign libroot {
|
||||
_to_positive_error :: proc(error: i32) -> i32 ---
|
||||
_to_negative_error :: proc(error: i32) -> i32 ---
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
#+build haiku
|
||||
package sys_haiku
|
||||
|
||||
import "base:intrinsics"
|
||||
|
||||
foreign import libroot "system:c"
|
||||
|
||||
directory_which :: enum i32 {
|
||||
// Per volume directories
|
||||
DESKTOP_DIRECTORY = 0,
|
||||
TRASH_DIRECTORY,
|
||||
|
||||
// System directories
|
||||
SYSTEM_DIRECTORY = 1000,
|
||||
SYSTEM_ADDONS_DIRECTORY = 1002,
|
||||
SYSTEM_BOOT_DIRECTORY,
|
||||
SYSTEM_FONTS_DIRECTORY,
|
||||
SYSTEM_LIB_DIRECTORY,
|
||||
SYSTEM_SERVERS_DIRECTORY,
|
||||
SYSTEM_APPS_DIRECTORY,
|
||||
SYSTEM_BIN_DIRECTORY,
|
||||
SYSTEM_DOCUMENTATION_DIRECTORY = 1010,
|
||||
SYSTEM_PREFERENCES_DIRECTORY,
|
||||
SYSTEM_TRANSLATORS_DIRECTORY,
|
||||
SYSTEM_MEDIA_NODES_DIRECTORY,
|
||||
SYSTEM_SOUNDS_DIRECTORY,
|
||||
SYSTEM_DATA_DIRECTORY,
|
||||
SYSTEM_DEVELOP_DIRECTORY,
|
||||
SYSTEM_PACKAGES_DIRECTORY,
|
||||
SYSTEM_HEADERS_DIRECTORY,
|
||||
SYSTEM_ETC_DIRECTORY = 2008,
|
||||
SYSTEM_SETTINGS_DIRECTORY = 2010,
|
||||
SYSTEM_LOG_DIRECTORY = 2012,
|
||||
SYSTEM_SPOOL_DIRECTORY,
|
||||
SYSTEM_TEMP_DIRECTORY,
|
||||
SYSTEM_VAR_DIRECTORY,
|
||||
SYSTEM_CACHE_DIRECTORY = 2020,
|
||||
SYSTEM_NONPACKAGED_DIRECTORY = 2023,
|
||||
SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
|
||||
SYSTEM_NONPACKAGED_TRANSLATORS_DIRECTORY,
|
||||
SYSTEM_NONPACKAGED_MEDIA_NODES_DIRECTORY,
|
||||
SYSTEM_NONPACKAGED_BIN_DIRECTORY,
|
||||
SYSTEM_NONPACKAGED_DATA_DIRECTORY,
|
||||
SYSTEM_NONPACKAGED_FONTS_DIRECTORY,
|
||||
SYSTEM_NONPACKAGED_SOUNDS_DIRECTORY,
|
||||
SYSTEM_NONPACKAGED_DOCUMENTATION_DIRECTORY,
|
||||
SYSTEM_NONPACKAGED_LIB_DIRECTORY,
|
||||
SYSTEM_NONPACKAGED_HEADERS_DIRECTORY,
|
||||
SYSTEM_NONPACKAGED_DEVELOP_DIRECTORY,
|
||||
|
||||
// User directories. These are interpreted in the context of the user making the find_directory call.
|
||||
USER_DIRECTORY = 3000,
|
||||
USER_CONFIG_DIRECTORY,
|
||||
USER_ADDONS_DIRECTORY,
|
||||
USER_BOOT_DIRECTORY,
|
||||
USER_FONTS_DIRECTORY,
|
||||
USER_LIB_DIRECTORY,
|
||||
USER_SETTINGS_DIRECTORY,
|
||||
USER_DESKBAR_DIRECTORY,
|
||||
USER_PRINTERS_DIRECTORY,
|
||||
USER_TRANSLATORS_DIRECTORY,
|
||||
USER_MEDIA_NODES_DIRECTORY,
|
||||
USER_SOUNDS_DIRECTORY,
|
||||
USER_DATA_DIRECTORY,
|
||||
USER_CACHE_DIRECTORY,
|
||||
USER_PACKAGES_DIRECTORY,
|
||||
USER_HEADERS_DIRECTORY,
|
||||
USER_NONPACKAGED_DIRECTORY,
|
||||
USER_NONPACKAGED_ADDONS_DIRECTORY,
|
||||
USER_NONPACKAGED_TRANSLATORS_DIRECTORY,
|
||||
USER_NONPACKAGED_MEDIA_NODES_DIRECTORY,
|
||||
USER_NONPACKAGED_BIN_DIRECTORY,
|
||||
USER_NONPACKAGED_DATA_DIRECTORY,
|
||||
USER_NONPACKAGED_FONTS_DIRECTORY,
|
||||
USER_NONPACKAGED_SOUNDS_DIRECTORY,
|
||||
USER_NONPACKAGED_DOCUMENTATION_DIRECTORY,
|
||||
USER_NONPACKAGED_LIB_DIRECTORY,
|
||||
USER_NONPACKAGED_HEADERS_DIRECTORY,
|
||||
USER_NONPACKAGED_DEVELOP_DIRECTORY,
|
||||
USER_DEVELOP_DIRECTORY,
|
||||
USER_DOCUMENTATION_DIRECTORY,
|
||||
USER_SERVERS_DIRECTORY,
|
||||
USER_APPS_DIRECTORY,
|
||||
USER_BIN_DIRECTORY,
|
||||
USER_PREFERENCES_DIRECTORY,
|
||||
USER_ETC_DIRECTORY,
|
||||
USER_LOG_DIRECTORY,
|
||||
USER_SPOOL_DIRECTORY,
|
||||
USER_VAR_DIRECTORY,
|
||||
|
||||
// Global directories
|
||||
APPS_DIRECTORY = 4000,
|
||||
PREFERENCES_DIRECTORY,
|
||||
UTILITIES_DIRECTORY,
|
||||
PACKAGE_LINKS_DIRECTORY,
|
||||
|
||||
// Obsolete: Legacy BeOS definition to be phased out
|
||||
BEOS_DIRECTORY = 1000,
|
||||
BEOS_SYSTEM_DIRECTORY,
|
||||
BEOS_ADDONS_DIRECTORY,
|
||||
BEOS_BOOT_DIRECTORY,
|
||||
BEOS_FONTS_DIRECTORY,
|
||||
BEOS_LIB_DIRECTORY,
|
||||
BEOS_SERVERS_DIRECTORY,
|
||||
BEOS_APPS_DIRECTORY,
|
||||
BEOS_BIN_DIRECTORY,
|
||||
BEOS_ETC_DIRECTORY,
|
||||
BEOS_DOCUMENTATION_DIRECTORY,
|
||||
BEOS_PREFERENCES_DIRECTORY,
|
||||
BEOS_TRANSLATORS_DIRECTORY,
|
||||
BEOS_MEDIA_NODES_DIRECTORY,
|
||||
BEOS_SOUNDS_DIRECTORY,
|
||||
}
|
||||
|
||||
find_path_flag :: enum u32 {
|
||||
CREATE_DIRECTORY = intrinsics.constant_log2(0x0001),
|
||||
CREATE_PARENT_DIRECTORY = intrinsics.constant_log2(0x0002),
|
||||
EXISTING_ONLY = intrinsics.constant_log2(0x0004),
|
||||
|
||||
// find_paths() only
|
||||
SYSTEM_ONLY = intrinsics.constant_log2(0x0010),
|
||||
USER_ONLY = intrinsics.constant_log2(0x0020),
|
||||
}
|
||||
find_path_flags :: distinct bit_set[find_path_flag; u32]
|
||||
|
||||
path_base_directory :: enum i32 {
|
||||
INSTALLATION_LOCATION_DIRECTORY,
|
||||
ADD_ONS_DIRECTORY,
|
||||
APPS_DIRECTORY,
|
||||
BIN_DIRECTORY,
|
||||
BOOT_DIRECTORY,
|
||||
CACHE_DIRECTORY,
|
||||
DATA_DIRECTORY,
|
||||
DEVELOP_DIRECTORY,
|
||||
DEVELOP_LIB_DIRECTORY,
|
||||
DOCUMENTATION_DIRECTORY,
|
||||
ETC_DIRECTORY,
|
||||
FONTS_DIRECTORY,
|
||||
HEADERS_DIRECTORY,
|
||||
LIB_DIRECTORY,
|
||||
LOG_DIRECTORY,
|
||||
MEDIA_NODES_DIRECTORY,
|
||||
PACKAGES_DIRECTORY,
|
||||
PREFERENCES_DIRECTORY,
|
||||
SERVERS_DIRECTORY,
|
||||
SETTINGS_DIRECTORY,
|
||||
SOUNDS_DIRECTORY,
|
||||
SPOOL_DIRECTORY,
|
||||
TRANSLATORS_DIRECTORY,
|
||||
VAR_DIRECTORY,
|
||||
|
||||
// find_path() only
|
||||
IMAGE_PATH = 1000,
|
||||
PACKAGE_PATH,
|
||||
}
|
||||
|
||||
// value that can be used instead of a pointer to a symbol in the program image
|
||||
APP_IMAGE_SYMBOL :: rawptr(addr_t(0))
|
||||
// pointer to a symbol in the callers image (same as B_CURRENT_IMAGE_SYMBOL)
|
||||
current_image_symbol :: proc "contextless" () -> rawptr { return rawptr(current_image_symbol) }
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign libroot {
|
||||
find_directory :: proc(which: directory_which, volume: dev_t, createIt: bool, pathString: [^]byte, length: i32) -> status_t ---
|
||||
find_path :: proc(codePointer: rawptr, baseDirectory: path_base_directory, subPath: cstring, pathBuffer: [^]byte, bufferSize: uint) -> status_t ---
|
||||
find_path_etc :: proc(codePointer: rawptr, dependency: cstring, architecture: cstring, baseDirectory: path_base_directory, subPath: cstring, flags: find_path_flags, pathBuffer: [^]byte, bufferSize: uint) -> status_t ---
|
||||
find_path_for_path :: proc(path: cstring, baseDirectory: path_base_directory, subPath: cstring, pathBuffer: [^]byte, bufferSize: uint) -> status_t ---
|
||||
find_path_for_path_etc :: proc(path: cstring, dependency: cstring, architecture: cstring, baseDirectory: path_base_directory, subPath: cstring, flags: find_path_flags, pathBuffer: [^]byte, bufferSize: uint) -> status_t ---
|
||||
find_paths :: proc(baseDirectory: path_base_directory, subPath: cstring, _paths: ^[^][^]byte, _pathCount: ^uint) -> status_t ---
|
||||
find_paths_etc :: proc(architecture: cstring, baseDirectory: path_base_directory, subPath: cstring, flags: find_path_flags, _paths: ^[^][^]byte, _pathCount: ^uint) -> status_t ---
|
||||
}
|
||||
@@ -1,498 +0,0 @@
|
||||
#+build haiku
|
||||
package sys_haiku
|
||||
|
||||
import "base:intrinsics"
|
||||
import "core:sys/posix"
|
||||
|
||||
foreign import libroot "system:c"
|
||||
|
||||
PATH_MAX :: 1024
|
||||
NAME_MAX :: 256
|
||||
MAXPATHLEN :: PATH_MAX
|
||||
|
||||
FILE_NAME_LENGTH :: NAME_MAX
|
||||
PATH_NAME_LENGTH :: MAXPATHLEN
|
||||
OS_NAME_LENGTH :: 32
|
||||
|
||||
// Areas
|
||||
|
||||
area_info :: struct {
|
||||
area: area_id,
|
||||
name: [OS_NAME_LENGTH]byte,
|
||||
size: uint,
|
||||
lock: u32,
|
||||
protection: u32,
|
||||
team: team_id,
|
||||
ram_size: u32,
|
||||
copy_count: u32,
|
||||
in_count: u32,
|
||||
out_count: u32,
|
||||
address: rawptr,
|
||||
}
|
||||
|
||||
area_locking :: enum u32 {
|
||||
NO_LOCK = 0,
|
||||
LAZY_LOCK = 1,
|
||||
FULL_LOCK = 2,
|
||||
CONTIGUOUS = 3,
|
||||
LOMEM = 4, // CONTIGUOUS, < 16 MB physical address
|
||||
_32_BIT_FULL_LOCK = 5, // FULL_LOCK, < 4 GB physical addresses
|
||||
_32_BIT_CONTIGUOUS = 6, // CONTIGUOUS, < 4 GB physical address
|
||||
}
|
||||
|
||||
// for create_area() and clone_area()
|
||||
address_spec :: enum u32 {
|
||||
ANY_ADDRESS = 0,
|
||||
EXACT_ADDRESS = 1,
|
||||
BASE_ADDRESS = 2,
|
||||
CLONE_ADDRESS = 3,
|
||||
ANY_KERNEL_ADDRESS = 4,
|
||||
// ANY_KERNEL_BLOCK_ADDRESS = 5,
|
||||
RANDOMIZED_ANY_ADDRESS = 6,
|
||||
RANDOMIZED_BASE_ADDRESS = 7,
|
||||
}
|
||||
|
||||
area_protection_flag :: enum u32 {
|
||||
READ_AREA = 0,
|
||||
WRITE_AREA = 1,
|
||||
EXECUTE_AREA = 2,
|
||||
// "stack" protection is not available on most platforms - it's used
|
||||
// to only commit memory as needed, and have guard pages at the
|
||||
// bottom of the stack.
|
||||
STACK_AREA = 3,
|
||||
CLONEABLE_AREA = 8,
|
||||
}
|
||||
area_protection_flags :: distinct bit_set[area_protection_flag; u32]
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign libroot {
|
||||
create_area :: proc(name: cstring, startAddress: ^rawptr, addressSpec: address_spec, size: uint, lock: area_locking, protection: area_protection_flags) -> area_id ---
|
||||
clone_area :: proc(name: cstring, destAddress: ^rawptr, addressSpec: address_spec, protection: area_protection_flags, source: area_id) -> area_id ---
|
||||
find_area :: proc(name: cstring) -> area_id ---
|
||||
area_for :: proc(address: rawptr) -> area_id ---
|
||||
delete_area :: proc(id: area_id) -> status_t ---
|
||||
resize_area :: proc(id: area_id, newSize: uint) -> status_t ---
|
||||
set_area_protection :: proc(id: area_id, newProtection: area_protection_flags) -> status_t ---
|
||||
_get_area_info :: proc(id: area_id, areaInfo: ^area_info, size: uint) -> status_t ---
|
||||
_get_next_area_info :: proc(team: team_id, cookie: ^int, areaInfo: ^area_info, size: uint) -> status_t ---
|
||||
}
|
||||
|
||||
// Ports
|
||||
|
||||
port_info :: struct {
|
||||
port: port_id,
|
||||
team: team_id,
|
||||
name: [OS_NAME_LENGTH]byte,
|
||||
capacity: i32, // queue depth
|
||||
queue_count: i32, // # msgs waiting to be read
|
||||
total_count: i32, // total # msgs read so far
|
||||
}
|
||||
|
||||
port_flag :: enum u32 {
|
||||
USE_USER_MEMCPY = intrinsics.constant_log2(0x80000000),
|
||||
// read the message, but don't remove it; kernel-only; memory must be locked
|
||||
PEEK_PORT_MESSAGE = intrinsics.constant_log2(0x100),
|
||||
}
|
||||
port_flags :: distinct bit_set[port_flag; u32]
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign libroot {
|
||||
create_port :: proc(capacity: i32, name: cstring) -> port_id ---
|
||||
find_port :: proc(name: cstring) -> port_id ---
|
||||
read_port :: proc(port: port_id, code: ^i32, buffer: rawptr, bufferSize: uint) -> int ---
|
||||
read_port_etc :: proc(port: port_id, code: ^i32, buffer: rawptr, bufferSize: uint, flags: port_flags, timeout: bigtime_t) -> int ---
|
||||
write_port :: proc(port: port_id, code: i32, buffer: rawptr, bufferSize: uint) -> status_t ---
|
||||
write_port_etc :: proc(port: port_id, code: i32, buffer: rawptr, bufferSize: uint, flags: port_flags, timeout: bigtime_t) -> status_t ---
|
||||
close_port :: proc(port: port_id) -> status_t ---
|
||||
delete_port :: proc(port: port_id) -> status_t ---
|
||||
port_buffer_size :: proc(port: port_id) -> int ---
|
||||
port_buffer_size_etc :: proc(port: port_id, flags: port_flags, timeout: bigtime_t) -> int ---
|
||||
port_count :: proc(port: port_id) -> int ---
|
||||
set_port_owner :: proc(port: port_id, team: team_id) -> status_t ---
|
||||
_get_port_info :: proc(port: port_id, portInfo: ^port_info, portInfoSize: uint) -> status_t ---
|
||||
_get_next_port_info :: proc(team: team_id, cookie: ^i32, portInfo: ^port_info, portInfoSize: uint) -> status_t ---
|
||||
}
|
||||
|
||||
// Semaphores
|
||||
|
||||
sem_info :: struct {
|
||||
sem: sem_id,
|
||||
team: team_id,
|
||||
name: [OS_NAME_LENGTH]byte,
|
||||
count: i32,
|
||||
latest_holder: thread_id,
|
||||
}
|
||||
|
||||
semaphore_flag :: enum u32 {
|
||||
CAN_INTERRUPT = intrinsics.constant_log2(0x01), // acquisition of the semaphore can be interrupted (system use only)
|
||||
CHECK_PERMISSION = intrinsics.constant_log2(0x04), // ownership will be checked (system use only)
|
||||
KILL_CAN_INTERRUPT = intrinsics.constant_log2(0x20), // acquisition of the semaphore can be interrupted by SIGKILL[THR], even if not CAN_INTERRUPT (system use only)
|
||||
|
||||
// release_sem_etc() only flags
|
||||
DO_NOT_RESCHEDULE = intrinsics.constant_log2(0x02), // thread is not rescheduled
|
||||
RELEASE_ALL = intrinsics.constant_log2(0x08), // all waiting threads will be woken up, count will be zeroed
|
||||
RELEASE_IF_WAITING_ONLY = intrinsics.constant_log2(0x10), // release count only if there are any threads waiting
|
||||
}
|
||||
semaphore_flags :: distinct bit_set[semaphore_flag; u32]
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign libroot {
|
||||
create_sem :: proc(count: i32, name: cstring) -> sem_id ---
|
||||
delete_sem :: proc(id: sem_id) -> status_t ---
|
||||
acquire_sem :: proc(id: sem_id) -> status_t ---
|
||||
acquire_sem_etc :: proc(id: sem_id, count: i32, flags: semaphore_flags, timeout: bigtime_t) -> status_t ---
|
||||
release_sem :: proc(id: sem_id) -> status_t ---
|
||||
release_sem_etc :: proc(id: sem_id, count: i32, flags: semaphore_flags) -> status_t ---
|
||||
switch_sem :: proc(semToBeReleased: sem_id) -> status_t ---
|
||||
switch_sem_etc :: proc(semToBeReleased: sem_id, id: sem_id, count: i32, flags: semaphore_flags, timeout: bigtime_t) -> status_t ---
|
||||
get_sem_count :: proc(id: sem_id, threadCount: ^i32) -> status_t ---
|
||||
set_sem_owner :: proc(id: sem_id, team: team_id) -> status_t ---
|
||||
_get_sem_info :: proc(id: sem_id, info: ^sem_info, infoSize: uint) -> status_t ---
|
||||
_get_next_sem_info :: proc(team: team_id, cookie: ^i32, info: ^sem_info, infoSize: uint) -> status_t ---
|
||||
}
|
||||
|
||||
// Teams
|
||||
|
||||
team_info :: struct {
|
||||
team: team_id,
|
||||
thread_count: i32,
|
||||
image_count: i32,
|
||||
area_count: i32,
|
||||
debugger_nub_thread: thread_id,
|
||||
debugger_nub_port: port_id,
|
||||
argc: i32,
|
||||
args: [64]byte,
|
||||
uid: uid_t,
|
||||
gid: gid_t,
|
||||
|
||||
// Haiku R1 extensions
|
||||
real_uid: uid_t,
|
||||
real_gid: gid_t,
|
||||
group_id: pid_t,
|
||||
session_id: pid_t,
|
||||
parent: team_id,
|
||||
name: [OS_NAME_LENGTH]byte,
|
||||
start_time: bigtime_t,
|
||||
}
|
||||
|
||||
CURRENT_TEAM :: 0
|
||||
SYSTEM_TEAM :: 1
|
||||
|
||||
team_usage_info :: struct {
|
||||
user_time: bigtime_t,
|
||||
kernel_time: bigtime_t,
|
||||
}
|
||||
|
||||
team_usage_who :: enum i32 {
|
||||
// compatible to sys/resource.h RUSAGE_SELF and RUSAGE_CHILDREN
|
||||
SELF = 0,
|
||||
CHILDREN = -1,
|
||||
}
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign libroot {
|
||||
// see also: send_signal()
|
||||
kill_team :: proc(team: team_id) -> status_t ---
|
||||
_get_team_info :: proc(id: team_id, info: ^team_info, size: uint) -> status_t ---
|
||||
_get_next_team_info :: proc(cookie: ^i32, info: ^team_info, size: uint) -> status_t ---
|
||||
_get_team_usage_info :: proc(id: team_id, who: team_usage_who, info: ^team_usage_info, size: uint) -> status_t ---
|
||||
}
|
||||
|
||||
// Threads
|
||||
|
||||
thread_state :: enum i32 {
|
||||
RUNNING = 1,
|
||||
READY,
|
||||
RECEIVING,
|
||||
ASLEEP,
|
||||
SUSPENDED,
|
||||
WAITING,
|
||||
}
|
||||
|
||||
thread_info :: struct {
|
||||
thread: thread_id,
|
||||
team: team_id,
|
||||
name: [OS_NAME_LENGTH]byte,
|
||||
state: thread_state,
|
||||
priority: thread_priority,
|
||||
sem: sem_id,
|
||||
user_time: bigtime_t,
|
||||
kernel_time: bigtime_t,
|
||||
stack_base: rawptr,
|
||||
stack_end: rawptr,
|
||||
}
|
||||
|
||||
thread_priority :: enum i32 {
|
||||
IDLE_PRIORITY = 0,
|
||||
LOWEST_ACTIVE_PRIORITY = 1,
|
||||
LOW_PRIORITY = 5,
|
||||
NORMAL_PRIORITY = 10,
|
||||
DISPLAY_PRIORITY = 15,
|
||||
URGENT_DISPLAY_PRIORITY = 20,
|
||||
REAL_TIME_DISPLAY_PRIORITY = 100,
|
||||
URGENT_PRIORITY = 110,
|
||||
REAL_TIME_PRIORITY = 120,
|
||||
}
|
||||
|
||||
FIRST_REAL_TIME_PRIORITY :: thread_priority.REAL_TIME_PRIORITY
|
||||
|
||||
// time base for snooze_*(), compatible with the clockid_t constants defined in <time.h>
|
||||
SYSTEM_TIMEBASE :: 0
|
||||
|
||||
thread_func :: #type proc "c" (rawptr) -> status_t
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign libroot {
|
||||
spawn_thread :: proc(thread_func, name: cstring, priority: thread_priority, data: rawptr) -> thread_id ---
|
||||
kill_thread :: proc(thread: thread_id) -> status_t ---
|
||||
resume_thread :: proc(thread: thread_id) -> status_t ---
|
||||
suspend_thread :: proc(thread: thread_id) -> status_t ---
|
||||
rename_thread :: proc(thread: thread_id, newName: cstring) -> status_t ---
|
||||
set_thread_priority :: proc(thread: thread_id, newPriority: thread_priority) -> status_t ---
|
||||
exit_thread :: proc(status: status_t) ---
|
||||
wait_for_thread :: proc(thread: thread_id, returnValue: ^status_t) -> status_t ---
|
||||
// FIXME: Find and define those flags.
|
||||
wait_for_thread_etc :: proc(id: thread_id, flags: u32, timeout: bigtime_t, _returnCode: ^status_t) -> status_t ---
|
||||
on_exit_thread :: proc(callback: proc "c" (rawptr), data: rawptr) -> status_t ---
|
||||
find_thread :: proc(name: cstring) -> thread_id ---
|
||||
send_data :: proc(thread: thread_id, code: i32, buffer: rawptr, bufferSize: uint) -> status_t ---
|
||||
receive_data :: proc(sender: ^thread_id, buffer: rawptr, bufferSize: uint) -> i32 ---
|
||||
has_data :: proc(thread: thread_id) -> bool ---
|
||||
snooze :: proc(amount: bigtime_t) -> status_t ---
|
||||
// FIXME: Find and define those flags.
|
||||
snooze_etc :: proc(amount: bigtime_t, timeBase: i32, flags: u32) -> status_t ---
|
||||
snooze_until :: proc(time: bigtime_t, timeBase: i32) -> status_t ---
|
||||
_get_thread_info :: proc(id: thread_id, info: ^thread_info, size: uint) -> status_t ---
|
||||
_get_next_thread_info :: proc(team: team_id, cookie: ^i32, info: ^thread_info, size: uint) -> status_t ---
|
||||
// bridge to the pthread API
|
||||
get_pthread_thread_id :: proc(thread: pthread_t) -> thread_id ---
|
||||
}
|
||||
|
||||
// Time
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign libroot {
|
||||
real_time_clock :: proc() -> uint ---
|
||||
set_real_time_clock :: proc(secsSinceJan1st1970: uint) ---
|
||||
real_time_clock_usecs :: proc() -> bigtime_t ---
|
||||
// time since booting in microseconds
|
||||
system_time :: proc() -> bigtime_t ---
|
||||
// time since booting in nanoseconds
|
||||
system_time_nsecs :: proc() -> nanotime_t ---
|
||||
}
|
||||
|
||||
// Alarm
|
||||
|
||||
alarm_mode :: enum u32 {
|
||||
ONE_SHOT_ABSOLUTE_ALARM = 1,
|
||||
ONE_SHOT_RELATIVE_ALARM,
|
||||
PERIODIC_ALARM, // "when" specifies the period
|
||||
}
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign libroot {
|
||||
set_alarm :: proc(_when: bigtime_t, mode: alarm_mode) -> bigtime_t ---
|
||||
}
|
||||
|
||||
// Debugger
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign libroot {
|
||||
debugger :: proc(message: cstring) ---
|
||||
/*
|
||||
calling this function with a non-zero value will cause your thread
|
||||
to receive signals for any exceptional conditions that occur (i.e.
|
||||
you'll get SIGSEGV for data access exceptions, SIGFPE for floating
|
||||
point errors, SIGILL for illegal instructions, etc).
|
||||
|
||||
to re-enable the default debugger pass a zero.
|
||||
*/
|
||||
disable_debugger :: proc(state: i32) -> i32 ---
|
||||
}
|
||||
|
||||
// System information
|
||||
|
||||
cpu_info :: struct {
|
||||
active_time: bigtime_t,
|
||||
enabled: bool,
|
||||
current_frequency: u64,
|
||||
}
|
||||
|
||||
system_info :: struct {
|
||||
boot_time: bigtime_t, // time of boot (usecs since 1/1/1970)
|
||||
|
||||
cpu_count: u32, // number of cpus
|
||||
|
||||
max_pages: u64, // total # of accessible pages
|
||||
used_pages: u64, // # of accessible pages in use
|
||||
cached_pages: u64,
|
||||
block_cache_pages: u64,
|
||||
ignored_pages: u64, // # of ignored/inaccessible pages
|
||||
|
||||
needed_memory: u64,
|
||||
free_memory: u64,
|
||||
|
||||
max_swap_pages: u64,
|
||||
free_swap_pages: u64,
|
||||
|
||||
page_faults: u32, // # of page faults
|
||||
|
||||
max_sems: u32,
|
||||
used_sems: u32,
|
||||
|
||||
max_ports: u32,
|
||||
used_ports: u32,
|
||||
|
||||
max_threads: u32,
|
||||
used_threads: u32,
|
||||
|
||||
max_teams: u32,
|
||||
used_teams: u32,
|
||||
|
||||
kernel_name: [FILE_NAME_LENGTH]byte,
|
||||
kernel_build_date: [OS_NAME_LENGTH]byte,
|
||||
kernel_build_time: [OS_NAME_LENGTH]byte,
|
||||
|
||||
kernel_version: i64,
|
||||
abi: u32, // the system API
|
||||
}
|
||||
|
||||
topology_level_type :: enum i32 {
|
||||
UNKNOWN,
|
||||
ROOT,
|
||||
SMT,
|
||||
CORE,
|
||||
PACKAGE,
|
||||
}
|
||||
|
||||
cpu_platform :: enum i32 {
|
||||
UNKNOWN,
|
||||
x86,
|
||||
x86_64,
|
||||
PPC,
|
||||
PPC_64,
|
||||
M68K,
|
||||
ARM,
|
||||
ARM_64,
|
||||
ALPHA,
|
||||
MIPS,
|
||||
SH,
|
||||
SPARC,
|
||||
RISC_V,
|
||||
}
|
||||
|
||||
cpu_vendor :: enum i32 {
|
||||
UNKNOWN,
|
||||
AMD,
|
||||
CYRIX,
|
||||
IDT,
|
||||
INTEL,
|
||||
NATIONAL_SEMICONDUCTOR,
|
||||
RISE,
|
||||
TRANSMETA,
|
||||
VIA,
|
||||
IBM,
|
||||
MOTOROLA,
|
||||
NEC,
|
||||
HYGON,
|
||||
SUN,
|
||||
FUJITSU,
|
||||
}
|
||||
|
||||
cpu_topology_node_info :: struct {
|
||||
id: u32,
|
||||
type: topology_level_type,
|
||||
level: u32,
|
||||
|
||||
data: struct #raw_union {
|
||||
_root: struct {
|
||||
platform: cpu_platform,
|
||||
},
|
||||
_package: struct {
|
||||
vendor: cpu_vendor,
|
||||
cache_line_size: u32,
|
||||
},
|
||||
_core: struct {
|
||||
model: u32,
|
||||
default_frequency: u64,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
when ODIN_ARCH == .amd64 || ODIN_ARCH == .i386 {
|
||||
cpuid_info :: struct #raw_union {
|
||||
eax_0: struct {
|
||||
max_eax: u32,
|
||||
vendor_id: [12]byte,
|
||||
},
|
||||
|
||||
eax_1: struct {
|
||||
using _: bit_field u32 {
|
||||
stepping: u32 | 4,
|
||||
model: u32 | 4,
|
||||
family: u32 | 4,
|
||||
type: u32 | 2,
|
||||
reserved_0: u32 | 2,
|
||||
extended_model: u32 | 4,
|
||||
extended_family: u32 | 8,
|
||||
reserved_1: u32 | 4,
|
||||
},
|
||||
|
||||
using _: bit_field u32 {
|
||||
brand_index: u32 | 8,
|
||||
clflush: u32 | 8,
|
||||
logical_cpus: u32 | 8,
|
||||
apic_id: u32 | 8,
|
||||
},
|
||||
|
||||
features: u32,
|
||||
extended_features: u32,
|
||||
},
|
||||
|
||||
eax_2: struct {
|
||||
call_num: u8,
|
||||
cache_descriptors: [15]u8,
|
||||
},
|
||||
|
||||
eax_3: struct {
|
||||
reserved: [2]u32,
|
||||
serial_number_high: u32,
|
||||
serial_number_low: u32,
|
||||
},
|
||||
|
||||
as_chars: [16]byte,
|
||||
|
||||
regs: struct {
|
||||
eax: u32,
|
||||
ebx: u32,
|
||||
edx: u32,
|
||||
ecx: u32,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign libroot {
|
||||
get_system_info :: proc(info: ^system_info) -> status_t ---
|
||||
_get_cpu_info_etc :: proc(firstCPU: u32, cpuCount: u32, info: ^cpu_info, size: uint) -> status_t ---
|
||||
get_cpu_topology_info :: proc(topologyInfos: [^]cpu_topology_node_info, topologyInfoCount: ^u32) -> status_t ---
|
||||
|
||||
when ODIN_ARCH == .amd64 || ODIN_ARCH == .i386 {
|
||||
get_cpuid :: proc(info: ^cpuid_info, eaxRegister: u32, cpuNum: u32) -> status_t ---
|
||||
}
|
||||
|
||||
is_computer_on :: proc() -> i32 ---
|
||||
is_computer_on_fire :: proc() -> f64 ---
|
||||
}
|
||||
|
||||
// POSIX signals
|
||||
|
||||
@(default_calling_convention="c")
|
||||
foreign libroot {
|
||||
/*
|
||||
Wait for queued signals.
|
||||
|
||||
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigtimedwait.html ]]
|
||||
*/
|
||||
sigtimedwait :: proc(set: ^posix.sigset_t, info: ^posix.siginfo_t, timeout: ^posix.timespec) -> posix.result ---
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
#+build haiku
|
||||
package sys_haiku
|
||||
|
||||
status_t :: Errno
|
||||
bigtime_t :: i64
|
||||
nanotime_t :: i64
|
||||
type_code :: u32
|
||||
perform_code :: u32
|
||||
|
||||
phys_addr_t :: uintptr
|
||||
phys_size_t :: phys_addr_t
|
||||
generic_addr_t :: uintptr
|
||||
generic_size_t :: generic_addr_t
|
||||
|
||||
area_id :: i32
|
||||
port_id :: i32
|
||||
sem_id :: i32
|
||||
team_id :: i32
|
||||
thread_id :: i32
|
||||
|
||||
blkcnt_t :: i64
|
||||
blksize_t :: i32
|
||||
fsblkcnt_t :: i64
|
||||
fsfilcnt_t :: i64
|
||||
off_t :: i64
|
||||
ino_t :: i64
|
||||
cnt_t :: i32
|
||||
dev_t :: i32
|
||||
pid_t :: i32
|
||||
id_t :: i32
|
||||
|
||||
uid_t :: u32
|
||||
gid_t :: u32
|
||||
mode_t :: u32
|
||||
umode_t :: u32
|
||||
nlink_t :: i32
|
||||
|
||||
caddr_t :: [^]byte
|
||||
|
||||
addr_t :: phys_addr_t
|
||||
key_t :: i32
|
||||
|
||||
clockid_t :: i32
|
||||
|
||||
time_t :: int
|
||||
timespec :: struct {
|
||||
tv_sec: time_t,
|
||||
tv_nsec: int,
|
||||
}
|
||||
|
||||
sig_atomic_t :: i32
|
||||
sigset_t :: u64
|
||||
|
||||
image_id :: i32
|
||||
|
||||
pthread_t :: rawptr
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build openbsd, freebsd, netbsd, haiku
|
||||
#+build openbsd, freebsd, netbsd
|
||||
package sysinfo
|
||||
|
||||
@(private)
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#+build haiku
|
||||
package sysinfo
|
||||
|
||||
import "base:runtime"
|
||||
|
||||
@(private)
|
||||
_ram_stats :: proc "contextless" () -> (total_ram, free_ram, total_swap, free_swap: i64, ok: bool) {
|
||||
return
|
||||
}
|
||||
|
||||
@(private)
|
||||
_os_version :: proc(allocator: runtime.Allocator, loc := #caller_location) -> (res: OS_Version, ok: bool) {
|
||||
return {}, false
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
#+build darwin, linux, freebsd, openbsd, netbsd, haiku
|
||||
#+build darwin, linux, freebsd, openbsd, netbsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System"
|
||||
} else when ODIN_OS == .Haiku {
|
||||
foreign import lib "system:network"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build darwin, linux, freebsd, openbsd, netbsd, haiku
|
||||
#+build darwin, linux, freebsd, openbsd, netbsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -227,15 +227,4 @@ when ODIN_OS == .Darwin {
|
||||
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) */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build windows, darwin, linux, freebsd, openbsd, netbsd, haiku
|
||||
#+build windows, darwin, linux, freebsd, openbsd, netbsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -536,92 +536,4 @@ 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)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, openbsd, freebsd, netbsd, haiku
|
||||
#+build linux, darwin, openbsd, freebsd, netbsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -409,72 +409,6 @@ 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build darwin, linux, openbsd, freebsd, netbsd, haiku
|
||||
#+build darwin, linux, openbsd, freebsd, netbsd
|
||||
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 || ODIN_OS == .Haiku {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD {
|
||||
|
||||
FNM_NOMATCH :: 1
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
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 || ODIN_OS == .Haiku {
|
||||
} else when ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD {
|
||||
|
||||
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 || ODIN_OS == .Haiku else 0x0100
|
||||
GLOB_NOESCAPE :: 0x2000 when ODIN_OS == .FreeBSD else 0x0100
|
||||
GLOB_NOSORT :: 0x0020
|
||||
|
||||
GLOB_ABORTED :: -2
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
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 == .Haiku || ODIN_OS == .Linux {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
|
||||
|
||||
gid_t :: distinct c.uint32_t
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -143,7 +143,7 @@ nl_item :: enum nl_item_t {
|
||||
CRNCYSTR = CRNCYSTR,
|
||||
}
|
||||
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .Haiku {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD {
|
||||
|
||||
// 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 || ODIN_OS == .Haiku {
|
||||
YESEXPR :: 52
|
||||
NOEXPR :: 53
|
||||
|
||||
CRNCYSTR :: 54 when ODIN_OS == .Haiku else 56
|
||||
CRNCYSTR :: 56
|
||||
|
||||
} else when ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build windows, linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build windows, linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c/libc"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
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 || ODIN_OS == .Haiku {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
|
||||
|
||||
hostent :: struct {
|
||||
h_name: cstring, /* [PSX] official name of host */
|
||||
@@ -444,23 +444,6 @@ 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 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -31,31 +31,20 @@ Protocol :: enum c.int {
|
||||
UDP = IPPROTO_UDP,
|
||||
}
|
||||
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux || ODIN_OS == .Haiku {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
|
||||
|
||||
in_addr :: struct {
|
||||
s_addr: in_addr_t, /* [PSX] big endian address */
|
||||
}
|
||||
|
||||
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,
|
||||
},
|
||||
}
|
||||
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 {
|
||||
@@ -88,13 +77,8 @@ 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
|
||||
}
|
||||
@(private)
|
||||
_SIN_ZEROSIZE :: 8
|
||||
|
||||
sockaddr_in :: struct {
|
||||
sin_len: c.uint8_t,
|
||||
@@ -118,23 +102,13 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
|
||||
ipv6mr_interface: c.uint, /* [PSX] interface index */
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "base:intrinsics"
|
||||
@@ -25,7 +25,7 @@ foreign lib {
|
||||
poll :: proc(fds: [^]pollfd, nfds: nfds_t, timeout: c.int) -> c.int ---
|
||||
}
|
||||
|
||||
when ODIN_OS == .Haiku || ODIN_OS == .Linux {
|
||||
when ODIN_OS == .Linux {
|
||||
nfds_t :: c.ulong
|
||||
} else {
|
||||
nfds_t :: c.uint
|
||||
@@ -57,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 || ODIN_OS == .Haiku {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD {
|
||||
|
||||
pollfd :: struct {
|
||||
fd: FD, /* [PSX] the following descriptor being polled */
|
||||
@@ -65,35 +65,17 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
|
||||
revents: Poll_Event, /* [PSX] the output event flags */
|
||||
}
|
||||
|
||||
when ODIN_OS == .Haiku {
|
||||
POLLIN :: 0x0001
|
||||
POLLRDNORM :: 0x0040
|
||||
POLLRDBAND :: 0x0080
|
||||
POLLPRI :: 0x0002
|
||||
POLLOUT :: 0x0004
|
||||
POLLWRNORM :: POLLOUT
|
||||
POLLWRBAND :: 0x0100
|
||||
|
||||
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 {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#+build !netbsd
|
||||
#+build !openbsd
|
||||
#+build !freebsd
|
||||
#+build !haiku
|
||||
package posix
|
||||
|
||||
_IS_SUPPORTED :: false
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
_IS_SUPPORTED :: true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -554,56 +554,6 @@ 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -176,16 +176,4 @@ 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. */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -101,11 +101,4 @@ 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
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "base:intrinsics"
|
||||
@@ -1186,150 +1186,4 @@ when ODIN_OS == .Darwin {
|
||||
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,4 +1,4 @@
|
||||
#+build linux, windows, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, windows, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "base:intrinsics"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, openbsd, freebsd, netbsd, haiku
|
||||
#+build linux, darwin, openbsd, freebsd, netbsd
|
||||
package posix
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, windows, linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, windows, linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "base:intrinsics"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, windows, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, windows, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "base:intrinsics"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, windows, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, windows, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -111,27 +111,4 @@ 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
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -171,22 +171,4 @@ 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 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -96,21 +96,15 @@ when ODIN_OS == .NetBSD {
|
||||
@(private) LGETRUSAGE :: "getrusage"
|
||||
}
|
||||
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux || ODIN_OS == .Haiku {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
|
||||
|
||||
PRIO_PROCESS :: 0
|
||||
PRIO_PGRP :: 1
|
||||
PRIO_USER :: 2
|
||||
|
||||
when ODIN_OS == .Haiku {
|
||||
rlim_t :: distinct c.ulong
|
||||
} else {
|
||||
rlim_t :: distinct c.uint64_t
|
||||
}
|
||||
rlim_t :: distinct c.uint64_t
|
||||
|
||||
when ODIN_OS == .Haiku {
|
||||
RLIM_INFINITY :: rlim_t(0xFFFFFFFF)
|
||||
} else when ODIN_OS == .Linux {
|
||||
when ODIN_OS == .Linux {
|
||||
RLIM_INFINITY :: ~rlim_t(0)
|
||||
} else {
|
||||
RLIM_INFINITY :: (rlim_t(1) << 63) - 1
|
||||
@@ -151,29 +145,19 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
|
||||
ru_nivcsw: c.long, /* involuntary " */
|
||||
}
|
||||
|
||||
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_CORE :: 4
|
||||
RLIMIT_CPU :: 0
|
||||
RLIMIT_DATA :: 2
|
||||
RLIMIT_FSIZE :: 1
|
||||
RLIMIT_NOFILE :: 7 when ODIN_OS == .Linux else 8
|
||||
RLIMIT_STACK :: 3
|
||||
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
|
||||
}
|
||||
when ODIN_OS == .Linux {
|
||||
RLIMIT_AS :: 9
|
||||
} else when ODIN_OS == .Darwin || ODIN_OS == .OpenBSD {
|
||||
RLIMIT_AS :: 5
|
||||
} else {
|
||||
RLIMIT_AS :: 10
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
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 || ODIN_OS == .Haiku {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
|
||||
|
||||
suseconds_t :: distinct (c.int32_t when ODIN_OS == .Darwin || ODIN_OS == .NetBSD || ODIN_OS == .Haiku else c.long)
|
||||
suseconds_t :: distinct (c.int32_t when ODIN_OS == .Darwin || ODIN_OS == .NetBSD else c.long)
|
||||
|
||||
timeval :: struct {
|
||||
tv_sec: time_t, /* [PSX] seconds */
|
||||
@@ -75,14 +75,8 @@ 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)
|
||||
|
||||
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,
|
||||
}
|
||||
fd_set :: struct #align(ALIGN) {
|
||||
fds_bits: [(FD_SETSIZE / __NFDBITS) when (FD_SETSIZE % __NFDBITS) == 0 else (FD_SETSIZE / __NFDBITS) + 1]c.int32_t,
|
||||
}
|
||||
|
||||
@(private)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -168,30 +168,4 @@ 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 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -328,17 +328,12 @@ when ODIN_OS == .NetBSD {
|
||||
@(private) LSOCKET :: "socket"
|
||||
}
|
||||
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux || ODIN_OS == .Haiku {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
|
||||
|
||||
socklen_t :: distinct c.uint
|
||||
|
||||
when ODIN_OS == .Haiku {
|
||||
@(private)
|
||||
_SA_DATASIZE :: 30
|
||||
} else {
|
||||
@(private)
|
||||
_SA_DATASIZE :: 14
|
||||
}
|
||||
@(private)
|
||||
_SA_DATASIZE :: 14
|
||||
|
||||
when ODIN_OS == .Linux {
|
||||
_sa_family_t :: distinct c.ushort
|
||||
@@ -363,11 +358,6 @@ 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
|
||||
@@ -499,26 +489,6 @@ 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
|
||||
|
||||
@@ -556,11 +526,7 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
|
||||
}
|
||||
|
||||
// The maximum backlog queue length for listen().
|
||||
when ODIN_OS == .Haiku {
|
||||
SOMAXCONN :: 32
|
||||
} else {
|
||||
SOMAXCONN :: 128
|
||||
}
|
||||
SOMAXCONN :: 128
|
||||
|
||||
when ODIN_OS == .Linux {
|
||||
MSG_CTRUNC :: 0x008
|
||||
@@ -586,18 +552,11 @@ 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
|
||||
}
|
||||
}
|
||||
|
||||
when ODIN_OS == .Haiku {
|
||||
AF_INET :: 1
|
||||
AF_UNIX :: 9
|
||||
} else {
|
||||
AF_INET :: 2
|
||||
AF_UNIX :: 1
|
||||
}
|
||||
AF_INET :: 2
|
||||
AF_UNIX :: 1
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
AF_INET6 :: 30
|
||||
@@ -607,8 +566,6 @@ 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -428,36 +428,6 @@ 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -78,15 +78,4 @@ 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
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
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 || ODIN_OS == .Haiku {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
|
||||
|
||||
tms :: struct {
|
||||
tms_utime: clock_t, /* [PSX] user CPU time */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
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 || ODIN_OS == .Haiku {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
|
||||
|
||||
iovec :: struct {
|
||||
iov_base: rawptr, /* [PSX] base address of I/O memory region */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -20,12 +20,4 @@ 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 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
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 || ODIN_OS == .Haiku {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD {
|
||||
|
||||
@(private)
|
||||
_SYS_NAMELEN :: 32 when ODIN_OS == .Haiku else 256
|
||||
_SYS_NAMELEN :: 256
|
||||
|
||||
utsname :: struct {
|
||||
sysname: [_SYS_NAMELEN]c.char `fmt:"s,0"`, /* [PSX] name of OS */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -443,55 +443,4 @@ when ODIN_OS == .Darwin {
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -138,31 +138,19 @@ CLocal_Flag_Bits :: enum tcflag_t {
|
||||
}
|
||||
CLocal_Flags :: bit_set[CLocal_Flag_Bits; tcflag_t]
|
||||
|
||||
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_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]
|
||||
|
||||
// character size mask
|
||||
@@ -610,151 +598,4 @@ 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
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -230,17 +230,6 @@ 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
@@ -2032,174 +2032,4 @@ when ODIN_OS == .Darwin {
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, windows, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, windows, darwin, netbsd, openbsd, freebsd
|
||||
package posix
|
||||
|
||||
import "core:c"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
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 || ODIN_OS == .Haiku {
|
||||
when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD || ODIN_OS == .Linux {
|
||||
|
||||
utimbuf :: struct {
|
||||
actime: time_t, /* [PSX] access time (seconds since epoch) */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#+private
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
package terminal
|
||||
|
||||
import "base:runtime"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#+private
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
package testing
|
||||
|
||||
/*
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#+build !freebsd
|
||||
#+build !openbsd
|
||||
#+build !netbsd
|
||||
#+build !haiku
|
||||
package testing
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||
#+private
|
||||
package testing
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
#+private
|
||||
package thread
|
||||
|
||||
@@ -83,7 +83,7 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
|
||||
// NOTE(tetra, 2019-11-01): These only fail if their argument is invalid.
|
||||
res = posix.pthread_attr_setdetachstate(&attrs, .CREATE_JOINABLE)
|
||||
assert(res == nil)
|
||||
when ODIN_OS != .Haiku && ODIN_OS != .NetBSD {
|
||||
when ODIN_OS != .NetBSD {
|
||||
res = posix.pthread_attr_setinheritsched(&attrs, .EXPLICIT_SCHED)
|
||||
assert(res == nil)
|
||||
}
|
||||
@@ -96,7 +96,7 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
|
||||
|
||||
// Set thread priority.
|
||||
policy: posix.Sched_Policy
|
||||
when ODIN_OS != .Haiku && ODIN_OS != .NetBSD {
|
||||
when ODIN_OS != .NetBSD {
|
||||
res = posix.pthread_attr_getschedpolicy(&attrs, &policy)
|
||||
assert(res == nil)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#+build !wasi
|
||||
#+build !windows
|
||||
#+build !orca
|
||||
#+build !haiku
|
||||
package time
|
||||
|
||||
_IS_SUPPORTED :: false
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#+private
|
||||
#+build darwin, freebsd, openbsd, netbsd, haiku
|
||||
#+build darwin, freebsd, openbsd, netbsd
|
||||
package time
|
||||
|
||||
import "core:sys/posix"
|
||||
|
||||
@@ -20,7 +20,6 @@ enum TargetOsKind : u16 {
|
||||
TargetOs_freebsd,
|
||||
TargetOs_openbsd,
|
||||
TargetOs_netbsd,
|
||||
TargetOs_haiku,
|
||||
|
||||
TargetOs_wasi,
|
||||
TargetOs_js,
|
||||
@@ -39,7 +38,6 @@ gb_global String target_os_names[TargetOs_COUNT] = {
|
||||
str_lit("freebsd"),
|
||||
str_lit("openbsd"),
|
||||
str_lit("netbsd"),
|
||||
str_lit("haiku"),
|
||||
|
||||
str_lit("wasi"),
|
||||
str_lit("js"),
|
||||
@@ -774,12 +772,6 @@ gb_global TargetMetrics target_netbsd_arm64 = {
|
||||
str_lit("aarch64-unknown-netbsd-elf"),
|
||||
};
|
||||
|
||||
gb_global TargetMetrics target_haiku_amd64 = {
|
||||
TargetOs_haiku,
|
||||
TargetArch_amd64,
|
||||
8, 8, AMD64_MAX_ALIGNMENT, 32,
|
||||
str_lit("x86_64-unknown-haiku"),
|
||||
};
|
||||
|
||||
gb_global TargetMetrics target_freestanding_wasm32 = {
|
||||
TargetOs_freestanding,
|
||||
@@ -906,7 +898,6 @@ gb_global NamedTargetMetrics named_targets[] = {
|
||||
{ str_lit("netbsd_arm64"), &target_netbsd_arm64 },
|
||||
|
||||
{ str_lit("openbsd_amd64"), &target_openbsd_amd64 },
|
||||
{ str_lit("haiku_amd64"), &target_haiku_amd64 },
|
||||
|
||||
{ str_lit("freestanding_wasm32"), &target_freestanding_wasm32 },
|
||||
{ str_lit("wasi_wasm32"), &target_wasi_wasm32 },
|
||||
@@ -1168,58 +1159,6 @@ gb_internal String internal_odin_root_dir(void) {
|
||||
return path;
|
||||
}
|
||||
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
|
||||
#include <FindDirectory.h>
|
||||
|
||||
gb_internal String path_to_fullpath(gbAllocator a, String s, bool *ok_);
|
||||
|
||||
gb_internal String internal_odin_root_dir(void) {
|
||||
String path = global_module_path;
|
||||
isize len, i;
|
||||
u8 *text;
|
||||
|
||||
if (global_module_path_set) {
|
||||
return global_module_path;
|
||||
}
|
||||
|
||||
TEMPORARY_ALLOCATOR_GUARD();
|
||||
auto path_buf = array_make<char>(temporary_allocator(), 300);
|
||||
|
||||
len = 0;
|
||||
for (;;) {
|
||||
u32 sz = path_buf.count;
|
||||
int res = find_path(B_APP_IMAGE_SYMBOL, B_FIND_PATH_IMAGE_PATH, nullptr, &path_buf[0], sz);
|
||||
if(res == B_OK) {
|
||||
len = sz;
|
||||
break;
|
||||
} else {
|
||||
array_resize(&path_buf, sz + 1);
|
||||
}
|
||||
}
|
||||
|
||||
mutex_lock(&string_buffer_mutex);
|
||||
defer (mutex_unlock(&string_buffer_mutex));
|
||||
|
||||
text = permanent_alloc_array<u8>(len + 1);
|
||||
gb_memmove(text, &path_buf[0], len);
|
||||
|
||||
path = path_to_fullpath(heap_allocator(), make_string(text, len), nullptr);
|
||||
|
||||
for (i = path.len-1; i >= 0; i--) {
|
||||
u8 c = path[i];
|
||||
if (c == '/' || c == '\\') {
|
||||
break;
|
||||
}
|
||||
path.len--;
|
||||
}
|
||||
|
||||
global_module_path = path;
|
||||
global_module_path_set = true;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
#elif defined(GB_SYSTEM_OSX)
|
||||
|
||||
#include <mach-o/dyld.h>
|
||||
@@ -1825,8 +1764,6 @@ gb_internal void init_build_context(TargetMetrics *cross_target, Subtarget subta
|
||||
#else
|
||||
metrics = &target_netbsd_amd64;
|
||||
#endif
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
metrics = &target_haiku_amd64;
|
||||
#elif defined(GB_CPU_ARM)
|
||||
metrics = &target_linux_arm64;
|
||||
#elif defined(GB_CPU_RISCV)
|
||||
@@ -2593,7 +2530,6 @@ gb_internal bool init_build_paths(String init_filename) {
|
||||
case TargetOs_freebsd:
|
||||
case TargetOs_openbsd:
|
||||
case TargetOs_netbsd:
|
||||
case TargetOs_haiku:
|
||||
gb_printf_err("-no-crt on Unix systems requires either -default-to-nil-allocator or -default-to-panic-allocator to also be present, because the default allocator requires CRT\n");
|
||||
no_crt_checks_failed = true;
|
||||
}
|
||||
@@ -2606,7 +2542,6 @@ gb_internal bool init_build_paths(String init_filename) {
|
||||
case TargetOs_freebsd:
|
||||
case TargetOs_openbsd:
|
||||
case TargetOs_netbsd:
|
||||
case TargetOs_haiku:
|
||||
gb_printf_err("-no-crt on Unix systems requires the -no-thread-local flag to also be present, because the TLS is inaccessible without CRT\n");
|
||||
no_crt_checks_failed = true;
|
||||
}
|
||||
|
||||
@@ -6598,7 +6598,6 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
|
||||
switch (build_context.metrics.os) {
|
||||
case TargetOs_darwin:
|
||||
case TargetOs_linux:
|
||||
case TargetOs_haiku:
|
||||
switch (build_context.metrics.arch) {
|
||||
case TargetArch_i386:
|
||||
case TargetArch_amd64:
|
||||
|
||||
@@ -1171,7 +1171,6 @@ gb_internal void init_universal(void) {
|
||||
{"Darwin", TargetOs_darwin},
|
||||
{"Linux", TargetOs_linux},
|
||||
{"FreeBSD", TargetOs_freebsd},
|
||||
{"Haiku", TargetOs_haiku},
|
||||
{"OpenBSD", TargetOs_openbsd},
|
||||
{"NetBSD", TargetOs_netbsd},
|
||||
{"WASI", TargetOs_wasi},
|
||||
|
||||
48
src/gb/gb.h
48
src/gb/gb.h
@@ -87,10 +87,6 @@ extern "C" {
|
||||
#ifndef GB_SYSTEM_NETBSD
|
||||
#define GB_SYSTEM_NETBSD 1
|
||||
#endif
|
||||
#elif defined(__HAIKU__) || defined(__haiku__)
|
||||
#ifndef GB_SYSTEM_HAIKU
|
||||
#define GB_SYSTEM_HAIKU 1
|
||||
#endif
|
||||
#else
|
||||
#error This UNIX operating system is not supported
|
||||
#endif
|
||||
@@ -219,7 +215,7 @@ extern "C" {
|
||||
#endif
|
||||
#include <stdlib.h> // NOTE(bill): malloc on linux
|
||||
#include <sys/mman.h>
|
||||
#if !defined(GB_SYSTEM_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__HAIKU__)
|
||||
#if !defined(GB_SYSTEM_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
|
||||
#include <sys/sendfile.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
@@ -267,13 +263,6 @@ extern "C" {
|
||||
#define lseek64 lseek
|
||||
#endif
|
||||
|
||||
#if defined(GB_SYSTEM_HAIKU)
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <kernel/OS.h>
|
||||
#define lseek64 lseek
|
||||
#endif
|
||||
|
||||
#if defined(GB_SYSTEM_UNIX)
|
||||
#include <semaphore.h>
|
||||
#endif
|
||||
@@ -847,13 +836,6 @@ typedef struct gbAffinity {
|
||||
isize thread_count;
|
||||
isize threads_per_core;
|
||||
} gbAffinity;
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
typedef struct gbAffinity {
|
||||
b32 is_accurate;
|
||||
isize core_count;
|
||||
isize thread_count;
|
||||
isize threads_per_core;
|
||||
} gbAffinity;
|
||||
#else
|
||||
#error TODO(bill): Unknown system
|
||||
#endif
|
||||
@@ -3042,8 +3024,6 @@ gb_inline u32 gb_thread_current_id(void) {
|
||||
__asm__("mov %%fs:0x10,%0" : "=r"(thread_id));
|
||||
#elif defined(GB_SYSTEM_LINUX)
|
||||
thread_id = gettid();
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
thread_id = find_thread(NULL);
|
||||
#elif defined(GB_SYSTEM_FREEBSD)
|
||||
thread_id = pthread_getthreadid_np();
|
||||
#elif defined(GB_SYSTEM_NETBSD)
|
||||
@@ -3256,9 +3236,6 @@ b32 gb_affinity_set(gbAffinity *a, isize core, isize thread_index) {
|
||||
//info.affinity_tag = cast(integer_t)index;
|
||||
//result = thread_policy_set(thread, THREAD_AFFINITY_POLICY, cast(thread_policy_t)&info, THREAD_AFFINITY_POLICY_COUNT);
|
||||
|
||||
#if !defined(GB_SYSTEM_HAIKU)
|
||||
result = pthread_setaffinity_np(thread, sizeof(cpuset_t), &mn);
|
||||
#endif
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
@@ -3339,29 +3316,6 @@ isize gb_affinity_thread_count_for_core(gbAffinity *a, isize core) {
|
||||
return a->threads_per_core;
|
||||
}
|
||||
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
#include <unistd.h>
|
||||
|
||||
void gb_affinity_init(gbAffinity *a) {
|
||||
a->core_count = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
a->threads_per_core = 1;
|
||||
a->is_accurate = a->core_count > 0;
|
||||
a->core_count = a->is_accurate ? a->core_count : 1;
|
||||
a->thread_count = a->core_count;
|
||||
}
|
||||
|
||||
void gb_affinity_destroy(gbAffinity *a) {
|
||||
gb_unused(a);
|
||||
}
|
||||
|
||||
b32 gb_affinity_set(gbAffinity *a, isize core, isize thread_index) {
|
||||
return true;
|
||||
}
|
||||
|
||||
isize gb_affinity_thread_count_for_core(gbAffinity *a, isize core) {
|
||||
GB_ASSERT(0 <= core && core < a->core_count);
|
||||
return a->threads_per_core;
|
||||
}
|
||||
#else
|
||||
#error TODO(bill): Unknown system
|
||||
#endif
|
||||
|
||||
@@ -791,11 +791,10 @@ try_cross_linking:;
|
||||
// Do not disable PIE, let the linker choose. (most likely you want it enabled)
|
||||
} else if (build_context.build_mode != BuildMode_DynamicLibrary) {
|
||||
if (build_context.metrics.os != TargetOs_openbsd
|
||||
&& build_context.metrics.os != TargetOs_haiku
|
||||
&& build_context.metrics.arch != TargetArch_riscv64
|
||||
&& !is_android
|
||||
) {
|
||||
// OpenBSD and Haiku default to PIE executable. do not pass -no-pie for it.
|
||||
// OpenBSD defaults to PIE executable, do not pass -no-pie for it.
|
||||
link_settings = gb_string_appendc(link_settings, "-no-pie ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3156,8 +3156,8 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
||||
|
||||
switch (build_context.reloc_mode) {
|
||||
case RelocMode_Default:
|
||||
if (build_context.metrics.os == TargetOs_openbsd || build_context.metrics.os == TargetOs_haiku) {
|
||||
// Always use PIC for OpenBSD and Haiku: they default to PIE
|
||||
if (build_context.metrics.os == TargetOs_openbsd) {
|
||||
// Always use PIC for OpenBSD: it defaults to PIE
|
||||
reloc_mode = LLVMRelocPIC;
|
||||
}
|
||||
|
||||
|
||||
@@ -400,7 +400,7 @@ gb_internal ReadDirectoryError read_directory(String path, Array<FileInfo> *fi)
|
||||
|
||||
return ReadDirectory_None;
|
||||
}
|
||||
#elif defined(GB_SYSTEM_LINUX) || defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_FREEBSD) || defined(GB_SYSTEM_OPENBSD) || defined(GB_SYSTEM_NETBSD) || defined(GB_SYSTEM_HAIKU)
|
||||
#elif defined(GB_SYSTEM_LINUX) || defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_FREEBSD) || defined(GB_SYSTEM_OPENBSD) || defined(GB_SYSTEM_NETBSD)
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
@@ -549,8 +549,6 @@ gb_internal u32 thread_current_id(void) {
|
||||
__asm__("mov %%fs:0x10,%0" : "=r"(thread_id));
|
||||
#elif defined(GB_SYSTEM_LINUX)
|
||||
thread_id = gettid();
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
thread_id = find_thread(NULL);
|
||||
#elif defined(GB_SYSTEM_FREEBSD)
|
||||
thread_id = pthread_getthreadid_np();
|
||||
#elif defined(GB_SYSTEM_NETBSD)
|
||||
@@ -1027,175 +1025,6 @@ gb_internal void futex_wait(Futex *f, Footex val) {
|
||||
} while (f->load() == val);
|
||||
}
|
||||
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
|
||||
// Futex implementation taken from https://tavianator.com/2023/futex.html
|
||||
|
||||
#include <pthread.h>
|
||||
#include <atomic>
|
||||
|
||||
struct _Spinlock {
|
||||
std::atomic_flag state;
|
||||
|
||||
void init() {
|
||||
state.clear();
|
||||
}
|
||||
|
||||
void lock() {
|
||||
while (state.test_and_set(std::memory_order_acquire)) {
|
||||
#if defined(GB_CPU_X86)
|
||||
_mm_pause();
|
||||
#else
|
||||
(void)0; // spin...
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
state.clear(std::memory_order_release);
|
||||
}
|
||||
};
|
||||
|
||||
struct Futex_Waitq;
|
||||
|
||||
struct Futex_Waiter {
|
||||
_Spinlock lock;
|
||||
pthread_t thread;
|
||||
Futex *futex;
|
||||
Futex_Waitq *waitq;
|
||||
Futex_Waiter *prev, *next;
|
||||
};
|
||||
|
||||
struct Futex_Waitq {
|
||||
_Spinlock lock;
|
||||
Futex_Waiter list;
|
||||
|
||||
void init() {
|
||||
auto head = &list;
|
||||
head->prev = head->next = head;
|
||||
}
|
||||
};
|
||||
|
||||
// FIXME: This approach may scale badly in the future,
|
||||
// possible solution - hash map (leads to deadlocks now).
|
||||
|
||||
Futex_Waitq g_waitq = {
|
||||
.lock = ATOMIC_FLAG_INIT,
|
||||
.list = {
|
||||
.prev = &g_waitq.list,
|
||||
.next = &g_waitq.list,
|
||||
},
|
||||
};
|
||||
|
||||
Futex_Waitq *get_waitq(Futex *f) {
|
||||
// Future hash map method...
|
||||
return &g_waitq;
|
||||
}
|
||||
|
||||
void futex_signal(Futex *f) {
|
||||
auto waitq = get_waitq(f);
|
||||
|
||||
waitq->lock.lock();
|
||||
|
||||
auto head = &waitq->list;
|
||||
for (auto waiter = head->next; waiter != head; waiter = waiter->next) {
|
||||
if (waiter->futex != f) {
|
||||
continue;
|
||||
}
|
||||
waitq->lock.unlock();
|
||||
pthread_kill(waiter->thread, SIGCONT);
|
||||
return;
|
||||
}
|
||||
|
||||
waitq->lock.unlock();
|
||||
}
|
||||
|
||||
void futex_broadcast(Futex *f) {
|
||||
auto waitq = get_waitq(f);
|
||||
|
||||
waitq->lock.lock();
|
||||
|
||||
auto head = &waitq->list;
|
||||
for (auto waiter = head->next; waiter != head; waiter = waiter->next) {
|
||||
if (waiter->futex != f) {
|
||||
continue;
|
||||
}
|
||||
if (waiter->next == head) {
|
||||
waitq->lock.unlock();
|
||||
pthread_kill(waiter->thread, SIGCONT);
|
||||
return;
|
||||
} else {
|
||||
pthread_kill(waiter->thread, SIGCONT);
|
||||
}
|
||||
}
|
||||
|
||||
waitq->lock.unlock();
|
||||
}
|
||||
|
||||
void futex_wait(Futex *f, Footex val) {
|
||||
Futex_Waiter waiter;
|
||||
waiter.thread = pthread_self();
|
||||
waiter.futex = f;
|
||||
|
||||
auto waitq = get_waitq(f);
|
||||
while (waitq->lock.state.test_and_set(std::memory_order_acquire)) {
|
||||
if (f->load(std::memory_order_relaxed) != val) {
|
||||
return;
|
||||
}
|
||||
#if defined(GB_CPU_X86)
|
||||
_mm_pause();
|
||||
#else
|
||||
(void)0; // spin...
|
||||
#endif
|
||||
}
|
||||
|
||||
waiter.waitq = waitq;
|
||||
waiter.lock.init();
|
||||
waiter.lock.lock();
|
||||
|
||||
auto head = &waitq->list;
|
||||
waiter.prev = head->prev;
|
||||
waiter.next = head;
|
||||
waiter.prev->next = &waiter;
|
||||
waiter.next->prev = &waiter;
|
||||
|
||||
waiter.prev->next = &waiter;
|
||||
waiter.next->prev = &waiter;
|
||||
|
||||
sigset_t old_mask, mask;
|
||||
sigemptyset(&mask);
|
||||
sigaddset(&mask, SIGCONT);
|
||||
pthread_sigmask(SIG_BLOCK, &mask, &old_mask);
|
||||
|
||||
if (f->load(std::memory_order_relaxed) == val) {
|
||||
waiter.lock.unlock();
|
||||
waitq->lock.unlock();
|
||||
|
||||
int sig;
|
||||
sigwait(&mask, &sig);
|
||||
|
||||
waitq->lock.lock();
|
||||
waiter.lock.lock();
|
||||
|
||||
while (waitq != waiter.waitq) {
|
||||
auto req = waiter.waitq;
|
||||
waiter.lock.unlock();
|
||||
waitq->lock.unlock();
|
||||
waitq = req;
|
||||
waitq->lock.lock();
|
||||
waiter.lock.lock();
|
||||
}
|
||||
}
|
||||
|
||||
waiter.prev->next = waiter.next;
|
||||
waiter.next->prev = waiter.prev;
|
||||
|
||||
pthread_sigmask(SIG_SETMASK, &old_mask, NULL);
|
||||
|
||||
waiter.lock.unlock();
|
||||
waitq->lock.unlock();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
|
||||
@@ -34,7 +34,7 @@ package main
|
||||
},
|
||||
}, {// [2]
|
||||
src = `
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
#+build arm32, arm64
|
||||
package main
|
||||
`,
|
||||
@@ -45,7 +45,6 @@ package main
|
||||
{os = {.FreeBSD}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
||||
{os = {.OpenBSD}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
||||
{os = {.NetBSD}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
||||
{os = {.Haiku}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
||||
parser.BUILD_KIND_NEWLINE_MARKER,
|
||||
{os = runtime.ALL_ODIN_OS_TYPES, arch = {.arm32}},
|
||||
{os = runtime.ALL_ODIN_OS_TYPES, arch = {.arm64}},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
package tests_core_posix
|
||||
|
||||
import "core:log"
|
||||
@@ -65,17 +65,8 @@ test_dirent :: proc(t: ^testing.T) {
|
||||
for entry in entries {
|
||||
defer posix.free(entry)
|
||||
|
||||
when ODIN_OS == .Haiku {
|
||||
stat: posix.stat_t
|
||||
posix.stat(cstring(raw_data(entry.d_name[:])), &stat)
|
||||
|
||||
if !posix.S_ISREG(stat.st_mode) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
if entry.d_type != .REG {
|
||||
continue
|
||||
}
|
||||
if entry.d_type != .REG {
|
||||
continue
|
||||
}
|
||||
|
||||
name := string(cstring(raw_data(entry.d_name[:])))
|
||||
@@ -95,17 +86,8 @@ test_dirent :: proc(t: ^testing.T) {
|
||||
break
|
||||
}
|
||||
|
||||
when ODIN_OS == .Haiku {
|
||||
stat: posix.stat_t
|
||||
posix.stat(cstring(raw_data(entry.d_name[:])), &stat)
|
||||
|
||||
if !posix.S_ISREG(stat.st_mode) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
if entry.d_type != .REG {
|
||||
continue
|
||||
}
|
||||
if entry.d_type != .REG {
|
||||
continue
|
||||
}
|
||||
|
||||
name := string(cstring(raw_data(entry.d_name[:])))
|
||||
@@ -165,8 +147,8 @@ test_libgen :: proc(t: ^testing.T) {
|
||||
{ "///", "/", "/" },
|
||||
{ "/usr/", "/", "usr" },
|
||||
{ "/usr/lib", "/usr", "lib" },
|
||||
{ "//usr//lib//", "//usr" + ("/" when ODIN_OS == .Haiku else ""), "lib" },
|
||||
{ "/home//dwc//test", "/home//dwc" + ("/" when ODIN_OS == .Haiku else ""), "test" },
|
||||
{ "//usr//lib//", "//usr", "lib" },
|
||||
{ "/home//dwc//test", "/home//dwc", "test" },
|
||||
}
|
||||
|
||||
for test in tests {
|
||||
@@ -259,4 +241,4 @@ open_permissions :: proc(t: ^testing.T) {
|
||||
stat: posix.stat_t
|
||||
res := posix.fstat(fd, &stat)
|
||||
testing.expectf(t, res == .OK, "failed to stat: %v", posix.strerror())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
package tests_core_posix
|
||||
|
||||
import "core:log"
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
#include <poll.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#ifndef __HAIKU__
|
||||
#include <sys/shm.h>
|
||||
#endif
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
@@ -31,9 +29,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <utime.h>
|
||||
|
||||
#ifndef __HAIKU__
|
||||
#include <wordexp.h>
|
||||
#endif
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
@@ -78,9 +74,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf("passwd %zu %zu\n", sizeof(struct passwd), _Alignof(struct passwd));
|
||||
|
||||
#ifndef __HAIKU__
|
||||
printf("shmid_ds %zu %zu\n", sizeof(struct shmid_ds), _Alignof(struct shmid_ds));
|
||||
#endif
|
||||
|
||||
printf("ipc_perm %zu %zu\n", sizeof(struct ipc_perm), _Alignof(struct ipc_perm));
|
||||
printf("msqid_ds %zu %zu\n", sizeof(struct msqid_ds), _Alignof(struct msqid_ds));
|
||||
@@ -114,9 +108,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf("utimbuf %zu %zu\n", sizeof(struct utimbuf), _Alignof(struct utimbuf));
|
||||
|
||||
#ifndef __HAIKU__
|
||||
printf("wordexp_t %zu %zu\n", sizeof(wordexp_t), _Alignof(wordexp_t));
|
||||
#endif
|
||||
|
||||
printf("time_t %zu %zu\n", sizeof(time_t), _Alignof(time_t));
|
||||
printf("timespec %zu %zu\n", sizeof(struct timespec), _Alignof(struct timespec));
|
||||
|
||||
@@ -45,9 +45,7 @@ main :: proc() {
|
||||
|
||||
fmt.println("passwd", size_of(posix.passwd), align_of(posix.passwd))
|
||||
|
||||
when ODIN_OS != .Haiku {
|
||||
fmt.println("shmid_ds", size_of(posix.shmid_ds), align_of(posix.shmid_ds))
|
||||
}
|
||||
fmt.println("shmid_ds", size_of(posix.shmid_ds), align_of(posix.shmid_ds))
|
||||
|
||||
fmt.println("ipc_perm", size_of(posix.ipc_perm), align_of(posix.ipc_perm))
|
||||
fmt.println("msqid_ds", size_of(posix.msqid_ds), align_of(posix.msqid_ds))
|
||||
@@ -81,9 +79,7 @@ main :: proc() {
|
||||
|
||||
fmt.println("utimbuf", size_of(posix.utimbuf), align_of(posix.utimbuf))
|
||||
|
||||
when ODIN_OS != .Haiku {
|
||||
fmt.println("wordexp_t", size_of(posix.wordexp_t), align_of(posix.wordexp_t))
|
||||
}
|
||||
fmt.println("wordexp_t", size_of(posix.wordexp_t), align_of(posix.wordexp_t))
|
||||
|
||||
fmt.println("time_t", size_of(posix.time_t), align_of(posix.time_t))
|
||||
fmt.println("timespec", size_of(posix.timespec), align_of(posix.timespec))
|
||||
|
||||
37
vendor/directx/dxc/dxcdef_haiku.odin
vendored
37
vendor/directx/dxc/dxcdef_haiku.odin
vendored
@@ -1,37 +0,0 @@
|
||||
#+build haiku
|
||||
package directx_dxc
|
||||
import "core:c"
|
||||
|
||||
FILETIME :: struct {
|
||||
dwLowDateTime: DWORD,
|
||||
dwHighDateTime: DWORD,
|
||||
}
|
||||
|
||||
GUID :: struct {
|
||||
Data1: DWORD,
|
||||
Data2: WORD,
|
||||
Data3: WORD,
|
||||
Data4: [8]BYTE,
|
||||
}
|
||||
|
||||
BYTE :: distinct u8
|
||||
WORD :: u16
|
||||
DWORD :: u32
|
||||
BOOL :: distinct b32
|
||||
SIZE_T :: uint
|
||||
ULONG :: c.ulong
|
||||
CLSID :: GUID
|
||||
IID :: GUID
|
||||
LONG :: distinct c.long
|
||||
HRESULT :: distinct LONG
|
||||
wstring :: [^]c.wchar_t
|
||||
BSTR :: wstring
|
||||
|
||||
IUnknown :: struct {
|
||||
using _iunknown_vtable: ^IUnknown_VTable,
|
||||
}
|
||||
IUnknown_VTable :: struct {
|
||||
QueryInterface: proc "c" (this: ^IUnknown, riid: ^IID, ppvObject: ^rawptr) -> HRESULT,
|
||||
AddRef: proc "c" (this: ^IUnknown) -> ULONG,
|
||||
Release: proc "c" (this: ^IUnknown) -> ULONG,
|
||||
}
|
||||
Reference in New Issue
Block a user