Skip to content

Conversation

@vonosmas
Copy link
Contributor

@vonosmas vonosmas commented Jan 8, 2025

This has been added in 0071a79 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).

This has been added in 0071a79 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).
@llvmbot
Copy link
Member

llvmbot commented Jan 8, 2025

@llvm/pr-subscribers-libc

Author: Alexey Samsonov (vonosmas)

Changes

This has been added in 0071a79 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 --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() {

@vonosmas vonosmas merged commit b30f9d7 into llvm:main Jan 9, 2025
13 checks passed
@vonosmas vonosmas deleted the thread-callback branch January 9, 2025 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants