summaryrefslogtreecommitdiff
path: root/ptw32_MCS_lock.c
diff options
context:
space:
mode:
authorrpj <rpj>2011-07-01 00:51:56 +0000
committerrpj <rpj>2011-07-01 00:51:56 +0000
commit1e0bb8a09c86d144f3779bc4d5724afe3f637922 (patch)
treeb4c0c0a6221360107d2bf816523594352eac5f34 /ptw32_MCS_lock.c
parent5af9e85e56dbcae60f771619131ecbc17980fdaa (diff)
Redo Interlocked macros; see the ChangeLog
Diffstat (limited to 'ptw32_MCS_lock.c')
-rw-r--r--ptw32_MCS_lock.c25
1 files changed, 14 insertions, 11 deletions
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 */