[libc-commits] [libc] b30f9d7 - [libc] Fix return value of __cxa_thread_atexit_impl function. (#122171)
via libc-commits
libc-commits at lists.llvm.org
Wed Jan 8 21:48:01 PST 2025
Author: Alexey Samsonov
Date: 2025-01-08T21:47:58-08:00
New Revision: b30f9d74d6a0f735ef597b1acae73daac2d7df39
URL: https://github.com/llvm/llvm-project/commit/b30f9d74d6a0f735ef597b1acae73daac2d7df39
DIFF: https://github.com/llvm/llvm-project/commit/b30f9d74d6a0f735ef597b1acae73daac2d7df39.diff
LOG: [libc] Fix return value of __cxa_thread_atexit_impl function. (#122171)
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).
Added:
Modified:
libc/src/__support/threads/thread.cpp
Removed:
################################################################################
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() {
More information about the libc-commits
mailing list