Kaydet (Commit) 2c04fa0b authored tarafından Joseph Powers's avatar Joseph Powers

Fix interlck.c to work on Mac OS again...

mmeeks, we love your patch; however, some of us are forced to use the very
old 4.0 version of GCC (I blame Apple) and __sync_add_and_fetch() wasn't
added until version 4.4.

PS: Moving the target OS version to 10.5 wont help because that still uses
the 4.2.1 version.
üst b7d48fa5
......@@ -48,11 +48,10 @@ oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount*
{
// 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;
register oslInterlockedCount nCount asm("%eax");
nCount = 1;
if ( osl_isSingleCPU ) {
__asm__ __volatile__ (
"xaddl %0, %1\n\t"
: "+r" (nCount), "+m" (*pCount)
......@@ -60,26 +59,48 @@ oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount*
: "memory");
return ++nCount;
}
#if ( __GNUC__ > 4 ) || (( __GNUC__ == 4) && ( __GNUC_MINOR__ >= 4 ))
else
return __sync_add_and_fetch (pCount, 1);
#else
else {
__asm__ __volatile__ (
"lock\n\t"
"xaddl %0, %1\n\t"
: "+r" (nCount), "+m" (*pCount)
: /* nothing */
: "memory");
}
return ++nCount;
#endif
}
oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount)
{
if ( osl_isSingleCPU ) {
register oslInterlockedCount nCount asm("%eax");
nCount = -1;
register oslInterlockedCount nCount asm("%eax");
nCount = -1;
if ( osl_isSingleCPU ) {
__asm__ __volatile__ (
"xaddl %0, %1\n\t"
: "+r" (nCount), "+m" (*pCount)
: /* nothing */
: "memory");
return --nCount;
}
#if ( __GNUC__ > 4 ) || (( __GNUC__ == 4) && ( __GNUC_MINOR__ >= 4 ))
else
return __sync_sub_and_fetch (pCount, 1);
#else
else {
__asm__ __volatile__ (
"lock\n\t"
"xaddl %0, %1\n\t"
: "+r" (nCount), "+m" (*pCount)
: /* nothing */
: "memory");
}
return --nCount;
#endif
}
#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