Make _Thread_local more seamlessly working

This commit is contained in:
Justine Tunney 2022-07-10 08:27:50 -07:00
parent 5f4f6b0e69
commit 5fa77f1e8f
23 changed files with 217 additions and 283 deletions

View file

@ -18,16 +18,15 @@
*/
#include "libc/errno.h"
#include "libc/nexgen32e/gettls.h"
#include "libc/thread/internal.h"
#include "libc/thread/thread.h"
STATIC_YOINK("_main_thread_ctor");
/**
* Gets value of TLS slot for current thread.
*/
void *pthread_getspecific(pthread_key_t key) {
if (key < PTHREAD_KEYS_MAX) {
return ((cthread_t)__get_tls_inline())->key[key];
if (0 <= key && key < PTHREAD_KEYS_MAX) {
return _pthread_keys[key];
} else {
return 0;
}