From d7a2504b1e8c12fe9c7118548f0413b9b5d920b6 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 20 Nov 2003 23:23:22 +0000 Subject: [PATCH] MFamd64: use a less compiler-intensive MD implementation of 'curthread' so that the compiler doesn't have to do so much work. Approved by: re (jhb) --- sys/i386/i386/machdep.c | 3 +++ sys/i386/include/pcpu.h | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index fed0166a3f2..ff608d992dc 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -128,6 +128,9 @@ __FBSDID("$FreeBSD$"); #include #include +/* Sanity check for __curthread() */ +CTASSERT(offsetof(struct pcpu, pc_curthread) == 0); + extern void init386(int first); extern void dblfault_handler(void); diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h index 1e5cba40976..357f52e4e60 100644 --- a/sys/i386/include/pcpu.h +++ b/sys/i386/include/pcpu.h @@ -151,6 +151,16 @@ extern struct pcpu *pcpup; #define PCPU_PTR(member) __PCPU_PTR(pc_ ## member) #define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val) +static __inline struct thread * +__curthread(void) +{ + struct thread *td; + + __asm __volatile("movl %%fs:0,%0" : "=r" (td)); + return (td); +} +#define curthread (__curthread()) + #else #error gcc or lint is required to use this file #endif -- 2.45.2