apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig Rodrigues <rodr...@attbi.com>
Subject [PATCH] fix apr_atomic.h for FreeBSD
Date Sun, 23 Mar 2003 04:39:54 GMT
Hi,

I saw two problems with apr_atomic.h which causes the testatomic
test to fail under FreeBSD.

The two problems are:

- atomic_subtract_int() returns void, but apr_atomic_dec() needs
  to return an int
- the semantics of atomic_set_int() is:
   atomic_set_int(P, V)         (*(u_int*)(P) |= (V))

  but apr_atomic_set requires the semantics to be:
        *P = V

Here is a patch.


Index: apr_atomic.h
===================================================================
RCS file: /home/cvspublic/apr/include/apr_atomic.h,v
retrieving revision 1.47
diff -u -u -r1.47 apr_atomic.h
--- apr_atomic.h	5 Mar 2003 21:22:25 -0000	1.47
+++ apr_atomic.h	23 Mar 2003 04:30:50 -0000
@@ -206,10 +206,16 @@
 
 #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_set(mem, val)     (*(mem) = val)
 #define apr_atomic_read(mem)         (*mem)
+
+#define APR_OVERRIDE_ATOMIC_DEC 1
+APR_INLINE int apr_atomic_dec(apr_atomic_t *mem)
+{
+    atomic_subtract_int(mem,1);
+    return *mem;
+}
 
 #elif (defined(__linux__) || defined(__EMX__)) && defined(__i386__) && !APR_FORCE_ATOMIC_GENERIC
 



-- 
Craig Rodrigues        
http://home.attbi.com/~rodrigc
rodrigc@attbi.com

Mime
View raw message