diff options
| author | Jakob Kaivo <jkk@ung.org> | 2019-02-20 12:00:12 -0500 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2019-02-20 12:00:12 -0500 |
| commit | 52b8c93b7180eac72721d59315aae2b592e7b3a1 (patch) | |
| tree | d304c2e253c56ca39df04e5d346309f08f67c445 /src/nonstd/__pthread_per_thread.c | |
| parent | 49836ed4fa13e431fdbb52e418499853df8693c6 (diff) | |
add symbols from POSIX.1b-1993
Diffstat (limited to 'src/nonstd/__pthread_per_thread.c')
| -rw-r--r-- | src/nonstd/__pthread_per_thread.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/nonstd/__pthread_per_thread.c b/src/nonstd/__pthread_per_thread.c new file mode 100644 index 00000000..0dff3999 --- /dev/null +++ b/src/nonstd/__pthread_per_thread.c @@ -0,0 +1,24 @@ +#include "pthread.h" + +static pthread_key_t __per_thread_key; + +static void __make_key(void) +{ + pthread_key_create(&key, NULL); +} + +static struct per_thread *per_thread(void) +{ + static pthread_once_t key_once = PTHREAD_ONCE_INIT; + struct per_thread *pt; + pthread_once(&key_once, __make_key); + if ((pt = pthread_getspecific(key)) == NULL) { + pt = calloc(1, sizeof (*pt)); + pthread_setspecific(key, pt); + } + return pt; +} + +/* +LINK(pthread) +*/ |
