MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / pthread_getspecific

Function pthread_getspecific

components/libc/posix/pthreads/pthread_tls.c:49–66  ·  view source on GitHub ↗

* @brief Retrieves the value associated with a thread-specific data key for the calling thread. * * This function returns the value that was previously set for the specified key * in the calling thread using `pthread_setspecific`. Each thread has its own independent * value for the same key. * * @param[in] key * The thread-specific data key, created using `pthread_key_create`. * * @re

Source from the content-addressed store, hash-verified

47 * @see pthread_key_create(), pthread_setspecific(), pthread_key_delete()
48 */
49void *pthread_getspecific(pthread_key_t key)
50{
51 struct _pthread_data* ptd;
52
53 if (rt_thread_self() == NULL) return NULL;
54
55 /* get pthread data from user data of thread */
56 ptd = (_pthread_data_t *)rt_thread_self()->pthread_data;
57 RT_ASSERT(ptd != NULL);
58
59 if (ptd->tls == NULL)
60 return NULL;
61
62 if ((key < PTHREAD_KEY_MAX) && (_thread_keys[key].is_used))
63 return ptd->tls[key];
64
65 return NULL;
66}
67RTM_EXPORT(pthread_getspecific);
68
69/**

Callers 3

emutls_get_address_arrayFunction · 0.85
__ARM_TPL_tls_getFunction · 0.85
str_accumulateFunction · 0.85

Calls 1

rt_thread_selfFunction · 0.85

Tested by

no test coverage detected