summaryrefslogtreecommitdiff
path: root/spin.c
diff options
context:
space:
mode:
authorrpj <rpj>2001-10-25 13:24:58 +0000
committerrpj <rpj>2001-10-25 13:24:58 +0000
commit222a76c37c89ee37eebecd53dd32fd481245e6fa (patch)
tree160ed8d069da4d9e94b16c436943def676e355c5 /spin.c
parent7b714286cfd65e797364fbdc583e13adba71a2ee (diff)
* barrier.c: Move _LONG and _LPLONG defines into
implement.h; rename to PTW32_INTERLOCKED_LONG and PTW32_INTERLOCKED_LPLONG respectively. * spin.c: Likewise; ptw32_interlocked_compare_exchange used in place of InterlockedCompareExchange directly. * global.c (ptw32_interlocked_compare_exchange): Add prototype for this new routine pointer to be used when InterlockedCompareExchange isn't supported by Windows. * nonportable.c (pthread_win32_process_attach_np): Check for support of InterlockedCompareExchange in kernel32 and assign its address to ptw32_interlocked_compare_exchange if it exists, or our own ix86 specific implementation ptw32_InterlockedCompareExchange. *private.c (ptw32_InterlockedCompareExchange): An implementation of InterlockedCompareExchange() which is specific to ix86; written directly in assembler for either MSVC or GNU C; needed because Windows 95 doesn't support InterlockedCompareExchange(). * sched.c (sched_get_priority_min): Extend to return THREAD_PRIORITY_IDLE. (sched_get_priority_max): Extend to return THREAD_PRIORITY_CRITICAL.
Diffstat (limited to 'spin.c')
-rw-r--r--spin.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/spin.c b/spin.c
index b35b9f0..09c5031 100644
--- a/spin.c
+++ b/spin.c
@@ -26,13 +26,6 @@
#include "pthread.h"
#include "implement.h"
-#ifdef __MINGW32__
-#define _LONG long
-#define _LPLONG long*
-#else
-#define _LONG PVOID
-#define _LPLONG PVOID*
-#endif
static INLINE int
ptw32_spinlock_check_need_init(pthread_spinlock_t *lock)
@@ -177,10 +170,10 @@ pthread_spin_destroy(pthread_spinlock_t *lock)
return pthread_mutex_destroy(&(s->u.mutex));
}
- if ( (_LONG) PTW32_SPIN_UNLOCKED ==
- InterlockedCompareExchange((_LPLONG) &(s->interlock),
- (_LONG) PTW32_OBJECT_INVALID,
- (_LONG) PTW32_SPIN_UNLOCKED))
+ if ( (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED ==
+ ptw32_interlocked_compare_exchange((PTW32_INTERLOCKED_LPLONG) &(s->interlock),
+ (PTW32_INTERLOCKED_LONG) PTW32_OBJECT_INVALID,
+ (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED))
{
return 0;
}
@@ -243,10 +236,10 @@ pthread_spin_lock(pthread_spinlock_t *lock)
s = *lock;
- while ( (_LONG) PTW32_SPIN_LOCKED ==
- InterlockedCompareExchange((_LPLONG) &(s->interlock),
- (_LONG) PTW32_SPIN_LOCKED,
- (_LONG) PTW32_SPIN_UNLOCKED) )
+ while ( (PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED ==
+ ptw32_interlocked_compare_exchange((PTW32_INTERLOCKED_LPLONG) &(s->interlock),
+ (PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED,
+ (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED) )
{}
if (s->interlock == PTW32_SPIN_LOCKED)
@@ -271,9 +264,9 @@ pthread_spin_unlock(pthread_spinlock_t *lock)
return EPERM;
}
- switch ((long) InterlockedCompareExchange((_LPLONG) &(s->interlock),
- (_LONG) PTW32_SPIN_UNLOCKED,
- (_LONG) PTW32_SPIN_LOCKED ))
+ switch ((long) ptw32_interlocked_compare_exchange((PTW32_INTERLOCKED_LPLONG) &(s->interlock),
+ (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED,
+ (PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED ))
{
case PTW32_SPIN_LOCKED: return 0;
case PTW32_SPIN_UNLOCKED: return EPERM;
@@ -298,9 +291,9 @@ pthread_spin_trylock(pthread_spinlock_t *lock)
}
}
- switch ((long) InterlockedCompareExchange((_LPLONG) &(s->interlock),
- (_LONG) PTW32_SPIN_LOCKED,
- (_LONG) PTW32_SPIN_UNLOCKED ))
+ switch ((long) ptw32_interlocked_compare_exchange((PTW32_INTERLOCKED_LPLONG) &(s->interlock),
+ (PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED,
+ (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED ))
{
case PTW32_SPIN_UNLOCKED: return 0;
case PTW32_SPIN_LOCKED: return EBUSY;