[libc-commits] [libc] c1bb710 - [libc] Special case sniffing of thread start args for riscv.
Siva Chandra via libc-commits
libc-commits at lists.llvm.org
Mon Mar 13 00:30:22 PDT 2023
Author: Siva Chandra
Date: 2023-03-13T07:29:35Z
New Revision: c1bb7108a2ffe7e6c95224c17b0ff62ccb2639f8
URL: https://github.com/llvm/llvm-project/commit/c1bb7108a2ffe7e6c95224c17b0ff62ccb2639f8
DIFF: https://github.com/llvm/llvm-project/commit/c1bb7108a2ffe7e6c95224c17b0ff62ccb2639f8.diff
LOG: [libc] Special case sniffing of thread start args for riscv.
Added:
Modified:
libc/src/__support/threads/linux/thread.cpp
Removed:
################################################################################
diff --git a/libc/src/__support/threads/linux/thread.cpp b/libc/src/__support/threads/linux/thread.cpp
index c0bbd3d77e885..e9b95eed99a58 100644
--- a/libc/src/__support/threads/linux/thread.cpp
+++ b/libc/src/__support/threads/linux/thread.cpp
@@ -116,12 +116,15 @@ __attribute__((always_inline)) inline uintptr_t get_start_args_addr() {
// on to the stack. So, we have to step past two 64-bit values to get
// to the start args.
+ sizeof(uintptr_t) * 2;
-#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) || \
- defined(LIBC_TARGET_ARCH_IS_RISCV64)
+#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
// The frame pointer after cloning the new thread in the Thread::run method
// is set to the stack pointer where start args are stored. So, we fetch
// from there.
return reinterpret_cast<uintptr_t>(__builtin_frame_address(1));
+#elif defined(LIBC_TARGET_ARCH_IS_RISCV64)
+ // The current frame pointer is the previous stack pointer where the start
+ // args are stored.
+ return reinterpret_cast<uintptr_t>(__builtin_frame_address(0));
#endif
}
More information about the libc-commits
mailing list