summaryrefslogtreecommitdiff
path: root/sal/osl/unx/interlck.c
diff options
context:
space:
mode:
Diffstat (limited to 'sal/osl/unx/interlck.c')
-rw-r--r--sal/osl/unx/interlck.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/sal/osl/unx/interlck.c b/sal/osl/unx/interlck.c
index 569f17ab1c83..3ab6e9600efd 100644
--- a/sal/osl/unx/interlck.c
+++ b/sal/osl/unx/interlck.c
@@ -48,11 +48,10 @@ oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount*
{
// Fast case for old, slow, single CPU Intel machines for whom
// interlocking is a performance nightmare.
- if ( osl_isSingleCPU ) {
- register oslInterlockedCount nCount asm("%eax");
-
- nCount = 1;
+ register oslInterlockedCount nCount asm("%eax");
+ nCount = 1;
+ if ( osl_isSingleCPU ) {
__asm__ __volatile__ (
"xaddl %0, %1\n\t"
: "+r" (nCount), "+m" (*pCount)
@@ -60,26 +59,48 @@ oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount*
: "memory");
return ++nCount;
}
+#if ( __GNUC__ > 4 ) || (( __GNUC__ == 4) && ( __GNUC_MINOR__ >= 4 ))
else
return __sync_add_and_fetch (pCount, 1);
+#else
+ else {
+ __asm__ __volatile__ (
+ "lock\n\t"
+ "xaddl %0, %1\n\t"
+ : "+r" (nCount), "+m" (*pCount)
+ : /* nothing */
+ : "memory");
+ }
+ return ++nCount;
+#endif
}
oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount)
{
- if ( osl_isSingleCPU ) {
- register oslInterlockedCount nCount asm("%eax");
-
- nCount = -1;
+ register oslInterlockedCount nCount asm("%eax");
+ nCount = -1;
+ if ( osl_isSingleCPU ) {
__asm__ __volatile__ (
"xaddl %0, %1\n\t"
: "+r" (nCount), "+m" (*pCount)
: /* nothing */
: "memory");
- return --nCount;
}
+#if ( __GNUC__ > 4 ) || (( __GNUC__ == 4) && ( __GNUC_MINOR__ >= 4 ))
else
return __sync_sub_and_fetch (pCount, 1);
+#else
+ else {
+ __asm__ __volatile__ (
+ "lock\n\t"
+ "xaddl %0, %1\n\t"
+ : "+r" (nCount), "+m" (*pCount)
+ : /* nothing */
+ : "memory");
+ }
+ return --nCount;
+#endif
}
#elif defined ( GCC )