diff options
Diffstat (limited to 'lib/libpthread/thread')
-rw-r--r-- | lib/libpthread/thread/Makefile.inc | 5 | ||||
-rw-r--r-- | lib/libpthread/thread/thread_malloc_lock.c | 45 | ||||
-rw-r--r-- | lib/libpthread/thread/thread_mutex.c | 49 | ||||
-rw-r--r-- | lib/libpthread/thread/thread_tag.c | 121 |
4 files changed, 0 insertions, 220 deletions
diff --git a/lib/libpthread/thread/Makefile.inc b/lib/libpthread/thread/Makefile.inc deleted file mode 100644 index a7f50b57a01..00000000000 --- a/lib/libpthread/thread/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.7 2007/06/05 18:11:48 kurt Exp $ - -.PATH: ${SRCDIR}/thread - -SRCS+= thread_tag.c thread_malloc_lock.c thread_mutex.c diff --git a/lib/libpthread/thread/thread_malloc_lock.c b/lib/libpthread/thread/thread_malloc_lock.c deleted file mode 100644 index 6c2057b708e..00000000000 --- a/lib/libpthread/thread/thread_malloc_lock.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: thread_malloc_lock.c,v 1.7 2008/06/13 21:18:43 otto Exp $ */ -/* Public Domain <marc@snafu.org> */ - -#include <pthread.h> -#include "pthread_private.h" - -static spinlock_t malloc_lock = _SPINLOCK_INITIALIZER; -static spinlock_t atexit_lock = _SPINLOCK_INITIALIZER; -static spinlock_t arc4_lock = _SPINLOCK_INITIALIZER; - -void -_thread_malloc_lock() -{ - _SPINLOCK(&malloc_lock); -} - -void -_thread_malloc_unlock() -{ - _SPINUNLOCK(&malloc_lock); -} - -void -_thread_atexit_lock() -{ - _SPINLOCK(&atexit_lock); -} - -void -_thread_atexit_unlock() -{ - _SPINUNLOCK(&atexit_lock); -} - -void -_thread_arc4_lock() -{ - _SPINLOCK(&arc4_lock); -} - -void -_thread_arc4_unlock() -{ - _SPINUNLOCK(&arc4_lock); -} diff --git a/lib/libpthread/thread/thread_mutex.c b/lib/libpthread/thread/thread_mutex.c deleted file mode 100644 index 979a2e2e3fc..00000000000 --- a/lib/libpthread/thread/thread_mutex.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: thread_mutex.c,v 1.1 2007/06/05 18:11:48 kurt Exp $ */ - -/* - * Copyright (c) 2007 Kurt Miller <kurt@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> -#include "thread_private.h" -#include "pthread.h" -#include "pthread_private.h" - -void -_thread_mutex_lock(void **mutex) -{ - pthread_mutex_t *pmutex = (pthread_mutex_t *)mutex; - - if (pthread_mutex_lock(pmutex) != 0) - PANIC("mutex lock failure"); -} - -void -_thread_mutex_unlock(void **mutex) -{ - pthread_mutex_t *pmutex = (pthread_mutex_t *)mutex; - - if (pthread_mutex_unlock(pmutex) != 0) - PANIC("mutex unlock failure"); -} - -void -_thread_mutex_destroy(void **mutex) -{ - pthread_mutex_t *pmutex = (pthread_mutex_t *)mutex; - - if (pthread_mutex_destroy(pmutex) != 0) - PANIC("mutex destroy failure"); -} diff --git a/lib/libpthread/thread/thread_tag.c b/lib/libpthread/thread/thread_tag.c deleted file mode 100644 index 8f7f427aa8d..00000000000 --- a/lib/libpthread/thread/thread_tag.c +++ /dev/null @@ -1,121 +0,0 @@ -/* $OpenBSD: thread_tag.c,v 1.3 2007/06/05 16:30:13 kurt Exp $ */ - -/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */ - -#include <sys/time.h> - -#include <stdlib.h> -#include <string.h> - -#include "thread_private.h" -#include "pthread.h" -#include "pthread_private.h" - -/* - * A thread tag is a pointer to a structure of this type. An opaque - * tag is used to decouple libc from the thread library. - */ -struct _thread_tag { - pthread_mutex_t m; /* the tag's mutex */ - pthread_key_t k; /* a key for private data */ -}; - -/* - * local mutex to protect against tag creation races. - */ -static pthread_mutex_t _thread_tag_mutex = PTHREAD_MUTEX_INITIALIZER; - -/* - * Initialize a thread tag structure once. This function is called - * if the tag is null. Allocation and initialization are controlled - * by a mutex. If the tag is not null when the mutex is obtained - * the caller lost a race -- some other thread initialized the tag. - * This function will never return NULL. - */ -static void -_thread_tag_init(void **tag) -{ - struct _thread_tag *tt; - int result; - - result = pthread_mutex_lock(&_thread_tag_mutex); - if (result == 0) { - if (*tag == NULL) { - tt = malloc(sizeof *tt); - if (tt != NULL) { - result = pthread_mutex_init(&tt->m, NULL); - result |= pthread_key_create(&tt->k, free); - *tag = tt; - } - } - result |= pthread_mutex_unlock(&_thread_tag_mutex); - } - if (result != 0) - PANIC(__func__); -} - -/* - * lock the mutex associated with the given tag - */ -void -_thread_tag_lock(void **tag) -{ - struct _thread_tag *tt; - - if (__isthreaded) { - if (*tag == NULL) - _thread_tag_init(tag); - tt = *tag; - if (pthread_mutex_lock(&tt->m) != 0) - PANIC(__func__); - } -} - -/* - * unlock the mutex associated with the given tag - */ -void -_thread_tag_unlock(void **tag) -{ - struct _thread_tag *tt; - - if (__isthreaded) { - if (*tag == NULL) - _thread_tag_init(tag); - tt = *tag; - if (pthread_mutex_unlock(&tt->m) != 0) - PANIC(__func__); - } -} - -/* - * return the thread specific data for the given tag. If there - * is no data for this thread initialize it from 'storage'. - * On any error return 'err'. - */ -void * -_thread_tag_storage(void **tag, void *storage, size_t sz, void *err) -{ - struct _thread_tag *tt; - void *ret; - - if (*tag == NULL) - _thread_tag_init(tag); - tt = *tag; - - ret = pthread_getspecific(tt->k); - if (ret == NULL) { - ret = malloc(sz); - if (ret == NULL) - ret = err; - else { - if (pthread_setspecific(tt->k, ret) == 0) - memcpy(ret, storage, sz); - else { - free(ret); - ret = err; - } - } - } - return ret; -} |