diff options
-rw-r--r-- | Bmakefile | 1 | ||||
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | GNUmakefile | 2 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.NONPORTABLE | 5 | ||||
-rw-r--r-- | implement.h | 97 | ||||
-rw-r--r-- | private.c | 3 | ||||
-rw-r--r-- | pthread.h | 2 | ||||
-rw-r--r-- | pthread_barrier_wait.c | 4 | ||||
-rwxr-xr-x | pthread_mutex_consistent.c | 12 | ||||
-rw-r--r-- | pthread_mutex_lock.c | 52 | ||||
-rw-r--r-- | pthread_mutex_timedlock.c | 52 | ||||
-rw-r--r-- | pthread_mutex_trylock.c | 18 | ||||
-rw-r--r-- | pthread_mutex_unlock.c | 22 | ||||
-rw-r--r-- | pthread_once.c | 6 | ||||
-rw-r--r-- | pthread_spin_destroy.c | 11 | ||||
-rw-r--r-- | pthread_spin_lock.c | 11 | ||||
-rw-r--r-- | pthread_spin_trylock.c | 9 | ||||
-rw-r--r-- | pthread_spin_unlock.c | 9 | ||||
-rw-r--r-- | pthread_win32_attach_detach_np.c | 8 | ||||
-rw-r--r-- | ptw32_MCS_lock.c | 25 |
21 files changed, 187 insertions, 175 deletions
@@ -145,7 +145,6 @@ PRIVATE_SRCS = \ ptw32_timespec.c \ ptw32_relmillisecs.c \ ptw32_throw.c \ - ptw32_InterlockedCompareExchange.c \ ptw32_getprocessors.c RWLOCK_SRCS = \ @@ -1,3 +1,14 @@ +2011-07-01 Ross Johnson <ross dot johnson at homemail dot com dot au>
+
+ * *.[ch] (PTW32_INTERLOCKED_*): Redo 23 and 64 bit versions of these
+ macros and re-apply in code to undo the incorrect changes from
+ 2011-06-29; remove some size_t casts which should not be required
+ and may be problematic.a
+ There are now two sets of macros:
+ 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.
+
2011-06-30 Ross Johnson <ross dot johnson at homemail dot com dot au>
* pthread_once.c: Tighten 'if' statement casting; fix interlocked
diff --git a/GNUmakefile b/GNUmakefile index 3ee8763..a117dfe 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -229,7 +229,6 @@ SMALL_STATIC_OBJS = \ ptw32_callUserDestroyRoutines.o \ ptw32_timespec.o \ ptw32_throw.o \ - ptw32_InterlockedCompareExchange.o \ ptw32_getprocessors.o \ ptw32_calloc.o \ ptw32_new.o \ @@ -372,7 +371,6 @@ PRIVATE_SRCS = \ ptw32_relmillisecs.c \ ptw32_timespec.c \ ptw32_throw.c \ - ptw32_InterlockedCompareExchange.c \ ptw32_getprocessors.c RWLOCK_SRCS = \ @@ -174,7 +174,6 @@ SMALL_STATIC_OBJS = \ ptw32_callUserDestroyRoutines.obj \ ptw32_timespec.obj \ ptw32_throw.obj \ - ptw32_InterlockedCompareExchange.obj \ ptw32_getprocessors.obj \ ptw32_calloc.obj \ ptw32_new.obj \ @@ -315,7 +314,6 @@ PRIVATE_SRCS = \ ptw32_semwait.c \ ptw32_timespec.c \ ptw32_throw.c \ - ptw32_InterlockedCompareExchange.c \ ptw32_getprocessors.c RWLOCK_SRCS = \ diff --git a/README.NONPORTABLE b/README.NONPORTABLE index e25fc50..0821104 100644 --- a/README.NONPORTABLE +++ b/README.NONPORTABLE @@ -15,6 +15,11 @@ pthread_win32_test_features_np(int mask) PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE
Return TRUE if the native version of
InterlockedCompareExchange() is being used.
+ This feature is not meaningful in recent
+ library versions as MSVC builds only support
+ system implemented ICE. Note that all Mingw
+ builds use inlined asm versions of all the
+ Interlocked routines.
PTW32_ALERTABLE_ASYNC_CANCEL
Return TRUE is the QueueUserAPCEx package
QUSEREX.DLL is available and the AlertDrv.sys
diff --git a/implement.h b/implement.h index 5772a78..0d8a958 100644 --- a/implement.h +++ b/implement.h @@ -82,24 +82,21 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam); #define INLINE #endif -#if defined(_WIN64) -#define PTW32_INTERLOCKED_VALUE size_t -#define PTW32_INTERLOCKED_PTR volatile size_t* -#define PTW32_INTERLOCKED_PVOID PVOID -#define PTW32_INTERLOCKED_PVOID_PTR volatile PVOID* -#else -#define PTW32_INTERLOCKED_VALUE size_t +#define PTW32_INTERLOCKED_LONG long +#define PTW32_INTERLOCKED_SIZE size_t #define PTW32_INTERLOCKED_PTR volatile size_t* #define PTW32_INTERLOCKED_PVOID PVOID #define PTW32_INTERLOCKED_PVOID_PTR volatile PVOID* -#endif #if defined(__MINGW64__) || defined(__MINGW32__) -#include <stdint.h> +# include <stdint.h> #elif defined(__BORLANDC__) -#define int64_t ULONGLONG +# define int64_t ULONGLONG #else -#define int64_t _int64 +# define int64_t _int64 +# if defined(_MSC_VER) && _MSC_VER <= 1300 + typedef long intptr_t; +# endif #endif typedef enum @@ -273,6 +270,7 @@ struct pthread_mutexattr_t_ * "u.cpus" isn't used for anything yet, but could be used at * some point to optimise spinlock behaviour. */ +#define PTW32_SPIN_INVALID (0) #define PTW32_SPIN_UNLOCKED (1) #define PTW32_SPIN_LOCKED (2) #define PTW32_SPIN_USE_MUTEX (3) @@ -738,7 +736,7 @@ extern "C" */ #if defined(__GNUC__) # if defined(_WIN64) -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE(location, value, comparand) \ +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64(location, value, comparand) \ ({ \ __typeof (value) _result; \ __asm__ __volatile__ \ @@ -750,7 +748,7 @@ extern "C" :"memory", "cc"); \ _result; \ }) -# define PTW32_INTERLOCKED_EXCHANGE(location, value) \ +# define PTW32_INTERLOCKED_EXCHANGE_64(location, value) \ ({ \ __typeof (value) _result; \ __asm__ __volatile__ \ @@ -761,7 +759,7 @@ extern "C" :"memory", "cc"); \ _result; \ }) -# define PTW32_INTERLOCKED_EXCHANGE_ADD(location, value) \ +# define PTW32_INTERLOCKED_EXCHANGE_ADD_64(location, value) \ ({ \ __typeof (value) _result; \ __asm__ __volatile__ \ @@ -773,9 +771,9 @@ extern "C" :"memory", "cc"); \ _result; \ }) -# define PTW32_INTERLOCKED_INCREMENT(location) \ +# define PTW32_INTERLOCKED_INCREMENT_64(location) \ ({ \ - long long _temp = 1; \ + PTW32_INTERLOCKED_LONG _temp = 1; \ __asm__ __volatile__ \ ( \ "lock\n\t" \ @@ -785,9 +783,9 @@ extern "C" :"memory", "cc"); \ ++_temp; \ }) -# define PTW32_INTERLOCKED_DECREMENT(location) \ +# define PTW32_INTERLOCKED_DECREMENT_64(location) \ ({ \ - long long _temp = -1; \ + PTW32_INTERLOCKED_LONG _temp = -1; \ __asm__ __volatile__ \ ( \ "lock\n\t" \ @@ -797,8 +795,8 @@ extern "C" :"memory", "cc"); \ --_temp; \ }) -#else -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE(location, value, comparand) \ +#endif +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \ ({ \ __typeof (value) _result; \ __asm__ __volatile__ \ @@ -810,7 +808,7 @@ extern "C" :"memory", "cc"); \ _result; \ }) -# define PTW32_INTERLOCKED_EXCHANGE(location, value) \ +# define PTW32_INTERLOCKED_EXCHANGE_LONG(location, value) \ ({ \ __typeof (value) _result; \ __asm__ __volatile__ \ @@ -821,7 +819,7 @@ extern "C" :"memory", "cc"); \ _result; \ }) -# define PTW32_INTERLOCKED_EXCHANGE_ADD(location, value) \ +# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(location, value) \ ({ \ __typeof (value) _result; \ __asm__ __volatile__ \ @@ -833,9 +831,9 @@ extern "C" :"memory", "cc"); \ _result; \ }) -# define PTW32_INTERLOCKED_INCREMENT(location) \ +# define PTW32_INTERLOCKED_INCREMENT_LONG(location) \ ({ \ - long _temp = 1; \ + PTW32_INTERLOCKED_LONG _temp = 1; \ __asm__ __volatile__ \ ( \ "lock\n\t" \ @@ -845,9 +843,9 @@ extern "C" :"memory", "cc"); \ ++_temp; \ }) -# define PTW32_INTERLOCKED_DECREMENT(location) \ +# define PTW32_INTERLOCKED_DECREMENT_LONG(location) \ ({ \ - long _temp = -1; \ + PTW32_INTERLOCKED_LONG _temp = -1; \ __asm__ __volatile__ \ ( \ "lock\n\t" \ @@ -857,27 +855,38 @@ extern "C" :"memory", "cc"); \ --_temp; \ }) -#endif -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(location, value, comparand) \ - PTW32_INTERLOCKED_COMPARE_EXCHANGE(location, (size_t)value, (size_t)comparand) -# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \ - PTW32_INTERLOCKED_EXCHANGE(location, (size_t)value) +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(location, value, comparand) \ + PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(location, value, comparand) +# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \ + PTW32_INTERLOCKED_EXCHANGE_SIZE(location, value) #else -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR InterlockedCompareExchangePointer -# define PTW32_INTERLOCKED_EXCHANGE_PTR InterlockedExchangePointer # if defined(_WIN64) -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange64 -# define PTW32_INTERLOCKED_EXCHANGE InterlockedExchange64 -# define PTW32_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd64 -# define PTW32_INTERLOCKED_INCREMENT InterlockedIncrement64 -# define PTW32_INTERLOCKED_DECREMENT InterlockedDecrement64 -# else -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE InterlockedCompareExchange -# define PTW32_INTERLOCKED_EXCHANGE InterlockedExchange -# define PTW32_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd -# define PTW32_INTERLOCKED_INCREMENT InterlockedIncrement -# define PTW32_INTERLOCKED_DECREMENT InterlockedDecrement +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64 InterlockedCompareExchange64 +# define PTW32_INTERLOCKED_EXCHANGE_64 InterlockedExchange64 +# define PTW32_INTERLOCKED_EXCHANGE_ADD_64 InterlockedExchangeAdd64 +# define PTW32_INTERLOCKED_INCREMENT_64 InterlockedIncrement64 +# define PTW32_INTERLOCKED_DECREMENT_64 InterlockedDecrement64 # endif +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG InterlockedCompareExchange +# define PTW32_INTERLOCKED_EXCHANGE_LONG InterlockedExchange +# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG InterlockedExchangeAdd +# define PTW32_INTERLOCKED_INCREMENT_LONG InterlockedIncrement +# define PTW32_INTERLOCKED_DECREMENT_LONG InterlockedDecrement +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR InterlockedCompareExchangePointer +# define PTW32_INTERLOCKED_EXCHANGE_PTR InterlockedExchangePointer +#endif +#if defined(_WIN64) +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE PTW32_INTERLOCKED_COMPARE_EXCHANGE_64 +# define PTW32_INTERLOCKED_EXCHANGE_SIZE PTW32_INTERLOCKED_EXCHANGE_64 +# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE PTW32_INTERLOCKED_EXCHANGE_ADD_64 +# define PTW32_INTERLOCKED_INCREMENT_SIZE PTW32_INTERLOCKED_INCREMENT_64 +# define PTW32_INTERLOCKED_DECREMENT_SIZE PTW32_INTERLOCKED_DECREMENT_64 +#else +# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG +# define PTW32_INTERLOCKED_EXCHANGE_SIZE PTW32_INTERLOCKED_EXCHANGE_LONG +# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE PTW32_INTERLOCKED_EXCHANGE_ADD_LONG +# define PTW32_INTERLOCKED_INCREMENT_SIZE PTW32_INTERLOCKED_INCREMENT_LONG +# define PTW32_INTERLOCKED_DECREMENT_SIZE PTW32_INTERLOCKED_DECREMENT_LONG #endif #if defined(NEED_CREATETHREAD) @@ -38,9 +38,6 @@ #include "pthread.h" #include "implement.h" -/* Must be first to define HAVE_INLINABLE_INTERLOCKED_CMPXCHG */ -#include "ptw32_InterlockedCompareExchange.c" - #include "ptw32_MCS_lock.c" #include "ptw32_is_attr.c" #include "ptw32_processInitialize.c" @@ -1177,7 +1177,7 @@ PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * */ PTW32_DLLPORT int PTW32_CDECL pthread_delay_np (struct timespec * interval); PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void); -PTW32_DLLPORT unsigned long long PTW32_CDECL pthread_getunique_np(pthread_t thread); +PTW32_DLLPORT unsigned __int64 PTW32_CDECL pthread_getunique_np(pthread_t thread); /* * Useful if an application wants to statically link diff --git a/pthread_barrier_wait.c b/pthread_barrier_wait.c index 7a2cab2..17c9781 100644 --- a/pthread_barrier_wait.c +++ b/pthread_barrier_wait.c @@ -87,8 +87,8 @@ pthread_barrier_wait (pthread_barrier_t * barrier) result = ptw32_semwait (&(b->semBarrierBreeched)); } - if ((PTW32_INTERLOCKED_VALUE)PTW32_INTERLOCKED_INCREMENT((PTW32_INTERLOCKED_PTR)&b->nCurrentBarrierHeight) - == (PTW32_INTERLOCKED_VALUE)b->nInitialBarrierHeight) + if ((PTW32_INTERLOCKED_LONG)PTW32_INTERLOCKED_INCREMENT_LONG((PTW32_INTERLOCKED_PTR)&b->nCurrentBarrierHeight) + == (PTW32_INTERLOCKED_LONG)b->nInitialBarrierHeight) { /* * We are the last thread to cross this barrier diff --git a/pthread_mutex_consistent.c b/pthread_mutex_consistent.c index 0f63d1b..ac17dd8 100755 --- a/pthread_mutex_consistent.c +++ b/pthread_mutex_consistent.c @@ -80,10 +80,10 @@ ptw32_robust_mutex_inherit(pthread_mutex_t * mutex) pthread_mutex_t mx = *mutex; ptw32_robust_node_t* robust = mx->robustNode; - switch ((LONG)(size_t)PTW32_INTERLOCKED_COMPARE_EXCHANGE( + switch ((LONG)PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR)&robust->stateInconsistent, - (PTW32_INTERLOCKED_VALUE)PTW32_ROBUST_INCONSISTENT, - (PTW32_INTERLOCKED_VALUE)-1 /* The terminating thread sets this */)) + (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT, + (PTW32_INTERLOCKED_LONG)-1 /* The terminating thread sets this */)) { case -1L: result = EOWNERDEAD; @@ -177,10 +177,10 @@ pthread_mutex_consistent (pthread_mutex_t* mutex) } if (mx->kind >= 0 - || (PTW32_INTERLOCKED_VALUE)PTW32_ROBUST_INCONSISTENT != PTW32_INTERLOCKED_COMPARE_EXCHANGE( + || (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT != PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR)&mx->robustNode->stateInconsistent, - (PTW32_INTERLOCKED_VALUE)PTW32_ROBUST_CONSISTENT, - (PTW32_INTERLOCKED_VALUE)PTW32_ROBUST_INCONSISTENT)) + (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_CONSISTENT, + (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT)) { result = EINVAL; } diff --git a/pthread_mutex_lock.c b/pthread_mutex_lock.c index f6bdcbd..b54e155 100644 --- a/pthread_mutex_lock.c +++ b/pthread_mutex_lock.c @@ -77,13 +77,13 @@ pthread_mutex_lock (pthread_mutex_t * mutex) /* Non-robust */ if (PTHREAD_MUTEX_NORMAL == kind) { - if ((PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_EXCHANGE( + if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) 1) != 0) + (PTW32_INTERLOCKED_LONG) 1) != 0) { - while ((PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_EXCHANGE( + while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) -1) != 0) + (PTW32_INTERLOCKED_LONG) -1) != 0) { if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) { @@ -97,10 +97,10 @@ pthread_mutex_lock (pthread_mutex_t * mutex) { pthread_t self = pthread_self(); - if ((PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_COMPARE_EXCHANGE( + if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) 1, - (PTW32_INTERLOCKED_VALUE) 0) == 0) + (PTW32_INTERLOCKED_LONG) 1, + (PTW32_INTERLOCKED_LONG) 0) == 0) { mx->recursive_count = 1; mx->ownerThread = self; @@ -120,9 +120,9 @@ pthread_mutex_lock (pthread_mutex_t * mutex) } else { - while ((PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_EXCHANGE( + while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) -1) != 0) + (PTW32_INTERLOCKED_LONG) -1) != 0) { if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) { @@ -149,9 +149,9 @@ pthread_mutex_lock (pthread_mutex_t * mutex) */ ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent; - if ((PTW32_INTERLOCKED_VALUE)PTW32_ROBUST_NOTRECOVERABLE == PTW32_INTERLOCKED_EXCHANGE_ADD( + if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( (PTW32_INTERLOCKED_PTR)statePtr, - (PTW32_INTERLOCKED_VALUE)0)) + (PTW32_INTERLOCKED_LONG)0)) { result = ENOTRECOVERABLE; } @@ -163,24 +163,24 @@ pthread_mutex_lock (pthread_mutex_t * mutex) if (PTHREAD_MUTEX_NORMAL == kind) { - if ((PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_EXCHANGE( + if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) 1) != 0) + (PTW32_INTERLOCKED_LONG) 1) != 0) { while (0 == (result = ptw32_robust_mutex_inherit(mutex)) - && (PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_EXCHANGE( + && (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) -1) != 0) + (PTW32_INTERLOCKED_LONG) -1) != 0) { if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) { result = EINVAL; break; } - if ((PTW32_INTERLOCKED_VALUE)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD( + if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == + PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( (PTW32_INTERLOCKED_PTR)statePtr, - (PTW32_INTERLOCKED_VALUE)0)) + (PTW32_INTERLOCKED_LONG)0)) { /* Unblock the next thread */ SetEvent(mx->event); @@ -200,10 +200,10 @@ pthread_mutex_lock (pthread_mutex_t * mutex) } else { - if ((PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_COMPARE_EXCHANGE( + if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) 1, - (PTW32_INTERLOCKED_VALUE) 0) == 0) + (PTW32_INTERLOCKED_LONG) 1, + (PTW32_INTERLOCKED_LONG) 0) == 0) { mx->recursive_count = 1; /* @@ -228,19 +228,19 @@ pthread_mutex_lock (pthread_mutex_t * mutex) else { while (0 == (result = ptw32_robust_mutex_inherit(mutex)) - && (PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_EXCHANGE( + && (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) -1) != 0) + (PTW32_INTERLOCKED_LONG) -1) != 0) { if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) { result = EINVAL; break; } - if ((PTW32_INTERLOCKED_VALUE)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD( + if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == + PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( (PTW32_INTERLOCKED_PTR)statePtr, - (PTW32_INTERLOCKED_VALUE)0)) + (PTW32_INTERLOCKED_LONG)0)) { /* Unblock the next thread */ SetEvent(mx->event); diff --git a/pthread_mutex_timedlock.c b/pthread_mutex_timedlock.c index 14843af..a2fd5a0 100644 --- a/pthread_mutex_timedlock.c +++ b/pthread_mutex_timedlock.c @@ -138,13 +138,13 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, { if (mx->kind == PTHREAD_MUTEX_NORMAL) { - if ((PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_EXCHANGE( + if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) 1) != 0) + (PTW32_INTERLOCKED_LONG) 1) != 0) { - while ((PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_EXCHANGE( + while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) -1) != 0) + (PTW32_INTERLOCKED_LONG) -1) != 0) { if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) { @@ -157,10 +157,10 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, { pthread_t self = pthread_self(); - if ((PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_COMPARE_EXCHANGE( + if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) 1, - (PTW32_INTERLOCKED_VALUE) 0) == 0) + (PTW32_INTERLOCKED_LONG) 1, + (PTW32_INTERLOCKED_LONG) 0) == 0) { mx->recursive_count = 1; mx->ownerThread = self; @@ -180,9 +180,9 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, } else { - while ((PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_EXCHANGE( + while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) -1) != 0) + (PTW32_INTERLOCKED_LONG) -1) != 0) { if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) { @@ -205,9 +205,9 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, */ ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent; - if ((PTW32_INTERLOCKED_VALUE)PTW32_ROBUST_NOTRECOVERABLE == PTW32_INTERLOCKED_EXCHANGE_ADD( + if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( (PTW32_INTERLOCKED_PTR)statePtr, - (PTW32_INTERLOCKED_VALUE)0)) + (PTW32_INTERLOCKED_LONG)0)) { result = ENOTRECOVERABLE; } @@ -219,23 +219,23 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, if (PTHREAD_MUTEX_NORMAL == kind) { - if ((PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_EXCHANGE( + if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) 1) != 0) + (PTW32_INTERLOCKED_LONG) 1) != 0) { while (0 == (result = ptw32_robust_mutex_inherit(mutex)) - && (PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_EXCHANGE( + && (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) -1) != 0) + (PTW32_INTERLOCKED_LONG) -1) != 0) { if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) { return result; } - if ((PTW32_INTERLOCKED_VALUE)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD( + if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == + PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( (PTW32_INTERLOCKED_PTR)statePtr, - (PTW32_INTERLOCKED_VALUE)0)) + (PTW32_INTERLOCKED_LONG)0)) { /* Unblock the next thread */ SetEvent(mx->event); @@ -258,10 +258,10 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, { pthread_t self = pthread_self(); - if (0 == (PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_COMPARE_EXCHANGE( + if (0 == (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) 1, - (PTW32_INTERLOCKED_VALUE) 0)) + (PTW32_INTERLOCKED_LONG) 1, + (PTW32_INTERLOCKED_LONG) 0)) { mx->recursive_count = 1; /* @@ -286,9 +286,9 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, else { while (0 == (result = ptw32_robust_mutex_inherit(mutex)) - && (PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_EXCHANGE( + && (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) -1) != 0) + (PTW32_INTERLOCKED_LONG) -1) != 0) { if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) { @@ -296,10 +296,10 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, } } - if ((PTW32_INTERLOCKED_VALUE)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD( + if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == + PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( (PTW32_INTERLOCKED_PTR)statePtr, - (PTW32_INTERLOCKED_VALUE)0)) + (PTW32_INTERLOCKED_LONG)0)) { /* Unblock the next thread */ SetEvent(mx->event); diff --git a/pthread_mutex_trylock.c b/pthread_mutex_trylock.c index a57986c..aeb79cd 100644 --- a/pthread_mutex_trylock.c +++ b/pthread_mutex_trylock.c @@ -69,10 +69,10 @@ pthread_mutex_trylock (pthread_mutex_t * mutex) if (kind >= 0) { /* Non-robust */ - if (0 == (PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_COMPARE_EXCHANGE ( + if (0 == (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) 1, - (PTW32_INTERLOCKED_VALUE) 0)) + (PTW32_INTERLOCKED_LONG) 1, + (PTW32_INTERLOCKED_LONG) 0)) { if (kind != PTHREAD_MUTEX_NORMAL) { @@ -103,10 +103,10 @@ pthread_mutex_trylock (pthread_mutex_t * mutex) pthread_t self; ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent; - if ((PTW32_INTERLOCKED_VALUE)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD( + if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == + PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( (PTW32_INTERLOCKED_PTR)statePtr, - (PTW32_INTERLOCKED_VALUE)0)) + (PTW32_INTERLOCKED_LONG)0)) { return ENOTRECOVERABLE; } @@ -114,10 +114,10 @@ pthread_mutex_trylock (pthread_mutex_t * mutex) self = pthread_self(); kind = -kind - 1; /* Convert to non-robust range */ - if (0 == (PTW32_INTERLOCKED_VALUE) PTW32_INTERLOCKED_COMPARE_EXCHANGE ( + if (0 == (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ( (PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) 1, - (PTW32_INTERLOCKED_VALUE) 0)) + (PTW32_INTERLOCKED_LONG) 1, + (PTW32_INTERLOCKED_LONG) 0)) { if (kind != PTHREAD_MUTEX_NORMAL) { diff --git a/pthread_mutex_unlock.c b/pthread_mutex_unlock.c index 59604fd..51e2b78 100644 --- a/pthread_mutex_unlock.c +++ b/pthread_mutex_unlock.c @@ -66,8 +66,8 @@ pthread_mutex_unlock (pthread_mutex_t * mutex) { LONG idx; - idx = (LONG)(size_t) PTW32_INTERLOCKED_EXCHANGE ((PTW32_INTERLOCKED_PTR)&mx->lock_idx, - (PTW32_INTERLOCKED_VALUE)0); + idx = (LONG) PTW32_INTERLOCKED_EXCHANGE_LONG ((PTW32_INTERLOCKED_PTR)&mx->lock_idx, + (PTW32_INTERLOCKED_LONG)0); if (idx != 0) { if (idx < 0) @@ -91,8 +91,8 @@ pthread_mutex_unlock (pthread_mutex_t * mutex) { mx->ownerThread.p = NULL; - if ((LONG)(size_t) PTW32_INTERLOCKED_EXCHANGE ((PTW32_INTERLOCKED_PTR)&mx->lock_idx, - (PTW32_INTERLOCKED_VALUE)0) < 0) + if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG ((PTW32_INTERLOCKED_PTR)&mx->lock_idx, + (PTW32_INTERLOCKED_LONG)0) < 0L) { /* Someone may be waiting on that mutex */ if (SetEvent (mx->event) == 0) @@ -120,15 +120,15 @@ pthread_mutex_unlock (pthread_mutex_t * mutex) */ if (pthread_equal (mx->ownerThread, self)) { - PTW32_INTERLOCKED_COMPARE_EXCHANGE((PTW32_INTERLOCKED_PTR) &mx->robustNode->stateInconsistent, - (PTW32_INTERLOCKED_VALUE)PTW32_ROBUST_NOTRECOVERABLE, - (PTW32_INTERLOCKED_VALUE)PTW32_ROBUST_INCONSISTENT); + PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG((PTW32_INTERLOCKED_PTR) &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)(size_t) PTW32_INTERLOCKED_EXCHANGE((PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) 0) < 0) + if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG((PTW32_INTERLOCKED_PTR) &mx->lock_idx, + (PTW32_INTERLOCKED_LONG) 0) < 0) { /* * Someone may be waiting on that mutex. @@ -146,8 +146,8 @@ pthread_mutex_unlock (pthread_mutex_t * mutex) { ptw32_robust_mutex_remove(mutex, NULL); - if ((LONG)(size_t) PTW32_INTERLOCKED_EXCHANGE((PTW32_INTERLOCKED_PTR) &mx->lock_idx, - (PTW32_INTERLOCKED_VALUE) 0) < 0) + if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG((PTW32_INTERLOCKED_PTR) &mx->lock_idx, + (PTW32_INTERLOCKED_LONG) 0) < 0) { /* * Someone may be waiting on that mutex. diff --git a/pthread_once.c b/pthread_once.c index fcfd999..129e4b5 100644 --- a/pthread_once.c +++ b/pthread_once.c @@ -45,9 +45,9 @@ pthread_once (pthread_once_t * once_control, void (*init_routine) (void)) return EINVAL; } - if ((PTW32_INTERLOCKED_VALUE)PTW32_FALSE == - (PTW32_INTERLOCKED_VALUE)PTW32_INTERLOCKED_EXCHANGE_ADD((PTW32_INTERLOCKED_PTR)&once_control->done, - (PTW32_INTERLOCKED_VALUE)0)) /* MBR fence */ + if ((PTW32_INTERLOCKED_LONG)PTW32_FALSE == + (PTW32_INTERLOCKED_LONG)PTW32_INTERLOCKED_EXCHANGE_ADD_LONG((PTW32_INTERLOCKED_PTR)&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 2be1e32..7518c20 100644 --- a/pthread_spin_destroy.c +++ b/pthread_spin_destroy.c @@ -55,13 +55,10 @@ pthread_spin_destroy (pthread_spinlock_t * lock) { result = pthread_mutex_destroy (&(s->u.mutex)); } - else if ((PTW32_INTERLOCKED_VALUE) PTW32_SPIN_UNLOCKED != - PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_PTR) - & (s->interlock), - (PTW32_INTERLOCKED_VALUE) - (size_t)PTW32_OBJECT_INVALID, - (PTW32_INTERLOCKED_VALUE) - (size_t)PTW32_SPIN_UNLOCKED)) + else if ((PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED != + PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_PTR) &s->interlock, + (PTW32_INTERLOCKED_LONG) PTW32_SPIN_INVALID, + (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED)) { result = EINVAL; } diff --git a/pthread_spin_lock.c b/pthread_spin_lock.c index 1e1a51f..6553aee 100644 --- a/pthread_spin_lock.c +++ b/pthread_spin_lock.c @@ -60,13 +60,10 @@ pthread_spin_lock (pthread_spinlock_t * lock) s = *lock; - while ((PTW32_INTERLOCKED_VALUE) PTW32_SPIN_LOCKED == - PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_PTR) & - (s->interlock), - (PTW32_INTERLOCKED_VALUE) - PTW32_SPIN_LOCKED, - (PTW32_INTERLOCKED_VALUE) - PTW32_SPIN_UNLOCKED)) + while ((PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED == + PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_PTR) &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 fbcf526..89d2602 100644 --- a/pthread_spin_trylock.c +++ b/pthread_spin_trylock.c @@ -61,12 +61,9 @@ pthread_spin_trylock (pthread_spinlock_t * lock) s = *lock; switch ((long) - PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_PTR) & - (s->interlock), - (PTW32_INTERLOCKED_VALUE) - PTW32_SPIN_LOCKED, - (PTW32_INTERLOCKED_VALUE) - PTW32_SPIN_UNLOCKED)) + PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_PTR) &s->interlock, + (PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED, + (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED)) { case PTW32_SPIN_UNLOCKED: return 0; diff --git a/pthread_spin_unlock.c b/pthread_spin_unlock.c index c5317ea..c2bb6b7 100644 --- a/pthread_spin_unlock.c +++ b/pthread_spin_unlock.c @@ -56,12 +56,9 @@ pthread_spin_unlock (pthread_spinlock_t * lock) } switch ((long) - PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_PTR) & - (s->interlock), - (PTW32_INTERLOCKED_VALUE) - PTW32_SPIN_UNLOCKED, - (PTW32_INTERLOCKED_VALUE) - PTW32_SPIN_LOCKED)) + PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_PTR) &s->interlock, + (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED, + (PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED)) { case PTW32_SPIN_LOCKED: return 0; diff --git a/pthread_win32_attach_detach_np.c b/pthread_win32_attach_detach_np.c index 6a42c93..c3ff0a2 100644 --- a/pthread_win32_attach_detach_np.c +++ b/pthread_win32_attach_detach_np.c @@ -58,7 +58,11 @@ pthread_win32_process_attach_np () pthread_count++; #endif +#if defined(__GNUC__) ptw32_features = 0; +#else + ptw32_features = PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE; +#endif /* * Load QUSEREX.DLL and try to get address of QueueUserAPCEx @@ -208,9 +212,9 @@ pthread_win32_thread_detach_np () { pthread_mutex_t mx = sp->robustMxList->mx; ptw32_robust_mutex_remove(&mx, sp); - (void) PTW32_INTERLOCKED_EXCHANGE( + (void) PTW32_INTERLOCKED_EXCHANGE_LONG( (PTW32_INTERLOCKED_PTR)&mx->robustNode->stateInconsistent, - (PTW32_INTERLOCKED_VALUE)-1); + (PTW32_INTERLOCKED_LONG)-1); /* * If there are no waiters then the next thread to block will * sleep, wakeup immediately and then go back to sleep. diff --git a/ptw32_MCS_lock.c b/ptw32_MCS_lock.c index 303fba9..42674cf 100644 --- a/ptw32_MCS_lock.c +++ b/ptw32_MCS_lock.c @@ -102,10 +102,10 @@ INLINE void ptw32_mcs_flag_set (LONG * flag) { - HANDLE e = (HANDLE)(PTW32_INTERLOCKED_VALUE)PTW32_INTERLOCKED_COMPARE_EXCHANGE( + HANDLE e = (HANDLE)(PTW32_INTERLOCKED_SIZE)PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( (PTW32_INTERLOCKED_PTR)flag, - (PTW32_INTERLOCKED_VALUE)-1, - (PTW32_INTERLOCKED_VALUE)0); + (PTW32_INTERLOCKED_SIZE)-1, + (PTW32_INTERLOCKED_SIZE)0); if ((HANDLE)0 != e) { /* another thread has already stored an event handle in the flag */ @@ -122,16 +122,18 @@ ptw32_mcs_flag_set (LONG * flag) INLINE void ptw32_mcs_flag_wait (LONG * flag) { - if (0 == PTW32_INTERLOCKED_EXCHANGE_ADD((PTW32_INTERLOCKED_PTR)flag, (PTW32_INTERLOCKED_VALUE)0)) /* MBR fence */ + if ((PTW32_INTERLOCKED_LONG)0 == + PTW32_INTERLOCKED_EXCHANGE_ADD_LONG((PTW32_INTERLOCKED_PTR)flag, + (PTW32_INTERLOCKED_LONG)0)) /* MBR fence */ { /* the flag is not set. create event. */ HANDLE e = CreateEvent(NULL, PTW32_FALSE, PTW32_FALSE, NULL); - if (0 == PTW32_INTERLOCKED_COMPARE_EXCHANGE( + if ((PTW32_INTERLOCKED_SIZE)0 == PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( (PTW32_INTERLOCKED_PTR)flag, - (PTW32_INTERLOCKED_VALUE)e, - (PTW32_INTERLOCKED_VALUE)0)) + (PTW32_INTERLOCKED_SIZE)e, + (PTW32_INTERLOCKED_SIZE)0)) { /* stored handle in the flag. wait on it now. */ WaitForSingleObject(e, INFINITE); @@ -190,8 +192,9 @@ void 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 *)(size_t) - PTW32_INTERLOCKED_EXCHANGE_ADD((PTW32_INTERLOCKED_PTR)&node->next, (PTW32_INTERLOCKED_VALUE)0); /* MBR fence */ + 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 */ if (0 == next) { @@ -208,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 *)(size_t) - PTW32_INTERLOCKED_EXCHANGE_ADD((PTW32_INTERLOCKED_PTR)&node->next, (PTW32_INTERLOCKED_VALUE)0); /* MBR fence */ + next = (ptw32_mcs_local_node_t *)(intptr_t) + PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_PTR)&node->next, (PTW32_INTERLOCKED_SIZE)0); /* MBR fence */ } /* pass the lock */ |