LibC: Define pthread_{equal,self} as macros

These really should get inlined :D
This commit is contained in:
2026-04-21 00:25:16 +03:00
parent 8665195350
commit 558ed8fd44
2 changed files with 19 additions and 12 deletions

View File

@@ -169,6 +169,12 @@ void pthread_testcancel(void);
void pthread_cleanup_pop(int execute);
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 { \
struct uthread* uthread = _get_uthread(); \
if (__builtin_expect(uthread->cancel_state == PTHREAD_CANCEL_ENABLE, 1)) \

View File

@@ -489,29 +489,29 @@ void pthread_exit(void* value_ptr)
ASSERT_NOT_REACHED();
}
#undef pthread_equal
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)
{
pthread_testcancel();
errno = 0;
while (syscall(SYS_PTHREAD_JOIN, thread, value_ptr) == -1 && errno == EINTR)
{
do {
pthread_testcancel();
errno = 0;
}
} while (syscall(SYS_PTHREAD_JOIN, thread, value_ptr) == -1 && errno == EINTR);
return errno;
}
pthread_t pthread_self(void)
{
return _get_uthread()->id;
}
int pthread_once(pthread_once_t* once_control, void (*init_routine)(void))
{
static_assert(PTHREAD_ONCE_INIT == 0);
@@ -671,6 +671,7 @@ void pthread_testcancel(void)
{
_pthread_testcancel();
}
#define pthread_testcancel() _pthread_testcancel()
int pthread_getschedparam(pthread_t thread, int* __restrict policy, struct sched_param* __restrict param)
{