Kaydet (Commit) 1f7d7438 authored tarafından Miklos Vajna's avatar Miklos Vajna

sal: check for HAVE_GCC_BUILTIN_ATOMIC only once in interlck

Change-Id: Iaddc79cee0c06f72f636a3d35959922fd78f4e20
üst bc4e8de8
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment