From fae1c3c350593cb218030a55f8d650439e4003d6 Mon Sep 17 00:00:00 2001 From: marius Date: Sat, 19 Nov 2011 13:04:17 +0000 Subject: [PATCH] MFC: r227539 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. Approved by: re (kib) git-svn-id: svn://svn.freebsd.org/base/releng/9.0@227715 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/sparc64/include/pcpu.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/sparc64/include/pcpu.h b/sys/sparc64/include/pcpu.h index 24548d0b..033f7e52 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. -- 2.42.0