Kaydet (Commit) d7f50df6 authored tarafından Michael Meeks's avatar Michael Meeks

further simplify old-style interlocked inc/dec

üst 5b3360fa
...@@ -46,52 +46,40 @@ extern int osl_isSingleCPU; ...@@ -46,52 +46,40 @@ extern int osl_isSingleCPU;
/*****************************************************************************/ /*****************************************************************************/
oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount) oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount)
{ {
register oslInterlockedCount nCount asm("%eax"); // Fast case for old, slow, single CPU Intel machines for whom
// interlocking is a performance nightmare.
if ( osl_isSingleCPU ) {
register oslInterlockedCount nCount asm("%eax");
nCount = 1; nCount = 1;
if ( osl_isSingleCPU ) {
__asm__ __volatile__ ( __asm__ __volatile__ (
"xaddl %0, %1\n\t" "xaddl %0, %1\n\t"
: "+r" (nCount), "+m" (*pCount) : "+r" (nCount), "+m" (*pCount)
: /* nothing */ : /* nothing */
: "memory"); : "memory");
return ++nCount;
} }
else { else
__asm__ __volatile__ ( return __sync_add_and_fetch (pCount, 1);
"lock\n\t"
"xaddl %0, %1\n\t"
: "+r" (nCount), "+m" (*pCount)
: /* nothing */
: "memory");
}
return ++nCount;
} }
oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount) oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount)
{ {
register oslInterlockedCount nCount asm("%eax"); if ( osl_isSingleCPU ) {
register oslInterlockedCount nCount asm("%eax");
nCount = -1; nCount = -1;
if ( osl_isSingleCPU ) {
__asm__ __volatile__ ( __asm__ __volatile__ (
"xaddl %0, %1\n\t" "xaddl %0, %1\n\t"
: "+r" (nCount), "+m" (*pCount) : "+r" (nCount), "+m" (*pCount)
: /* nothing */ : /* nothing */
: "memory"); : "memory");
return --nCount;
} }
else { else
__asm__ __volatile__ ( return __sync_sub_and_fetch (pCount, 1);
"lock\n\t"
"xaddl %0, %1\n\t"
: "+r" (nCount), "+m" (*pCount)
: /* nothing */
: "memory");
}
return --nCount;
} }
#elif defined ( GCC ) #elif defined ( GCC )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment