Skip to content

Commit

Permalink
[libc] Fix return value of __cxa_thread_atexit_impl function. (llvm#1…
Browse files Browse the repository at this point in the history
…22171)

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).
  • Loading branch information
vonosmas authored Jan 9, 2025
1 parent 459d413 commit b30f9d7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libc/src/__support/threads/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit b30f9d7

Please sign in to comment.