LibC: Make _get_uthread a macro

This allows nice inlining :)
This commit is contained in:
2025-08-03 19:33:01 +03:00
parent 4e705a91af
commit 4a95343936
3 changed files with 14 additions and 13 deletions

View File

@@ -87,6 +87,20 @@ struct uthread
#define _PTHREAD_ATFORK_CHILD 2
void _pthread_call_atfork(int state);
#if defined(__x86_64__)
#define _get_uthread() ({ \
struct uthread* __tmp; \
asm volatile("movq %%fs:0, %0" : "=r"(__tmp)); \
__tmp; \
})
#elif defined(__i686__)
#define _get_uthread() ({ \
struct uthread* __tmp; \
asm volatile("movl %%gs:0, %0" : "=r"(__tmp)); \
__tmp; \
})
#endif
int pthread_atfork(void (*prepare)(void), void (*parent)(void), void(*child)(void));
int pthread_attr_destroy(pthread_attr_t* attr);
int pthread_attr_getdetachstate(const pthread_attr_t* attr, int* detachstate);