Hi,
I got some feedback from John Baldwin <[EMAIL PROTECTED]>
of the FreeBSD project. Here is a refined patch to correct
some of the APR atomic macros.
How does this look?
Index: apr_atomic.h
===================================================================
RCS file: /home/cvspublic/apr/include/apr_atomic.h,v
retrieving revision 1.47
diff -u -r1.47 apr_atomic.h
--- apr_atomic.h 5 Mar 2003 21:22:25 -0000 1.47
+++ apr_atomic.h 26 Mar 2003 19:47:02 -0000
@@ -206,10 +206,22 @@
#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
+
+static APR_INLINE int apr_atomic_dec(volatile apr_atomic_t *mem)
+{
+ apr_atomic_t x;
+
+ do {
+ x = *mem;
+ } while (atomic_cmpset_int(mem, x, x - 1) == 0);
+ return (x-1);
+}
+
#elif (defined(__linux__) || defined(__EMX__)) && defined(__i386__) &&
!APR_FORCE_ATOMIC_GENERIC
--
Craig Rodrigues
http://home.attbi.com/~rodrigc
[EMAIL PROTECTED]