Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/include/pcpu_aux.h
Show All 27 Lines | |||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#ifndef _MACHINE_PCPU_AUX_H_ | #ifndef _MACHINE_PCPU_AUX_H_ | ||||
#define _MACHINE_PCPU_AUX_H_ | #define _MACHINE_PCPU_AUX_H_ | ||||
#ifndef _KERNEL | #if !defined(_KERNEL) && !defined(_KERNEL_UT) | ||||
#error "Not for userspace" | #error "Not for userspace" | ||||
#endif | #endif | ||||
#ifndef _SYS_PCPU_H_ | #ifndef _SYS_PCPU_H_ | ||||
#error "Do not include machine/pcpu_aux.h directly" | #error "Do not include machine/pcpu_aux.h directly" | ||||
#endif | #endif | ||||
/* Required for counters(9) to work on x86. */ | /* Required for counters(9) to work on x86. */ | ||||
_Static_assert(sizeof(struct pcpu) == UMA_PCPU_ALLOC_SIZE, "fix pcpu size"); | _Static_assert(sizeof(struct pcpu) == UMA_PCPU_ALLOC_SIZE, "fix pcpu size"); | ||||
extern struct pcpu *__pcpu; | extern struct pcpu *__pcpu; | ||||
extern struct pcpu temp_bsp_pcpu; | extern struct pcpu temp_bsp_pcpu; | ||||
#ifndef _KERNEL_UT | |||||
imp: same | |||||
static __inline __pure2 struct thread * | static __inline __pure2 struct thread * | ||||
__curthread(void) | __curthread(void) | ||||
{ | { | ||||
struct thread *td; | struct thread *td; | ||||
__asm("movq %%gs:%P1,%0" : "=r" (td) : "n" (offsetof(struct pcpu, | __asm("movq %%gs:%P1,%0" : "=r" (td) : "n" (offsetof(struct pcpu, | ||||
pc_curthread))); | pc_curthread))); | ||||
return (td); | return (td); | ||||
} | } | ||||
#else | |||||
struct thread *__curthread(void); | |||||
#endif | |||||
#define curthread (__curthread()) | #define curthread (__curthread()) | ||||
#define curpcb (&curthread->td_md.md_pcb) | #define curpcb (&curthread->td_md.md_pcb) | ||||
#endif /* _MACHINE_PCPU_AUX_H_ */ | #endif /* _MACHINE_PCPU_AUX_H_ */ |
same