[Libreoffice-commits] .: sal/osl

Joseph Powers jpowers at kemper.freedesktop.org
Fri Jan 28 21:29:11 PST 2011


 sal/osl/unx/interlck.c |   41 +++++++++++++++++++++++++++++++----------
 1 file changed, 31 insertions(+), 10 deletions(-)

New commits:
commit 8238a1bbb6978fc2d51db0eb7379318e5e58b1f8
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Fri Jan 28 21:28:46 2011 -0800

    Fix interlck.c to work on Mac OS again...
    
    mmeeks, we love your patch; however, some of us are forced to use the very
    old 4.0 version of GCC (I blame Apple) and __sync_add_and_fetch() wasn't
    added until version 4.4.
    
    PS: Moving the target OS version to 10.5 wont help because that still uses
    the 4.2.1 version.

diff --git a/sal/osl/unx/interlck.c b/sal/osl/unx/interlck.c
index 71f8d9c..3ab6e96 100644
--- a/sal/osl/unx/interlck.c
+++ b/sal/osl/unx/interlck.c
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -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 )


More information about the Libreoffice-commits mailing list