summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorKristján Valur Jónsson <kristjan@ccpgames.com>2007-05-07 18:28:12 +0000
committerKristján Valur Jónsson <kristjan@ccpgames.com>2007-05-07 18:28:12 +0000
commite1d85669ab155818a5b4f97632e62384352325f8 (patch)
tree3c7d85ba6613f000024bb66bb3a294a40022af1c /Python
parent9fbde1783e69f19c504d9a0540b7b6e48a69f148 (diff)
downloadcpython-e1d85669ab155818a5b4f97632e62384352325f8.tar.gz
Fix NonRecursiveMutex on x64. The signature of the faux-InterlockedCompareExchange function was wrong: It works with LONG and not PVOID objects, and it needs to have the target marked as volatile. Further, it is not needed at all for x64 targets, since that platform always has the real McCoy.
Diffstat (limited to 'Python')
-rw-r--r--Python/thread_nt.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/Python/thread_nt.h b/Python/thread_nt.h
index 27fca72cd8..4e6198b349 100644
--- a/Python/thread_nt.h
+++ b/Python/thread_nt.h
@@ -15,14 +15,14 @@ typedef struct NRMUTEX {
HANDLE hevent ;
} NRMUTEX, *PNRMUTEX ;
-typedef PVOID WINAPI interlocked_cmp_xchg_t(PVOID *dest, PVOID exc, PVOID comperand) ;
+typedef LONG WINAPI interlocked_cmp_xchg_t(LONG volatile *dest, LONG exc, LONG comperand) ;
/* Sorry mate, but we haven't got InterlockedCompareExchange in Win95! */
-static PVOID WINAPI
-interlocked_cmp_xchg(PVOID *dest, PVOID exc, PVOID comperand)
+static LONG WINAPI
+interlocked_cmp_xchg(LONG volatile *dest, LONG exc, LONG comperand)
{
static LONG spinlock = 0 ;
- PVOID result ;
+ LONG result ;
DWORD dwSleep = 0;
/* Acqire spinlock (yielding control to other threads if cant aquire for the moment) */
@@ -76,10 +76,12 @@ InitializeNonRecursiveMutex(PNRMUTEX mutex)
return mutex->hevent != NULL ; /* TRUE if the mutex is created */
}
+#ifndef MS_WIN64
#ifdef InterlockedCompareExchange
#undef InterlockedCompareExchange
#endif
#define InterlockedCompareExchange(dest,exchange,comperand) (ixchg((dest), (exchange), (comperand)))
+#endif
VOID
DeleteNonRecursiveMutex(PNRMUTEX mutex)
@@ -98,7 +100,7 @@ EnterNonRecursiveMutex(PNRMUTEX mutex, BOOL wait)
/* InterlockedIncrement(&mutex->owned) == 0 means that no thread currently owns the mutex */
if (!wait)
{
- if (InterlockedCompareExchange((PVOID *)&mutex->owned, (PVOID)0, (PVOID)-1) != (PVOID)-1)
+ if (InterlockedCompareExchange(&mutex->owned, 0, -1) != -1)
return WAIT_TIMEOUT ;
ret = WAIT_OBJECT_0 ;
}