apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grega...@apache.org
Subject cvs commit: apr/atomic/unix apr_atomic.c
Date Fri, 05 Dec 2003 18:57:22 GMT
gregames    2003/12/05 10:57:22

  Modified:    atomic/unix apr_atomic.c
  Log:
  use an inlined function to eliminate one copy of the xadd assembler code.
  You need to specify at least -O1 to enable inlining.  That seems fair.
  
  Revision  Changes    Path
  1.32      +9 -8      apr/atomic/unix/apr_atomic.c
  
  Index: apr_atomic.c
  ===================================================================
  RCS file: /home/cvs/apr/atomic/unix/apr_atomic.c,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -d -b -u -r1.31 -r1.32
  --- apr_atomic.c	5 Dec 2003 13:12:03 -0000	1.31
  +++ apr_atomic.c	5 Dec 2003 18:57:21 -0000	1.32
  @@ -105,7 +105,8 @@
   }
   #define APR_OVERRIDE_ATOMIC_CAS32
   
  -APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
  +static apr_uint32_t inline intel_atomic_add32(volatile apr_uint32_t *mem, 
  +                                              apr_uint32_t val)
   {
       asm volatile ("lock; xaddl %1, (%2)"                              
                     : "=r"(val)          /* output, same as 1st input */
  @@ -113,6 +114,12 @@
                     : "%1","memory");    /* tell gcc they are clobbered */
       return val;
   }
  +
  +APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, 
  +                                           apr_uint32_t val)
  +{
  +    return intel_atomic_add32(mem, val);
  +}
   #define APR_OVERRIDE_ATOMIC_ADD32
   
   APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
  @@ -141,13 +148,7 @@
   
   APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem)
   {
  -    apr_uint32_t val = 1;
  -
  -    asm volatile ("lock; xaddl %1, (%2)"                              
  -                  : "=r"(val)          /* output, same as 1st input */
  -                  : "0"(val), "r"(mem) /* inputs */
  -                  : "%1","memory");    /* tell gcc they are clobbered */
  -    return val;
  +    return intel_atomic_add32(mem, 1);
   }
   #define APR_OVERRIDE_ATOMIC_INC32
   
  
  
  

Mime
View raw message