Changeset View
Changeset View
Standalone View
Standalone View
lib/libthr/arch/arm/include/pthread_md.h
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | struct tcb { | ||||
void *tcb_dtv; /* required by rtld */ | void *tcb_dtv; /* required by rtld */ | ||||
struct pthread *tcb_thread; /* our hook */ | struct pthread *tcb_thread; /* our hook */ | ||||
}; | }; | ||||
/* Called from the thread to set its private data. */ | /* Called from the thread to set its private data. */ | ||||
static __inline void | static __inline void | ||||
_tcb_set(struct tcb *tcb) | _tcb_set(struct tcb *tcb) | ||||
{ | { | ||||
#ifdef ARM_TP_ADDRESS | |||||
*((struct tcb **)ARM_TP_ADDRESS) = tcb; /* avoids a system call */ | |||||
#else | |||||
sysarch(ARM_SET_TP, tcb); | sysarch(ARM_SET_TP, tcb); | ||||
#endif | |||||
} | } | ||||
/* | /* | ||||
* Get the current tcb. | * Get the current tcb. | ||||
*/ | */ | ||||
static __inline struct tcb * | static __inline struct tcb * | ||||
_tcb_get(void) | _tcb_get(void) | ||||
{ | { | ||||
#ifdef ARM_TP_ADDRESS | |||||
return (*((struct tcb **)ARM_TP_ADDRESS)); | |||||
#else | |||||
struct tcb *tcb; | struct tcb *tcb; | ||||
__asm __volatile("mrc p15, 0, %0, c13, c0, 3" \ | __asm __volatile("mrc p15, 0, %0, c13, c0, 3" \ | ||||
: "=r" (tcb)); | : "=r" (tcb)); | ||||
return (tcb); | return (tcb); | ||||
#endif | |||||
} | } | ||||
static __inline struct pthread * | static __inline struct pthread * | ||||
_get_curthread(void) | _get_curthread(void) | ||||
{ | { | ||||
if (_thr_initial) | if (_thr_initial) | ||||
return (_tcb_get()->tcb_thread); | return (_tcb_get()->tcb_thread); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
#endif /* _PTHREAD_MD_H_ */ | #endif /* _PTHREAD_MD_H_ */ |