svn commit: r227716 - stable/8/sys/sparc64/include

Marius Strobl marius at FreeBSD.org
Sat Nov 19 13:29:55 UTC 2011


Author: marius
Date: Sat Nov 19 13:29:55 2011
New Revision: 227716
URL: http://svn.freebsd.org/changeset/base/227716

Log:
  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.

Modified:
  stable/8/sys/sparc64/include/pcpu.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/sparc64/include/pcpu.h
==============================================================================
--- stable/8/sys/sparc64/include/pcpu.h	Sat Nov 19 13:04:17 2011	(r227715)
+++ stable/8/sys/sparc64/include/pcpu.h	Sat Nov 19 13:29:55 2011	(r227716)
@@ -73,6 +73,16 @@ register struct pcpu *pcpup __asm__(__XS
 
 #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.


More information about the svn-src-all mailing list