summaryrefslogtreecommitdiff
path: root/lib/libpthread/uthread/uthread_spec.c
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2001-08-21 19:24:54 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2001-08-21 19:24:54 +0000
commit16d25a545116e8f7dfac9140d654821d417a8eba (patch)
tree3f00c8ca19e17cde8d276fc02cb5f85fa1d8e5f3 /lib/libpthread/uthread/uthread_spec.c
parent3cfb4c4b00852105397632dba44ff455c6e1cb8f (diff)
Start syncing with FreeBSD:
o Implement _get_curthread() and _set_curthread(). Use it where possible. o Add missing _thread_[enter|leave]_cancellation_point(). o Add a couple of not yet used vars to pthread_private.h. o Remove return's from void functions. This is by no means complete, but instead of doing a big commit, i'll split it in small ones, minimizing diffs.
Diffstat (limited to 'lib/libpthread/uthread/uthread_spec.c')
-rw-r--r--lib/libpthread/uthread/uthread_spec.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/libpthread/uthread/uthread_spec.c b/lib/libpthread/uthread/uthread_spec.c
index 1ac1df46fe4..b1fdeb9dfa5 100644
--- a/lib/libpthread/uthread/uthread_spec.c
+++ b/lib/libpthread/uthread/uthread_spec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_spec.c,v 1.6 1999/11/25 07:01:46 d Exp $ */
+/* $OpenBSD: uthread_spec.c,v 1.7 2001/08/21 19:24:53 fgsch Exp $ */
/*
* Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
* All rights reserved.
@@ -89,6 +89,7 @@ pthread_key_delete(pthread_key_t key)
void
_thread_cleanupspecific(void)
{
+ struct pthread *curthread = _get_curthread();
void *data;
int key;
int itr;
@@ -96,16 +97,16 @@ _thread_cleanupspecific(void)
for (itr = 0; itr < PTHREAD_DESTRUCTOR_ITERATIONS; itr++) {
for (key = 0; key < PTHREAD_KEYS_MAX; key++) {
- if (_thread_run->specific_data_count) {
+ if (curthread->specific_data_count) {
/* Lock the key table entry: */
_SPINLOCK(&key_table[key].lock);
destructor = data = NULL;
if (key_table[key].allocated) {
- if (_thread_run->specific_data[key]) {
- data = (void *) _thread_run->specific_data[key];
- _thread_run->specific_data[key] = NULL;
- _thread_run->specific_data_count--;
+ if (curthread->specific_data[key]) {
+ data = (void *) curthread->specific_data[key];
+ curthread->specific_data[key] = NULL;
+ curthread->specific_data_count--;
destructor = key_table[key].destructor;
}
}
@@ -120,14 +121,14 @@ _thread_cleanupspecific(void)
if (destructor)
destructor(data);
} else {
- free(_thread_run->specific_data);
- _thread_run->specific_data = NULL;
+ free(curthread->specific_data);
+ curthread->specific_data = NULL;
return;
}
}
}
- free(_thread_run->specific_data);
- _thread_run->specific_data = NULL;
+ free(curthread->specific_data);
+ curthread->specific_data = NULL;
}
static inline const void **
@@ -143,11 +144,11 @@ pthread_key_allocate_data(void)
int
pthread_setspecific(pthread_key_t key, const void *value)
{
- pthread_t pthread;
- int ret = 0;
+ struct pthread *pthread;
+ int ret = 0;
/* Point to the running thread: */
- pthread = _thread_run;
+ pthread = _get_curthread();
if ((pthread->specific_data) ||
(pthread->specific_data = pthread_key_allocate_data())) {
@@ -174,11 +175,11 @@ pthread_setspecific(pthread_key_t key, const void *value)
void *
pthread_getspecific(pthread_key_t key)
{
- pthread_t pthread;
+ struct pthread *pthread;
void *data;
/* Point to the running thread: */
- pthread = _thread_run;
+ pthread = _get_curthread();
/* Check if there is specific data: */
if (pthread->specific_data != NULL && key < PTHREAD_KEYS_MAX) {