Fix Linux compile error

This was SVN commit r7743.
This commit is contained in:
Ykkrosh 2010-07-12 22:14:28 +00:00
parent 9f66c86d64
commit ee72115b7a
2 changed files with 13 additions and 2 deletions

View File

@ -52,7 +52,7 @@ LibError ModuleInit(volatile ModuleInitState* initState, LibError (*init)())
const ModuleInitState latchedInitState = *initState;
if(latchedInitState == UNINITIALIZED || latchedInitState == BUSY)
{
_mm_pause();
cpu_Pause();
continue;
}
@ -77,7 +77,7 @@ LibError ModuleShutdown(volatile ModuleInitState* initState, void (*shutdown)())
const ModuleInitState latchedInitState = *initState;
if(latchedInitState == INITIALIZED || latchedInitState == BUSY)
{
_mm_pause();
cpu_Pause();
continue;
}

View File

@ -101,6 +101,17 @@ LIB_API void cpu_AtomicAdd(volatile intptr_t* location, intptr_t increment);
**/
LIB_API void cpu_Serialize();
/**
* pause in spin-wait loops, as a performance optimisation.
**/
inline void cpu_Pause()
{
#if MSC_VER && (ARCH_IA32 || ARCH_AMD64)
_mm_pause();
#elif GCC_VER && (ARCH_IA32 || ARCH_AMD64)
__asm__ __volatile__( "rep; nop" : : : "memory" );
#endif
}
//-----------------------------------------------------------------------------
// misc