Ignore:
Timestamp:
2011-03-21T22:00:17Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
143932e3
Parents:
b50b5af2 (diff), 7308e84 (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:

Merge mainline changes (needs fixes).

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/amd64/include/atomic.h

    rb50b5af2 r04803bf  
    3838#define LIBC_amd64_ATOMIC_H_
    3939
    40 static inline void atomic_inc(atomic_t *val) {
    41         asm volatile ("lock incq %0\n" : "+m" (val->count));
     40#define LIBC_ARCH_ATOMIC_H_
     41
     42#include <atomicdflt.h>
     43
     44static inline void atomic_inc(atomic_t *val)
     45{
     46        asm volatile (
     47                "lock incq %[count]\n"
     48                : [count] "+m" (val->count)
     49        );
    4250}
    4351
    44 static inline void atomic_dec(atomic_t *val) {
    45         asm volatile ("lock decq %0\n" : "+m" (val->count));
     52static inline void atomic_dec(atomic_t *val)
     53{
     54        asm volatile (
     55                "lock decq %[count]\n"
     56                : [count] "+m" (val->count)
     57        );
    4658}
    4759
    48 static inline long atomic_postinc(atomic_t *val)
     60static inline atomic_count_t atomic_postinc(atomic_t *val)
    4961{
    50         long r;
    51 
    52         asm volatile (
    53                 "movq $1, %0\n"
    54                 "lock xaddq %0, %1\n"
    55                 : "=r" (r), "+m" (val->count)
    56         );
    57 
    58         return r;
    59 }
    60 
    61 static inline long atomic_postdec(atomic_t *val)
    62 {
    63         long r;
     62        atomic_count_t r = 1;
    6463       
    6564        asm volatile (
    66                 "movq $-1, %0\n"
    67                 "lock xaddq %0, %1\n"
    68                 : "=r" (r), "+m" (val->count)
     65                "lock xaddq %[r], %[count]\n"
     66                : [count] "+m" (val->count),
     67                  [r] "+r" (r)
    6968        );
    7069       
     
    7271}
    7372
    74 #define atomic_preinc(val) (atomic_postinc(val) + 1)
    75 #define atomic_predec(val) (atomic_postdec(val) - 1)
     73static inline atomic_count_t atomic_postdec(atomic_t *val)
     74{
     75        atomic_count_t r = -1;
     76       
     77        asm volatile (
     78                "lock xaddq %[r], %[count]\n"
     79                : [count] "+m" (val->count),
     80                  [r] "+r" (r)
     81        );
     82       
     83        return r;
     84}
     85
     86#define atomic_preinc(val)  (atomic_postinc(val) + 1)
     87#define atomic_predec(val)  (atomic_postdec(val) - 1)
    7688
    7789#endif
Note: See TracChangeset for help on using the changeset viewer.