LibC: Make _get_uthread a macro
This allows nice inlining :)
This commit is contained in:
parent
4e705a91af
commit
4a95343936
|
@ -1,8 +1,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern uthread* _get_uthread();
|
|
||||||
|
|
||||||
int* __errno_location()
|
int* __errno_location()
|
||||||
{
|
{
|
||||||
return &_get_uthread()->errno_;
|
return &_get_uthread()->errno_;
|
||||||
|
|
|
@ -87,6 +87,20 @@ struct uthread
|
||||||
#define _PTHREAD_ATFORK_CHILD 2
|
#define _PTHREAD_ATFORK_CHILD 2
|
||||||
void _pthread_call_atfork(int state);
|
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_atfork(void (*prepare)(void), void (*parent)(void), void(*child)(void));
|
||||||
int pthread_attr_destroy(pthread_attr_t* attr);
|
int pthread_attr_destroy(pthread_attr_t* attr);
|
||||||
int pthread_attr_getdetachstate(const pthread_attr_t* attr, int* detachstate);
|
int pthread_attr_getdetachstate(const pthread_attr_t* attr, int* detachstate);
|
||||||
|
|
|
@ -54,17 +54,6 @@ extern "C" void _pthread_trampoline_cpp(void* arg)
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
uthread* _get_uthread()
|
|
||||||
{
|
|
||||||
uthread* result;
|
|
||||||
#if ARCH(x86_64)
|
|
||||||
asm volatile("movq %%fs:0, %0" : "=r"(result));
|
|
||||||
#elif ARCH(i686)
|
|
||||||
asm volatile("movl %%gs:0, %0" : "=r"(result));
|
|
||||||
#endif
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void free_uthread(uthread* uthread)
|
static void free_uthread(uthread* uthread)
|
||||||
{
|
{
|
||||||
if (uthread->dtv[0] == 0)
|
if (uthread->dtv[0] == 0)
|
||||||
|
|
Loading…
Reference in New Issue