Changeset View
Changeset View
Standalone View
Standalone View
lib/libthr/thread/thr_init.c
Show First 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | |||||
STATIC_LIB_REQUIRE(_pthread_create); | STATIC_LIB_REQUIRE(_pthread_create); | ||||
/* Pull in all symbols required by libthread_db */ | /* Pull in all symbols required by libthread_db */ | ||||
STATIC_LIB_REQUIRE(_thread_state_running); | STATIC_LIB_REQUIRE(_thread_state_running); | ||||
#define DUAL_ENTRY(entry) \ | #define DUAL_ENTRY(entry) \ | ||||
(pthread_func_t)entry, (pthread_func_t)entry | (pthread_func_t)entry, (pthread_func_t)entry | ||||
void __pthread_cleanup_push_imp1(void (*)(void *), void *, | |||||
struct _pthread_cleanup_info *); | |||||
void __pthread_cleanup_pop_imp1(int); | |||||
void _thr_cancel_enter(struct pthread *); | |||||
void _thr_cancel_leave(struct pthread *, int); | |||||
static pthread_func_t jmp_table[][2] = { | static pthread_func_t jmp_table[][2] = { | ||||
{DUAL_ENTRY(_pthread_atfork)}, /* PJT_ATFORK */ | {DUAL_ENTRY(_pthread_atfork)}, /* PJT_ATFORK */ | ||||
{DUAL_ENTRY(_pthread_attr_destroy)}, /* PJT_ATTR_DESTROY */ | {DUAL_ENTRY(_pthread_attr_destroy)}, /* PJT_ATTR_DESTROY */ | ||||
{DUAL_ENTRY(_pthread_attr_getdetachstate)}, /* PJT_ATTR_GETDETACHSTATE */ | {DUAL_ENTRY(_pthread_attr_getdetachstate)}, /* PJT_ATTR_GETDETACHSTATE */ | ||||
{DUAL_ENTRY(_pthread_attr_getguardsize)}, /* PJT_ATTR_GETGUARDSIZE */ | {DUAL_ENTRY(_pthread_attr_getguardsize)}, /* PJT_ATTR_GETGUARDSIZE */ | ||||
{DUAL_ENTRY(_pthread_attr_getinheritsched)}, /* PJT_ATTR_GETINHERITSCHED */ | {DUAL_ENTRY(_pthread_attr_getinheritsched)}, /* PJT_ATTR_GETINHERITSCHED */ | ||||
{DUAL_ENTRY(_pthread_attr_getschedparam)}, /* PJT_ATTR_GETSCHEDPARAM */ | {DUAL_ENTRY(_pthread_attr_getschedparam)}, /* PJT_ATTR_GETSCHEDPARAM */ | ||||
{DUAL_ENTRY(_pthread_attr_getschedpolicy)}, /* PJT_ATTR_GETSCHEDPOLICY */ | {DUAL_ENTRY(_pthread_attr_getschedpolicy)}, /* PJT_ATTR_GETSCHEDPOLICY */ | ||||
Show All 18 Lines | static pthread_func_t jmp_table[][2] = { | ||||
{DUAL_ENTRY(_pthread_cond_signal)}, /* PJT_COND_SIGNAL */ | {DUAL_ENTRY(_pthread_cond_signal)}, /* PJT_COND_SIGNAL */ | ||||
{DUAL_ENTRY(_pthread_cond_timedwait)}, /* PJT_COND_TIMEDWAIT */ | {DUAL_ENTRY(_pthread_cond_timedwait)}, /* PJT_COND_TIMEDWAIT */ | ||||
{(pthread_func_t)__pthread_cond_wait, | {(pthread_func_t)__pthread_cond_wait, | ||||
(pthread_func_t)_pthread_cond_wait}, /* PJT_COND_WAIT */ | (pthread_func_t)_pthread_cond_wait}, /* PJT_COND_WAIT */ | ||||
{DUAL_ENTRY(_pthread_detach)}, /* PJT_DETACH */ | {DUAL_ENTRY(_pthread_detach)}, /* PJT_DETACH */ | ||||
{DUAL_ENTRY(_pthread_equal)}, /* PJT_EQUAL */ | {DUAL_ENTRY(_pthread_equal)}, /* PJT_EQUAL */ | ||||
{DUAL_ENTRY(_pthread_exit)}, /* PJT_EXIT */ | {DUAL_ENTRY(_pthread_exit)}, /* PJT_EXIT */ | ||||
{DUAL_ENTRY(_pthread_getspecific)}, /* PJT_GETSPECIFIC */ | {DUAL_ENTRY(_pthread_getspecific)}, /* PJT_GETSPECIFIC */ | ||||
{DUAL_ENTRY(_pthread_join)}, /* PJT_JOIN */ | {DUAL_ENTRY(_thr_join)}, /* PJT_JOIN */ | ||||
{DUAL_ENTRY(_pthread_key_create)}, /* PJT_KEY_CREATE */ | {DUAL_ENTRY(_pthread_key_create)}, /* PJT_KEY_CREATE */ | ||||
{DUAL_ENTRY(_pthread_key_delete)}, /* PJT_KEY_DELETE*/ | {DUAL_ENTRY(_pthread_key_delete)}, /* PJT_KEY_DELETE*/ | ||||
{DUAL_ENTRY(_pthread_kill)}, /* PJT_KILL */ | {DUAL_ENTRY(_pthread_kill)}, /* PJT_KILL */ | ||||
{DUAL_ENTRY(_pthread_main_np)}, /* PJT_MAIN_NP */ | {DUAL_ENTRY(_pthread_main_np)}, /* PJT_MAIN_NP */ | ||||
{DUAL_ENTRY(_pthread_mutexattr_destroy)}, /* PJT_MUTEXATTR_DESTROY */ | {DUAL_ENTRY(_pthread_mutexattr_destroy)}, /* PJT_MUTEXATTR_DESTROY */ | ||||
{DUAL_ENTRY(_pthread_mutexattr_init)}, /* PJT_MUTEXATTR_INIT */ | {DUAL_ENTRY(_pthread_mutexattr_init)}, /* PJT_MUTEXATTR_INIT */ | ||||
{DUAL_ENTRY(_pthread_mutexattr_settype)}, /* PJT_MUTEXATTR_SETTYPE */ | {DUAL_ENTRY(_pthread_mutexattr_settype)}, /* PJT_MUTEXATTR_SETTYPE */ | ||||
{DUAL_ENTRY(_pthread_mutex_destroy)}, /* PJT_MUTEX_DESTROY */ | {DUAL_ENTRY(_pthread_mutex_destroy)}, /* PJT_MUTEX_DESTROY */ | ||||
Show All 12 Lines | static pthread_func_t jmp_table[][2] = { | ||||
{DUAL_ENTRY(_pthread_rwlock_unlock)}, /* PJT_RWLOCK_UNLOCK */ | {DUAL_ENTRY(_pthread_rwlock_unlock)}, /* PJT_RWLOCK_UNLOCK */ | ||||
{DUAL_ENTRY(_pthread_rwlock_wrlock)}, /* PJT_RWLOCK_WRLOCK */ | {DUAL_ENTRY(_pthread_rwlock_wrlock)}, /* PJT_RWLOCK_WRLOCK */ | ||||
{DUAL_ENTRY(_pthread_self)}, /* PJT_SELF */ | {DUAL_ENTRY(_pthread_self)}, /* PJT_SELF */ | ||||
{DUAL_ENTRY(_pthread_setcancelstate)}, /* PJT_SETCANCELSTATE */ | {DUAL_ENTRY(_pthread_setcancelstate)}, /* PJT_SETCANCELSTATE */ | ||||
{DUAL_ENTRY(_pthread_setcanceltype)}, /* PJT_SETCANCELTYPE */ | {DUAL_ENTRY(_pthread_setcanceltype)}, /* PJT_SETCANCELTYPE */ | ||||
{DUAL_ENTRY(_pthread_setspecific)}, /* PJT_SETSPECIFIC */ | {DUAL_ENTRY(_pthread_setspecific)}, /* PJT_SETSPECIFIC */ | ||||
{DUAL_ENTRY(_pthread_sigmask)}, /* PJT_SIGMASK */ | {DUAL_ENTRY(_pthread_sigmask)}, /* PJT_SIGMASK */ | ||||
{DUAL_ENTRY(_pthread_testcancel)}, /* PJT_TESTCANCEL */ | {DUAL_ENTRY(_pthread_testcancel)}, /* PJT_TESTCANCEL */ | ||||
{DUAL_ENTRY(__pthread_cleanup_pop_imp)},/* PJT_CLEANUP_POP_IMP */ | {DUAL_ENTRY(__pthread_cleanup_pop_imp1)},/* PJT_CLEANUP_POP_IMP */ | ||||
{DUAL_ENTRY(__pthread_cleanup_push_imp)},/* PJT_CLEANUP_PUSH_IMP */ | {DUAL_ENTRY(__pthread_cleanup_push_imp1)},/* PJT_CLEANUP_PUSH_IMP */ | ||||
{DUAL_ENTRY(_pthread_cancel_enter)}, /* PJT_CANCEL_ENTER */ | {DUAL_ENTRY(_thr_cancel_enter)}, /* PJT_CANCEL_ENTER */ | ||||
{DUAL_ENTRY(_pthread_cancel_leave)}, /* PJT_CANCEL_LEAVE */ | {DUAL_ENTRY(_thr_cancel_leave)}, /* PJT_CANCEL_LEAVE */ | ||||
{DUAL_ENTRY(_pthread_mutex_consistent)},/* PJT_MUTEX_CONSISTENT */ | {DUAL_ENTRY(_pthread_mutex_consistent)},/* PJT_MUTEX_CONSISTENT */ | ||||
{DUAL_ENTRY(_pthread_mutexattr_getrobust)},/* PJT_MUTEXATTR_GETROBUST */ | {DUAL_ENTRY(_pthread_mutexattr_getrobust)},/* PJT_MUTEXATTR_GETROBUST */ | ||||
{DUAL_ENTRY(_pthread_mutexattr_setrobust)},/* PJT_MUTEXATTR_SETROBUST */ | {DUAL_ENTRY(_pthread_mutexattr_setrobust)},/* PJT_MUTEXATTR_SETROBUST */ | ||||
{DUAL_ENTRY(_pthread_getthreadid_np)}, /* PJT_GETTHREADID_NP */ | {DUAL_ENTRY(_pthread_getthreadid_np)}, /* PJT_GETTHREADID_NP */ | ||||
}; | }; | ||||
static int init_once = 0; | static int init_once = 0; | ||||
Show All 23 Lines | |||||
* | * | ||||
* This is only called under two conditions: | * This is only called under two conditions: | ||||
* | * | ||||
* 1) Some thread routines have detected that the library hasn't yet | * 1) Some thread routines have detected that the library hasn't yet | ||||
* been initialized (_thr_initial == NULL && curthread == NULL), or | * been initialized (_thr_initial == NULL && curthread == NULL), or | ||||
* | * | ||||
* 2) An explicit call to reinitialize after a fork (indicated | * 2) An explicit call to reinitialize after a fork (indicated | ||||
* by curthread != NULL) | * by curthread != NULL) | ||||
*/ | */ | ||||
arichardson: Actually we might get the same problem as for `_thr_self` here since there is a `thr_kill`… | |||||
Done Inline ActionsAnd thr_exit. kib: And thr_exit. | |||||
void | void | ||||
_libpthread_init(struct pthread *curthread) | _libpthread_init(struct pthread *curthread) | ||||
{ | { | ||||
int first, dlopened; | int first, dlopened; | ||||
/* Check if this function has already been called: */ | /* Check if this function has already been called: */ | ||||
if (_thr_initial != NULL && curthread == NULL) | if (_thr_initial != NULL && curthread == NULL) | ||||
/* Only initialize the threaded application once. */ | /* Only initialize the threaded application once. */ | ||||
▲ Show 20 Lines • Show All 180 Lines • Show Last 20 Lines |
Actually we might get the same problem as for _thr_self here since there is a thr_kill syscall?