diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-03-18 20:07:31 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-03-18 20:09:26 +0200 |
commit | 0a21cce0c90a639918d8e58ac5daa4b8f674666f (patch) | |
tree | 5d2fd5842ebbbe7544f3fda4eb79cdc9b3058738 /sal/osl | |
parent | renamed method, it determines if symbol combines (diff) | |
download | core-0a21cce0c90a639918d8e58ac5daa4b8f674666f.tar.gz core-0a21cce0c90a639918d8e58ac5daa4b8f674666f.zip |
Use InterlockedIncrement() and InterlockedDecrement() unconditionally
Much simpler.
Change-Id: I6837f95121f881d6265eb65343f6b311c1a6c33f
Diffstat (limited to 'sal/osl')
-rw-r--r-- | sal/osl/w32/dllentry.c | 19 | ||||
-rw-r--r-- | sal/osl/w32/interlck.c | 101 |
2 files changed, 0 insertions, 120 deletions
diff --git a/sal/osl/w32/dllentry.c b/sal/osl/w32/dllentry.c index 90b7eb286e1c..5890ed761b98 100644 --- a/sal/osl/w32/dllentry.c +++ b/sal/osl/w32/dllentry.c @@ -77,11 +77,6 @@ extern BOOL (WINAPI *_pRawDllMain)(HANDLE, DWORD, LPVOID) = _RawDllMain; #endif -//------------------------------------------------------------------------------ -// DllMain -//------------------------------------------------------------------------------ -int osl_isSingleCPU = 0; - #ifdef __MINGW32__ void @@ -158,20 +153,6 @@ static BOOL WINAPI _RawDllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvR { #endif - SYSTEM_INFO SystemInfo; - - GetSystemInfo(&SystemInfo); - - /* Determine if we are on a multiprocessor/multicore/HT x86/x64 system - * - * The lock prefix for atomic operations in osl_[inc|de]crementInterlockedCount() - * comes with a cost and is especially expensive on pre HT x86 single processor - * systems, where it isn't needed at all. - */ - if ( SystemInfo.dwNumberOfProcessors == 1 ) { - osl_isSingleCPU = 1; - } - #if OSL_DEBUG_LEVEL < 2 /* Suppress file error messages from system like "Floppy A: not inserted" */ SetErrorMode( SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS ); diff --git a/sal/osl/w32/interlck.c b/sal/osl/w32/interlck.c index 13392c89ee05..32ce6f694bb3 100644 --- a/sal/osl/w32/interlck.c +++ b/sal/osl/w32/interlck.c @@ -22,119 +22,18 @@ #include <osl/interlck.h> #include <osl/diagnose.h> -extern int osl_isSingleCPU; - -/* For all Intel x86 above x486 we use a spezial inline assembler implementation. - The main reason is that WIN9? does not return the result of the operation. - Instead there is only returned a value greater than zero is the increment - result is greater than zero, but not the result of the addition. - For Windows NT the native function could be used, because the correct result - is returned. Beacuse of simpler code maintance and performace reasons we use - on every x86-Windows-Platform the inline assembler implementation. -*/ - #if defined __MINGW32__ #pragma GCC diagnostic warning "-Wreturn-type" #endif -/*****************************************************************************/ -/* osl_incrementInterlockedCount */ -/*****************************************************************************/ oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount) -#ifdef _M_IX86 -#ifdef __MINGW32__ -{ - asm - ( - " movl %0, %%ecx\n" - " movl $1, %%eax\n" - " movl %1, %%edx\n" - " cmpl $0, %%edx\n" - " je 1f\n" - " xadd %%eax, (%%ecx)\n" - " jmp 2f\n" - "1:\n" - " lock xadd %%eax, (%%ecx)\n" - "2:\n" - " incl %%eax\n" - ::"m"(pCount),"m"(osl_isSingleCPU) - ); -} -#else -#pragma warning(disable: 4035) -{ - __asm - { - mov ecx, pCount - mov eax, 1 - mov edx, osl_isSingleCPU - cmp edx, 0 - je is_not_single - xadd dword ptr [ecx],eax - jmp cont - is_not_single: - lock xadd dword ptr [ecx],eax - cont: - inc eax - } -} -#pragma warning(default: 4035) -#endif -#else -#pragma message("WARNING: Using system InterlockedIncrement") { return (InterlockedIncrement(pCount)); } -#endif -/*****************************************************************************/ -/* osl_decrementInterlockedCount */ -/*****************************************************************************/ oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount) -#ifdef _M_IX86 -#ifdef __MINGW32__ -{ - asm - ( - " movl %0, %%ecx\n" - " orl $-1, %%eax\n" - " movl %1, %%edx\n" - " cmpl $0, %%edx\n" - " je 1f\n" - " xadd %%eax, (%%ecx)\n" - " jmp 2f\n" - "1:\n" - " lock xadd %%eax, (%%ecx)\n" - "2:\n" - " decl %%eax\n" - ::"m"(pCount),"m"(osl_isSingleCPU) - ); -} -#else -#pragma warning(disable: 4035) -{ - __asm - { - mov ecx, pCount - or eax, -1 - mov edx, osl_isSingleCPU - cmp edx, 0 - je is_not_single - xadd dword ptr [ecx],eax - jmp cont - is_not_single: - lock xadd dword ptr [ecx],eax - cont: - dec eax - } -} -#pragma warning(default: 4035) -#endif -#else -#pragma message("WARNING: Using system InterlockedDecrement") { return (InterlockedDecrement(pCount)); } -#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |