LibC: Define pthread_{equal,self} as macros
These really should get inlined :D
This commit is contained in:
@@ -169,6 +169,12 @@ void pthread_testcancel(void);
|
|||||||
void pthread_cleanup_pop(int execute);
|
void pthread_cleanup_pop(int execute);
|
||||||
void pthread_cleanup_push(void (*routine)(void*), void* arg);
|
void pthread_cleanup_push(void (*routine)(void*), void* arg);
|
||||||
|
|
||||||
|
#define _pthread_equal(t1, t2) ((t1) == (t2))
|
||||||
|
#define pthread_equal(t1, t2) _pthread_equal(t1, t2)
|
||||||
|
|
||||||
|
#define _pthread_self() (_get_uthread()->id)
|
||||||
|
#define pthread_self() _pthread_self()
|
||||||
|
|
||||||
#define _pthread_testcancel() do { \
|
#define _pthread_testcancel() do { \
|
||||||
struct uthread* uthread = _get_uthread(); \
|
struct uthread* uthread = _get_uthread(); \
|
||||||
if (__builtin_expect(uthread->cancel_state == PTHREAD_CANCEL_ENABLE, 1)) \
|
if (__builtin_expect(uthread->cancel_state == PTHREAD_CANCEL_ENABLE, 1)) \
|
||||||
|
|||||||
@@ -489,29 +489,29 @@ void pthread_exit(void* value_ptr)
|
|||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef pthread_equal
|
||||||
int pthread_equal(pthread_t t1, pthread_t t2)
|
int pthread_equal(pthread_t t1, pthread_t t2)
|
||||||
{
|
{
|
||||||
return t1 == t2;
|
return _pthread_equal(t1, t2);
|
||||||
}
|
}
|
||||||
|
#define pthread_equal(t1, t2) _pthread_equal(t1, t2)
|
||||||
|
|
||||||
|
#undef pthread_self
|
||||||
|
pthread_t pthread_self(void)
|
||||||
|
{
|
||||||
|
return _pthread_self();
|
||||||
|
}
|
||||||
|
#define pthread_self() _pthread_self()
|
||||||
|
|
||||||
int pthread_join(pthread_t thread, void** value_ptr)
|
int pthread_join(pthread_t thread, void** value_ptr)
|
||||||
{
|
{
|
||||||
pthread_testcancel();
|
do {
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
while (syscall(SYS_PTHREAD_JOIN, thread, value_ptr) == -1 && errno == EINTR)
|
|
||||||
{
|
|
||||||
pthread_testcancel();
|
pthread_testcancel();
|
||||||
errno = 0;
|
errno = 0;
|
||||||
}
|
} while (syscall(SYS_PTHREAD_JOIN, thread, value_ptr) == -1 && errno == EINTR);
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_t pthread_self(void)
|
|
||||||
{
|
|
||||||
return _get_uthread()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pthread_once(pthread_once_t* once_control, void (*init_routine)(void))
|
int pthread_once(pthread_once_t* once_control, void (*init_routine)(void))
|
||||||
{
|
{
|
||||||
static_assert(PTHREAD_ONCE_INIT == 0);
|
static_assert(PTHREAD_ONCE_INIT == 0);
|
||||||
@@ -671,6 +671,7 @@ void pthread_testcancel(void)
|
|||||||
{
|
{
|
||||||
_pthread_testcancel();
|
_pthread_testcancel();
|
||||||
}
|
}
|
||||||
|
#define pthread_testcancel() _pthread_testcancel()
|
||||||
|
|
||||||
int pthread_getschedparam(pthread_t thread, int* __restrict policy, struct sched_param* __restrict param)
|
int pthread_getschedparam(pthread_t thread, int* __restrict policy, struct sched_param* __restrict param)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user