Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

See the ChangeLog

  • Loading branch information...
commit a94e5fec58ffe5abb8403fe74a1be8e0b40dd9ae 1 parent cebf646
rpj authored
View
2  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>
View
24 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
View
2  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)
{
/*
View
4 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))
{
View
22 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 */
View
22 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 */
View
6 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))
{
View
10 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)
{
/*
View
2  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;
View
2  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))
{
View
2  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))
{
View
2  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))
{
View
2  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))
{
View
2  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
View
2  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)
{
View
20 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 */
Please sign in to comment.
Something went wrong with that request. Please try again.