/* Copyright (c) 1993 Xerox Corporation. All rights reserved. */ /* * PCR_ThCurr.h * * Current thread computation guaranteed to work even when there * are multiple processors. * */ #ifndef __PCR_ThCurr_h #define __PCR_ThCurr_h #include #include extern PCR_ThPvt_SlotData * PCR_ThCurr_GetSlotData(void); extern PCR_ThPvt_SlotData * PCR_ThCurr_GetSlotDataFromSP(void *p); /* Return pointer to the thread slot data of the current thread or the thread whose stack contains location p. The caller must ensure that the thread won't disappear, either by holding appropriate locks or by being the thread. */ #define PCR_ThCurr_GetForkData() \ ((PCR_ThCurr_GetSlotData())->tsd_tfd) #define PCR_ThCurr_GetForkDataFromSP(p) \ ((PCR_ThCurr_GetSlotDataFromSP(p))->tsd_tfd) extern PCR_Th_T * PCR_Th_CurrThread(void); /* Return (opaque) pointer to current thread. This is also declared in PCR_Th.h. Equivalent to PCR_ThPvt_PublicFromForkData(PCR_ThCurr_GetForkData()) for any automatic variable x. */ extern void PCR_ThCurr_Update(PCR_ThPvt_SlotData *tsd, PCR_ThPvt_SlotData *newVal); /* Insert tsd's stack into the ThCurr data structures so that a call to PCR_ThCurr_GetThread(p) (where p is an address in the stack of tsd) will return newVal. Standard usage: PCR_ThCurr_Update(tsd, tsd) at thread create time. PCR_ThCurr_Update(tsd, NIL) at thread slot destroy time. The update to NIL is necessary to allow the thread slot to be garbage collected. */ #endif /* __PCR_ThCurr_h */