|
|
@ -121,38 +121,38 @@ private:
|
|
|
|
// Tested: works on multi-processor
|
|
|
|
// Tested: works on multi-processor
|
|
|
|
#ifdef HAVE_X86_64
|
|
|
|
#ifdef HAVE_X86_64
|
|
|
|
# define ASM_ASWAP_FOR_GCC_XCHG __asm__ volatile( \
|
|
|
|
# define ASM_ASWAP_FOR_GCC_XCHG __asm__ volatile( \
|
|
|
|
"mov %1, %%rcx;" \
|
|
|
|
"mov %1, %%rcx;" \
|
|
|
|
"mov $1, %%eax;" \
|
|
|
|
"mov $1, %%eax;" \
|
|
|
|
"xchg %%eax, (%%rcx);" \
|
|
|
|
"xchg %%eax, (%%rcx);" \
|
|
|
|
"mov %%eax, %0" \
|
|
|
|
"mov %%eax, %0" \
|
|
|
|
: "=m" (result) \
|
|
|
|
: "=m" (result) \
|
|
|
|
: "m" (lockPtr) \
|
|
|
|
: "m" (lockPtr) \
|
|
|
|
: "eax", "rcx", "memory" ); // force to use registers and memory
|
|
|
|
: "eax", "rcx", "memory" ); // force to use registers and memory
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
# define ASM_ASWAP_FOR_GCC_XCHG __asm__ volatile( \
|
|
|
|
# define ASM_ASWAP_FOR_GCC_XCHG __asm__ volatile( \
|
|
|
|
"mov %1, %%ecx;" \
|
|
|
|
"mov %1, %%ecx;" \
|
|
|
|
"mov $1, %%eax;" \
|
|
|
|
"mov $1, %%eax;" \
|
|
|
|
"xchg %%eax, (%%ecx);" \
|
|
|
|
"xchg %%eax, (%%ecx);" \
|
|
|
|
"mov %%eax, %0" \
|
|
|
|
"mov %%eax, %0" \
|
|
|
|
: "=m" (result) \
|
|
|
|
: "=m" (result) \
|
|
|
|
: "m" (lockPtr) \
|
|
|
|
: "m" (lockPtr) \
|
|
|
|
: "eax", "ecx", "memory" ); // force to use registers and memory
|
|
|
|
: "eax", "ecx", "memory" ); // force to use registers and memory
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
// Tested: does not work (at least on multi-processor)! (with or without 'lock' prefix)
|
|
|
|
// Tested: does not work (at least on multi-processor)! (with or without 'lock' prefix)
|
|
|
|
#define ASM_ASWAP_FOR_GCC_CMPXCHG __asm__ volatile( \
|
|
|
|
#define ASM_ASWAP_FOR_GCC_CMPXCHG __asm__ volatile( \
|
|
|
|
"mov $1, %%edx;" \
|
|
|
|
"mov $1, %%edx;" \
|
|
|
|
"mov %1, %%ecx;" \
|
|
|
|
"mov %1, %%ecx;" \
|
|
|
|
"mov (%%ecx), %%eax;" \
|
|
|
|
"mov (%%ecx), %%eax;" \
|
|
|
|
"1:nop;" \
|
|
|
|
"1:nop;" \
|
|
|
|
"lock cmpxchgl %%edx, (%%ecx);" \
|
|
|
|
"lock cmpxchgl %%edx, (%%ecx);" \
|
|
|
|
"jne 1b;" \
|
|
|
|
"jne 1b;" \
|
|
|
|
"mov %%eax, %0" \
|
|
|
|
"mov %%eax, %0" \
|
|
|
|
: "=m" (result) \
|
|
|
|
: "=m" (result) \
|
|
|
|
: "m" (lockPtr) \
|
|
|
|
: "m" (lockPtr) \
|
|
|
|
: "eax", "ecx", "edx", "memory" ); // force to use registers and memory
|
|
|
|
: "eax", "ecx", "edx", "memory" ); // force to use registers and memory
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// Tested: does not work on hyper-threading processors!
|
|
|
|
// Tested: does not work on hyper-threading processors!
|
|
|
@ -206,6 +206,7 @@ test_again:
|
|
|
|
#ifdef NL_OS_WINDOWS
|
|
|
|
#ifdef NL_OS_WINDOWS
|
|
|
|
#pragma managed(push, off)
|
|
|
|
#pragma managed(push, off)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
class CFastMutex
|
|
|
|
class CFastMutex
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
@ -565,7 +566,7 @@ struct TMutexLocks
|
|
|
|
uint32 TimeInMutex; // cumulated time between enter and leave
|
|
|
|
uint32 TimeInMutex; // cumulated time between enter and leave
|
|
|
|
uint32 Nb; // number of calls of enter
|
|
|
|
uint32 Nb; // number of calls of enter
|
|
|
|
uint32 WaitingMutex; // number of thread that waiting this mutex
|
|
|
|
uint32 WaitingMutex; // number of thread that waiting this mutex
|
|
|
|
sint32 MutexNum; // identifying a mutex
|
|
|
|
sint32 MutexNum; // identifying a mutex
|
|
|
|
uint ThreadHavingTheMutex; // thread id of the thread that is in this mutex (0xFFFFFFFF if no thread)
|
|
|
|
uint ThreadHavingTheMutex; // thread id of the thread that is in this mutex (0xFFFFFFFF if no thread)
|
|
|
|
bool Dead; // True if the mutex is dead (deleted)
|
|
|
|
bool Dead; // True if the mutex is dead (deleted)
|
|
|
|
std::string MutexName; // Name of the mutex
|
|
|
|
std::string MutexName; // Name of the mutex
|
|
|
|