Lines Matching full:key

39 static inline size_t to_posix_key_idx(pthread_key_t key)  in to_posix_key_idx()  argument
41 return mark_pthread_obj_uninitialized(key); in to_posix_key_idx()
44 static pthread_key_obj *get_posix_key(pthread_key_t key) in get_posix_key() argument
47 size_t bit = to_posix_key_idx(key); in get_posix_key()
50 if (!is_pthread_obj_initialized(key)) { in get_posix_key()
51 LOG_DBG("Key is uninitialized (%x)", key); in get_posix_key()
57 LOG_DBG("Key is invalid (%x)", key); in get_posix_key()
63 LOG_DBG("Key claims to be initialized (%x)", key); in get_posix_key()
70 static pthread_key_obj *to_posix_key(pthread_key_t *key) in to_posix_key() argument
75 if (*key != PTHREAD_KEY_INITIALIZER) { in to_posix_key()
76 return get_posix_key(*key); in to_posix_key()
86 *key = mark_pthread_obj_initialized(bit); in to_posix_key()
96 * @brief Create a key for thread-specific data
100 int pthread_key_create(pthread_key_t *key, in pthread_key_create() argument
105 *key = PTHREAD_KEY_INITIALIZER; in pthread_key_create()
106 new_key = to_posix_key(key); in pthread_key_create()
114 LOG_DBG("Initialized key %p (%x)", new_key, *key); in pthread_key_create()
120 * @brief Delete a key for thread-specific data
124 int pthread_key_delete(pthread_key_t key) in pthread_key_delete() argument
133 key_obj = get_posix_key(key); in pthread_key_delete()
139 /* Delete thread-specific elements associated with the key */ in pthread_key_delete()
147 LOG_DBG("Freed key data %p for key %x in thread %x", key_data, key, in pthread_key_delete()
157 LOG_DBG("Deleted key %p (%x)", key_obj, key); in pthread_key_delete()
164 * @brief Associate a thread-specific value with a key
168 int pthread_setspecific(pthread_key_t key, const void *value) in pthread_setspecific() argument
181 /* Traverse the list of keys set by the thread, looking for key. in pthread_setspecific()
182 * If the key is already in the list, re-assign its value. in pthread_setspecific()
183 * Else add the key to the thread's list. in pthread_setspecific()
186 key_obj = get_posix_key(key); in pthread_setspecific()
195 if (thread_spec_data->key == key_obj) { in pthread_setspecific()
196 /* Key is already present so associate thread specific data */ in pthread_setspecific()
198 LOG_DBG("Paired key %x to value %p for thread %x", key, value, in pthread_setspecific()
206 /* Key is already present, so we are done */ in pthread_setspecific()
210 /* Key and data need to be added */ in pthread_setspecific()
214 LOG_DBG("Failed to allocate key data for key %x", key); in pthread_setspecific()
219 LOG_DBG("Allocated key data %p for key %x in thread %x", key_data, key, in pthread_setspecific()
222 /* Associate thread specific data, initialize new key */ in pthread_setspecific()
223 key_data->thread_data.key = key_obj; in pthread_setspecific()
226 /* Append new thread key data to thread's key list */ in pthread_setspecific()
229 /* Append new key data to the key object's list */ in pthread_setspecific()
232 LOG_DBG("Paired key %x to value %p for thread %x", key, value, pthread_self()); in pthread_setspecific()
239 * @brief Get the thread-specific value associated with the key
243 void *pthread_getspecific(pthread_key_t key) in pthread_getspecific() argument
257 key_obj = get_posix_key(key); in pthread_getspecific()
263 /* Traverse the list of keys set by the thread, looking for key */ in pthread_getspecific()
267 if (thread_spec_data->key == key_obj) { in pthread_getspecific()
268 /* Key is present, so get the set thread data */ in pthread_getspecific()