You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by br...@apache.org on 2002/10/19 21:05:53 UTC
cvs commit: apr/atomic/solaris_sparc Makefile.in apr_atomic_sparc_no_support.c
brianp 2002/10/19 12:05:53
Modified: . CHANGES configure.in
include apr_atomic.h
atomic/unix apr_atomic.c
atomic/solaris_sparc Makefile.in
apr_atomic_sparc_no_support.c
Log:
Add pointer version of apr_atomic_cas
Revision Changes Path
1.347 +3 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.346
retrieving revision 1.347
diff -u -r1.346 -r1.347
--- CHANGES 18 Oct 2002 12:03:59 -0000 1.346
+++ CHANGES 19 Oct 2002 19:05:53 -0000 1.347
@@ -1,5 +1,8 @@
Changes with APR 0.9.2
+ *) Add apr_atomic_casptr() to support atomic compare-and-swap
+ of pointers [Brian Pane]
+
*) Add apr_socket_create_ex() to allow protocol to be specified for the
socket. With APR 1.0, this function will be removed and apr_socket_create()
will have the additional parameter.
1.493 +2 -2 apr/configure.in
Index: configure.in
===================================================================
RCS file: /home/cvs/apr/configure.in,v
retrieving revision 1.492
retrieving revision 1.493
diff -u -r1.492 -r1.493
--- configure.in 19 Oct 2002 18:00:53 -0000 1.492
+++ configure.in 19 Oct 2002 19:05:53 -0000 1.493
@@ -402,7 +402,7 @@
case "$sparc_arch" in
sun4c|sun4m|sun4d|sun4t|sun4)
apr_force_atomic_generic=1
- apr_atomic_sparc_compile=apr_atomic_sparc_no_support.lo
+ apr_atomic_sparc_compile=""
;;
*)
if test -n "$is_gnu_as"; then
@@ -418,7 +418,7 @@
esac
else
apr_force_atomic_generic=1
- apr_atomic_sparc_compile=apr_atomic_sparc_no_support.lo
+ apr_atomic_sparc_compile=""
fi
AC_SUBST(ASCPPFLAGS)
AC_SUBST(ASFLAGS)
1.38 +20 -0 apr/include/apr_atomic.h
Index: apr_atomic.h
===================================================================
RCS file: /home/cvs/apr/include/apr_atomic.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- apr_atomic.h 22 Sep 2002 04:17:02 -0000 1.37
+++ apr_atomic.h 19 Oct 2002 19:05:53 -0000 1.38
@@ -63,6 +63,7 @@
extern "C" {
#endif
+#include "apr.h"
#include "apr_pools.h"
/**
@@ -134,6 +135,16 @@
* 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);
+
+/**
+ * compare the pointer's value with cmp.
+ * If they are the same swap the value with 'with'
+ * @param mem pointer to the pointer
+ * @param with what to swap it with
+ * @param the value to compare it to
+ * @return the old value of the pointer
+ */
+void *apr_atomic_casptr(volatile void **mem, void *with, const void *cmp);
#else /* !DOXYGEN */
/* The following definitions provide optimized, OS-specific
@@ -306,6 +317,15 @@
#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_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)
+#else
+void *apr_atomic_casptr(volatile void **mem, void *with, const void *cmp);
+#define APR_ATOMIC_NEED_DEFAULT_INIT 1
+#endif
#endif
#ifndef APR_ATOMIC_NEED_DEFAULT_INIT
1.21 +26 -0 apr/atomic/unix/apr_atomic.c
Index: apr_atomic.c
===================================================================
RCS file: /home/cvs/apr/atomic/unix/apr_atomic.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- apr_atomic.c 19 Oct 2002 18:06:59 -0000 1.20
+++ apr_atomic.c 19 Oct 2002 19:05:53 -0000 1.21
@@ -183,3 +183,29 @@
#endif /* APR_HAS_THREADS */
}
#endif /*!defined(apr_atomic_cas) && !defined(APR_OVERRIDE_ATOMIC_CAS) */
+
+#if !defined(apr_atomic_casptr) && !defined(APR_OVERRIDE_ATOMIC_CASPTR)
+void *apr_atomic_casptr(volatile void **mem, void *with, const void *cmp)
+{
+ void *prev;
+#if APR_HAS_THREADS
+ apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)];
+
+ if (apr_thread_mutex_lock(lock) == APR_SUCCESS) {
+ prev = *(void **)mem;
+ if (prev == cmp) {
+ *mem = with;
+ }
+ apr_thread_mutex_unlock(lock);
+ return prev;
+ }
+ return *(void **)mem;
+#else
+ prev = *(void **)mem;
+ if (prev == cmp) {
+ *mem = with;
+ }
+ return prev;
+#endif /* APR_HAS_THREADS */
+}
+#endif /*!defined(apr_atomic_cas) && !defined(APR_OVERRIDE_ATOMIC_CAS) */
1.10 +1 -1 apr/atomic/solaris_sparc/Makefile.in
Index: Makefile.in
===================================================================
RCS file: /home/cvs/apr/atomic/solaris_sparc/Makefile.in,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Makefile.in 23 Apr 2002 19:01:35 -0000 1.9
+++ Makefile.in 19 Oct 2002 19:05:53 -0000 1.10
@@ -1,7 +1,7 @@
srcdir = @srcdir@
VPATH = @srcdir@
-TARGETS = @apr_atomic_sparc_compile@
+TARGETS = @apr_atomic_sparc_compile@ apr_atomic_sparc_no_support.lo
ASFLAGS += @ASFLAGS@
ASCPPFLAGS = @ASCPPFLAGS@
1.2 +3 -2 apr/atomic/solaris_sparc/apr_atomic_sparc_no_support.c
Index: apr_atomic_sparc_no_support.c
===================================================================
RCS file: /home/cvs/apr/atomic/solaris_sparc/apr_atomic_sparc_no_support.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- apr_atomic_sparc_no_support.c 21 Feb 2002 23:34:10 -0000 1.1
+++ apr_atomic_sparc_no_support.c 19 Oct 2002 19:05:53 -0000 1.2
@@ -1,5 +1,6 @@
#include "apr.h"
-#if APR_FORCE_ATOMIC_GENERIC
+/* Pick up the default implementations of any atomic operations
+ * that haven't been redefined as Sparc-specific functions
+ */
#include "../unix/apr_atomic.c"
-#else
#endif