diff options
author | Joseph Powers <jpowers27@cox.net> | 2011-01-28 21:28:46 -0800 |
---|---|---|
committer | Joseph Powers <jpowers27@cox.net> | 2011-01-28 21:28:46 -0800 |
commit | 2c04fa0b995cafaa60c868e2f1231595b8a68878 (patch) | |
tree | 25ac95ab86b661de77c000265e054aabe2f01065 | |
parent | Skip the this pointer in cpp2uno_call() (diff) | |
download | core-2c04fa0b995cafaa60c868e2f1231595b8a68878.tar.gz core-2c04fa0b995cafaa60c868e2f1231595b8a68878.zip |
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.
-rw-r--r-- | sal/osl/unx/interlck.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/sal/osl/unx/interlck.c b/sal/osl/unx/interlck.c index 569f17ab1c83..3ab6e9600efd 100644 --- a/sal/osl/unx/interlck.c +++ b/sal/osl/unx/interlck.c @@ -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 ) |