You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2003/11/16 02:33:02 UTC
cvs commit: apr/test testatomic.c
trawick 2003/11/15 17:33:02
Modified: . CHANGES
atomic/os390 atomic.c
atomic/unix apr_atomic.c
include apr_atomic.h
locks/unix thread_mutex.c
test testatomic.c
Log:
axing deprecated apr_atomic_foo functions
Revision Changes Path
1.440 +6 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.439
retrieving revision 1.440
diff -u -r1.439 -r1.440
--- CHANGES 3 Nov 2003 13:42:10 -0000 1.439
+++ CHANGES 16 Nov 2003 01:33:01 -0000 1.440
@@ -20,6 +20,12 @@
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
1.5 +3 -3 apr/atomic/os390/atomic.c
Index: atomic.c
===================================================================
RCS file: /home/cvs/apr/atomic/os390/atomic.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- atomic.c 5 Nov 2003 03:39:33 -0000 1.4
+++ atomic.c 16 Nov 2003 01:33:02 -0000 1.5
@@ -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 @@
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;
1.25 +0 -100 apr/atomic/unix/apr_atomic.c
Index: apr_atomic.c
===================================================================
RCS file: /home/cvs/apr/atomic/unix/apr_atomic.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- apr_atomic.c 26 Sep 2003 01:51:53 -0000 1.24
+++ apr_atomic.c 16 Nov 2003 01:33:02 -0000 1.25
@@ -84,106 +84,6 @@
}
#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)
{
1.63 +20 -127 apr/include/apr_atomic.h
Index: apr_atomic.h
===================================================================
RCS file: /home/cvs/apr/include/apr_atomic.h,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- apr_atomic.h 3 Nov 2003 13:42:10 -0000 1.62
+++ apr_atomic.h 16 Nov 2003 01:33:02 -0000 1.63
@@ -99,57 +99,6 @@
* @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 @@
#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 @@
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 @@
#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 @@
: "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 @@
: "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 @@
#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 @@
* 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_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 @@
#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
1.21 +5 -5 apr/locks/unix/thread_mutex.c
Index: thread_mutex.c
===================================================================
RCS file: /home/cvs/apr/locks/unix/thread_mutex.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- thread_mutex.c 8 Aug 2003 19:20:23 -0000 1.20
+++ thread_mutex.c 16 Nov 2003 01:33:02 -0000 1.21
@@ -114,7 +114,7 @@
* 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 @@
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 @@
* 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 @@
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 @@
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;
}
1.33 +6 -111 apr/test/testatomic.c
Index: testatomic.c
===================================================================
RCS file: /home/cvs/apr/test/testatomic.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- testatomic.c 26 Sep 2003 01:51:53 -0000 1.32
+++ testatomic.c 16 Nov 2003 01:33:02 -0000 1.33
@@ -72,99 +72,6 @@
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 @@
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 @@
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 @@
}
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 @@
}
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 {