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");
/**
* Sets value of TLS slot for current thread.
*/
int pthread_setspecific(pthread_key_t key, void *val) {
if (key < PTHREAD_KEYS_MAX) {
((cthread_t)__get_tls_inline())->key[key] = val;
if (0 <= key && key < PTHREAD_KEYS_MAX) {
_pthread_keys[key] = val;
return 0;
} else {
return EINVAL;