diff options
| author | flysand7 <yyakut.ac@gmail.com> | 2023-11-10 05:14:37 +1100 |
|---|---|---|
| committer | flysand7 <yyakut.ac@gmail.com> | 2023-11-10 05:14:42 +1100 |
| commit | aed67ba665ad75857b5a11b07cf31b7e72d695bd (patch) | |
| tree | bb3adca9c7f55cbce47ade14365b7bb97c91f8f0 /core/sys/linux | |
| parent | 548ab2e1b6e854a85f957449951ef4a854f6c26d (diff) | |
[sys/linux]: Fix arch-specific issues
Diffstat (limited to 'core/sys/linux')
| -rw-r--r-- | core/sys/linux/sys.odin | 31 | ||||
| -rw-r--r-- | core/sys/linux/types.odin | 4 |
2 files changed, 28 insertions, 7 deletions
diff --git a/core/sys/linux/sys.odin b/core/sys/linux/sys.odin index 58ecbce98..6668c54c8 100644 --- a/core/sys/linux/sys.odin +++ b/core/sys/linux/sys.odin @@ -393,9 +393,14 @@ dup2 :: proc "contextless" (old: Fd, new: Fd) -> (Fd, Errno) { /* Wait until the next signal is delivered. Available since Linux 1.0. + On ARM64 available since Linux 2.6.16. */ pause :: proc "contextless" () { - syscall(SYS_pause) + when ODIN_ARCH == .arm64 { + syscall(SYS_ppoll, 0, 0, 0, 0) + } else { + syscall(SYS_pause) + } } /* @@ -421,7 +426,14 @@ getitimer :: proc "contextless" (which: ITimer_Which, cur: ^ITimer_Val) -> (Errn Available since Linux 1.0. */ alarm :: proc "contextless" (seconds: u32) -> u32 { - return cast(u32) syscall(SYS_alarm, seconds) + when ODIN_ARCH == .arm64 { + new := ITimer_Val { value = { seconds = cast(int) seconds } } + old := ITimer_Val {} + syscall(SYS_setitimer, ITimer_Which.REAL, &new, &old) + return u32(old.value.seconds) + u32(new.value.microseconds) + } else { + return cast(u32) syscall(SYS_alarm, seconds) + } } /* @@ -742,7 +754,7 @@ vfork :: proc "contextless" () -> Pid { when ODIN_ARCH != .arm64 { return Pid(syscall(SYS_vfork)) } else { - return Pid(syscall(SYS_fork)) + ret := Pid(syscall(SYS_clone, Signal.SIGCHLD)) } } @@ -816,8 +828,17 @@ semget :: proc "contextless" (key: Key, n: i32, flags: IPC_Flags) -> (Key, Errno Available since Linux 2.0. */ semop :: proc "contextless" (key: Key, ops: []Sem_Buf) -> (Errno) { - ret := syscall(SYS_semop, key, raw_data(ops), len(ops)) - return Errno(-ret) + when ODIN_ARCH != .i386 { + ret := syscall(SYS_semop, key, raw_data(ops), len(ops)) + return Errno(-ret) + } else { + // Note(flysand): Max time limit, let's not worry about nanoseconds... + max_timespec := Time_Spec { + time_sec = max(uint), + time_nsec = 0, + } + ret := syscall(SYS_semtimedop_time64, key, raw_data(ops), len(ops), &max_timespec) + } } semctl3 :: proc "contextless" (key: Key, semnum: i32, cmd: IPC_Cmd) -> (int, Errno) { diff --git a/core/sys/linux/types.odin b/core/sys/linux/types.odin index 9928c6cb6..997c9592b 100644 --- a/core/sys/linux/types.odin +++ b/core/sys/linux/types.odin @@ -851,7 +851,7 @@ when ODIN_ARCH == .i386 { nsems: uint, _: [2]uint, } -} else when ODIN_ARCH == .amd32 { +} else when ODIN_ARCH == .arm32 { _Arch_Semid_DS :: struct { perm: IPC_Perm, otime: uint, @@ -861,7 +861,7 @@ when ODIN_ARCH == .i386 { nsems: uint, _: [2]uint, } -} else when ODIN_ARCH == .amd64 { +} else when ODIN_ARCH == .arm64 { _Arch_Semid_DS :: struct { perm: IPC_Perm, otime: int, |