diff options
author | davidxu <davidxu@FreeBSD.org> | 2013-05-16 03:01:04 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2013-05-16 03:01:04 +0000 |
commit | 3eb907a897a67c33fedfa8e99adbc2deac174202 (patch) | |
tree | dcf677237d665b67a00bde03ed8ea3cc48275581 | |
parent | e34342dafe64b19e42001c803d6709c96c3570f4 (diff) | |
download | FreeBSD-src-3eb907a897a67c33fedfa8e99adbc2deac174202.zip FreeBSD-src-3eb907a897a67c33fedfa8e99adbc2deac174202.tar.gz |
Return one-based key so that user can check if the key is ever allocated
in the first place.
Initial patch submitted by: phk
-rw-r--r-- | lib/libthr/thread/thr_spec.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libthr/thread/thr_spec.c b/lib/libthr/thread/thr_spec.c index 86dc794..46a6105 100644 --- a/lib/libthr/thread/thr_spec.c +++ b/lib/libthr/thread/thr_spec.c @@ -70,7 +70,7 @@ _pthread_key_create(pthread_key_t *key, void (*destructor) (void *)) /* Unlock the key table: */ THR_LOCK_RELEASE(curthread, &_keytable_lock); - *key = i; + *key = i + 1; return (0); } @@ -81,9 +81,10 @@ _pthread_key_create(pthread_key_t *key, void (*destructor) (void *)) } int -_pthread_key_delete(pthread_key_t key) +_pthread_key_delete(pthread_key_t userkey) { struct pthread *curthread = _get_curthread(); + int key = userkey - 1; int ret = 0; if ((unsigned int)key < PTHREAD_KEYS_MAX) { @@ -178,9 +179,10 @@ pthread_key_allocate_data(void) } int -_pthread_setspecific(pthread_key_t key, const void *value) +_pthread_setspecific(pthread_key_t userkey, const void *value) { struct pthread *pthread; + pthread_key_t key = userkey - 1; int ret = 0; /* Point to the running thread: */ @@ -209,9 +211,10 @@ _pthread_setspecific(pthread_key_t key, const void *value) } void * -_pthread_getspecific(pthread_key_t key) +_pthread_getspecific(pthread_key_t userkey) { struct pthread *pthread; + pthread_key_t key = userkey - 1; const void *data; /* Point to the running thread: */ |