1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 02:13:56 +09:00

LibC+LibPthread: Implement function forwarding for libpthread

GCC will insert various calls to pthread functions when compiling
C++ code with static initializers, even when the user doesn't link
their program against libpthread explicitly.

This is used to make static initializers thread-safe, e.g. when
building a library that does not itself use thread functionality
and thus does not link against libpthread - but is intended to
be used with other code that does use libpthread explicitly.

This makes these symbols available in libc.
This commit is contained in:
Gunnar Beutner 2021-04-17 18:38:32 +02:00 committed by Andreas Kling
parent db3fd11646
commit 88cebb05ad
Notes: sideshowbarker 2024-07-18 19:19:38 +09:00
14 changed files with 381 additions and 100 deletions

View file

@ -49,8 +49,6 @@
#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);
@ -228,8 +226,9 @@ void exit(int status)
fflush(stdout);
fflush(stderr);
if (__libc_pthread_key_destroy_for_current_thread)
__libc_pthread_key_destroy_for_current_thread();
#ifndef _DYNAMIC_LOADER
__pthread_key_destroy_for_current_thread();
#endif
_exit(status);
}