From 1d6e13e13b36163c07fc6013c9c3da6fc553e697 Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Mon, 27 Aug 2012 10:38:05 +0200 Subject: fdo#53855: Use the newly added HAVE_GCC_BUILTIN_ATOMIC for sal Signed-off-by: Stephan Bergmann : * nCount is needed in else branches after all * tabs -> spaces Change-Id: Iaa39ba9e1ed645819905f0e484fa4f1812271700 --- sal/osl/unx/interlck.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'sal/osl/unx/interlck.c') diff --git a/sal/osl/unx/interlck.c b/sal/osl/unx/interlck.c index bf9ff62b2ecc..91dd9c8d4d56 100644 --- a/sal/osl/unx/interlck.c +++ b/sal/osl/unx/interlck.c @@ -49,10 +49,9 @@ oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* { // Fast case for old, slow, single CPU Intel machines for whom // interlocking is a performance nightmare. - register oslInterlockedCount nCount asm("%eax"); - nCount = 1; - if ( osl_isSingleCPU ) { + register oslInterlockedCount nCount asm("%eax"); + nCount = 1; __asm__ __volatile__ ( "xaddl %0, %1\n\t" : "+r" (nCount), "+m" (*pCount) @@ -60,28 +59,29 @@ oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* : "memory"); return ++nCount; } -#if ( __GNUC__ > 4 ) || (( __GNUC__ == 4) && ( __GNUC_MINOR__ >= 4 )) +#if defined( HAVE_GCC_BUILTIN_ATOMIC ) else return __sync_add_and_fetch (pCount, 1); #else else { + register oslInterlockedCount nCount asm("%eax"); + nCount = 1; __asm__ __volatile__ ( "lock\n\t" "xaddl %0, %1\n\t" : "+r" (nCount), "+m" (*pCount) : /* nothing */ : "memory"); + return ++nCount; } - return ++nCount; #endif } oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount) { - register oslInterlockedCount nCount asm("%eax"); - nCount = -1; - if ( osl_isSingleCPU ) { + register oslInterlockedCount nCount asm("%eax"); + nCount = -1; __asm__ __volatile__ ( "xaddl %0, %1\n\t" : "+r" (nCount), "+m" (*pCount) @@ -89,22 +89,24 @@ oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* : "memory"); return --nCount; } -#if ( __GNUC__ > 4 ) || (( __GNUC__ == 4) && ( __GNUC_MINOR__ >= 4 )) +#if defined( HAVE_GCC_BUILTIN_ATOMIC ) else return __sync_sub_and_fetch (pCount, 1); #else else { + register oslInterlockedCount nCount asm("%eax"); + nCount = -1; __asm__ __volatile__ ( "lock\n\t" "xaddl %0, %1\n\t" : "+r" (nCount), "+m" (*pCount) : /* nothing */ : "memory"); + return --nCount; } - return --nCount; #endif } -#elif ( __GNUC__ > 4 ) || (( __GNUC__ == 4) && ( __GNUC_MINOR__ >= 4 )) +#elif defined( HAVE_GCC_BUILTIN_ATOMIC ) oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount) { return __sync_add_and_fetch(pCount, 1); -- cgit