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 Tue, 09 Dec 2003 22:20:22 GMT
gregames    2003/12/09 14:20:22

  Modified:    atomic/unix apr_atomic.c
  Log:
  ppc + gcc updates
  
  apr_atomic_cas32:
  * make sure gcc uses a valid base register (not r0) for mem,
  * tell gcc that the condition code is clobbered, and
  * use asm local labels to avoid future namespace collisions
  
  apr_atomic_add32: add a native implementation
  
  Revision  Changes    Path
  1.38      +29 -6     apr/atomic/unix/apr_atomic.c
  
  Index: apr_atomic.c
  ===================================================================
  RCS file: /home/cvs/apr/atomic/unix/apr_atomic.c,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -d -b -u -r1.37 -r1.38
  --- apr_atomic.c	9 Dec 2003 15:51:09 -0000	1.37
  +++ apr_atomic.c	9 Dec 2003 22:20:22 -0000	1.38
  @@ -182,21 +182,44 @@
   {
       apr_uint32_t prev;
                                                                                   
  -    asm volatile ("retry:\n\t"
  +    asm volatile ("0:\n\t"                   /* retry local label     */
                     "lwarx  %0,0,%1\n\t"       /* load prev and reserve */
                     "cmpw   %0,%3\n\t"         /* does it match cmp?    */
  -                  "bne-   exit\n\t"          /* ...no, bail out       */
  +                  "bne-   1f\n\t"            /* ...no, bail out       */
                     "stwcx. %2,0,%1\n\t"       /* ...yes, conditionally
                                                   store swap            */
  -                  "bne-   retry\n\t"         /* start over if we lost
  +                  "bne-   0b\n\t"            /* start over if we lost
                                                   the reservation       */
  -                  "exit:"
  +                  "1:"                       /* exit local label      */
  +
                     : "=&r"(prev)                        /* output      */
  -                  : "r" (mem), "r" (swap), "r"(cmp)    /* inputs      */
  -                  : "memory");                         /* clobbered   */
  +                  : "b" (mem), "r" (swap), "r"(cmp)    /* inputs      */
  +                  : "memory", "cc");                   /* clobbered   */
       return prev;
   }
   #define APR_OVERRIDE_ATOMIC_CAS32
  +
  +APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem,
  +                                           apr_uint32_t delta)
  +{
  +    apr_uint32_t prev, temp;
  +                                                                                
  +    asm volatile ("0:\n\t"                   /* retry local label     */
  +                  "lwarx  %0,0,%2\n\t"       /* load prev and reserve */
  +                  "add    %1,%0,%3\n\t"      /* temp = prev + delta   */
  +                  "stwcx. %1,0,%2\n\t"       /* conditionally store   */
  +                  "bne-   0b"                /* start over if we lost
  +                                                the reservation       */
  +
  +                  /*XXX find a cleaner way to define the temp         
  +                   *    it's not an output
  +                   */
  +                  : "=&r" (prev), "=&r" (temp)        /* output, temp */
  +                  : "b" (mem), "r" (delta)            /* inputs       */
  +                  : "memory", "cc");                  /* clobbered    */
  +    return prev;
  +}
  +#define APR_OVERRIDE_ATOMIC_ADD32
   
   #endif /* __PPC__ && __GNUC__ */
   
  
  
  

Mime
View raw message