Changeset View
Changeset View
Standalone View
Standalone View
lib/libthr/thread/thr_list.c
Show All 33 Lines | |||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <pthread.h> | #include <pthread.h> | ||||
#include "libc_private.h" | #include "libc_private.h" | ||||
#include "thr_private.h" | #include "thr_private.h" | ||||
#include "static_tls.h" | |||||
/*#define DEBUG_THREAD_LIST */ | /*#define DEBUG_THREAD_LIST */ | ||||
#ifdef DEBUG_THREAD_LIST | #ifdef DEBUG_THREAD_LIST | ||||
#define DBG_MSG stdout_debug | #define DBG_MSG stdout_debug | ||||
#else | #else | ||||
#define DBG_MSG(x...) | #define DBG_MSG(x...) | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | if (include_dead == 0 && pthread->state == PS_DEAD) { | ||||
THR_THREAD_UNLOCK(curthread, pthread); | THR_THREAD_UNLOCK(curthread, pthread); | ||||
ret = ESRCH; | ret = ESRCH; | ||||
} | } | ||||
} else { | } else { | ||||
ret = ESRCH; | ret = ESRCH; | ||||
} | } | ||||
THREAD_LIST_UNLOCK(curthread); | THREAD_LIST_UNLOCK(curthread); | ||||
return (ret); | return (ret); | ||||
} | |||||
#include "pthread_tls.h" | |||||
static void | |||||
thr_distribute_static_tls(uintptr_t tlsbase, void *src, size_t len, | |||||
size_t total_len) | |||||
{ | |||||
memcpy((void *)tlsbase, src, len); | |||||
memset((char *)tlsbase + len, 0, total_len - len); | |||||
} | |||||
void | |||||
__pthread_distribute_static_tls(size_t offset, void *src, size_t len, | |||||
size_t total_len) | |||||
{ | |||||
struct pthread *curthread, *thrd; | |||||
uintptr_t tlsbase; | |||||
if (!_thr_is_inited()) { | |||||
tlsbase = _libc_get_static_tls_base(offset); | |||||
thr_distribute_static_tls(tlsbase, src, len, total_len); | |||||
return; | |||||
} | |||||
curthread = _get_curthread(); | |||||
THREAD_LIST_RDLOCK(curthread); | |||||
TAILQ_FOREACH(thrd, &_thread_list, tle) { | |||||
tlsbase = _get_static_tls_base(thrd, offset); | |||||
thr_distribute_static_tls(tlsbase, src, len, total_len); | |||||
} | |||||
THREAD_LIST_UNLOCK(curthread); | |||||
} | } |