apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject cvs commit: apr/include apr_atomic.h
Date Sun, 14 Sep 2003 02:56:52 GMT
brianp      2003/09/13 19:56:52

  Modified:    include  apr_atomic.h
  Log:
  more efficient implementation of atomic_dec for x86
  
  Revision  Changes    Path
  1.52      +9 -5      apr/include/apr_atomic.h
  
  Index: apr_atomic.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_atomic.h,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- apr_atomic.h	14 Sep 2003 01:59:54 -0000	1.51
  +++ apr_atomic.h	14 Sep 2003 02:56:52 -0000	1.52
  @@ -229,11 +229,15 @@
       : "memory")
   
   #define apr_atomic_dec(mem)                                     \
  -({ register apr_atomic_t last;                                  \
  -   do {                                                         \
  -       last = *(mem);                                           \
  -   } while (apr_atomic_cas((mem), last - 1, last) != last);     \
  -  (--last != 0); })
  +({ int prev;                                                    \
  +   asm volatile ("mov $0, %%eax;\n\t"                           \
  +                 "lock; decl %1;\n\t"                           \
  +                 "setnz %%al;\n\t"                              \
  +                 "mov %%eax, %0"                                \
  +                 : "=r" (prev)                                  \
  +                 : "m" (*(mem))                                 \
  +                 : "memory", "%eax");                           \
  +   prev;})
   
   #define apr_atomic_inc(mem)                                     \
    asm volatile ("lock; incl %0"                                  \
  
  
  

Mime
View raw message