apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r413786 - in /apr/apr/trunk: CHANGES atomic/unix/apr_atomic.c
Date Tue, 13 Jun 2006 02:22:06 GMT
Author: colm
Date: Mon Jun 12 19:22:05 2006
New Revision: 413786

URL: http://svn.apache.org/viewvc?rev=413786&view=rev
Log:
Implement apr_atomics using Solaris' native atomic API.

   * Use each of the atomic_ functions that we can.

   * atomic_add is NOT implemented, as Solaris' implementation
     can handle only signed deltas.
 
   * each function is conditionalised on its corresponding
     APR_OVERRIDE_* macro to avoid double-implementation. 
     On Solaris x86/x64 with gcc we implement atomics using
     our inline assembly.

Thank to: Mads Toftum for pointing out atomic_cas


Modified:
    apr/apr/trunk/CHANGES
    apr/apr/trunk/atomic/unix/apr_atomic.c

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=413786&r1=413785&r2=413786&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES (original)
+++ apr/apr/trunk/CHANGES Mon Jun 12 19:22:05 2006
@@ -1,5 +1,8 @@
 Changes for APR 1.3.0
 
+  *) Utilise Solaris' native atomic_* functions for apr_atomics
+     where appropriate. [Colm MacCarthaigh]
+
   *) Make apr_socket_recvfrom initialize the port field in the from
      sockaddr.  PR 39325 [Anthony Minessale <anthmct yahoo.com>]
 

Modified: apr/apr/trunk/atomic/unix/apr_atomic.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/atomic/unix/apr_atomic.c?rev=413786&r1=413785&r2=413786&view=diff
==============================================================================
--- apr/apr/trunk/atomic/unix/apr_atomic.c (original)
+++ apr/apr/trunk/atomic/unix/apr_atomic.c Mon Jun 12 19:22:05 2006
@@ -21,6 +21,9 @@
 #include "apr_private.h"
 
 #include <stdlib.h>
+#if (defined(SOLARIS2) && SOLARIS2 >= 10)
+#include <atomic.h>
+#endif
 
 #if defined(__GNUC__) && defined(__STRICT_ANSI__) && !defined(USE_GENERIC_ATOMICS)
 /* force use of generic atomics if building e.g. with -std=c89, which
@@ -161,6 +164,58 @@
 #define APR_OVERRIDE_ATOMIC_ADD32
 
 #endif /* __PPC__ && __GNUC__ */
+
+#if (defined(SOLARIS2) && SOLARIS2 >= 10) \
+    && !defined(USE_GENERIC_ATOMICS)
+
+#if !defined(APR_OVERRIDE_ATOMIC_CAS32)
+APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem,
+                                           apr_uint32_t with,
+                                           apr_uint32_t cmp)
+{
+    return atomic_cas_32(mem, cmp, with);
+}
+#define APR_OVERRIDE_ATOMIC_CAS32
+#endif /* APR_OVERRIDE_ATOMIC_CAS32 */
+
+#if !defined(APR_OVERRIDE_ATOMIC_DEC32)
+APR_DECLARE(apr_uint32_t) apr_atomic_dec32(volatile apr_uint32_t *mem)
+{
+    apr_uint32_t prev = *mem;
+    atomic_dec_32(mem);
+    return prev != 1;
+}
+#define APR_OVERRIDE_ATOMIC_DEC32
+#endif /* APR_OVERRIDE_ATOMIC_DEC32 */
+
+#if !defined(APR_OVERRIDE_ATOMIC_INC32)
+APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem)
+{
+    apr_uint32_t prev = *mem;
+    atomic_inc_32(mem);
+    return prev;
+}
+#define APR_OVERRIDE_ATOMIC_INC32
+#endif /* APR_OVERRIDE_ATOMIC_INC32 */
+
+#if !defined(APR_OVERRIDE_ATOMIC_SET32)
+APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
+{
+    *mem = val;
+}
+#define APR_OVERRIDE_ATOMIC_SET32
+#endif /* APR_OVERRIDE_ATOMIC_SET32 */
+
+#if !defined(APR_OVERRIDE_ATOMIC_XCHG32)
+APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem,
+                                            apr_uint32_t val) 
+{
+    return atomic_swap_32(mem, val);
+}
+#define APR_OVERRIDE_ATOMIC_XCHG32
+#endif /* APR_OVERRIDE_ATOMIC_XCHG32 */
+
+#endif /* SOLARIS2 && SOLARIS2 >= 10 */
 
 #if !defined(APR_OVERRIDE_ATOMIC_INIT)
 



Mime
View raw message