Index: sys/amd64/amd64/support.S =================================================================== --- sys/amd64/amd64/support.S +++ sys/amd64/amd64/support.S @@ -1556,3 +1556,9 @@ ret #undef L1D_FLUSH_SIZE END(flush_l1d_sw) + +/* Return the current thread. */ +ENTRY(__curthread) + movq PCPU(CURTHREAD),%rax + ret +END(__curthread) Index: sys/amd64/include/pcpu.h =================================================================== --- sys/amd64/include/pcpu.h +++ sys/amd64/include/pcpu.h @@ -218,22 +218,7 @@ #define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val) #define OFFSETOF_CURTHREAD 0 -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnull-dereference" -#endif -static __inline __pure2 struct thread * -__curthread(void) -{ - struct thread *td; - - __asm("movq %%gs:%1,%0" : "=r" (td) - : "m" (*(char *)OFFSETOF_CURTHREAD)); - return (td); -} -#ifdef __clang__ -#pragma clang diagnostic pop -#endif +struct thread * __curthread(void) __pure2 __attribute__((no_caller_saved_registers)); #define curthread (__curthread()) #define OFFSETOF_CURPCB 32