Ignore:
Timestamp:
2010-02-20T20:54:53Z (14 years ago)
Author:
Pavel Rimsky <pavel@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
721d4e85, 95c4776
Parents:
f516bc2 (diff), b03a666 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Synchronize with head.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/arch/ia32/include/atomic.h

    rf516bc2 rc2efbb4  
    4040#include <atomicdflt.h>
    4141
    42 static inline void atomic_inc(atomic_t *val) {
    43         asm volatile ("lock incl %0\n" : "+m" (val->count));
     42static inline void atomic_inc(atomic_t *val)
     43{
     44        asm volatile (
     45                "lock incl %[count]\n"
     46                : [count] "+m" (val->count)
     47        );
    4448}
    4549
    46 static inline void atomic_dec(atomic_t *val) {
    47         asm volatile ("lock decl %0\n" : "+m" (val->count));
     50static inline void atomic_dec(atomic_t *val)
     51{
     52        asm volatile (
     53                "lock decl %[count]\n"
     54                : [count] "+m" (val->count)
     55        );
    4856}
    4957
    50 static inline long atomic_postinc(atomic_t *val)
     58static inline atomic_count_t atomic_postinc(atomic_t *val)
    5159{
    52         long r;
    53 
    54         asm volatile (
    55                 "movl $1, %0\n"
    56                 "lock xaddl %0, %1\n"
    57                 : "=r" (r), "+m" (val->count)
    58         );
    59 
    60         return r;
    61 }
    62 
    63 static inline long atomic_postdec(atomic_t *val)
    64 {
    65         long r;
     60        atomic_count_t r = 1;
    6661       
    6762        asm volatile (
    68                 "movl $-1, %0\n"
    69                 "lock xaddl %0, %1\n"
    70                 : "=r" (r), "+m" (val->count)
     63                "lock xaddl %[r], %[count]\n"
     64                : [count] "+m" (val->count),
     65                  [r] "+r" (r)
    7166        );
    7267       
     
    7469}
    7570
    76 #define atomic_preinc(val) (atomic_postinc(val) + 1)
    77 #define atomic_predec(val) (atomic_postdec(val) - 1)
     71static inline atomic_count_t atomic_postdec(atomic_t *val)
     72{
     73        atomic_count_t r = -1;
     74       
     75        asm volatile (
     76                "lock xaddl %[r], %[count]\n"
     77                : [count] "+m" (val->count),
     78                  [r] "+r" (r)
     79        );
     80       
     81        return r;
     82}
     83
     84#define atomic_preinc(val)  (atomic_postinc(val) + 1)
     85#define atomic_predec(val)  (atomic_postdec(val) - 1)
    7886
    7987#endif
Note: See TracChangeset for help on using the changeset viewer.