Return one-based key so that user can check if the key is ever allocated
in the first place. Initial patch submitted by: phk
This commit is contained in:
parent
fa0deba90f
commit
8096915018
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=250691
@ -70,7 +70,7 @@ _pthread_key_create(pthread_key_t *key, void (*destructor) (void *))
|
|||||||
|
|
||||||
/* Unlock the key table: */
|
/* Unlock the key table: */
|
||||||
THR_LOCK_RELEASE(curthread, &_keytable_lock);
|
THR_LOCK_RELEASE(curthread, &_keytable_lock);
|
||||||
*key = i;
|
*key = i + 1;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,9 +81,10 @@ _pthread_key_create(pthread_key_t *key, void (*destructor) (void *))
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_pthread_key_delete(pthread_key_t key)
|
_pthread_key_delete(pthread_key_t userkey)
|
||||||
{
|
{
|
||||||
struct pthread *curthread = _get_curthread();
|
struct pthread *curthread = _get_curthread();
|
||||||
|
int key = userkey - 1;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if ((unsigned int)key < PTHREAD_KEYS_MAX) {
|
if ((unsigned int)key < PTHREAD_KEYS_MAX) {
|
||||||
@ -178,9 +179,10 @@ pthread_key_allocate_data(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_pthread_setspecific(pthread_key_t key, const void *value)
|
_pthread_setspecific(pthread_key_t userkey, const void *value)
|
||||||
{
|
{
|
||||||
struct pthread *pthread;
|
struct pthread *pthread;
|
||||||
|
pthread_key_t key = userkey - 1;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* Point to the running thread: */
|
/* Point to the running thread: */
|
||||||
@ -209,9 +211,10 @@ _pthread_setspecific(pthread_key_t key, const void *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
_pthread_getspecific(pthread_key_t key)
|
_pthread_getspecific(pthread_key_t userkey)
|
||||||
{
|
{
|
||||||
struct pthread *pthread;
|
struct pthread *pthread;
|
||||||
|
pthread_key_t key = userkey - 1;
|
||||||
const void *data;
|
const void *data;
|
||||||
|
|
||||||
/* Point to the running thread: */
|
/* Point to the running thread: */
|
||||||
|
Loading…
Reference in New Issue
Block a user