diff options
author | marius <marius@FreeBSD.org> | 2011-11-15 20:17:18 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2011-11-15 20:17:18 +0000 |
commit | 6e89cebeb5a84ba17752fa897457afc9290cfe7d (patch) | |
tree | 251a03c5132cc63ad8bfccb9c7c28568a43dab16 /sys/sparc64 | |
parent | e4caa3a047dedda183a89b1d822fddedbafda85d (diff) | |
download | FreeBSD-src-6e89cebeb5a84ba17752fa897457afc9290cfe7d.zip FreeBSD-src-6e89cebeb5a84ba17752fa897457afc9290cfe7d.tar.gz |
Define curthread as an inline function that loads the thread pointer
directly from g7, the pcpu pointer. This guarantees correct behavior
when the thread migrates to a different CPU.
Commit message stolen from r205431. Additional testing by Peter Jeremy.
MFC after: 3 days
Diffstat (limited to 'sys/sparc64')
-rw-r--r-- | sys/sparc64/include/pcpu.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/sparc64/include/pcpu.h b/sys/sparc64/include/pcpu.h index 24548d0..033f7e5 100644 --- a/sys/sparc64/include/pcpu.h +++ b/sys/sparc64/include/pcpu.h @@ -74,6 +74,16 @@ register struct pcpu *pcpup __asm__(__XSTRING(PCPU_REG)); #define PCPU_GET(member) (pcpup->pc_ ## member) +static __inline __pure2 struct thread * +__curthread(void) +{ + struct thread *td; + + __asm("ldx [%" __XSTRING(PCPU_REG) "], %0" : "=r" (td)); + return (td); +} +#define curthread (__curthread()) + /* * XXX The implementation of this operation should be made atomic * with respect to preemption. |