Define curthread as an inline function that loads the thread pointer

directly from r13, the pcpu pointer. This guarantees correct behaviour
when the thread migrates to a different CPU.
This commit is contained in:
Marcel Moolenaar 2010-03-22 02:01:33 +00:00
parent a5d64faeca
commit c56153c577

View File

@ -70,6 +70,16 @@ struct pcpu;
register struct pcpu *pcpup __asm__("r13");
static __inline struct thread *
__curthread(void)
{
struct thread *td;
__asm __volatile("ld8.acq %0=[r13]" : "=r"(td));
return (td);
}
#define curthread (__curthread())
#define PCPU_GET(member) (pcpup->pc_ ## member)
/*