/*++ Function: PAL_ReenterForEH Abstract: This function needs to be called on a thread when it enters a region of code that depends on this instance of the PAL in the process, and it is unknown whether the current thread is already running in the PAL. Returns TRUE if and only if the thread was not running in the PAL previously. NOTE: This function must not modify LastError. --*/ BOOL PALAPI PAL_ReenterForEH() { // Only trace if we actually reenter (otherwise, too verbose) // ENTRY_EXTERNAL("PAL_ReenterForEH()\n"); // Thus we have to split up what ENTRY_EXTERNAL does. CHECK_STACK_ALIGN; BOOL fEntered = FALSE; CPalThread *pThread = GetCurrentPalThread(); if (pThread == NULL) { ASSERT("PAL_ReenterForEH called on a thread unknown to this PAL\n"); } else if (!pThread->IsInPal()) { #if !_NO_DEBUG_MESSAGES_ DBG_PRINTF(DLI_ENTRY, defdbgchan, TRUE)("PAL_ReenterForEH()\n"); #endif // We ignore the return code. This call should only fail on internal // error, and we assert at the actual failure. pThread->Enter(PAL_BoundaryEH); fEntered = TRUE; LOGEXIT("PAL_ReenterForEH returns TRUE\n"); } else { // LOGEXIT("PAL_ReenterForEH returns FALSE\n"); } return fEntered; }
/*++ Function: PAL_HasEntered Abstract: This function can be called to determine if the thread has entered the PAL through PAL_Enter or related calls. --*/ BOOL PALAPI PAL_HasEntered() { ENTRY_EXTERNAL("PAL_HasEntered()\n"); CPalThread *pThread = GetCurrentPalThread(); if (pThread == NULL) { ASSERT("PAL_Reenter called on a thread unknown to this PAL\n"); } LOGEXIT("PAL_HasEntered returned\n"); return pThread->IsInPal(); }
/*++ Function: CheckPalThread Abstract: This function is called by the ENTRY macro to validate consistency: Whenever a PAL function is called, that thread must have previously registered the fact that it is currently executing code that depends on this PAL by means of PAL_ReverseEnter or PAL_Enter. --*/ extern "C" void CheckPalThread() { if (PALIsInitialized()) { CPalThread *pThread = InternalGetCurrentThread(); if (!pThread) { ASSERT("PAL function called on a thread unknown to this PAL\n"); } else if (!pThread->IsInPal()) { // There are several outstanding issues where we are not maintaining // correct in- vs. out-of-thePAL state. With the advent of // single registration of Mach EH handling per thread, there's no // need to actually be in the PAL any more, and so the following // is being made into a warning, and we'll deprecate the // entire concept later. WARN("PAL function called on a thread external to this PAL\n"); } } }