diff options
author | 2004-06-07 21:11:23 +0000 | |
---|---|---|
committer | 2004-06-07 21:11:23 +0000 | |
commit | f91de67f292fa8f5ed29aa37e5f5b87d8645664d (patch) | |
tree | dab54fdaea4206ab36fc68dc883c9be239ea81d6 /lib/libpthread/thread/thread_storage.c | |
parent | Correctly handle an unaligned long long parameter on stack in varargs functions; (diff) | |
download | wireguard-openbsd-f91de67f292fa8f5ed29aa37e5f5b87d8645664d.tar.xz wireguard-openbsd-f91de67f292fa8f5ed29aa37e5f5b87d8645664d.zip |
major bump to libc and libpthread to break the dependency of a
particular implementation of libpthread for libc. libc no longer
needs pthread.h to compile.
OK millert@, brad@, tedu@
Diffstat (limited to 'lib/libpthread/thread/thread_storage.c')
-rw-r--r-- | lib/libpthread/thread/thread_storage.c | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/lib/libpthread/thread/thread_storage.c b/lib/libpthread/thread/thread_storage.c deleted file mode 100644 index 61609f9c277..00000000000 --- a/lib/libpthread/thread/thread_storage.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $OpenBSD: thread_storage.c,v 1.6 2002/11/05 22:19:55 marc Exp $ */ -/* Public Domain */ - -/* - * libpthread's stronger functions - */ - -#include <stdlib.h> -#include <pthread.h> -#include <string.h> -#include "pthread_private.h" - -void -_libc_private_storage_lock(mutex) - pthread_mutex_t *mutex; -{ - if (__isthreaded && pthread_mutex_lock(mutex) != 0) - PANIC("_libc_private_storage_lock"); -} - -void -_libc_private_storage_unlock(mutex) - pthread_mutex_t *mutex; -{ - if (__isthreaded && pthread_mutex_unlock(mutex) != 0) - PANIC("_libc_private_storage_unlock"); -} - -void * -_libc_private_storage(volkey, init, initsz, error) - volatile struct _thread_private_key_struct * volkey; - void * init; - size_t initsz; - void * error; -{ - void *result; - void (*cleanfn)(void *); - struct _thread_private_key_struct * key; - - /* Use static storage while not threaded: */ - if (!__isthreaded) - return init; - - key = (struct _thread_private_key_struct *)volkey; /* for gcc */ - - /* Create the key once: */ - if (volkey->once.state == PTHREAD_NEEDS_INIT) { - if (pthread_mutex_lock(&key->once.mutex) != 0) - return error; - if (volkey->once.state == PTHREAD_NEEDS_INIT) { - if (key->cleanfn == NULL) - cleanfn = free; - else - cleanfn = key->cleanfn; - if (pthread_key_create(&key->key, cleanfn) != 0) { - pthread_mutex_unlock(&key->once.mutex); - return error; - } - key->once.state = PTHREAD_DONE_INIT; - } - pthread_mutex_unlock(&key->once.mutex); - } - - /* XXX signals may cause re-entrancy here? */ - - /* Acquire this key's thread-specific storage: */ - result = pthread_getspecific(key->key); - - /* Allocate and initialise storage if unallocated: */ - if (result == NULL) { - result = malloc(initsz); - if (result == NULL) - return error; - if (pthread_setspecific(key->key, result) != 0) { - free(result); - return error; - } - memcpy(result, init, initsz); - } - - return result; -} |