summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-11-29 21:51:54 +0100
committerAndras Timar <andras.timar@collabora.com>2018-03-19 14:55:50 +0100
commit6dbc7ef6944e89738a4843903a2ae60751d13e0d (patch)
tree9906168c65cbeab126e600d8fff1cf6cbc0af987 /sal
parent0b216454fbce1225d34bde9f5bb7e748da2fe94e (diff)
sal: check for HAVE_GCC_BUILTIN_ATOMIC only once in interlck
Change-Id: Iaddc79cee0c06f72f636a3d35959922fd78f4e20 (cherry picked from commit 1f7d74380222cae1668067fa7205e0347bd08d93)
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/interlck.cxx26
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 */