1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #include <stdlib.h>
- #include "pthreadP.h"
- attribute_protected
- void *
- __pthread_getspecific (pthread_key_t key)
- {
- struct pthread_key_data *data;
-
- if (__builtin_expect (key < PTHREAD_KEY_2NDLEVEL_SIZE, 1))
- data = &THREAD_SELF->specific_1stblock[key];
- else
- {
-
- if (key >= PTHREAD_KEYS_MAX)
-
- return NULL;
- unsigned int idx1st = key / PTHREAD_KEY_2NDLEVEL_SIZE;
- unsigned int idx2nd = key % PTHREAD_KEY_2NDLEVEL_SIZE;
-
- struct pthread_key_data *level2 = THREAD_GETMEM_NC (THREAD_SELF,
- specific, idx1st);
- if (level2 == NULL)
-
- return NULL;
-
- data = &level2[idx2nd];
- }
- void *result = data->data;
- if (result != NULL)
- {
- uintptr_t seq = data->seq;
- if (__builtin_expect (seq != __pthread_keys[key].seq, 0))
- result = data->data = NULL;
- }
- return result;
- }
- strong_alias (__pthread_getspecific, pthread_getspecific)
- strong_alias (__pthread_getspecific, __pthread_getspecific_internal)
|