sal/osl/unx/interlck.cxx | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
New commits: commit 1f7d74380222cae1668067fa7205e0347bd08d93 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Nov 29 21:51:54 2017 +0100 sal: check for HAVE_GCC_BUILTIN_ATOMIC only once in interlck Change-Id: Iaddc79cee0c06f72f636a3d35959922fd78f4e20 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 */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits