diff options
-rw-r--r-- | sal/osl/unx/interlck.cxx | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/sal/osl/unx/interlck.cxx b/sal/osl/unx/interlck.cxx index bd069e9638dd..e114485877db 100644 --- a/sal/osl/unx/interlck.cxx +++ b/sal/osl/unx/interlck.cxx @@ -25,14 +25,20 @@ #error please use asm/interlck_sparc.s #elif defined (__sun) && defined ( X86 ) #error please use asm/interlck_x86.s +#elif HAVE_GCC_BUILTIN_ATOMIC +oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount) +{ + return __sync_add_and_fetch(pCount, 1); +} +oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount) +{ + return __sync_sub_and_fetch(pCount, 1); +} #elif defined ( __GNUC__ ) && ( defined ( X86 ) || defined ( X86_64 ) ) /* That's possible on x86-64 too since oslInterlockedCount is a sal_Int32 */ oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount) { -#if HAVE_GCC_BUILTIN_ATOMIC - return __sync_add_and_fetch (pCount, 1); -#else register oslInterlockedCount nCount asm("%eax"); nCount = 1; __asm__ __volatile__ ( @@ -42,14 +48,10 @@ oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* : /* nothing */ : "memory"); return ++nCount; -#endif } oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount) { -#if HAVE_GCC_BUILTIN_ATOMIC - return __sync_sub_and_fetch (pCount, 1); -#else register oslInterlockedCount nCount asm("%eax"); nCount = -1; __asm__ __volatile__ ( @@ -59,16 +61,6 @@ oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* : /* nothing */ : "memory"); return --nCount; -#endif -} -#elif HAVE_GCC_BUILTIN_ATOMIC -oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount) -{ - return __sync_add_and_fetch(pCount, 1); -} -oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount) -{ - return __sync_sub_and_fetch(pCount, 1); } #else /* use only if nothing else works, expensive due to single mutex for all reference counts */ |