bnicholes 2002/06/11 08:35:25
Modified: include apr_atomic.h
atomic/netware apr_atomic.c
Log:
Use the native cmpxchg() function for NetWare
Revision Changes Path
1.28 +1 -5 apr/include/apr_atomic.h
Index: apr_atomic.h
===================================================================
RCS file: /home/cvs/apr/include/apr_atomic.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- apr_atomic.h 6 May 2002 11:42:34 -0000 1.27
+++ apr_atomic.h 11 Jun 2002 15:35:25 -0000 1.28
@@ -164,12 +164,8 @@
#define apr_atomic_inc(mem) atomic_inc(mem)
#define apr_atomic_set(mem, val) (*mem = val)
#define apr_atomic_read(mem) (*mem)
-#if defined(cmpxchg)
#define apr_atomic_init(pool) APR_SUCCESS
-#define apr_atomic_cas(mem,with,cmp) cmpxchg(mem,cmp,with)
-#else
-#define APR_ATOMIC_NEED_CAS_DEFAULT 1
-#endif
+#define apr_atomic_cas(mem,with,cmp) atomic_cmpxchg(mem,with,cmp)
#elif defined(__FreeBSD__)
1.4 +0 -45 apr/atomic/netware/apr_atomic.c
Index: apr_atomic.c
===================================================================
RCS file: /home/cvs/apr/atomic/netware/apr_atomic.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- apr_atomic.c 9 Apr 2002 06:50:12 -0000 1.3
+++ apr_atomic.c 11 Jun 2002 15:35:25 -0000 1.4
@@ -54,56 +54,11 @@
#include "apr.h"
-#include "apr_thread_mutex.h"
#include "apr_atomic.h"
-#if APR_HAS_THREADS
-
-#if defined(APR_ATOMIC_NEED_DEFAULT) || defined(APR_ATOMIC_NEED_CAS_DEFAULT)
-
-#define NUM_ATOMIC_HASH 7
-/* shift by 2 to get rid of alignment issues */
-#define ATOMIC_HASH(x) (int)(((long)x>>2)%NUM_ATOMIC_HASH)
-static apr_thread_mutex_t **hash_mutex;
-
-apr_status_t apr_atomic_init(apr_pool_t *p )
-{
- int i;
- apr_status_t rv;
- hash_mutex =apr_palloc(p,sizeof(apr_thread_mutex_t*) * NUM_ATOMIC_HASH);
- for (i=0;i<NUM_ATOMIC_HASH;i++) {
- rv = apr_thread_mutex_create(&(hash_mutex[i]),
APR_THREAD_MUTEX_DEFAULT, p);
- if (rv != APR_SUCCESS)
- return rv;
- }
- return APR_SUCCESS;
-}
-#endif /* APR_ATOMIC_NEED_DEFAULT || APR_ATOMIC_NEED_CAS_DEFAULT */
-
int apr_atomic_dec(apr_atomic_t *mem)
{
atomic_dec(mem);
return *mem;
}
-#if defined(APR_ATOMIC_NEED_CAS_DEFAULT)
-
-apr_uint32_t apr_atomic_cas(volatile apr_uint32_t *mem,long with, long cmp)
-{
- apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)];
- long prev;
-
- 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;
-}
-#endif /* APR_ATOMIC_NEED_CAS_DEFAULT */
-
-
-#endif /* APR_HAS_THREADS */