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 Mon, 08 Dec 2003 19:49:16 GMT
gregames    2003/12/08 11:49:16

  Modified:    atomic/unix apr_atomic.c
  Log:
  add apr_atomic_cas32 for ppc with gcc.
  
  Could someone try this with testatomic on Mac OS X?  It should just
  work, but I couldn't test it.  moof no longer likes me.
  
  Revision  Changes    Path
  1.34      +25 -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.33
  retrieving revision 1.34
  diff -u -d -b -u -r1.33 -r1.34
  --- apr_atomic.c	5 Dec 2003 20:15:32 -0000	1.33
  +++ apr_atomic.c	8 Dec 2003 19:49:16 -0000	1.34
  @@ -175,6 +175,31 @@
   
   #endif /* (__linux__ || __EMX__ || __FreeBSD__) && __i386__ */
   
  +#if defined(__PPC__) && defined(__GNUC__) && !APR_FORCE_ATOMIC_GENERIC
  +APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem,
  +                                           apr_uint32_t swap,
  +                                           apr_uint32_t cmp)
  +{
  +    apr_uint32_t prev;
  +                                                                                
  +    asm volatile ("retry:\n\t"
  +                  "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       */
  +                  "stwcx. %2,0,%1\n\t"       /* ...yes, conditionally
  +                                                store swap            */
  +                  "bne-  retry\n\t"          /* start over if we lost
  +                                                the reservation       */
  +                  "exit:"
  +                  : "=&r"(prev)                        /* output      */
  +                  : "r" (mem), "r" (swap), "r"(cmp)    /* inputs      */
  +                  : "memory");                         /* clobbered   */
  +    return prev;
  +}
  +#define APR_OVERRIDE_ATOMIC_CAS32
  +
  +#endif /* __PPC__ && __GNUC__ */
  +
   #if !defined(apr_atomic_init) && !defined(APR_OVERRIDE_ATOMIC_INIT)
   
   #if APR_HAS_THREADS
  
  
  

Mime
View raw message