mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:17:34 +00:00
LibC+LibPthread: Make sure TLS keys are destroyed after everything else
This ensures that __thread variables can be used when global destructors are being invoked.
This commit is contained in:
parent
6eedb570a2
commit
4075b306f8
3 changed files with 18 additions and 12 deletions
|
@ -31,6 +31,7 @@
|
|||
#include <AK/Types.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <LibELF/AuxiliaryVector.h>
|
||||
#include <LibPthread/pthread.h>
|
||||
#include <alloca.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
@ -48,6 +49,8 @@
|
|||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void (*__libc_pthread_key_destroy_for_current_thread)() = nullptr;
|
||||
|
||||
static void strtons(const char* str, char** endptr)
|
||||
{
|
||||
assert(endptr);
|
||||
|
@ -224,6 +227,10 @@ void exit(int status)
|
|||
_fini();
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
if (__libc_pthread_key_destroy_for_current_thread)
|
||||
__libc_pthread_key_destroy_for_current_thread();
|
||||
|
||||
_exit(status);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue