summaryrefslogtreecommitdiff
path: root/pthread_setspecific.c
diff options
context:
space:
mode:
authorrpj <rpj>2004-11-03 01:08:41 +0000
committerrpj <rpj>2004-11-03 01:08:41 +0000
commitec8290acdaea21b16d98f1ef5d4ae8a28ab2109a (patch)
tree0bd3750ec1cc12594b6cfe69473e393da6ec101b /pthread_setspecific.c
parentcccaf0c2c82e78a72d69a4a50c872f308bed2f65 (diff)
Mutex, semaphore, thread ID, test suite changes - see ChangeLogs
Diffstat (limited to 'pthread_setspecific.c')
-rw-r--r--pthread_setspecific.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/pthread_setspecific.c b/pthread_setspecific.c
index b7c82d0..ed8253f 100644
--- a/pthread_setspecific.c
+++ b/pthread_setspecific.c
@@ -76,7 +76,7 @@ pthread_setspecific (pthread_key_t key, const void *value)
* thread if one wasn't explicitly created
*/
self = pthread_self ();
- if (self == NULL)
+ if (self.p == NULL)
{
return ENOENT;
}
@@ -87,11 +87,21 @@ pthread_setspecific (pthread_key_t key, const void *value)
* Resolve catch-22 of registering thread with selfThread
* key
*/
- self = (pthread_t) pthread_getspecific (ptw32_selfThreadKey);
- if (self == NULL)
- {
- self = (pthread_t) value;
- }
+ ptw32_thread_t * sp;
+
+ sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey);
+ if (sp == NULL)
+ {
+ if (value == NULL)
+ {
+ return ENOENT;
+ }
+ self = *((pthread_t *) value);
+ }
+ else
+ {
+ self = sp->ptHandle;
+ }
}
result = 0;
@@ -100,8 +110,10 @@ pthread_setspecific (pthread_key_t key, const void *value)
{
ThreadKeyAssoc *assoc;
- if (self != NULL && key->destructor != NULL && value != NULL)
+ if (self.p != NULL && key->destructor != NULL && value != NULL)
{
+ ptw32_thread_t * sp = (ptw32_thread_t *) self.p;
+
/*
* Only require associations if we have to
* call user destroy routine.
@@ -111,7 +123,7 @@ pthread_setspecific (pthread_key_t key, const void *value)
* on the association; setting assoc to NULL short
* circuits the search.
*/
- assoc = (ThreadKeyAssoc *) self->keys;
+ assoc = (ThreadKeyAssoc *) sp->keys;
/*
* Locate existing association
*/