diff options
| author | Mikhail R. Gadelha <mikhail@igalia.com> | 2023-08-03 09:30:36 -0300 |
|---|---|---|
| committer | Mikhail R. Gadelha <mikhail@igalia.com> | 2023-08-03 10:08:01 -0300 |
| commit | c9783d2bda95ec6921b3ca2df930b17af3a6c7b1 (patch) | |
| tree | b9b4a9ac4b7412f46b9ffef65467d8af5d79b3b6 /libc/src/threads | |
| parent | 1b5a3c90ccf3eb027220ff06cfce5d26612b57dc (diff) | |
[libc] Add support to compile some syscalls on 32 bit platform
This patch adds a bunch of ifdefs to handle the 32 bit versions of
some syscalls, which often only append a 64 to the name of the syscall
(with exception of SYS_lseek -> SYS_llseek and SYS_futex ->
SYS_futex_time64)
This patch also tries to handle cases where wait4 is not available
(as in riscv32): to implement wait, wait4 and waitpid when wait4 is
not available, we check for alternative wait calls and ultimately rely
on waitid to implement them all.
In riscv32, only waitid is available, so we need it to support this
platform.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D148371
Diffstat (limited to 'libc/src/threads')
| -rw-r--r-- | libc/src/threads/linux/CndVar.h | 8 | ||||
| -rw-r--r-- | libc/src/threads/linux/call_once.cpp | 5 |
2 files changed, 7 insertions, 6 deletions
diff --git a/libc/src/threads/linux/CndVar.h b/libc/src/threads/linux/CndVar.h index c6b0ea63280a..e3585ae38d3b 100644 --- a/libc/src/threads/linux/CndVar.h +++ b/libc/src/threads/linux/CndVar.h @@ -84,8 +84,8 @@ struct CndVar { } } - __llvm_libc::syscall_impl(SYS_futex, &waiter.futex_word.val, FUTEX_WAIT, - WS_Waiting, 0, 0, 0); + __llvm_libc::syscall_impl(FUTEX_SYSCALL_ID, &waiter.futex_word.val, + FUTEX_WAIT, WS_Waiting, 0, 0, 0); // At this point, if locking |m| fails, we can simply return as the // queued up waiter would have been removed from the queue. @@ -110,7 +110,7 @@ struct CndVar { qmtx.futex_word = FutexWordType(Mutex::LockState::Free); __llvm_libc::syscall_impl( - SYS_futex, &qmtx.futex_word.val, FUTEX_WAKE_OP, 1, 1, + FUTEX_SYSCALL_ID, &qmtx.futex_word.val, FUTEX_WAKE_OP, 1, 1, &first->futex_word.val, FUTEX_OP(FUTEX_OP_SET, WS_Signalled, FUTEX_OP_CMP_EQ, WS_Waiting)); return thrd_success; @@ -127,7 +127,7 @@ struct CndVar { // up the waiter. A dummy location is used for the other futex of // FUTEX_WAKE_OP. __llvm_libc::syscall_impl( - SYS_futex, &dummy_futex_word, FUTEX_WAKE_OP, 1, 1, + FUTEX_SYSCALL_ID, &dummy_futex_word, FUTEX_WAKE_OP, 1, 1, &waiter->futex_word.val, FUTEX_OP(FUTEX_OP_SET, WS_Signalled, FUTEX_OP_CMP_EQ, WS_Waiting)); waiter = waiter->next; diff --git a/libc/src/threads/linux/call_once.cpp b/libc/src/threads/linux/call_once.cpp index ac87a0d877d3..6a9c819b7853 100644 --- a/libc/src/threads/linux/call_once.cpp +++ b/libc/src/threads/linux/call_once.cpp @@ -46,7 +46,8 @@ LLVM_LIBC_FUNCTION(void, call_once, func(); auto status = futex_word->exchange(FINISH); if (status == WAITING) { - __llvm_libc::syscall_impl(SYS_futex, &futex_word->val, FUTEX_WAKE_PRIVATE, + __llvm_libc::syscall_impl(FUTEX_SYSCALL_ID, &futex_word->val, + FUTEX_WAKE_PRIVATE, INT_MAX, // Wake all waiters. 0, 0, 0); } @@ -57,7 +58,7 @@ LLVM_LIBC_FUNCTION(void, call_once, if (futex_word->compare_exchange_strong(status, WAITING) || status == WAITING) { __llvm_libc::syscall_impl( - SYS_futex, &futex_word->val, FUTEX_WAIT_PRIVATE, + FUTEX_SYSCALL_ID, &futex_word->val, FUTEX_WAIT_PRIVATE, WAITING, // Block only if status is still |WAITING|. 0, 0, 0); } |
