[libc-commits] [libc] [libc] Fix return value of __cxa_thread_atexit_impl function. (PR #122171)
via libc-commits
libc-commits at lists.llvm.org
Wed Jan 8 13:23:33 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Alexey Samsonov (vonosmas)
<details>
<summary>Changes</summary>
This has been added in 0071a79532e8d664b734956a431d8c8c942cc25e to support TLS destructors. Return value of __cxa_thread_atexit is supposed to be the same as std::atexit - zero on success, non-zero on failure. Update the code to do just that (also be consistent with llvm-libc's existing atexit / at_quick_exit implementations).
---
Full diff: https://github.com/llvm/llvm-project/pull/122171.diff
1 Files Affected:
- (modified) libc/src/__support/threads/thread.cpp (+3-1)
``````````diff
diff --git a/libc/src/__support/threads/thread.cpp b/libc/src/__support/threads/thread.cpp
index dad4f75f092ede..6f6b75be5766d0 100644
--- a/libc/src/__support/threads/thread.cpp
+++ b/libc/src/__support/threads/thread.cpp
@@ -117,7 +117,9 @@ class ThreadAtExitCallbackMgr {
int add_callback(AtExitCallback *callback, void *obj) {
cpp::lock_guard lock(mtx);
- return callback_list.push_back({callback, obj});
+ if (callback_list.push_back({callback, obj}))
+ return 0;
+ return -1;
}
void call() {
``````````
</details>
https://github.com/llvm/llvm-project/pull/122171
More information about the libc-commits
mailing list