summaryrefslogtreecommitdiff
path: root/srclib/apr/atomic/win32/apr_atomic.c
diff options
context:
space:
mode:
Diffstat (limited to 'srclib/apr/atomic/win32/apr_atomic.c')
-rw-r--r--srclib/apr/atomic/win32/apr_atomic.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/srclib/apr/atomic/win32/apr_atomic.c b/srclib/apr/atomic/win32/apr_atomic.c
index 42c19876..973c679e 100644
--- a/srclib/apr/atomic/win32/apr_atomic.c
+++ b/srclib/apr/atomic/win32/apr_atomic.c
@@ -38,11 +38,16 @@ typedef WINBASEAPI apr_uint32_t (WINAPI * apr_atomic_win32_ptr_val_val_fn)
typedef WINBASEAPI void * (WINAPI * apr_atomic_win32_ptr_ptr_ptr_fn)
(volatile void **,
void *, const void *);
+typedef WINBASEAPI void * (WINAPI * apr_atomic_win32_ptr_ptr_fn)
+ (volatile void **,
+ void *);
APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
{
#if (defined(_M_IA64) || defined(_M_AMD64))
return InterlockedExchangeAdd(mem, val);
+#elif defined(__MINGW32__)
+ return InterlockedExchangeAdd((long *)mem, val);
#else
return ((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, val);
#endif
@@ -55,6 +60,8 @@ APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
{
#if (defined(_M_IA64) || defined(_M_AMD64))
InterlockedExchangeAdd(mem, -val);
+#elif defined(__MINGW32__)
+ InterlockedExchangeAdd((long *)mem, -val);
#else
((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, -val);
#endif
@@ -65,6 +72,8 @@ APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem)
/* we return old value, win32 returns new value :( */
#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
return InterlockedIncrement(mem) - 1;
+#elif defined(__MINGW32__)
+ return InterlockedIncrement((long *)mem) - 1;
#else
return ((apr_atomic_win32_ptr_fn)InterlockedIncrement)(mem) - 1;
#endif
@@ -74,6 +83,8 @@ APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem)
{
#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
return InterlockedDecrement(mem);
+#elif defined(__MINGW32__)
+ return InterlockedDecrement((long *)mem);
#else
return ((apr_atomic_win32_ptr_fn)InterlockedDecrement)(mem);
#endif
@@ -83,6 +94,8 @@ APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
{
#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
InterlockedExchange(mem, val);
+#elif defined(__MINGW32__)
+ InterlockedExchange((long*)mem, val);
#else
((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val);
#endif
@@ -98,6 +111,8 @@ APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint3
{
#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
return InterlockedCompareExchange(mem, with, cmp);
+#elif defined(__MINGW32__)
+ return InterlockedCompareExchange((long*)mem, with, cmp);
#else
return ((apr_atomic_win32_ptr_val_val_fn)InterlockedCompareExchange)(mem, with, cmp);
#endif
@@ -106,7 +121,9 @@ APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint3
APR_DECLARE(void *) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp)
{
#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
- return InterlockedCompareExchangePointer((void* volatile*)mem, with, (void *)cmp);
+ return InterlockedCompareExchangePointer((void* volatile*)mem, with, (void*)cmp);
+#elif defined(__MINGW32__)
+ return InterlockedCompareExchangePointer((void**)mem, with, (void*)cmp);
#else
/* Too many VC6 users have stale win32 API files, stub this */
return ((apr_atomic_win32_ptr_ptr_ptr_fn)InterlockedCompareExchange)(mem, with, cmp);
@@ -117,7 +134,19 @@ APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint
{
#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
return InterlockedExchange(mem, val);
+#elif defined(__MINGW32__)
+ return InterlockedExchange((long *)mem, val);
#else
return ((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem, val);
#endif
}
+
+APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with)
+{
+#if (defined(_M_IA64) || defined(_M_AMD64) || defined(__MINGW32__)) && !defined(RC_INVOKED)
+ return InterlockedExchangePointer((void**)mem, with);
+#else
+ /* Too many VC6 users have stale win32 API files, stub this */
+ return ((apr_atomic_win32_ptr_ptr_fn)InterlockedExchange)(mem, with);
+#endif
+}