add support for linux_riscv64 and freestanding_riscv64

This commit is contained in:
Laytan
2024-08-20 14:06:40 +02:00
committed by Laytan Laats
parent 29838da782
commit ca6ef95b03
28 changed files with 1395 additions and 116 deletions
@@ -3,7 +3,7 @@ package chacha20_simd128
import "base:intrinsics"
import "core:crypto/_chacha20"
import "core:simd"
import "core:sys/info"
@(require) import "core:sys/info"
// Portable 128-bit `core:simd` implementation.
//
+2 -2
View File
@@ -33,8 +33,8 @@ Socket_Option :: enum c.int {
Linger = c.int(linux.Socket_Option.LINGER),
Receive_Buffer_Size = c.int(linux.Socket_Option.RCVBUF),
Send_Buffer_Size = c.int(linux.Socket_Option.SNDBUF),
Receive_Timeout = c.int(linux.Socket_Option.RCVTIMEO_NEW),
Send_Timeout = c.int(linux.Socket_Option.SNDTIMEO_NEW),
Receive_Timeout = c.int(linux.Socket_Option.RCVTIMEO),
Send_Timeout = c.int(linux.Socket_Option.SNDTIMEO),
}
// Wrappers and unwrappers for system-native types
+19
View File
@@ -284,6 +284,25 @@ when ODIN_ARCH == .arm64 {
_reserved: [2]i32,
}
#assert(size_of(OS_Stat) == 128)
} else when ODIN_ARCH == .riscv64 {
OS_Stat :: struct {
device_id: u64,
serial: u64,
mode: u32,
nlink: u32,
uid: u32,
gid: u32,
rdev: u64,
_: u64,
size: i64,
block_size: i32,
_: i32,
blocks: i64,
last_access: Unix_File_Time,
modified: Unix_File_Time,
status_change: Unix_File_Time,
_: [3]uint,
}
} else {
OS_Stat :: struct {
device_id: u64, // ID of device containing file
+46
View File
@@ -0,0 +1,46 @@
//+build riscv64
//+build linux
package sysinfo
import "base:intrinsics"
import "core:sys/linux"
@(init, private)
init_cpu_features :: proc() {
fd, err := linux.open("/proc/self/auxv", {})
if err != .NONE { return }
defer linux.close(fd)
// This is probably enough right?
buf: [4096]byte
n, rerr := linux.read(fd, buf[:])
if rerr != .NONE || n == 0 { return }
ulong :: u64
AT_HWCAP :: 16
// TODO: using these we could get more information than just the basics.
// AT_HWCAP2 :: 26
// AT_HWCAP3 :: 29
// AT_HWCAP4 :: 30
auxv := buf[:n]
for len(auxv) >= size_of(ulong)*2 {
key := intrinsics.unaligned_load((^ulong)(&auxv[0]))
val := intrinsics.unaligned_load((^ulong)(&auxv[size_of(ulong)]))
auxv = auxv[2*size_of(ulong):]
if key != AT_HWCAP {
continue
}
cpu_features = transmute(CPU_Features)(val)
break
}
}
@(init, private)
init_cpu_name :: proc() {
cpu_name = "RISCV64"
}
+16
View File
@@ -0,0 +1,16 @@
package sysinfo
CPU_Feature :: enum u64 {
I = 'I' - 'A', // Base features, don't think this is ever not here.
M = 'M' - 'A', // Integer multiplication and division, currently required by Odin.
A = 'A' - 'A', // Atomics.
F = 'F' - 'A', // Single precision floating point, currently required by Odin.
D = 'D' - 'A', // Double precision floating point, currently required by Odin.
C = 'C' - 'A', // Compressed instructions.
V = 'V' - 'A', // Vector operations.
}
CPU_Features :: distinct bit_set[CPU_Feature; u64]
cpu_features: Maybe(CPU_Features)
cpu_name: Maybe(string)
+1 -1
View File
@@ -1,6 +1,6 @@
package sysinfo
when !(ODIN_ARCH == .amd64 || ODIN_ARCH == .i386 || ODIN_ARCH == .arm32 || ODIN_ARCH == .arm64) {
when !(ODIN_ARCH == .amd64 || ODIN_ARCH == .i386 || ODIN_ARCH == .arm32 || ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64) {
#assert(false, "This package is unsupported on this architecture.")
}
+8 -6
View File
@@ -1343,14 +1343,16 @@ Socket_Option :: enum {
RESERVE_MEM = 73,
TXREHASH = 74,
RCVMARK = 75,
// Hardcoded 64-bit Time. It's time to move on.
TIMESTAMP = TIMESTAMP_NEW,
TIMESTAMPNS = TIMESTAMPNS_NEW,
TIMESTAMPING = TIMESTAMPING_NEW,
RCVTIMEO = RCVTIMEO_NEW,
SNDTIMEO = SNDTIMEO_NEW,
TIMESTAMP = TIMESTAMP_OLD when _SOCKET_OPTION_OLD else TIMESTAMP_NEW,
TIMESTAMPNS = TIMESTAMPNS_OLD when _SOCKET_OPTION_OLD else TIMESTAMPNS_NEW,
TIMESTAMPING = TIMESTAMPING_OLD when _SOCKET_OPTION_OLD else TIMESTAMPING_NEW,
RCVTIMEO = RCVTIMEO_OLD when _SOCKET_OPTION_OLD else RCVTIMEO_NEW,
SNDTIMEO = SNDTIMEO_OLD when _SOCKET_OPTION_OLD else SNDTIMEO_NEW,
}
@(private)
_SOCKET_OPTION_OLD :: size_of(rawptr) == 8 /* || size_of(time_t) == size_of(__kernel_long_t) */
Socket_UDP_Option :: enum {
CORK = 1,
ENCAP = 100,
+27 -27
View File
@@ -39,7 +39,7 @@ write :: proc "contextless" (fd: Fd, buf: []u8) -> (int, Errno) {
On ARM64 available since Linux 2.6.16.
*/
open :: proc "contextless" (name: cstring, flags: Open_Flags, mode: Mode = {}) -> (Fd, Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_openat, AT_FDCWD, transmute(uintptr) name, transmute(u32) flags, transmute(u32) mode)
return errno_unwrap(ret, Fd)
} else {
@@ -68,7 +68,7 @@ close :: proc "contextless" (fd: Fd) -> (Errno) {
*/
stat :: proc "contextless" (filename: cstring, stat: ^Stat) -> (Errno) {
when size_of(int) == 8 {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_fstatat, AT_FDCWD, cast(rawptr) filename, stat, 0)
return Errno(-ret)
} else {
@@ -111,7 +111,7 @@ fstat :: proc "contextless" (fd: Fd, stat: ^Stat) -> (Errno) {
*/
lstat :: proc "contextless" (filename: cstring, stat: ^Stat) -> (Errno) {
when size_of(int) == 8 {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
return fstatat(AT_FDCWD, filename, stat, {.SYMLINK_NOFOLLOW})
} else {
ret := syscall(SYS_lstat, cast(rawptr) filename, stat)
@@ -128,7 +128,7 @@ lstat :: proc "contextless" (filename: cstring, stat: ^Stat) -> (Errno) {
Available since Linux 2.2.
*/
poll :: proc "contextless" (fds: []Poll_Fd, timeout: i32) -> (i32, Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
seconds := cast(uint) timeout / 1000
nanoseconds := cast(uint) (timeout % 1000) * 1_000_000
timeout_spec := Time_Spec{seconds, nanoseconds}
@@ -291,7 +291,7 @@ writev :: proc "contextless" (fd: Fd, iov: []IO_Vec) -> (int, Errno) {
For ARM64 available since Linux 2.6.16.
*/
access :: proc "contextless" (name: cstring, mode: Mode = F_OK) -> (Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_faccessat, AT_FDCWD, cast(rawptr) name, transmute(u32) mode)
return Errno(-ret)
} else {
@@ -407,7 +407,7 @@ dup :: proc "contextless" (fd: Fd) -> (Fd, Errno) {
On ARM64 available since Linux 2.6.27.
*/
dup2 :: proc "contextless" (old: Fd, new: Fd) -> (Fd, Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_dup3, old, new, 0)
return errno_unwrap(ret, Fd)
} else {
@@ -422,7 +422,7 @@ dup2 :: proc "contextless" (old: Fd, new: Fd) -> (Fd, Errno) {
On ARM64 available since Linux 2.6.16.
*/
pause :: proc "contextless" () {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
syscall(SYS_ppoll, 0, 0, 0, 0)
} else {
syscall(SYS_pause)
@@ -452,7 +452,7 @@ getitimer :: proc "contextless" (which: ITimer_Which, cur: ^ITimer_Val) -> (Errn
Available since Linux 1.0.
*/
alarm :: proc "contextless" (seconds: u32) -> u32 {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
new := ITimer_Val { value = { seconds = cast(int) seconds } }
old := ITimer_Val {}
syscall(SYS_setitimer, ITimer_Which.REAL, &new, &old)
@@ -765,7 +765,7 @@ getsockopt :: proc {
Available since Linux 1.0.
*/
fork :: proc "contextless" () -> (Pid, Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_clone, u64(Signal.SIGCHLD), cast(rawptr) nil, cast(rawptr) nil, cast(rawptr) nil, u64(0))
return errno_unwrap(ret, Pid)
} else {
@@ -779,7 +779,7 @@ fork :: proc "contextless" () -> (Pid, Errno) {
Available since Linux 2.2.
*/
vfork :: proc "contextless" () -> Pid {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return Pid(syscall(SYS_vfork))
} else {
return Pid(syscall(SYS_clone, Signal.SIGCHLD))
@@ -792,7 +792,7 @@ vfork :: proc "contextless" () -> Pid {
On ARM64 available since Linux 3.19.
*/
execve :: proc "contextless" (name: cstring, argv: [^]cstring, envp: [^]cstring) -> (Errno) {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
ret := syscall(SYS_execve, cast(rawptr) name, cast(rawptr) argv, cast(rawptr) envp)
return Errno(-ret)
} else {
@@ -1193,7 +1193,7 @@ fchdir :: proc "contextless" (fd: Fd) -> (Errno) {
On ARM64 available since Linux 2.6.16.
*/
rename :: proc "contextless" (old: cstring, new: cstring) -> (Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_renameat, AT_FDCWD, cast(rawptr) old, AT_FDCWD, cast(rawptr) new)
return Errno(-ret)
} else {
@@ -1208,7 +1208,7 @@ rename :: proc "contextless" (old: cstring, new: cstring) -> (Errno) {
On ARM64 available since Linux 2.6.16.
*/
mkdir :: proc "contextless" (name: cstring, mode: Mode) -> (Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_mkdirat, AT_FDCWD, cast(rawptr) name, transmute(u32) mode)
return Errno(-ret)
} else {
@@ -1223,7 +1223,7 @@ mkdir :: proc "contextless" (name: cstring, mode: Mode) -> (Errno) {
On ARM64 available since Linux 2.6.16.
*/
rmdir :: proc "contextless" (name: cstring) -> (Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_unlinkat, AT_FDCWD, cast(rawptr) name, transmute(i32) FD_Flags{.REMOVEDIR})
return Errno(-ret)
} else {
@@ -1238,7 +1238,7 @@ rmdir :: proc "contextless" (name: cstring) -> (Errno) {
On ARM64 available since Linux 2.6.16.
*/
creat :: proc "contextless" (name: cstring, mode: Mode) -> (Fd, Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
return openat(AT_FDCWD, name, {.CREAT, .WRONLY,.TRUNC}, mode)
} else {
ret := syscall(SYS_creat, cast(rawptr) name, transmute(u32) mode)
@@ -1252,7 +1252,7 @@ creat :: proc "contextless" (name: cstring, mode: Mode) -> (Fd, Errno) {
On ARM64 available since Linux 2.6.16.
*/
link :: proc "contextless" (target: cstring, linkpath: cstring) -> (Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_linkat, AT_FDCWD, cast(rawptr) target, AT_FDCWD, cast(rawptr) linkpath, 0)
return Errno(-ret)
} else {
@@ -1267,7 +1267,7 @@ link :: proc "contextless" (target: cstring, linkpath: cstring) -> (Errno) {
On ARM64 available since Linux 2.6.16.
*/
unlink :: proc "contextless" (name: cstring) -> (Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_unlinkat, AT_FDCWD, cast(rawptr) name, 0)
return Errno(-ret)
} else {
@@ -1282,7 +1282,7 @@ unlink :: proc "contextless" (name: cstring) -> (Errno) {
On arm64 available since Linux 2.6.16.
*/
symlink :: proc "contextless" (target: cstring, linkpath: cstring) -> (Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_symlinkat, cast(rawptr) target, AT_FDCWD, cast(rawptr) linkpath)
return Errno(-ret)
} else {
@@ -1297,7 +1297,7 @@ symlink :: proc "contextless" (target: cstring, linkpath: cstring) -> (Errno) {
On arm64 available since Linux 2.6.16.
*/
readlink :: proc "contextless" (name: cstring, buf: []u8) -> (int, Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_readlinkat, AT_FDCWD, cast(rawptr) name, raw_data(buf), len(buf))
return errno_unwrap(ret, int)
} else {
@@ -1312,7 +1312,7 @@ readlink :: proc "contextless" (name: cstring, buf: []u8) -> (int, Errno) {
On ARM64 available since Linux 2.6.16.
*/
chmod :: proc "contextless" (name: cstring, mode: Mode) -> (Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_fchmodat, AT_FDCWD, cast(rawptr) name, transmute(u32) mode)
return Errno(-ret)
} else {
@@ -1340,7 +1340,7 @@ chown :: proc "contextless" (name: cstring, uid: Uid, gid: Gid) -> (Errno) {
when size_of(int) == 4 {
ret := syscall(SYS_chown32, cast(rawptr) name, uid, gid)
return Errno(-ret)
} else when ODIN_ARCH == .arm64 {
} else when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_fchownat, AT_FDCWD, cast(rawptr) name, uid, gid, 0)
return Errno(-ret)
} else {
@@ -1374,7 +1374,7 @@ lchown :: proc "contextless" (name: cstring, uid: Uid, gid: Gid) -> (Errno) {
when size_of(int) == 4 {
ret := syscall(SYS_lchown32, cast(rawptr) name, uid, gid)
return Errno(-ret)
} else when ODIN_ARCH == .arm64 {
} else when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_fchownat, AT_FDCWD, cast(rawptr) name, uid, gid, transmute(i32) FD_Flags{.SYMLINK_NOFOLLOW})
return Errno(-ret)
} else {
@@ -1727,7 +1727,7 @@ getppid :: proc "contextless" () -> Pid {
Available since Linux 1.0.
*/
getpgrp :: proc "contextless" () -> (Pid, Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_getpgid, 0)
return errno_unwrap(ret, Pid)
} else {
@@ -1950,7 +1950,7 @@ sigaltstack :: proc "contextless" (stack: ^Sig_Stack, old_stack: ^Sig_Stack) ->
On ARM64 available since Linux 2.6.16.
*/
mknod :: proc "contextless" (name: cstring, mode: Mode, dev: Dev) -> (Errno) {
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_mknodat, AT_FDCWD, cast(rawptr) name, transmute(u32) mode, dev)
return Errno(-ret)
} else {
@@ -2207,7 +2207,7 @@ gettid :: proc "contextless" () -> Pid {
Available since Linux 1.0.
*/
time :: proc "contextless" (tloc: ^uint) -> (Errno) {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
ret := syscall(SYS_time, tloc)
return Errno(-ret)
} else {
@@ -2335,7 +2335,7 @@ futex :: proc{
Available since Linux 2.6.
*/
epoll_create :: proc(size: i32 = 1) -> (Fd, Errno) {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
ret := syscall(SYS_epoll_create, i32(1))
return errno_unwrap(ret, Fd)
} else {
@@ -2433,7 +2433,7 @@ exit_group :: proc "contextless" (code: i32) -> ! {
Available since Linux 2.6.
*/
epoll_wait :: proc(epfd: Fd, events: [^]EPoll_Event, count: i32, timeout: i32) -> (i32, Errno) {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
ret := syscall(SYS_epoll_wait, epfd, events, count, timeout)
return errno_unwrap(ret, i32)
} else {
+334
View File
@@ -0,0 +1,334 @@
//+build riscv64
package linux
// https://github.com/riscv-collab/riscv-gnu-toolchain/blob/master/linux-headers/include/asm-generic/unistd.h
SYS_io_setup :: uintptr(0)
SYS_io_destroy :: uintptr(1)
SYS_io_submit :: uintptr(2)
SYS_io_cancel :: uintptr(3)
SYS_io_getevents :: uintptr(4)
SYS_setxattr :: uintptr(5)
SYS_lsetxattr :: uintptr(6)
SYS_fsetxattr :: uintptr(7)
SYS_getxattr :: uintptr(8)
SYS_lgetxattr :: uintptr(9)
SYS_fgetxattr :: uintptr(10)
SYS_listxattr :: uintptr(11)
SYS_llistxattr :: uintptr(12)
SYS_flistxattr :: uintptr(13)
SYS_removexattr :: uintptr(14)
SYS_lremovexattr :: uintptr(15)
SYS_fremovexattr :: uintptr(16)
SYS_getcwd :: uintptr(17)
SYS_lookup_dcookie :: uintptr(18)
SYS_eventfd2 :: uintptr(19)
SYS_epoll_create1 :: uintptr(20)
SYS_epoll_ctl :: uintptr(21)
SYS_epoll_pwait :: uintptr(22)
SYS_dup :: uintptr(23)
SYS_dup3 :: uintptr(24)
SYS_fcntl :: uintptr(25)
SYS_inotify_init1 :: uintptr(26)
SYS_inotify_add_watch :: uintptr(27)
SYS_inotify_rm_watch :: uintptr(28)
SYS_ioctl :: uintptr(29)
SYS_ioprio_set :: uintptr(30)
SYS_ioprio_get :: uintptr(31)
SYS_flock :: uintptr(32)
SYS_mknodat :: uintptr(33)
SYS_mkdirat :: uintptr(34)
SYS_unlinkat :: uintptr(35)
SYS_symlinkat :: uintptr(36)
SYS_linkat :: uintptr(37)
SYS_renameat :: uintptr(38)
SYS_umount2 :: uintptr(39)
SYS_mount :: uintptr(40)
SYS_pivot_root :: uintptr(41)
SYS_nfsservctl :: uintptr(42)
SYS_statfs :: uintptr(43)
SYS_fstatfs :: uintptr(44)
SYS_truncate :: uintptr(45)
SYS_ftruncate :: uintptr(46)
SYS_fallocate :: uintptr(47)
SYS_faccessat :: uintptr(48)
SYS_chdir :: uintptr(49)
SYS_fchdir :: uintptr(50)
SYS_chroot :: uintptr(51)
SYS_fchmod :: uintptr(52)
SYS_fchmodat :: uintptr(53)
SYS_fchownat :: uintptr(54)
SYS_fchown :: uintptr(55)
SYS_openat :: uintptr(56)
SYS_close :: uintptr(57)
SYS_vhangup :: uintptr(58)
SYS_pipe2 :: uintptr(59)
SYS_quotactl :: uintptr(60)
SYS_getdents64 :: uintptr(61)
SYS_lseek :: uintptr(62)
SYS_read :: uintptr(63)
SYS_write :: uintptr(64)
SYS_readv :: uintptr(65)
SYS_writev :: uintptr(66)
SYS_pread64 :: uintptr(67)
SYS_pwrite64 :: uintptr(68)
SYS_preadv :: uintptr(69)
SYS_pwritev :: uintptr(70)
SYS_sendfile :: uintptr(71)
SYS_pselect6 :: uintptr(72)
SYS_ppoll :: uintptr(73)
SYS_signalfd4 :: uintptr(74)
SYS_vmsplice :: uintptr(75)
SYS_splice :: uintptr(76)
SYS_tee :: uintptr(77)
SYS_readlinkat :: uintptr(78)
SYS_fstatat :: uintptr(79)
SYS_fstat :: uintptr(80)
SYS_sync :: uintptr(81)
SYS_fsync :: uintptr(82)
SYS_fdatasync :: uintptr(83)
SYS_sync_file_range2 :: uintptr(84)
SYS_sync_file_range :: uintptr(84)
SYS_timerfd_create :: uintptr(85)
SYS_timerfd_settime :: uintptr(86)
SYS_timerfd_gettime :: uintptr(87)
SYS_utimensat :: uintptr(88)
SYS_acct :: uintptr(89)
SYS_capget :: uintptr(90)
SYS_capset :: uintptr(91)
SYS_personality :: uintptr(92)
SYS_exit :: uintptr(93)
SYS_exit_group :: uintptr(94)
SYS_waitid :: uintptr(95)
SYS_set_tid_address :: uintptr(96)
SYS_unshare :: uintptr(97)
SYS_futex :: uintptr(98)
SYS_set_robust_list :: uintptr(99)
SYS_get_robust_list :: uintptr(100)
SYS_nanosleep :: uintptr(101)
SYS_getitimer :: uintptr(102)
SYS_setitimer :: uintptr(103)
SYS_kexec_load :: uintptr(104)
SYS_init_module :: uintptr(105)
SYS_delete_module :: uintptr(106)
SYS_timer_create :: uintptr(107)
SYS_timer_gettime :: uintptr(108)
SYS_timer_getoverrun :: uintptr(109)
SYS_timer_settime :: uintptr(110)
SYS_timer_delete :: uintptr(111)
SYS_clock_settime :: uintptr(112)
SYS_clock_gettime :: uintptr(113)
SYS_clock_getres :: uintptr(114)
SYS_clock_nanosleep :: uintptr(115)
SYS_syslog :: uintptr(116)
SYS_ptrace :: uintptr(117)
SYS_sched_setparam :: uintptr(118)
SYS_sched_setscheduler :: uintptr(119)
SYS_sched_getscheduler :: uintptr(120)
SYS_sched_getparam :: uintptr(121)
SYS_sched_setaffinity :: uintptr(122)
SYS_sched_getaffinity :: uintptr(123)
SYS_sched_yield :: uintptr(124)
SYS_sched_get_priority_max :: uintptr(125)
SYS_sched_get_priority_min :: uintptr(126)
SYS_sched_rr_get_interval :: uintptr(127)
SYS_restart_syscall :: uintptr(128)
SYS_kill :: uintptr(129)
SYS_tkill :: uintptr(130)
SYS_tgkill :: uintptr(131)
SYS_sigaltstack :: uintptr(132)
SYS_rt_sigsuspend :: uintptr(133)
SYS_rt_sigaction :: uintptr(134)
SYS_rt_sigprocmask :: uintptr(135)
SYS_rt_sigpending :: uintptr(136)
SYS_rt_sigtimedwait :: uintptr(137)
SYS_rt_sigqueueinfo :: uintptr(138)
SYS_rt_sigreturn :: uintptr(139)
SYS_setpriority :: uintptr(140)
SYS_getpriority :: uintptr(141)
SYS_reboot :: uintptr(142)
SYS_setregid :: uintptr(143)
SYS_setgid :: uintptr(144)
SYS_setreuid :: uintptr(145)
SYS_setuid :: uintptr(146)
SYS_setresuid :: uintptr(147)
SYS_getresuid :: uintptr(148)
SYS_setresgid :: uintptr(149)
SYS_getresgid :: uintptr(150)
SYS_setfsuid :: uintptr(151)
SYS_setfsgid :: uintptr(152)
SYS_times :: uintptr(153)
SYS_setpgid :: uintptr(154)
SYS_getpgid :: uintptr(155)
SYS_getsid :: uintptr(156)
SYS_setsid :: uintptr(157)
SYS_getgroups :: uintptr(158)
SYS_setgroups :: uintptr(159)
SYS_uname :: uintptr(160)
SYS_sethostname :: uintptr(161)
SYS_setdomainname :: uintptr(162)
SYS_getrlimit :: uintptr(163)
SYS_setrlimit :: uintptr(164)
SYS_getrusage :: uintptr(165)
SYS_umask :: uintptr(166)
SYS_prctl :: uintptr(167)
SYS_getcpu :: uintptr(168)
SYS_gettimeofday :: uintptr(169)
SYS_settimeofday :: uintptr(170)
SYS_adjtimex :: uintptr(171)
SYS_getpid :: uintptr(172)
SYS_getppid :: uintptr(173)
SYS_getuid :: uintptr(174)
SYS_geteuid :: uintptr(175)
SYS_getgid :: uintptr(176)
SYS_getegid :: uintptr(177)
SYS_gettid :: uintptr(178)
SYS_sysinfo :: uintptr(179)
SYS_mq_open :: uintptr(180)
SYS_mq_unlink :: uintptr(181)
SYS_mq_timedsend :: uintptr(182)
SYS_mq_timedreceive :: uintptr(183)
SYS_mq_notify :: uintptr(184)
SYS_mq_getsetattr :: uintptr(185)
SYS_msgget :: uintptr(186)
SYS_msgctl :: uintptr(187)
SYS_msgrcv :: uintptr(188)
SYS_msgsnd :: uintptr(189)
SYS_semget :: uintptr(190)
SYS_semctl :: uintptr(191)
SYS_semtimedop :: uintptr(192)
SYS_semop :: uintptr(193)
SYS_shmget :: uintptr(194)
SYS_shmctl :: uintptr(195)
SYS_shmat :: uintptr(196)
SYS_shmdt :: uintptr(197)
SYS_socket :: uintptr(198)
SYS_socketpair :: uintptr(199)
SYS_bind :: uintptr(200)
SYS_listen :: uintptr(201)
SYS_accept :: uintptr(202)
SYS_connect :: uintptr(203)
SYS_getsockname :: uintptr(204)
SYS_getpeername :: uintptr(205)
SYS_sendto :: uintptr(206)
SYS_recvfrom :: uintptr(207)
SYS_setsockopt :: uintptr(208)
SYS_getsockopt :: uintptr(209)
SYS_shutdown :: uintptr(210)
SYS_sendmsg :: uintptr(211)
SYS_recvmsg :: uintptr(212)
SYS_readahead :: uintptr(213)
SYS_brk :: uintptr(214)
SYS_munmap :: uintptr(215)
SYS_mremap :: uintptr(216)
SYS_add_key :: uintptr(217)
SYS_request_key :: uintptr(218)
SYS_keyctl :: uintptr(219)
SYS_clone :: uintptr(220)
SYS_execve :: uintptr(221)
SYS_mmap :: uintptr(222)
SYS_fadvise64 :: uintptr(223)
SYS_swapon :: uintptr(224)
SYS_swapoff :: uintptr(225)
SYS_mprotect :: uintptr(226)
SYS_msync :: uintptr(227)
SYS_mlock :: uintptr(228)
SYS_munlock :: uintptr(229)
SYS_mlockall :: uintptr(230)
SYS_munlockall :: uintptr(231)
SYS_mincore :: uintptr(232)
SYS_madvise :: uintptr(233)
SYS_remap_file_pages :: uintptr(234)
SYS_mbind :: uintptr(235)
SYS_get_mempolicy :: uintptr(236)
SYS_set_mempolicy :: uintptr(237)
SYS_migrate_pages :: uintptr(238)
SYS_move_pages :: uintptr(239)
SYS_rt_tgsigqueueinfo :: uintptr(240)
SYS_perf_event_open :: uintptr(241)
SYS_accept4 :: uintptr(242)
SYS_recvmmsg :: uintptr(243)
SYS_wait4 :: uintptr(260)
SYS_prlimit64 :: uintptr(261)
SYS_fanotify_init :: uintptr(262)
SYS_fanotify_mark :: uintptr(263)
SYS_name_to_handle_at :: uintptr(264)
SYS_open_by_handle_at :: uintptr(265)
SYS_clock_adjtime :: uintptr(266)
SYS_syncfs :: uintptr(267)
SYS_setns :: uintptr(268)
SYS_sendmmsg :: uintptr(269)
SYS_process_vm_readv :: uintptr(270)
SYS_process_vm_writev :: uintptr(271)
SYS_kcmp :: uintptr(272)
SYS_finit_module :: uintptr(273)
SYS_sched_setattr :: uintptr(274)
SYS_sched_getattr :: uintptr(275)
SYS_renameat2 :: uintptr(276)
SYS_seccomp :: uintptr(277)
SYS_getrandom :: uintptr(278)
SYS_memfd_create :: uintptr(279)
SYS_bpf :: uintptr(280)
SYS_execveat :: uintptr(281)
SYS_userfaultfd :: uintptr(282)
SYS_membarrier :: uintptr(283)
SYS_mlock2 :: uintptr(284)
SYS_copy_file_range :: uintptr(285)
SYS_preadv2 :: uintptr(286)
SYS_pwritev2 :: uintptr(287)
SYS_pkey_mprotect :: uintptr(288)
SYS_pkey_alloc :: uintptr(289)
SYS_pkey_free :: uintptr(290)
SYS_statx :: uintptr(291)
SYS_io_pgetevents :: uintptr(292)
SYS_rseq :: uintptr(293)
SYS_kexec_file_load :: uintptr(294)
SYS_clock_gettime64 :: uintptr(403)
SYS_clock_settime64 :: uintptr(404)
SYS_clock_adjtime64 :: uintptr(405)
SYS_clock_getres_time64 :: uintptr(406)
SYS_clock_nanosleep_time64 :: uintptr(407)
SYS_timer_gettime64 :: uintptr(408)
SYS_timer_settime64 :: uintptr(409)
SYS_timerfd_gettime64 :: uintptr(410)
SYS_timerfd_settime64 :: uintptr(411)
SYS_utimensat_time64 :: uintptr(412)
SYS_pselect6_time64 :: uintptr(413)
SYS_ppoll_time64 :: uintptr(414)
SYS_io_pgetevents_time64 :: uintptr(416)
SYS_recvmmsg_time64 :: uintptr(417)
SYS_mq_timedsend_time64 :: uintptr(418)
SYS_mq_timedreceive_time64 :: uintptr(419)
SYS_semtimedop_time64 :: uintptr(420)
SYS_rt_sigtimedwait_time64 :: uintptr(421)
SYS_futex_time64 :: uintptr(422)
SYS_sched_rr_get_interval_time64 :: uintptr(423)
SYS_pidfd_send_signal :: uintptr(424)
SYS_io_uring_setup :: uintptr(425)
SYS_io_uring_enter :: uintptr(426)
SYS_io_uring_register :: uintptr(427)
SYS_open_tree :: uintptr(428)
SYS_move_mount :: uintptr(429)
SYS_fsopen :: uintptr(430)
SYS_fsconfig :: uintptr(431)
SYS_fsmount :: uintptr(432)
SYS_fspick :: uintptr(433)
SYS_pidfd_open :: uintptr(434)
SYS_clone3 :: uintptr(435)
SYS_close_range :: uintptr(436)
SYS_openat2 :: uintptr(437)
SYS_pidfd_getfd :: uintptr(438)
SYS_faccessat2 :: uintptr(439)
SYS_process_madvise :: uintptr(440)
SYS_epoll_pwait2 :: uintptr(441)
SYS_mount_setattr :: uintptr(442)
SYS_quotactl_fd :: uintptr(443)
SYS_landlock_create_ruleset :: uintptr(444)
SYS_landlock_add_rule :: uintptr(445)
SYS_landlock_restrict_self :: uintptr(446)
SYS_memfd_secret :: uintptr(447)
SYS_process_mrelease :: uintptr(448)
SYS_futex_waitv :: uintptr(449)
SYS_set_mempolicy_home_node :: uintptr(450)
SYS_cachestat :: uintptr(451)
SYS_fchmodat2 :: uintptr(452)
+47 -1
View File
@@ -120,6 +120,25 @@ when ODIN_ARCH == .amd64 {
_: [3]uint,
}
} else when ODIN_ARCH == .arm64 {
_Arch_Stat :: struct {
dev: Dev,
ino: Inode,
mode: Mode,
nlink: u32,
uid: Uid,
gid: Gid,
rdev: Dev,
_: u64,
size: int,
blksize: i32,
_: i32,
blocks: int,
atime: Time_Spec,
mtime: Time_Spec,
ctime: Time_Spec,
_: [2]u32,
}
} else when ODIN_ARCH == .riscv64 {
_Arch_Stat :: struct {
dev: Dev,
ino: Inode,
@@ -927,7 +946,7 @@ when ODIN_ARCH == .i386 {
nsems: uint,
_: [2]uint,
}
} else when ODIN_ARCH == .arm64 {
} else when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
_Arch_Semid_DS :: struct {
perm: IPC_Perm,
otime: int,
@@ -1167,6 +1186,33 @@ when ODIN_ARCH == .arm32 {
xmm_space: [32]uint,
padding: [56]uint,
}
} else when ODIN_ARCH == .riscv64 {
_Arch_User_Regs :: struct {
pc, ra, sp, gp, tp,
t0, t1, t2,
s0, s1,
a0, a1, a2, a3, a4, a5, a6, a7,
s2, s3, s4, s5, s6, s7, s8, s9, s10, s11,
t3, t4, t5, t6: uint,
}
_Arch_User_FP_Regs :: struct #raw_union {
f_ext: struct {
f: [32]u32,
fcsr: u32,
},
d_ext: struct {
f: [32]u64,
fcsr: u32,
},
q_ext: struct {
using _: struct #align(16) {
f: [64]u64,
},
fcsr: u32,
reserved: [3]u32,
},
}
_Arch_User_FPX_Regs :: struct {}
}
/*
+356 -24
View File
@@ -1514,6 +1514,338 @@ when ODIN_ARCH == .amd64 {
SYS_landlock_create_ruleset : uintptr : 444
SYS_landlock_add_rule : uintptr : 445
SYS_landlock_restrict_self : uintptr : 446
} else when ODIN_ARCH == .riscv64 {
SYS_io_setup :: uintptr(0)
SYS_io_destroy :: uintptr(1)
SYS_io_submit :: uintptr(2)
SYS_io_cancel :: uintptr(3)
SYS_io_getevents :: uintptr(4)
SYS_setxattr :: uintptr(5)
SYS_lsetxattr :: uintptr(6)
SYS_fsetxattr :: uintptr(7)
SYS_getxattr :: uintptr(8)
SYS_lgetxattr :: uintptr(9)
SYS_fgetxattr :: uintptr(10)
SYS_listxattr :: uintptr(11)
SYS_llistxattr :: uintptr(12)
SYS_flistxattr :: uintptr(13)
SYS_removexattr :: uintptr(14)
SYS_lremovexattr :: uintptr(15)
SYS_fremovexattr :: uintptr(16)
SYS_getcwd :: uintptr(17)
SYS_lookup_dcookie :: uintptr(18)
SYS_eventfd2 :: uintptr(19)
SYS_epoll_create1 :: uintptr(20)
SYS_epoll_ctl :: uintptr(21)
SYS_epoll_pwait :: uintptr(22)
SYS_dup :: uintptr(23)
SYS_dup3 :: uintptr(24)
SYS_fcntl :: uintptr(25)
SYS_inotify_init1 :: uintptr(26)
SYS_inotify_add_watch :: uintptr(27)
SYS_inotify_rm_watch :: uintptr(28)
SYS_ioctl :: uintptr(29)
SYS_ioprio_set :: uintptr(30)
SYS_ioprio_get :: uintptr(31)
SYS_flock :: uintptr(32)
SYS_mknodat :: uintptr(33)
SYS_mkdirat :: uintptr(34)
SYS_unlinkat :: uintptr(35)
SYS_symlinkat :: uintptr(36)
SYS_linkat :: uintptr(37)
SYS_renameat :: uintptr(38)
SYS_umount2 :: uintptr(39)
SYS_mount :: uintptr(40)
SYS_pivot_root :: uintptr(41)
SYS_nfsservctl :: uintptr(42)
SYS_statfs :: uintptr(43)
SYS_fstatfs :: uintptr(44)
SYS_truncate :: uintptr(45)
SYS_ftruncate :: uintptr(46)
SYS_fallocate :: uintptr(47)
SYS_faccessat :: uintptr(48)
SYS_chdir :: uintptr(49)
SYS_fchdir :: uintptr(50)
SYS_chroot :: uintptr(51)
SYS_fchmod :: uintptr(52)
SYS_fchmodat :: uintptr(53)
SYS_fchownat :: uintptr(54)
SYS_fchown :: uintptr(55)
SYS_openat :: uintptr(56)
SYS_close :: uintptr(57)
SYS_vhangup :: uintptr(58)
SYS_pipe2 :: uintptr(59)
SYS_quotactl :: uintptr(60)
SYS_getdents64 :: uintptr(61)
SYS_lseek :: uintptr(62)
SYS_read :: uintptr(63)
SYS_write :: uintptr(64)
SYS_readv :: uintptr(65)
SYS_writev :: uintptr(66)
SYS_pread64 :: uintptr(67)
SYS_pwrite64 :: uintptr(68)
SYS_preadv :: uintptr(69)
SYS_pwritev :: uintptr(70)
SYS_sendfile :: uintptr(71)
SYS_pselect6 :: uintptr(72)
SYS_ppoll :: uintptr(73)
SYS_signalfd4 :: uintptr(74)
SYS_vmsplice :: uintptr(75)
SYS_splice :: uintptr(76)
SYS_tee :: uintptr(77)
SYS_readlinkat :: uintptr(78)
SYS_fstatat :: uintptr(79)
SYS_fstat :: uintptr(80)
SYS_sync :: uintptr(81)
SYS_fsync :: uintptr(82)
SYS_fdatasync :: uintptr(83)
SYS_sync_file_range2 :: uintptr(84)
SYS_sync_file_range :: uintptr(84)
SYS_timerfd_create :: uintptr(85)
SYS_timerfd_settime :: uintptr(86)
SYS_timerfd_gettime :: uintptr(87)
SYS_utimensat :: uintptr(88)
SYS_acct :: uintptr(89)
SYS_capget :: uintptr(90)
SYS_capset :: uintptr(91)
SYS_personality :: uintptr(92)
SYS_exit :: uintptr(93)
SYS_exit_group :: uintptr(94)
SYS_waitid :: uintptr(95)
SYS_set_tid_address :: uintptr(96)
SYS_unshare :: uintptr(97)
SYS_futex :: uintptr(98)
SYS_set_robust_list :: uintptr(99)
SYS_get_robust_list :: uintptr(100)
SYS_nanosleep :: uintptr(101)
SYS_getitimer :: uintptr(102)
SYS_setitimer :: uintptr(103)
SYS_kexec_load :: uintptr(104)
SYS_init_module :: uintptr(105)
SYS_delete_module :: uintptr(106)
SYS_timer_create :: uintptr(107)
SYS_timer_gettime :: uintptr(108)
SYS_timer_getoverrun :: uintptr(109)
SYS_timer_settime :: uintptr(110)
SYS_timer_delete :: uintptr(111)
SYS_clock_settime :: uintptr(112)
SYS_clock_gettime :: uintptr(113)
SYS_clock_getres :: uintptr(114)
SYS_clock_nanosleep :: uintptr(115)
SYS_syslog :: uintptr(116)
SYS_ptrace :: uintptr(117)
SYS_sched_setparam :: uintptr(118)
SYS_sched_setscheduler :: uintptr(119)
SYS_sched_getscheduler :: uintptr(120)
SYS_sched_getparam :: uintptr(121)
SYS_sched_setaffinity :: uintptr(122)
SYS_sched_getaffinity :: uintptr(123)
SYS_sched_yield :: uintptr(124)
SYS_sched_get_priority_max :: uintptr(125)
SYS_sched_get_priority_min :: uintptr(126)
SYS_sched_rr_get_interval :: uintptr(127)
SYS_restart_syscall :: uintptr(128)
SYS_kill :: uintptr(129)
SYS_tkill :: uintptr(130)
SYS_tgkill :: uintptr(131)
SYS_sigaltstack :: uintptr(132)
SYS_rt_sigsuspend :: uintptr(133)
SYS_rt_sigaction :: uintptr(134)
SYS_rt_sigprocmask :: uintptr(135)
SYS_rt_sigpending :: uintptr(136)
SYS_rt_sigtimedwait :: uintptr(137)
SYS_rt_sigqueueinfo :: uintptr(138)
SYS_rt_sigreturn :: uintptr(139)
SYS_setpriority :: uintptr(140)
SYS_getpriority :: uintptr(141)
SYS_reboot :: uintptr(142)
SYS_setregid :: uintptr(143)
SYS_setgid :: uintptr(144)
SYS_setreuid :: uintptr(145)
SYS_setuid :: uintptr(146)
SYS_setresuid :: uintptr(147)
SYS_getresuid :: uintptr(148)
SYS_setresgid :: uintptr(149)
SYS_getresgid :: uintptr(150)
SYS_setfsuid :: uintptr(151)
SYS_setfsgid :: uintptr(152)
SYS_times :: uintptr(153)
SYS_setpgid :: uintptr(154)
SYS_getpgid :: uintptr(155)
SYS_getsid :: uintptr(156)
SYS_setsid :: uintptr(157)
SYS_getgroups :: uintptr(158)
SYS_setgroups :: uintptr(159)
SYS_uname :: uintptr(160)
SYS_sethostname :: uintptr(161)
SYS_setdomainname :: uintptr(162)
SYS_getrlimit :: uintptr(163)
SYS_setrlimit :: uintptr(164)
SYS_getrusage :: uintptr(165)
SYS_umask :: uintptr(166)
SYS_prctl :: uintptr(167)
SYS_getcpu :: uintptr(168)
SYS_gettimeofday :: uintptr(169)
SYS_settimeofday :: uintptr(170)
SYS_adjtimex :: uintptr(171)
SYS_getpid :: uintptr(172)
SYS_getppid :: uintptr(173)
SYS_getuid :: uintptr(174)
SYS_geteuid :: uintptr(175)
SYS_getgid :: uintptr(176)
SYS_getegid :: uintptr(177)
SYS_gettid :: uintptr(178)
SYS_sysinfo :: uintptr(179)
SYS_mq_open :: uintptr(180)
SYS_mq_unlink :: uintptr(181)
SYS_mq_timedsend :: uintptr(182)
SYS_mq_timedreceive :: uintptr(183)
SYS_mq_notify :: uintptr(184)
SYS_mq_getsetattr :: uintptr(185)
SYS_msgget :: uintptr(186)
SYS_msgctl :: uintptr(187)
SYS_msgrcv :: uintptr(188)
SYS_msgsnd :: uintptr(189)
SYS_semget :: uintptr(190)
SYS_semctl :: uintptr(191)
SYS_semtimedop :: uintptr(192)
SYS_semop :: uintptr(193)
SYS_shmget :: uintptr(194)
SYS_shmctl :: uintptr(195)
SYS_shmat :: uintptr(196)
SYS_shmdt :: uintptr(197)
SYS_socket :: uintptr(198)
SYS_socketpair :: uintptr(199)
SYS_bind :: uintptr(200)
SYS_listen :: uintptr(201)
SYS_accept :: uintptr(202)
SYS_connect :: uintptr(203)
SYS_getsockname :: uintptr(204)
SYS_getpeername :: uintptr(205)
SYS_sendto :: uintptr(206)
SYS_recvfrom :: uintptr(207)
SYS_setsockopt :: uintptr(208)
SYS_getsockopt :: uintptr(209)
SYS_shutdown :: uintptr(210)
SYS_sendmsg :: uintptr(211)
SYS_recvmsg :: uintptr(212)
SYS_readahead :: uintptr(213)
SYS_brk :: uintptr(214)
SYS_munmap :: uintptr(215)
SYS_mremap :: uintptr(216)
SYS_add_key :: uintptr(217)
SYS_request_key :: uintptr(218)
SYS_keyctl :: uintptr(219)
SYS_clone :: uintptr(220)
SYS_execve :: uintptr(221)
SYS_mmap :: uintptr(222)
SYS_fadvise64 :: uintptr(223)
SYS_swapon :: uintptr(224)
SYS_swapoff :: uintptr(225)
SYS_mprotect :: uintptr(226)
SYS_msync :: uintptr(227)
SYS_mlock :: uintptr(228)
SYS_munlock :: uintptr(229)
SYS_mlockall :: uintptr(230)
SYS_munlockall :: uintptr(231)
SYS_mincore :: uintptr(232)
SYS_madvise :: uintptr(233)
SYS_remap_file_pages :: uintptr(234)
SYS_mbind :: uintptr(235)
SYS_get_mempolicy :: uintptr(236)
SYS_set_mempolicy :: uintptr(237)
SYS_migrate_pages :: uintptr(238)
SYS_move_pages :: uintptr(239)
SYS_rt_tgsigqueueinfo :: uintptr(240)
SYS_perf_event_open :: uintptr(241)
SYS_accept4 :: uintptr(242)
SYS_recvmmsg :: uintptr(243)
SYS_wait4 :: uintptr(260)
SYS_prlimit64 :: uintptr(261)
SYS_fanotify_init :: uintptr(262)
SYS_fanotify_mark :: uintptr(263)
SYS_name_to_handle_at :: uintptr(264)
SYS_open_by_handle_at :: uintptr(265)
SYS_clock_adjtime :: uintptr(266)
SYS_syncfs :: uintptr(267)
SYS_setns :: uintptr(268)
SYS_sendmmsg :: uintptr(269)
SYS_process_vm_readv :: uintptr(270)
SYS_process_vm_writev :: uintptr(271)
SYS_kcmp :: uintptr(272)
SYS_finit_module :: uintptr(273)
SYS_sched_setattr :: uintptr(274)
SYS_sched_getattr :: uintptr(275)
SYS_renameat2 :: uintptr(276)
SYS_seccomp :: uintptr(277)
SYS_getrandom :: uintptr(278)
SYS_memfd_create :: uintptr(279)
SYS_bpf :: uintptr(280)
SYS_execveat :: uintptr(281)
SYS_userfaultfd :: uintptr(282)
SYS_membarrier :: uintptr(283)
SYS_mlock2 :: uintptr(284)
SYS_copy_file_range :: uintptr(285)
SYS_preadv2 :: uintptr(286)
SYS_pwritev2 :: uintptr(287)
SYS_pkey_mprotect :: uintptr(288)
SYS_pkey_alloc :: uintptr(289)
SYS_pkey_free :: uintptr(290)
SYS_statx :: uintptr(291)
SYS_io_pgetevents :: uintptr(292)
SYS_rseq :: uintptr(293)
SYS_kexec_file_load :: uintptr(294)
SYS_clock_gettime64 :: uintptr(403)
SYS_clock_settime64 :: uintptr(404)
SYS_clock_adjtime64 :: uintptr(405)
SYS_clock_getres_time64 :: uintptr(406)
SYS_clock_nanosleep_time64 :: uintptr(407)
SYS_timer_gettime64 :: uintptr(408)
SYS_timer_settime64 :: uintptr(409)
SYS_timerfd_gettime64 :: uintptr(410)
SYS_timerfd_settime64 :: uintptr(411)
SYS_utimensat_time64 :: uintptr(412)
SYS_pselect6_time64 :: uintptr(413)
SYS_ppoll_time64 :: uintptr(414)
SYS_io_pgetevents_time64 :: uintptr(416)
SYS_recvmmsg_time64 :: uintptr(417)
SYS_mq_timedsend_time64 :: uintptr(418)
SYS_mq_timedreceive_time64 :: uintptr(419)
SYS_semtimedop_time64 :: uintptr(420)
SYS_rt_sigtimedwait_time64 :: uintptr(421)
SYS_futex_time64 :: uintptr(422)
SYS_sched_rr_get_interval_time64 :: uintptr(423)
SYS_pidfd_send_signal :: uintptr(424)
SYS_io_uring_setup :: uintptr(425)
SYS_io_uring_enter :: uintptr(426)
SYS_io_uring_register :: uintptr(427)
SYS_open_tree :: uintptr(428)
SYS_move_mount :: uintptr(429)
SYS_fsopen :: uintptr(430)
SYS_fsconfig :: uintptr(431)
SYS_fsmount :: uintptr(432)
SYS_fspick :: uintptr(433)
SYS_pidfd_open :: uintptr(434)
SYS_clone3 :: uintptr(435)
SYS_close_range :: uintptr(436)
SYS_openat2 :: uintptr(437)
SYS_pidfd_getfd :: uintptr(438)
SYS_faccessat2 :: uintptr(439)
SYS_process_madvise :: uintptr(440)
SYS_epoll_pwait2 :: uintptr(441)
SYS_mount_setattr :: uintptr(442)
SYS_quotactl_fd :: uintptr(443)
SYS_landlock_create_ruleset :: uintptr(444)
SYS_landlock_add_rule :: uintptr(445)
SYS_landlock_restrict_self :: uintptr(446)
SYS_memfd_secret :: uintptr(447)
SYS_process_mrelease :: uintptr(448)
SYS_futex_waitv :: uintptr(449)
SYS_set_mempolicy_home_node :: uintptr(450)
SYS_cachestat :: uintptr(451)
SYS_fchmodat2 :: uintptr(452)
SIGCHLD :: 17
} else {
#panic("Unsupported architecture")
}
@@ -1742,7 +2074,7 @@ sys_getrandom :: proc "contextless" (buf: [^]byte, buflen: uint, flags: int) ->
}
sys_open :: proc "contextless" (path: cstring, flags: int, mode: uint = 0o000) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_open, uintptr(rawptr(path)), uintptr(flags), uintptr(mode)))
} else { // NOTE: arm64 does not have open
return int(intrinsics.syscall(SYS_openat, AT_FDCWD, uintptr(rawptr(path)), uintptr(flags), uintptr(mode)))
@@ -1762,7 +2094,7 @@ sys_read :: proc "contextless" (fd: int, buf: rawptr, size: uint) -> int {
}
sys_pread :: proc "contextless" (fd: int, buf: rawptr, size: uint, offset: i64) -> int {
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 {
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
return int(intrinsics.syscall(SYS_pread64, uintptr(fd), uintptr(buf), uintptr(size), uintptr(offset)))
} else {
low := uintptr(offset & 0xFFFFFFFF)
@@ -1776,7 +2108,7 @@ sys_write :: proc "contextless" (fd: int, buf: rawptr, size: uint) -> int {
}
sys_pwrite :: proc "contextless" (fd: int, buf: rawptr, size: uint, offset: i64) -> int {
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 {
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
return int(intrinsics.syscall(SYS_pwrite64, uintptr(fd), uintptr(buf), uintptr(size), uintptr(offset)))
} else {
low := uintptr(offset & 0xFFFFFFFF)
@@ -1786,7 +2118,7 @@ sys_pwrite :: proc "contextless" (fd: int, buf: rawptr, size: uint, offset: i64)
}
sys_lseek :: proc "contextless" (fd: int, offset: i64, whence: int) -> i64 {
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 {
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
return i64(intrinsics.syscall(SYS_lseek, uintptr(fd), uintptr(offset), uintptr(whence)))
} else {
low := uintptr(offset & 0xFFFFFFFF)
@@ -1800,7 +2132,7 @@ sys_lseek :: proc "contextless" (fd: int, offset: i64, whence: int) -> i64 {
sys_stat :: proc "contextless" (path: cstring, stat: rawptr) -> int {
when ODIN_ARCH == .amd64 {
return int(intrinsics.syscall(SYS_stat, uintptr(rawptr(path)), uintptr(stat)))
} else when ODIN_ARCH != .arm64 {
} else when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_stat64, uintptr(rawptr(path)), uintptr(stat)))
} else { // NOTE: arm64 does not have stat
return int(intrinsics.syscall(SYS_fstatat, AT_FDCWD, uintptr(rawptr(path)), uintptr(stat), 0))
@@ -1808,7 +2140,7 @@ sys_stat :: proc "contextless" (path: cstring, stat: rawptr) -> int {
}
sys_fstat :: proc "contextless" (fd: int, stat: rawptr) -> int {
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 {
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
return int(intrinsics.syscall(SYS_fstat, uintptr(fd), uintptr(stat)))
} else {
return int(intrinsics.syscall(SYS_fstat64, uintptr(fd), uintptr(stat)))
@@ -1818,7 +2150,7 @@ sys_fstat :: proc "contextless" (fd: int, stat: rawptr) -> int {
sys_lstat :: proc "contextless" (path: cstring, stat: rawptr) -> int {
when ODIN_ARCH == .amd64 {
return int(intrinsics.syscall(SYS_lstat, uintptr(rawptr(path)), uintptr(stat)))
} else when ODIN_ARCH != .arm64 {
} else when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_lstat64, uintptr(rawptr(path)), uintptr(stat)))
} else { // NOTE: arm64 does not have any lstat
return int(intrinsics.syscall(SYS_fstatat, AT_FDCWD, uintptr(rawptr(path)), uintptr(stat), AT_SYMLINK_NOFOLLOW))
@@ -1826,7 +2158,7 @@ sys_lstat :: proc "contextless" (path: cstring, stat: rawptr) -> int {
}
sys_readlink :: proc "contextless" (path: cstring, buf: rawptr, bufsiz: uint) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_readlink, uintptr(rawptr(path)), uintptr(buf), uintptr(bufsiz)))
} else { // NOTE: arm64 does not have readlink
return int(intrinsics.syscall(SYS_readlinkat, AT_FDCWD, uintptr(rawptr(path)), uintptr(buf), uintptr(bufsiz)))
@@ -1834,7 +2166,7 @@ sys_readlink :: proc "contextless" (path: cstring, buf: rawptr, bufsiz: uint) ->
}
sys_symlink :: proc "contextless" (old_name: cstring, new_name: cstring) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_symlink, uintptr(rawptr(old_name)), uintptr(rawptr(new_name))))
} else { // NOTE: arm64 does not have symlink
return int(intrinsics.syscall(SYS_symlinkat, uintptr(rawptr(old_name)), AT_FDCWD, uintptr(rawptr(new_name))))
@@ -1842,7 +2174,7 @@ sys_symlink :: proc "contextless" (old_name: cstring, new_name: cstring) -> int
}
sys_access :: proc "contextless" (path: cstring, mask: int) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_access, uintptr(rawptr(path)), uintptr(mask)))
} else { // NOTE: arm64 does not have access
return int(intrinsics.syscall(SYS_faccessat, AT_FDCWD, uintptr(rawptr(path)), uintptr(mask)))
@@ -1862,7 +2194,7 @@ sys_fchdir :: proc "contextless" (fd: int) -> int {
}
sys_chmod :: proc "contextless" (path: cstring, mode: uint) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_chmod, uintptr(rawptr(path)), uintptr(mode)))
} else { // NOTE: arm64 does not have chmod
return int(intrinsics.syscall(SYS_fchmodat, AT_FDCWD, uintptr(rawptr(path)), uintptr(mode)))
@@ -1874,7 +2206,7 @@ sys_fchmod :: proc "contextless" (fd: int, mode: uint) -> int {
}
sys_chown :: proc "contextless" (path: cstring, user: int, group: int) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH !=. riscv64 {
return int(intrinsics.syscall(SYS_chown, uintptr(rawptr(path)), uintptr(user), uintptr(group)))
} else { // NOTE: arm64 does not have chown
return int(intrinsics.syscall(SYS_fchownat, AT_FDCWD, uintptr(rawptr(path)), uintptr(user), uintptr(group), 0))
@@ -1886,7 +2218,7 @@ sys_fchown :: proc "contextless" (fd: int, user: int, group: int) -> int {
}
sys_lchown :: proc "contextless" (path: cstring, user: int, group: int) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_lchown, uintptr(rawptr(path)), uintptr(user), uintptr(group)))
} else { // NOTE: arm64 does not have lchown
return int(intrinsics.syscall(SYS_fchownat, AT_FDCWD, uintptr(rawptr(path)), uintptr(user), uintptr(group), AT_SYMLINK_NOFOLLOW))
@@ -1894,7 +2226,7 @@ sys_lchown :: proc "contextless" (path: cstring, user: int, group: int) -> int {
}
sys_rename :: proc "contextless" (old, new: cstring) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_rename, uintptr(rawptr(old)), uintptr(rawptr(new))))
} else { // NOTE: arm64 does not have rename
return int(intrinsics.syscall(SYS_renameat, AT_FDCWD, uintptr(rawptr(old)), uintptr(rawptr(new))))
@@ -1902,7 +2234,7 @@ sys_rename :: proc "contextless" (old, new: cstring) -> int {
}
sys_link :: proc "contextless" (old_name: cstring, new_name: cstring) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_link, uintptr(rawptr(old_name)), uintptr(rawptr(new_name))))
} else { // NOTE: arm64 does not have link
return int(intrinsics.syscall(SYS_linkat, AT_FDCWD, uintptr(rawptr(old_name)), AT_FDCWD, uintptr(rawptr(new_name)), AT_SYMLINK_FOLLOW))
@@ -1910,7 +2242,7 @@ sys_link :: proc "contextless" (old_name: cstring, new_name: cstring) -> int {
}
sys_unlink :: proc "contextless" (path: cstring) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_unlink, uintptr(rawptr(path))))
} else { // NOTE: arm64 does not have unlink
return int(intrinsics.syscall(SYS_unlinkat, AT_FDCWD, uintptr(rawptr(path)), 0))
@@ -1922,7 +2254,7 @@ sys_unlinkat :: proc "contextless" (dfd: int, path: cstring, flag: int = 0) -> i
}
sys_rmdir :: proc "contextless" (path: cstring) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_rmdir, uintptr(rawptr(path))))
} else { // NOTE: arm64 does not have rmdir
return int(intrinsics.syscall(SYS_unlinkat, AT_FDCWD, uintptr(rawptr(path)), AT_REMOVEDIR))
@@ -1930,7 +2262,7 @@ sys_rmdir :: proc "contextless" (path: cstring) -> int {
}
sys_mkdir :: proc "contextless" (path: cstring, mode: uint) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_mkdir, uintptr(rawptr(path)), uintptr(mode)))
} else { // NOTE: arm64 does not have mkdir
return int(intrinsics.syscall(SYS_mkdirat, AT_FDCWD, uintptr(rawptr(path)), uintptr(mode)))
@@ -1942,7 +2274,7 @@ sys_mkdirat :: proc "contextless" (dfd: int, path: cstring, mode: uint) -> int {
}
sys_mknod :: proc "contextless" (path: cstring, mode: uint, dev: int) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_mknod, uintptr(rawptr(path)), uintptr(mode), uintptr(dev)))
} else { // NOTE: arm64 does not have mknod
return int(intrinsics.syscall(SYS_mknodat, AT_FDCWD, uintptr(rawptr(path)), uintptr(mode), uintptr(dev)))
@@ -1954,7 +2286,7 @@ sys_mknodat :: proc "contextless" (dfd: int, path: cstring, mode: uint, dev: int
}
sys_truncate :: proc "contextless" (path: cstring, length: i64) -> int {
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 {
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
return int(intrinsics.syscall(SYS_truncate, uintptr(rawptr(path)), uintptr(length)))
} else {
low := uintptr(length & 0xFFFFFFFF)
@@ -1964,7 +2296,7 @@ sys_truncate :: proc "contextless" (path: cstring, length: i64) -> int {
}
sys_ftruncate :: proc "contextless" (fd: int, length: i64) -> int {
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 {
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
return int(intrinsics.syscall(SYS_ftruncate, uintptr(fd), uintptr(length)))
} else {
low := uintptr(length & 0xFFFFFFFF)
@@ -1982,7 +2314,7 @@ sys_getdents64 :: proc "contextless" (fd: int, dirent: rawptr, count: int) -> in
}
sys_fork :: proc "contextless" () -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_fork))
} else {
return int(intrinsics.syscall(SYS_clone, SIGCHLD))
@@ -1992,7 +2324,7 @@ sys_pipe2 :: proc "contextless" (fds: rawptr, flags: int) -> int {
return int(intrinsics.syscall(SYS_pipe2, uintptr(fds), uintptr(flags)))
}
sys_dup2 :: proc "contextless" (oldfd: int, newfd: int) -> int {
when ODIN_ARCH != .arm64 {
when ODIN_ARCH != .arm64 && ODIN_ARCH != .riscv64 {
return int(intrinsics.syscall(SYS_dup2, uintptr(oldfd), uintptr(newfd)))
} else {
return int(intrinsics.syscall(SYS_dup3, uintptr(oldfd), uintptr(newfd), 0))
@@ -2076,7 +2408,7 @@ sys_fcntl :: proc "contextless" (fd: int, cmd: int, arg: int) -> int {
sys_poll :: proc "contextless" (fds: rawptr, nfds: uint, timeout: int) -> int {
// NOTE: specialcased here because `arm64` does not have `poll`
when ODIN_ARCH == .arm64 {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
seconds := i64(timeout / 1_000)
nanoseconds := i64((timeout % 1000) * 1_000_000)
timeout_spec := timespec{seconds, nanoseconds}