summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrpj <rpj>2011-07-01 09:33:35 +0000
committerrpj <rpj>2011-07-01 09:33:35 +0000
commitc3973648250aeb062d7d99a71257e2287c18a1ae (patch)
treef8c028e0bd909d6d3aad9d295490efc36500b0d6
parentff142e0fc8aa85cc9c11f0bf75422ce7297603fb (diff)
See the ChangeLog
-rw-r--r--ChangeLog2
-rw-r--r--implement.h24
-rw-r--r--pthread_barrier_wait.c2
-rwxr-xr-xpthread_mutex_consistent.c4
-rw-r--r--pthread_mutex_lock.c22
-rw-r--r--pthread_mutex_timedlock.c22
-rw-r--r--pthread_mutex_trylock.c6
-rw-r--r--pthread_mutex_unlock.c10
-rw-r--r--pthread_once.c2
-rw-r--r--pthread_spin_destroy.c2
-rw-r--r--pthread_spin_lock.c2
-rw-r--r--pthread_spin_trylock.c2
-rw-r--r--pthread_spin_unlock.c2
-rw-r--r--pthread_win32_attach_detach_np.c2
-rw-r--r--ptw32_InterlockedCompareExchange.c2
-rw-r--r--ptw32_MCS_lock.c20
16 files changed, 67 insertions, 59 deletions
diff --git a/ChangeLog b/ChangeLog
index 85eb10c..fe9bbe7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,8 @@
PTW32_INTERLOCKED_*_LONG which work only on 32 bit integer variables;
PTW32_INTERLOCKED_*_SIZE which work on size_t integer variables, i.e.
LONG for 32 bit systems and LONGLONG for 64 bit systems.
+ * implement.h (MCS locks): nextFlag and waitFlag are now HANDLE type.
+ * ptw32_MCS_locks.c: Likewise.
2011-06-30 Ross Johnson <ross dot johnson at homemail dot com dot au>
diff --git a/implement.h b/implement.h
index 6b1ab4f..8f0a8f2 100644
--- a/implement.h
+++ b/implement.h
@@ -84,7 +84,8 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
#define PTW32_INTERLOCKED_LONG long
#define PTW32_INTERLOCKED_SIZE size_t
-#define PTW32_INTERLOCKED_PTR volatile size_t*
+#define PTW32_INTERLOCKED_LONGPTR volatile long*
+#define PTW32_INTERLOCKED_SIZEPTR volatile size_t*
#define PTW32_INTERLOCKED_PVOID PVOID
#define PTW32_INTERLOCKED_PVOID_PTR volatile PVOID*
@@ -94,7 +95,7 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
# define int64_t ULONGLONG
#else
# define int64_t _int64
-# if defined(_MSC_VER) && _MSC_VER <= 1300
+# if defined(_MSC_VER) && _MSC_VER < 1300
typedef long intptr_t;
# endif
#endif
@@ -292,9 +293,9 @@ struct ptw32_mcs_node_t_
{
struct ptw32_mcs_node_t_ **lock; /* ptr to tail of queue */
struct ptw32_mcs_node_t_ *next; /* ptr to successor in queue */
- LONG readyFlag; /* set after lock is released by
+ HANDLE readyFlag; /* set after lock is released by
predecessor */
- LONG nextFlag; /* set after 'next' ptr is set by
+ HANDLE nextFlag; /* set after 'next' ptr is set by
successor */
};
@@ -856,9 +857,12 @@ extern "C"
--_temp; \
})
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(location, value, comparand) \
- PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(location, value, comparand)
+ PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE((PTW32_INTERLOCKED_SIZEPTR)location, \
+ (PTW32_INTERLOCKED_SIZE)value, \
+ (PTW32_INTERLOCKED_SIZE)comparand)
# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \
- PTW32_INTERLOCKED_EXCHANGE_SIZE(location, value)
+ PTW32_INTERLOCKED_EXCHANGE_SIZE((PTW32_INTERLOCKED_SIZEPTR)location, \
+ (PTW32_INTERLOCKED_SIZE)value)
#else
# if defined(_WIN64)
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64 InterlockedCompareExchange64
@@ -872,9 +876,11 @@ extern "C"
# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG InterlockedExchangeAdd
# define PTW32_INTERLOCKED_INCREMENT_LONG InterlockedIncrement
# define PTW32_INTERLOCKED_DECREMENT_LONG InterlockedDecrement
-# if defined(_MSC_VER) && _MSC_VER <= 1300
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR InterlockedCompareExchange
-# define PTW32_INTERLOCKED_EXCHANGE_PTR InterlockedExchange
+# if defined(_MSC_VER) && _MSC_VER < 1300
+# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(location, value, comparand) \
+ InterlockedCompareExchange((LONG*)location, (LONG)value, (LONG)comparand)
+# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \
+ InterlockedExchange((LONG*)location, (LONG)value)
# else
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR InterlockedCompareExchangePointer
# define PTW32_INTERLOCKED_EXCHANGE_PTR InterlockedExchangePointer
diff --git a/pthread_barrier_wait.c b/pthread_barrier_wait.c
index 17c9781..e0e97e6 100644
--- a/pthread_barrier_wait.c
+++ b/pthread_barrier_wait.c
@@ -87,7 +87,7 @@ pthread_barrier_wait (pthread_barrier_t * barrier)
result = ptw32_semwait (&(b->semBarrierBreeched));
}
- if ((PTW32_INTERLOCKED_LONG)PTW32_INTERLOCKED_INCREMENT_LONG((PTW32_INTERLOCKED_PTR)&b->nCurrentBarrierHeight)
+ if ((PTW32_INTERLOCKED_LONG)PTW32_INTERLOCKED_INCREMENT_LONG((PTW32_INTERLOCKED_LONGPTR)&b->nCurrentBarrierHeight)
== (PTW32_INTERLOCKED_LONG)b->nInitialBarrierHeight)
{
/*
diff --git a/pthread_mutex_consistent.c b/pthread_mutex_consistent.c
index ac17dd8..b7805e7 100755
--- a/pthread_mutex_consistent.c
+++ b/pthread_mutex_consistent.c
@@ -81,7 +81,7 @@ ptw32_robust_mutex_inherit(pthread_mutex_t * mutex)
ptw32_robust_node_t* robust = mx->robustNode;
switch ((LONG)PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR)&robust->stateInconsistent,
+ (PTW32_INTERLOCKED_LONGPTR)&robust->stateInconsistent,
(PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT,
(PTW32_INTERLOCKED_LONG)-1 /* The terminating thread sets this */))
{
@@ -178,7 +178,7 @@ pthread_mutex_consistent (pthread_mutex_t* mutex)
if (mx->kind >= 0
|| (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT != PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR)&mx->robustNode->stateInconsistent,
+ (PTW32_INTERLOCKED_LONGPTR)&mx->robustNode->stateInconsistent,
(PTW32_INTERLOCKED_LONG)PTW32_ROBUST_CONSISTENT,
(PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT))
{
diff --git a/pthread_mutex_lock.c b/pthread_mutex_lock.c
index b54e155..eee9abe 100644
--- a/pthread_mutex_lock.c
+++ b/pthread_mutex_lock.c
@@ -78,11 +78,11 @@ pthread_mutex_lock (pthread_mutex_t * mutex)
if (PTHREAD_MUTEX_NORMAL == kind)
{
if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) 1) != 0)
{
while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) -1) != 0)
{
if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE))
@@ -98,7 +98,7 @@ pthread_mutex_lock (pthread_mutex_t * mutex)
pthread_t self = pthread_self();
if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) 1,
(PTW32_INTERLOCKED_LONG) 0) == 0)
{
@@ -121,7 +121,7 @@ pthread_mutex_lock (pthread_mutex_t * mutex)
else
{
while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) -1) != 0)
{
if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE))
@@ -150,7 +150,7 @@ pthread_mutex_lock (pthread_mutex_t * mutex)
ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent;
if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(
- (PTW32_INTERLOCKED_PTR)statePtr,
+ (PTW32_INTERLOCKED_LONGPTR)statePtr,
(PTW32_INTERLOCKED_LONG)0))
{
result = ENOTRECOVERABLE;
@@ -164,12 +164,12 @@ pthread_mutex_lock (pthread_mutex_t * mutex)
if (PTHREAD_MUTEX_NORMAL == kind)
{
if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) 1) != 0)
{
while (0 == (result = ptw32_robust_mutex_inherit(mutex))
&& (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) -1) != 0)
{
if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE))
@@ -179,7 +179,7 @@ pthread_mutex_lock (pthread_mutex_t * mutex)
}
if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE ==
PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(
- (PTW32_INTERLOCKED_PTR)statePtr,
+ (PTW32_INTERLOCKED_LONGPTR)statePtr,
(PTW32_INTERLOCKED_LONG)0))
{
/* Unblock the next thread */
@@ -201,7 +201,7 @@ pthread_mutex_lock (pthread_mutex_t * mutex)
else
{
if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) 1,
(PTW32_INTERLOCKED_LONG) 0) == 0)
{
@@ -229,7 +229,7 @@ pthread_mutex_lock (pthread_mutex_t * mutex)
{
while (0 == (result = ptw32_robust_mutex_inherit(mutex))
&& (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) -1) != 0)
{
if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE))
@@ -239,7 +239,7 @@ pthread_mutex_lock (pthread_mutex_t * mutex)
}
if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE ==
PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(
- (PTW32_INTERLOCKED_PTR)statePtr,
+ (PTW32_INTERLOCKED_LONGPTR)statePtr,
(PTW32_INTERLOCKED_LONG)0))
{
/* Unblock the next thread */
diff --git a/pthread_mutex_timedlock.c b/pthread_mutex_timedlock.c
index a2fd5a0..1745316 100644
--- a/pthread_mutex_timedlock.c
+++ b/pthread_mutex_timedlock.c
@@ -139,11 +139,11 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex,
if (mx->kind == PTHREAD_MUTEX_NORMAL)
{
if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) 1) != 0)
{
while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) -1) != 0)
{
if (0 != (result = ptw32_timed_eventwait (mx->event, abstime)))
@@ -158,7 +158,7 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex,
pthread_t self = pthread_self();
if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) 1,
(PTW32_INTERLOCKED_LONG) 0) == 0)
{
@@ -181,7 +181,7 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex,
else
{
while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) -1) != 0)
{
if (0 != (result = ptw32_timed_eventwait (mx->event, abstime)))
@@ -206,7 +206,7 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex,
ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent;
if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(
- (PTW32_INTERLOCKED_PTR)statePtr,
+ (PTW32_INTERLOCKED_LONGPTR)statePtr,
(PTW32_INTERLOCKED_LONG)0))
{
result = ENOTRECOVERABLE;
@@ -220,12 +220,12 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex,
if (PTHREAD_MUTEX_NORMAL == kind)
{
if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) 1) != 0)
{
while (0 == (result = ptw32_robust_mutex_inherit(mutex))
&& (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) -1) != 0)
{
if (0 != (result = ptw32_timed_eventwait (mx->event, abstime)))
@@ -234,7 +234,7 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex,
}
if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE ==
PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(
- (PTW32_INTERLOCKED_PTR)statePtr,
+ (PTW32_INTERLOCKED_LONGPTR)statePtr,
(PTW32_INTERLOCKED_LONG)0))
{
/* Unblock the next thread */
@@ -259,7 +259,7 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex,
pthread_t self = pthread_self();
if (0 == (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) 1,
(PTW32_INTERLOCKED_LONG) 0))
{
@@ -287,7 +287,7 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex,
{
while (0 == (result = ptw32_robust_mutex_inherit(mutex))
&& (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) -1) != 0)
{
if (0 != (result = ptw32_timed_eventwait (mx->event, abstime)))
@@ -298,7 +298,7 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex,
if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE ==
PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(
- (PTW32_INTERLOCKED_PTR)statePtr,
+ (PTW32_INTERLOCKED_LONGPTR)statePtr,
(PTW32_INTERLOCKED_LONG)0))
{
/* Unblock the next thread */
diff --git a/pthread_mutex_trylock.c b/pthread_mutex_trylock.c
index aeb79cd..d6b6872 100644
--- a/pthread_mutex_trylock.c
+++ b/pthread_mutex_trylock.c
@@ -70,7 +70,7 @@ pthread_mutex_trylock (pthread_mutex_t * mutex)
{
/* Non-robust */
if (0 == (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG (
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) 1,
(PTW32_INTERLOCKED_LONG) 0))
{
@@ -105,7 +105,7 @@ pthread_mutex_trylock (pthread_mutex_t * mutex)
if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE ==
PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(
- (PTW32_INTERLOCKED_PTR)statePtr,
+ (PTW32_INTERLOCKED_LONGPTR)statePtr,
(PTW32_INTERLOCKED_LONG)0))
{
return ENOTRECOVERABLE;
@@ -115,7 +115,7 @@ pthread_mutex_trylock (pthread_mutex_t * mutex)
kind = -kind - 1; /* Convert to non-robust range */
if (0 == (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG (
- (PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) 1,
(PTW32_INTERLOCKED_LONG) 0))
{
diff --git a/pthread_mutex_unlock.c b/pthread_mutex_unlock.c
index 51e2b78..3d65d1a 100644
--- a/pthread_mutex_unlock.c
+++ b/pthread_mutex_unlock.c
@@ -66,7 +66,7 @@ pthread_mutex_unlock (pthread_mutex_t * mutex)
{
LONG idx;
- idx = (LONG) PTW32_INTERLOCKED_EXCHANGE_LONG ((PTW32_INTERLOCKED_PTR)&mx->lock_idx,
+ idx = (LONG) PTW32_INTERLOCKED_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR)&mx->lock_idx,
(PTW32_INTERLOCKED_LONG)0);
if (idx != 0)
{
@@ -91,7 +91,7 @@ pthread_mutex_unlock (pthread_mutex_t * mutex)
{
mx->ownerThread.p = NULL;
- if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG ((PTW32_INTERLOCKED_PTR)&mx->lock_idx,
+ if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR)&mx->lock_idx,
(PTW32_INTERLOCKED_LONG)0) < 0L)
{
/* Someone may be waiting on that mutex */
@@ -120,14 +120,14 @@ pthread_mutex_unlock (pthread_mutex_t * mutex)
*/
if (pthread_equal (mx->ownerThread, self))
{
- PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG((PTW32_INTERLOCKED_PTR) &mx->robustNode->stateInconsistent,
+ PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG((PTW32_INTERLOCKED_LONGPTR) &mx->robustNode->stateInconsistent,
(PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE,
(PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT);
if (PTHREAD_MUTEX_NORMAL == kind)
{
ptw32_robust_mutex_remove(mutex, NULL);
- if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG((PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG((PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) 0) < 0)
{
/*
@@ -146,7 +146,7 @@ pthread_mutex_unlock (pthread_mutex_t * mutex)
{
ptw32_robust_mutex_remove(mutex, NULL);
- if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG((PTW32_INTERLOCKED_PTR) &mx->lock_idx,
+ if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG((PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx,
(PTW32_INTERLOCKED_LONG) 0) < 0)
{
/*
diff --git a/pthread_once.c b/pthread_once.c
index 129e4b5..f4a36ca 100644
--- a/pthread_once.c
+++ b/pthread_once.c
@@ -46,7 +46,7 @@ pthread_once (pthread_once_t * once_control, void (*init_routine) (void))
}
if ((PTW32_INTERLOCKED_LONG)PTW32_FALSE ==
- (PTW32_INTERLOCKED_LONG)PTW32_INTERLOCKED_EXCHANGE_ADD_LONG((PTW32_INTERLOCKED_PTR)&once_control->done,
+ (PTW32_INTERLOCKED_LONG)PTW32_INTERLOCKED_EXCHANGE_ADD_LONG((PTW32_INTERLOCKED_LONGPTR)&once_control->done,
(PTW32_INTERLOCKED_LONG)0)) /* MBR fence */
{
ptw32_mcs_local_node_t node;
diff --git a/pthread_spin_destroy.c b/pthread_spin_destroy.c
index 7518c20..786c4e3 100644
--- a/pthread_spin_destroy.c
+++ b/pthread_spin_destroy.c
@@ -56,7 +56,7 @@ pthread_spin_destroy (pthread_spinlock_t * lock)
result = pthread_mutex_destroy (&(s->u.mutex));
}
else if ((PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED !=
- PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_PTR) &s->interlock,
+ PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR) &s->interlock,
(PTW32_INTERLOCKED_LONG) PTW32_SPIN_INVALID,
(PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED))
{
diff --git a/pthread_spin_lock.c b/pthread_spin_lock.c
index 6553aee..b560e14 100644
--- a/pthread_spin_lock.c
+++ b/pthread_spin_lock.c
@@ -61,7 +61,7 @@ pthread_spin_lock (pthread_spinlock_t * lock)
s = *lock;
while ((PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED ==
- PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_PTR) &s->interlock,
+ PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR) &s->interlock,
(PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED,
(PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED))
{
diff --git a/pthread_spin_trylock.c b/pthread_spin_trylock.c
index 89d2602..a6c65af 100644
--- a/pthread_spin_trylock.c
+++ b/pthread_spin_trylock.c
@@ -61,7 +61,7 @@ pthread_spin_trylock (pthread_spinlock_t * lock)
s = *lock;
switch ((long)
- PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_PTR) &s->interlock,
+ PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR) &s->interlock,
(PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED,
(PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED))
{
diff --git a/pthread_spin_unlock.c b/pthread_spin_unlock.c
index c2bb6b7..0e8add8 100644
--- a/pthread_spin_unlock.c
+++ b/pthread_spin_unlock.c
@@ -56,7 +56,7 @@ pthread_spin_unlock (pthread_spinlock_t * lock)
}
switch ((long)
- PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_PTR) &s->interlock,
+ PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR) &s->interlock,
(PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED,
(PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED))
{
diff --git a/pthread_win32_attach_detach_np.c b/pthread_win32_attach_detach_np.c
index c3ff0a2..bd52a7f 100644
--- a/pthread_win32_attach_detach_np.c
+++ b/pthread_win32_attach_detach_np.c
@@ -213,7 +213,7 @@ pthread_win32_thread_detach_np ()
pthread_mutex_t mx = sp->robustMxList->mx;
ptw32_robust_mutex_remove(&mx, sp);
(void) PTW32_INTERLOCKED_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_PTR)&mx->robustNode->stateInconsistent,
+ (PTW32_INTERLOCKED_LONGPTR)&mx->robustNode->stateInconsistent,
(PTW32_INTERLOCKED_LONG)-1);
/*
* If there are no waiters then the next thread to block will
diff --git a/ptw32_InterlockedCompareExchange.c b/ptw32_InterlockedCompareExchange.c
index df0c0cc..fcc729c 100644
--- a/ptw32_InterlockedCompareExchange.c
+++ b/ptw32_InterlockedCompareExchange.c
@@ -50,7 +50,7 @@
*/
PTW32_INTERLOCKED_VALUE WINAPI
-ptw32_InterlockedCompareExchange (PTW32_INTERLOCKED_PTR location,
+ptw32_InterlockedCompareExchange (PTW32_INTERLOCKED_LONGPTR location,
PTW32_INTERLOCKED_VALUE value,
PTW32_INTERLOCKED_VALUE comparand)
{
diff --git a/ptw32_MCS_lock.c b/ptw32_MCS_lock.c
index 42674cf..3a85c1b 100644
--- a/ptw32_MCS_lock.c
+++ b/ptw32_MCS_lock.c
@@ -100,10 +100,10 @@
* set flag to -1 otherwise. Note that -1 cannot be a valid handle value.
*/
INLINE void
-ptw32_mcs_flag_set (LONG * flag)
+ptw32_mcs_flag_set (HANDLE * flag)
{
HANDLE e = (HANDLE)(PTW32_INTERLOCKED_SIZE)PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(
- (PTW32_INTERLOCKED_PTR)flag,
+ (PTW32_INTERLOCKED_SIZEPTR)flag,
(PTW32_INTERLOCKED_SIZE)-1,
(PTW32_INTERLOCKED_SIZE)0);
if ((HANDLE)0 != e)
@@ -120,18 +120,18 @@ ptw32_mcs_flag_set (LONG * flag)
* set, and proceed without creating an event otherwise.
*/
INLINE void
-ptw32_mcs_flag_wait (LONG * flag)
+ptw32_mcs_flag_wait (HANDLE * flag)
{
if ((PTW32_INTERLOCKED_LONG)0 ==
- PTW32_INTERLOCKED_EXCHANGE_ADD_LONG((PTW32_INTERLOCKED_PTR)flag,
- (PTW32_INTERLOCKED_LONG)0)) /* MBR fence */
+ PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_SIZEPTR)flag,
+ (PTW32_INTERLOCKED_SIZE)0)) /* MBR fence */
{
/* the flag is not set. create event. */
HANDLE e = CreateEvent(NULL, PTW32_FALSE, PTW32_FALSE, NULL);
if ((PTW32_INTERLOCKED_SIZE)0 == PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(
- (PTW32_INTERLOCKED_PTR)flag,
+ (PTW32_INTERLOCKED_SIZEPTR)flag,
(PTW32_INTERLOCKED_SIZE)e,
(PTW32_INTERLOCKED_SIZE)0))
{
@@ -193,8 +193,8 @@ ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node)
{
ptw32_mcs_lock_t *lock = node->lock;
ptw32_mcs_local_node_t *next =
- (ptw32_mcs_local_node_t *)(intptr_t)
- PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_PTR)&node->next, (PTW32_INTERLOCKED_SIZE)0); /* MBR fence */
+ (ptw32_mcs_local_node_t *)
+ PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_SIZEPTR)&node->next, (PTW32_INTERLOCKED_SIZE)0); /* MBR fence */
if (0 == next)
{
@@ -211,8 +211,8 @@ ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node)
/* wait for successor */
ptw32_mcs_flag_wait(&node->nextFlag);
- next = (ptw32_mcs_local_node_t *)(intptr_t)
- PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_PTR)&node->next, (PTW32_INTERLOCKED_SIZE)0); /* MBR fence */
+ next = (ptw32_mcs_local_node_t *)
+ PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_SIZEPTR)&node->next, (PTW32_INTERLOCKED_SIZE)0); /* MBR fence */
}
/* pass the lock */