summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES6
-rw-r--r--atomic/os390/atomic.c6
-rw-r--r--atomic/unix/apr_atomic.c100
-rw-r--r--include/apr_atomic.h147
-rw-r--r--locks/unix/thread_mutex.c10
-rw-r--r--test/testatomic.c117
6 files changed, 40 insertions, 346 deletions
diff --git a/CHANGES b/CHANGES
index 4d623e924..a0319a789 100644
--- a/CHANGES
+++ b/CHANGES
@@ -20,6 +20,12 @@ Changes with APR 1.0
apr_allocator_set_max_free -> apr_allocator_max_free_set
apr_allocator_set_mutex -> apr_allocator_mutex_set
apr_allocator_set_owner -> apr_allocator_owner_set
+ apr_atomic_add -> apr_atomic_add32
+ apr_atomic_cas -> apr_atomic_cas32
+ apr_atomic_dec -> apr_atomic_dec32
+ apr_atomic_inc -> apr_atomic_inc32
+ apr_atomic_read -> apr_atomic_read32
+ apr_atomic_set -> apr_atomic_set32
apr_bind -> apr_socket_bind
apr_compare_groups -> apr_gid_compare
apr_compare_users -> apr_uid_compare
diff --git a/atomic/os390/atomic.c b/atomic/os390/atomic.c
index caa1a5e26..1c6d7db1b 100644
--- a/atomic/os390/atomic.c
+++ b/atomic/os390/atomic.c
@@ -58,7 +58,7 @@
#if APR_HAS_THREADS
-apr_int32_t apr_atomic_add(volatile apr_atomic_t *mem, apr_int32_t val)
+apr_int32_t apr_atomic_add32(volatile apr_atomic_t *mem, apr_int32_t val)
{
apr_atomic_t old, new_val;
@@ -70,8 +70,8 @@ apr_int32_t apr_atomic_add(volatile apr_atomic_t *mem, apr_int32_t val)
return new_val;
}
-apr_uint32_t apr_atomic_cas(volatile apr_atomic_t *mem, apr_uint32_t swap,
- apr_uint32_t cmp)
+apr_uint32_t apr_atomic_cas32(volatile apr_atomic_t *mem, apr_uint32_t swap,
+ apr_uint32_t cmp)
{
apr_uint32_t old = cmp;
diff --git a/atomic/unix/apr_atomic.c b/atomic/unix/apr_atomic.c
index 16912b968..34ef54275 100644
--- a/atomic/unix/apr_atomic.c
+++ b/atomic/unix/apr_atomic.c
@@ -84,106 +84,6 @@ apr_status_t apr_atomic_init(apr_pool_t *p)
}
#endif /*!defined(apr_atomic_init) && !defined(APR_OVERRIDE_ATOMIC_INIT) */
-#if !defined(apr_atomic_add) && !defined(APR_OVERRIDE_ATOMIC_ADD)
-void apr_atomic_add(volatile apr_atomic_t *mem, apr_uint32_t val)
-{
-#if APR_HAS_THREADS
- apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)];
- apr_uint32_t prev;
-
- if (apr_thread_mutex_lock(lock) == APR_SUCCESS) {
- prev = *mem;
- *mem += val;
- apr_thread_mutex_unlock(lock);
- }
-#else
- *mem += val;
-#endif /* APR_HAS_THREADS */
-}
-#endif /*!defined(apr_atomic_add) && !defined(APR_OVERRIDE_ATOMIC_ADD) */
-
-#if !defined(apr_atomic_set) && !defined(APR_OVERRIDE_ATOMIC_SET)
-void apr_atomic_set(volatile apr_atomic_t *mem, apr_uint32_t val)
-{
-#if APR_HAS_THREADS
- apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)];
- apr_uint32_t prev;
-
- if (apr_thread_mutex_lock(lock) == APR_SUCCESS) {
- prev = *mem;
- *mem = val;
- apr_thread_mutex_unlock(lock);
- }
-#else
- *mem = val;
-#endif /* APR_HAS_THREADS */
-}
-#endif /*!defined(apr_atomic_set) && !defined(APR_OVERRIDE_ATOMIC_SET) */
-
-#if !defined(apr_atomic_inc) && !defined(APR_OVERRIDE_ATOMIC_INC)
-void apr_atomic_inc(volatile apr_uint32_t *mem)
-{
-#if APR_HAS_THREADS
- apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)];
- apr_uint32_t prev;
-
- if (apr_thread_mutex_lock(lock) == APR_SUCCESS) {
- prev = *mem;
- (*mem)++;
- apr_thread_mutex_unlock(lock);
- }
-#else
- (*mem)++;
-#endif /* APR_HAS_THREADS */
-}
-#endif /*!defined(apr_atomic_inc) && !defined(APR_OVERRIDE_ATOMIC_INC) */
-
-#if !defined(apr_atomic_dec) && !defined(APR_OVERRIDE_ATOMIC_DEC)
-int apr_atomic_dec(volatile apr_atomic_t *mem)
-{
-#if APR_HAS_THREADS
- apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)];
- apr_uint32_t new;
-
- if (apr_thread_mutex_lock(lock) == APR_SUCCESS) {
- (*mem)--;
- new = *mem;
- apr_thread_mutex_unlock(lock);
- return new;
- }
-#else
- (*mem)--;
-#endif /* APR_HAS_THREADS */
- return *mem;
-}
-#endif /*!defined(apr_atomic_dec) && !defined(APR_OVERRIDE_ATOMIC_DEC) */
-
-#if !defined(apr_atomic_cas) && !defined(APR_OVERRIDE_ATOMIC_CAS)
-apr_uint32_t apr_atomic_cas(volatile apr_uint32_t *mem, long with, long cmp)
-{
- long prev;
-#if APR_HAS_THREADS
- apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)];
-
- if (apr_thread_mutex_lock(lock) == APR_SUCCESS) {
- prev = *(long*)mem;
- if (prev == cmp) {
- *(long*)mem = with;
- }
- apr_thread_mutex_unlock(lock);
- return prev;
- }
- return *(long*)mem;
-#else
- prev = *(long*)mem;
- if (prev == cmp) {
- *(long*)mem = with;
- }
- return prev;
-#endif /* APR_HAS_THREADS */
-}
-#endif /*!defined(apr_atomic_cas) && !defined(APR_OVERRIDE_ATOMIC_CAS) */
-
#if !defined(apr_atomic_add32) && !defined(APR_OVERRIDE_ATOMIC_ADD32)
void apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
{
diff --git a/include/apr_atomic.h b/include/apr_atomic.h
index d575b5447..21ceb9f81 100644
--- a/include/apr_atomic.h
+++ b/include/apr_atomic.h
@@ -99,57 +99,6 @@ typedef apr_atomic_t;
* @return APR_SUCCESS on successful completion
*/
apr_status_t apr_atomic_init(apr_pool_t *p);
-/**
- * read the value stored in a atomic variable
- * @param mem the pointer
- * @warning on certain platforms this number is not stored
- * directly in the pointer. in others it is
- * @deprecated
- */
-apr_uint32_t apr_atomic_read(volatile apr_atomic_t *mem);
-/**
- * set the value for atomic.
- * @param mem the pointer
- * @param val the value
- * @deprecated
- */
-void apr_atomic_set(volatile apr_atomic_t *mem, apr_uint32_t val);
-/**
- * Add 'val' to the atomic variable
- * @param mem pointer to the atomic value
- * @param val the addition
- * @deprecated
- */
-void apr_atomic_add(volatile apr_atomic_t *mem, apr_uint32_t val);
-
-/**
- * increment the atomic variable by 1
- * @param mem pointer to the atomic value
- * @deprecated
- */
-void apr_atomic_inc(volatile apr_atomic_t *mem);
-
-/**
- * decrement the atomic variable by 1
- * @param mem pointer to the atomic value
- * @return zero if the value is zero, otherwise non-zero
- * @deprecated
- */
-int apr_atomic_dec(volatile apr_atomic_t *mem);
-
-/**
- * compare the atomic's value with cmp.
- * If they are the same swap the value with 'with'
- * @param mem pointer to the atomic value
- * @param with what to swap it with
- * @param cmp the value to compare it to
- * @return the old value of the atomic
- * @warning do not mix apr_atomic's with the CAS function.
- * @deprecated
- * on some platforms they may be implemented by different mechanisms
- */
-apr_uint32_t apr_atomic_cas(volatile apr_uint32_t *mem, long with, long cmp);
-
/*
* Atomic operations on 32-bit values
@@ -238,12 +187,6 @@ void *apr_atomic_casptr(volatile void **mem, void *with, const void *cmp);
#define apr_atomic_t LONG
#define apr_atomic_init(pool) APR_SUCCESS
-#define apr_atomic_add(mem, val) InterlockedExchangeAdd(mem,val)
-#define apr_atomic_inc(mem) InterlockedIncrement(mem)
-#define apr_atomic_dec(mem) InterlockedDecrement(mem)
-#define apr_atomic_set(mem, val) InterlockedExchange(mem, val)
-#define apr_atomic_read(mem) (*mem)
-#define apr_atomic_cas(mem,with,cmp) InterlockedCompareExchange(mem,with,cmp)
#define apr_atomic_casptr(mem,with,cmp) InterlockedCompareExchangePointer(mem,with,cmp)
/*
@@ -311,13 +254,6 @@ inline void *apr_atomic_casptr(void **mem, void *with, const void *cmp)
return (void*)atomic_cmpxchg((unsigned long *)mem,(unsigned long)cmp,(unsigned long)with);
}
-#define apr_atomic_read(mem) apr_atomic_read32(mem)
-#define apr_atomic_set(mem, val) apr_atomic_set32(mem, val)
-#define apr_atomic_add(mem, val) apr_atomic_add32(mem,val)
-#define apr_atomic_inc(mem) apr_atomic_inc32(mem)
-#define apr_atomic_dec(mem) apr_atomic_dec32(mem)
-#define apr_atomic_cas(mem,with,cmp) apr_atomic_cas32(mem,with,cmp)
-
#define APR_OVERRIDE_ATOMIC_READ 1
#define APR_OVERRIDE_ATOMIC_SET 1
#define APR_OVERRIDE_ATOMIC_ADD 1
@@ -328,23 +264,17 @@ inline void *apr_atomic_casptr(void **mem, void *with, const void *cmp)
#elif defined(__FreeBSD__) && !defined(__i386__)
#define apr_atomic_t apr_uint32_t
-#define apr_atomic_add(mem, val) atomic_add_int(mem,val)
-#define apr_atomic_dec(mem) atomic_subtract_int(mem,1)
-#define apr_atomic_inc(mem) atomic_add_int(mem,1)
-#define apr_atomic_set(mem, val) atomic_set_int(mem, val)
-#define apr_atomic_read(mem) (*mem)
-
-#define apr_atomic_add32(mem, val) apr_atomic_add(mem, val)
-#define apr_atomic_dec32(mem) apr_atomic_dec(mem)
-#define apr_atomic_inc32(mem) apr_atomic_inc(mem)
-#define apr_atomic_set32(mem, val) apr_atomic_set(mem, val)
-#define apr_atomic_read32(mem) apr_atomic_read(mem)
+#define apr_atomic_add32(mem, val) atomic_add_int(mem,val)
+#define apr_atomic_dec32(mem) atomic_subtract_int(mem,1)
+#define apr_atomic_inc32(mem) atomic_add_int(mem,1)
+#define apr_atomic_set32(mem, val) atomic_set_int(mem, val)
+#define apr_atomic_read32(mem) (*mem)
#elif (defined(__linux__) || defined(__EMX__) || defined(__FreeBSD__)) \
&& defined(__i386__) && !APR_FORCE_ATOMIC_GENERIC
#define apr_atomic_t apr_uint32_t
-#define apr_atomic_cas(mem,with,cmp) \
+#define apr_atomic_cas32(mem,with,cmp) \
({ apr_atomic_t prev; \
asm volatile ("lock; cmpxchgl %1, %2" \
: "=a" (prev) \
@@ -352,19 +282,19 @@ inline void *apr_atomic_casptr(void **mem, void *with, const void *cmp)
: "memory"); \
prev;})
-#define apr_atomic_add(mem, val) \
+#define apr_atomic_add32(mem, val) \
asm volatile ("lock; addl %1, %0" \
: \
: "m" (*(mem)), "r" (val) \
: "memory")
-#define apr_atomic_sub(mem, val) \
+#define apr_atomic_sub32(mem, val) \
asm volatile ("lock; subl %1, %0" \
: \
: "m" (*(mem)), "r" (val) \
: "memory")
-#define apr_atomic_dec(mem) \
+#define apr_atomic_dec32(mem) \
({ int prev; \
asm volatile ("mov $0, %%eax;\n\t" \
"lock; decl %1;\n\t" \
@@ -375,22 +305,14 @@ inline void *apr_atomic_casptr(void **mem, void *with, const void *cmp)
: "memory", "%eax"); \
prev;})
-#define apr_atomic_inc(mem) \
+#define apr_atomic_inc32(mem) \
asm volatile ("lock; incl %0" \
: \
: "m" (*(mem)) \
: "memory")
-#define apr_atomic_set(mem, val) (*(mem) = val)
-#define apr_atomic_read(mem) (*(mem))
-
-#define apr_atomic_cas32(mem, with, cmp) apr_atomic_cas(mem, with, cmp)
-#define apr_atomic_add32(mem, val) apr_atomic_add(mem, val)
-#define apr_atomic_sub32(mem, val) apr_atomic_sub(mem, val)
-#define apr_atomic_dec32(mem) apr_atomic_dec(mem)
-#define apr_atomic_inc32(mem) apr_atomic_inc(mem)
-#define apr_atomic_set32(mem, val) apr_atomic_set(mem, val)
-#define apr_atomic_read32(mem) apr_atomic_read(mem)
+#define apr_atomic_set32(mem, val) (*(mem) = val)
+#define apr_atomic_read32(mem) (*(mem))
#define apr_atomic_xchg32(mem,val) \
({ apr_uint32_t prev = val; \
@@ -406,14 +328,14 @@ inline void *apr_atomic_casptr(void **mem, void *with, const void *cmp)
#define apr_atomic_t cs_t
-apr_int32_t apr_atomic_add(volatile apr_atomic_t *mem, apr_int32_t val);
-apr_uint32_t apr_atomic_cas(volatile apr_atomic_t *mem, apr_uint32_t swap,
- apr_uint32_t cmp);
+apr_int32_t apr_atomic_add32(volatile apr_atomic_t *mem, apr_int32_t val);
+apr_uint32_t apr_atomic_cas32(volatile apr_atomic_t *mem, apr_uint32_t swap,
+ apr_uint32_t cmp);
#define APR_OVERRIDE_ATOMIC_ADD 1
#define APR_OVERRIDE_ATOMIC_CAS 1
-#define apr_atomic_inc(mem) apr_atomic_add(mem, 1)
-#define apr_atomic_dec(mem) apr_atomic_add(mem, -1)
+#define apr_atomic_inc32(mem) apr_atomic_add32(mem, 1)
+#define apr_atomic_dec32(mem) apr_atomic_add32(mem, -1)
/*#define apr_atomic_init(pool) APR_SUCCESS*/
/* warning: the following two operations, _read and _set, are atomic
@@ -425,8 +347,8 @@ apr_uint32_t apr_atomic_cas(volatile apr_atomic_t *mem, apr_uint32_t swap,
* variables with other apr_atomic_* operations on OS/390.
*/
-#define apr_atomic_read(p) (*p)
-#define apr_atomic_set(mem, val) (*mem = val)
+#define apr_atomic_read32(p) (*p)
+#define apr_atomic_set32(mem, val) (*mem = val)
#endif /* end big if-elseif switch for platform-specifics */
@@ -449,35 +371,6 @@ apr_uint32_t apr_atomic_cas(volatile apr_atomic_t *mem, apr_uint32_t swap,
apr_status_t apr_atomic_init(apr_pool_t *p);
#endif
-#if !defined(apr_atomic_read) && !defined(APR_OVERRIDE_ATOMIC_READ)
-#define apr_atomic_read(p) *p
-#endif
-
-#if !defined(apr_atomic_set) && !defined(APR_OVERRIDE_ATOMIC_SET)
-void apr_atomic_set(volatile apr_atomic_t *mem, apr_uint32_t val);
-#define APR_ATOMIC_NEED_DEFAULT_INIT 1
-#endif
-
-#if !defined(apr_atomic_add) && !defined(APR_OVERRIDE_ATOMIC_ADD)
-void apr_atomic_add(volatile apr_atomic_t *mem, apr_uint32_t val);
-#define APR_ATOMIC_NEED_DEFAULT_INIT 1
-#endif
-
-#if !defined(apr_atomic_inc) && !defined(APR_OVERRIDE_ATOMIC_INC)
-void apr_atomic_inc(volatile apr_atomic_t *mem);
-#define APR_ATOMIC_NEED_DEFAULT_INIT 1
-#endif
-
-#if !defined(apr_atomic_dec) && !defined(APR_OVERRIDE_ATOMIC_DEC)
-int apr_atomic_dec(volatile apr_atomic_t *mem);
-#define APR_ATOMIC_NEED_DEFAULT_INIT 1
-#endif
-
-#if !defined(apr_atomic_cas) && !defined(APR_OVERRIDE_ATOMIC_CAS)
-apr_uint32_t apr_atomic_cas(volatile apr_uint32_t *mem,long with,long cmp);
-#define APR_ATOMIC_NEED_DEFAULT_INIT 1
-#endif
-
#if !defined(apr_atomic_read32) && !defined(APR_OVERRIDE_ATOMIC_READ32)
#define apr_atomic_read32(p) *p
#endif
@@ -520,7 +413,7 @@ apr_uint32_t apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val);
#if !defined(apr_atomic_casptr) && !defined(APR_OVERRIDE_ATOMIC_CASPTR)
#if APR_SIZEOF_VOIDP == 4
-#define apr_atomic_casptr(mem, with, cmp) (void *)apr_atomic_cas((apr_uint32_t *)(mem), (long)(with), (long)cmp)
+#define apr_atomic_casptr(mem, with, cmp) (void *)apr_atomic_cas32((apr_uint32_t *)(mem), (long)(with), (long)cmp)
#else
void *apr_atomic_casptr(volatile void **mem, void *with, const void *cmp);
#define APR_ATOMIC_NEED_DEFAULT_INIT 1
diff --git a/locks/unix/thread_mutex.c b/locks/unix/thread_mutex.c
index db637cdf0..306b02174 100644
--- a/locks/unix/thread_mutex.c
+++ b/locks/unix/thread_mutex.c
@@ -114,7 +114,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex)
* testing the mutex is owned by this thread, so a deadlock is expected.
*/
if (apr_os_thread_equal(mutex->owner, apr_os_thread_current())) {
- apr_atomic_inc(&mutex->owner_ref);
+ apr_atomic_inc32(&mutex->owner_ref);
return APR_SUCCESS;
}
@@ -126,7 +126,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex)
return rv;
}
- if (apr_atomic_cas(&mutex->owner_ref, 1, 0) != 0) {
+ if (apr_atomic_cas32(&mutex->owner_ref, 1, 0) != 0) {
/* The owner_ref should be zero when the lock is not held,
* if owner_ref was non-zero we have a mutex reference bug.
* XXX: so now what?
@@ -162,7 +162,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex)
* the trylock.
*/
if (apr_os_thread_equal(mutex->owner, apr_os_thread_current())) {
- apr_atomic_inc(&mutex->owner_ref);
+ apr_atomic_inc32(&mutex->owner_ref);
return APR_SUCCESS;
}
@@ -174,7 +174,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex)
return (rv == EBUSY) ? APR_EBUSY : rv;
}
- if (apr_atomic_cas(&mutex->owner_ref, 1, 0) != 0) {
+ if (apr_atomic_cas32(&mutex->owner_ref, 1, 0) != 0) {
/* The owner_ref should be zero when the lock is not held,
* if owner_ref was non-zero we have a mutex reference bug.
* XXX: so now what?
@@ -215,7 +215,7 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex)
return APR_EINVAL;
}
- if (apr_atomic_dec(&mutex->owner_ref) != 0)
+ if (apr_atomic_dec32(&mutex->owner_ref) != 0)
return APR_SUCCESS;
mutex->owner = 0;
}
diff --git a/test/testatomic.c b/test/testatomic.c
index 2ad4a743b..22e613b69 100644
--- a/test/testatomic.c
+++ b/test/testatomic.c
@@ -72,99 +72,6 @@ apr_pool_t *context;
apr_atomic_t y; /* atomic locks */
apr_uint32_t y32;
-static apr_status_t check_basic_atomics(void)
-{
- apr_atomic_t oldval;
- apr_uint32_t casval = 0;
- float object1, object2;
- void *casptr;
- void *oldptr;
-
- apr_atomic_set(&y, 2);
- printf("%-60s", "testing apr_atomic_dec");
- if (apr_atomic_dec(&y) == 0) {
- fprintf(stderr, "Failed\noldval =%d should not be zero\n",
- apr_atomic_read(&y));
- return APR_EGENERAL;
- }
- if (apr_atomic_dec(&y) != 0) {
- fprintf(stderr, "Failed\noldval =%d should be zero\n",
- apr_atomic_read(&y));
- return APR_EGENERAL;
- }
- printf("OK\n");
-
- printf("%-60s", "testing CAS");
- oldval = apr_atomic_cas(&casval, 12, 0);
- if (oldval != 0) {
- fprintf(stderr, "Failed\noldval =%d should be zero\n", oldval);
- return APR_EGENERAL;
- }
- printf("OK\n");
- printf("%-60s", "testing CAS - match non-null");
- oldval = apr_atomic_cas(&casval, 23, 12);
- if (oldval != 12) {
- fprintf(stderr, "Failed\noldval =%d should be 12 y=%d\n",
- oldval, casval);
- return APR_EGENERAL;
- }
- printf("OK\n");
- printf("%-60s", "testing CAS - no match");
- oldval = apr_atomic_cas(&casval, 23, 12);
- if (oldval != 23) {
- fprintf(stderr, "Failed\noldval =%d should be 23 y=%d\n",
- oldval, casval);
- return APR_EGENERAL;
- }
- printf("OK\n");
-
- printf("%-60s", "testing CAS for pointers");
- casptr = NULL;
- oldptr = apr_atomic_casptr(&casptr, &object1, 0);
- if (oldptr != 0) {
- fprintf(stderr, "Failed\noldval =%p should be zero\n", oldptr);
- return APR_EGENERAL;
- }
- printf("OK\n");
- printf("%-60s", "testing CAS for pointers - match non-null");
- oldptr = apr_atomic_casptr(&casptr, &object2, &object1);
- if (oldptr != &object1) {
- fprintf(stderr, "Failed\noldval =%p should be %p\n", oldptr, &object1);
- return APR_EGENERAL;
- }
- printf("OK\n");
- printf("%-60s", "testing CAS for pointers - no match");
- oldptr = apr_atomic_casptr(&casptr, &object2, &object1);
- if (oldptr != &object2) {
- fprintf(stderr, "Failed\noldval =%p should be %p\n", oldptr, &object2);
- return APR_EGENERAL;
- }
- printf("OK\n");
-
- printf("%-60s", "testing add");
- apr_atomic_set(&y, 23);
- apr_atomic_add(&y, 4);
- if ((oldval = apr_atomic_read(&y)) != 27) {
- fprintf(stderr,
- "Failed\nAtomic Add doesn't add up ;( expected 27 got %d\n",
- oldval);
- return APR_EGENERAL;
- }
-
- printf("OK\n");
- printf("%-60s", "testing add/inc");
- apr_atomic_set(&y, 0);
- apr_atomic_add(&y, 20);
- apr_atomic_inc(&y);
- if (apr_atomic_read(&y) != 21) {
- fprintf(stderr, "Failed.\natomics do not add up\n");
- return APR_EGENERAL;
- }
- fprintf(stdout, "OK\n");
-
- return APR_SUCCESS;
-}
-
static apr_status_t check_basic_atomics32(void)
{
apr_uint32_t oldval;
@@ -267,11 +174,6 @@ int main(void)
fprintf(stderr, "Failed.\nCould not initialize atomics\n");
exit(-1);
}
- rv = check_basic_atomics();
- if (rv != APR_SUCCESS) {
- fprintf(stderr, "Failed.\n");
- exit(-1);
- }
rv = check_basic_atomics32();
if (rv != APR_SUCCESS) {
@@ -312,10 +214,10 @@ void * APR_THREAD_FUNC thread_func_atomic(apr_thread_t *thd, void *data)
int i;
for (i = 0; i < NUM_ITERATIONS ; i++) {
- apr_atomic_inc(&y);
- apr_atomic_add(&y, 2);
- apr_atomic_dec(&y);
- apr_atomic_dec(&y);
+ apr_atomic_inc32(&y);
+ apr_atomic_add32(&y, 2);
+ apr_atomic_dec32(&y);
+ apr_atomic_dec32(&y);
}
apr_thread_exit(thd, exit_ret_val);
return NULL;
@@ -384,13 +286,6 @@ int main(int argc, char**argv)
}
printf("OK\n");
- rv = check_basic_atomics();
- if (rv != APR_SUCCESS) {
- fprintf(stderr, "Failed.\n");
- exit(-1);
- }
- apr_atomic_set(&y, 0);
-
rv = check_basic_atomics32();
if (rv != APR_SUCCESS) {
fprintf(stderr, "Failed.\n");
@@ -444,11 +339,11 @@ int main(int argc, char**argv)
}
else {
printf("%-60s", "Checking if atomic worked");
- if (apr_atomic_read(&y) != NUM_THREADS * NUM_ITERATIONS) {
+ if (apr_atomic_read32(&y) != NUM_THREADS * NUM_ITERATIONS) {
fflush(stdout);
fprintf(stderr,
"No!\nThe atomics didn't work?? y = %ld instead of %ld\n",
- (long)apr_atomic_read(&y),
+ (long)apr_atomic_read32(&y),
(long)NUM_THREADS * NUM_ITERATIONS);
}
else {