diff options
author | Rüdiger Timm <rt@openoffice.org> | 2006-10-27 10:59:29 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2006-10-27 10:59:29 +0000 |
commit | ab41e4afad4edffea2dbabbd987b0fe3ddbc07ab (patch) | |
tree | c9180480923a0b226662e4a2cada75b3ac42d63a | |
parent | ce4cb813ba9c6ad1d69e7c1e9f14299e3ddb964a (diff) |
INTEGRATION: CWS hr39 (1.12.156); FILE MERGED
2006/10/06 13:55:48 hr 1.12.156.1: #i70157#: don't use lock prefix on a single processor, single core, non HT machine
-rw-r--r-- | sal/osl/unx/interlck.c | 72 |
1 files changed, 46 insertions, 26 deletions
diff --git a/sal/osl/unx/interlck.c b/sal/osl/unx/interlck.c index 5e07528e5194..319763cff6f3 100644 --- a/sal/osl/unx/interlck.c +++ b/sal/osl/unx/interlck.c @@ -4,9 +4,9 @@ * * $RCSfile: interlck.c,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: rt $ $Date: 2005-09-08 14:57:16 $ + * last change: $Author: rt $ $Date: 2006-10-27 11:59:29 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -46,39 +46,59 @@ #elif defined ( GCC ) && ( defined ( X86 ) || defined ( X86_64 ) ) /* That's possible on x86-64 too since oslInterlockedCount is a sal_Int32 */ +extern int osl_isSingleCPU; + /*****************************************************************************/ /* osl_incrementInterlockedCount */ /*****************************************************************************/ oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount) { - oslInterlockedCount nCount; - - __asm__ __volatile__ ( - "movl $1, %0\n\t" - "lock\n\t" - "xaddl %0, %2\n\t" - "incl %0" - : "=&r" (nCount), "=m" (*pCount) - : "m" (*pCount) - : "memory"); - - return nCount; + register oslInterlockedCount nCount asm("%eax"); + + nCount = 1; + + if ( osl_isSingleCPU ) { + __asm__ __volatile__ ( + "xaddl %0, %1\n\t" + : "+r" (nCount), "+m" (*pCount) + : /* nothing */ + : "memory"); + } + else { + __asm__ __volatile__ ( + "lock\n\t" + "xaddl %0, %1\n\t" + : "+r" (nCount), "+m" (*pCount) + : /* nothing */ + : "memory"); + } + + return ++nCount; } oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount) { - oslInterlockedCount nCount; - - __asm__ __volatile__ ( - "movl $-1, %0\n\t" - "lock\n\t" - "xaddl %0, %2\n\t" - "decl %0" - : "=&r" (nCount), "=m" (*pCount) - : "m" (*pCount) - : "memory"); - - return nCount; + register oslInterlockedCount nCount asm("%eax"); + + nCount = -1; + + if ( osl_isSingleCPU ) { + __asm__ __volatile__ ( + "xaddl %0, %1\n\t" + : "+r" (nCount), "+m" (*pCount) + : /* nothing */ + : "memory"); + } + else { + __asm__ __volatile__ ( + "lock\n\t" + "xaddl %0, %1\n\t" + : "+r" (nCount), "+m" (*pCount) + : /* nothing */ + : "memory"); + } + + return --nCount; } #elif defined ( GCC ) && defined ( POWERPC ) |