summaryrefslogtreecommitdiffstats
path: root/atomic
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--atomic/netware/apr_atomic.c2
-rw-r--r--atomic/os390/atomic.c2
-rw-r--r--atomic/unix/builtins.c13
-rw-r--r--atomic/unix/builtins64.c11
-rw-r--r--atomic/unix/ia32.c2
-rw-r--r--atomic/unix/mutex64.c11
-rw-r--r--atomic/unix/ppc.c2
-rw-r--r--atomic/unix/s390.c2
-rw-r--r--atomic/unix/solaris.c2
-rw-r--r--atomic/win32/apr_atomic.c4
10 files changed, 30 insertions, 21 deletions
diff --git a/atomic/netware/apr_atomic.c b/atomic/netware/apr_atomic.c
index 9c3df80..daee00d 100644
--- a/atomic/netware/apr_atomic.c
+++ b/atomic/netware/apr_atomic.c
@@ -20,7 +20,7 @@
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *pool)
{
-#if defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
return apr__atomic_generic64_init(p);
#else
return APR_SUCCESS;
diff --git a/atomic/os390/atomic.c b/atomic/os390/atomic.c
index e6a1693..f526e34 100644
--- a/atomic/os390/atomic.c
+++ b/atomic/os390/atomic.c
@@ -20,7 +20,7 @@
apr_status_t apr_atomic_init(apr_pool_t *p)
{
-#if defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
return apr__atomic_generic64_init(p);
#else
return APR_SUCCESS;
diff --git a/atomic/unix/builtins.c b/atomic/unix/builtins.c
index 22b828c..5165e72 100644
--- a/atomic/unix/builtins.c
+++ b/atomic/unix/builtins.c
@@ -18,15 +18,20 @@
#ifdef USE_ATOMICS_BUILTINS
-#if defined(__arm__) || defined(__powerpc__) || defined(__powerpc64__)
-#define WEAK_MEMORY_ORDERING 1
-#else
+#if defined(__i386__) || defined(__x86_64__) \
+ || defined(__s390__) || defined(__s390x__)
#define WEAK_MEMORY_ORDERING 0
+#else
+#define WEAK_MEMORY_ORDERING 1
#endif
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
{
+#if defined (USE_ATOMICS_GENERIC64)
+ return apr__atomic_generic64_init(p);
+#else
return APR_SUCCESS;
+#endif
}
APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem)
@@ -114,7 +119,7 @@ APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint
APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *ptr, const void *cmp)
{
#if HAVE__ATOMIC_BUILTINS
- __atomic_compare_exchange_n(mem, (void **)&cmp, ptr, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
+ __atomic_compare_exchange_n(mem, (void *)&cmp, ptr, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
return (void *)cmp;
#else
return (void *)__sync_val_compare_and_swap(mem, (void *)cmp, ptr);
diff --git a/atomic/unix/builtins64.c b/atomic/unix/builtins64.c
index 7d84225..f0cdb30 100644
--- a/atomic/unix/builtins64.c
+++ b/atomic/unix/builtins64.c
@@ -18,17 +18,18 @@
#ifdef USE_ATOMICS_BUILTINS64
-#if defined(__arm__) || defined(__powerpc__) || defined(__powerpc64__)
-#define WEAK_MEMORY_ORDERING 1
-#else
+#if defined(__i386__) || defined(__x86_64__) \
+ || defined(__s390__) || defined(__s390x__)
#define WEAK_MEMORY_ORDERING 0
+#else
+#define WEAK_MEMORY_ORDERING 1
#endif
APR_DECLARE(apr_uint64_t) apr_atomic_read64(volatile apr_uint64_t *mem)
{
#if HAVE__ATOMIC_BUILTINS
return __atomic_load_n(mem, __ATOMIC_SEQ_CST);
-#elif WEAK_MEMORY_ORDERING
+#elif WEAK_MEMORY_ORDERING || APR_SIZEOF_VOIDP < 8
/* No __sync_load() available => apr_atomic_add64(mem, 0) */
return __sync_fetch_and_add(mem, 0);
#else
@@ -40,7 +41,7 @@ APR_DECLARE(void) apr_atomic_set64(volatile apr_uint64_t *mem, apr_uint64_t val)
{
#if HAVE__ATOMIC_BUILTINS
__atomic_store_n(mem, val, __ATOMIC_SEQ_CST);
-#elif WEAK_MEMORY_ORDERING
+#elif WEAK_MEMORY_ORDERING || APR_SIZEOF_VOIDP < 8
/* No __sync_store() available => apr_atomic_xchg64(mem, val) */
__sync_synchronize();
__sync_lock_test_and_set(mem, val);
diff --git a/atomic/unix/ia32.c b/atomic/unix/ia32.c
index cdb7a52..ce92c22 100644
--- a/atomic/unix/ia32.c
+++ b/atomic/unix/ia32.c
@@ -20,7 +20,7 @@
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
{
-#if defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
return apr__atomic_generic64_init(p);
#else
return APR_SUCCESS;
diff --git a/atomic/unix/mutex64.c b/atomic/unix/mutex64.c
index 9fc44af..4ea4d8f 100644
--- a/atomic/unix/mutex64.c
+++ b/atomic/unix/mutex64.c
@@ -17,7 +17,7 @@
#include "apr_arch_atomic.h"
#include "apr_thread_mutex.h"
-#if defined(USE_ATOMICS_GENERIC) || defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
#include <stdlib.h>
@@ -96,7 +96,14 @@ apr_status_t apr__atomic_generic64_init(apr_pool_t *p)
APR_DECLARE(apr_uint64_t) apr_atomic_read64(volatile apr_uint64_t *mem)
{
- return *mem;
+ apr_uint64_t cur_value;
+ DECLARE_MUTEX_LOCKED(mutex, mem);
+
+ cur_value = *mem;
+
+ MUTEX_UNLOCK(mutex);
+
+ return cur_value;
}
APR_DECLARE(void) apr_atomic_set64(volatile apr_uint64_t *mem, apr_uint64_t val)
diff --git a/atomic/unix/ppc.c b/atomic/unix/ppc.c
index 46554af..1ae727f 100644
--- a/atomic/unix/ppc.c
+++ b/atomic/unix/ppc.c
@@ -26,7 +26,7 @@
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
{
-#if defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
return apr__atomic_generic64_init(p);
#else
return APR_SUCCESS;
diff --git a/atomic/unix/s390.c b/atomic/unix/s390.c
index ae5d040..c036128 100644
--- a/atomic/unix/s390.c
+++ b/atomic/unix/s390.c
@@ -20,7 +20,7 @@
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
{
-#if defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
return apr__atomic_generic64_init(p);
#else
return APR_SUCCESS;
diff --git a/atomic/unix/solaris.c b/atomic/unix/solaris.c
index 9bc2de2..994354e 100644
--- a/atomic/unix/solaris.c
+++ b/atomic/unix/solaris.c
@@ -22,7 +22,7 @@
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
{
-#if defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
return apr__atomic_generic64_init(p);
#else
return APR_SUCCESS;
diff --git a/atomic/win32/apr_atomic.c b/atomic/win32/apr_atomic.c
index b29ea59..5c2a870 100644
--- a/atomic/win32/apr_atomic.c
+++ b/atomic/win32/apr_atomic.c
@@ -18,11 +18,7 @@
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
{
-#if defined (NEED_ATOMICS_GENERIC64)
- return apr__atomic_generic64_init(p);
-#else
return APR_SUCCESS;
-#endif
}
APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)