Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/include/atomic.h

    r7038f55 r7a0359b  
    2727 */
    2828
    29 /** @addtogroup ia64   
     29/** @addtogroup ia64
    3030 * @{
    3131 */
     
    3636#define KERN_ia64_ATOMIC_H_
    3737
    38 /** Atomic addition.
    39  *
    40  * @param val           Atomic value.
    41  * @param imm           Value to add.
    42  *
    43  * @return              Value before addition.
    44  */
    45 static inline long atomic_add(atomic_t *val, int imm)
     38#include <trace.h>
     39
     40NO_TRACE static inline atomic_count_t test_and_set(atomic_t *val)
    4641{
    47         long v;
    48 
    49         asm volatile ("fetchadd8.rel %0 = %1, %2\n" : "=r" (v),
    50             "+m" (val->count) : "i" (imm));
    51  
    52         return v;
    53 }
    54 
    55 static inline uint64_t test_and_set(atomic_t *val)
    56 {
    57         uint64_t v;
    58                
     42        atomic_count_t v;
     43       
    5944        asm volatile (
    60                 "movl %0 = 0x1;;\n"
    61                 "xchg8 %0 = %1, %0;;\n"
    62                 : "=r" (v), "+m" (val->count)
     45                "movl %[v] = 0x1;;\n"
     46                "xchg8 %[v] = %[count], %[v];;\n"
     47                : [v] "=r" (v),
     48                  [count] "+m" (val->count)
    6349        );
    6450       
     
    6652}
    6753
    68 static inline void atomic_lock_arch(atomic_t *val)
     54NO_TRACE static inline void atomic_lock_arch(atomic_t *val)
    6955{
    7056        do {
    71                 while (val->count)
    72                         ;
     57                while (val->count);
    7358        } while (test_and_set(val));
    7459}
    7560
    76 static inline void atomic_inc(atomic_t *val)
     61NO_TRACE static inline void atomic_inc(atomic_t *val)
    7762{
    78         atomic_add(val, 1);
     63        atomic_count_t v;
     64       
     65        asm volatile (
     66                "fetchadd8.rel %[v] = %[count], 1\n"
     67                : [v] "=r" (v),
     68                  [count] "+m" (val->count)
     69        );
    7970}
    8071
    81 static inline void atomic_dec(atomic_t *val)
     72NO_TRACE static inline void atomic_dec(atomic_t *val)
    8273{
    83         atomic_add(val, -1);
     74        atomic_count_t v;
     75       
     76        asm volatile (
     77                "fetchadd8.rel %[v] = %[count], -1\n"
     78                : [v] "=r" (v),
     79                  [count] "+m" (val->count)
     80        );
    8481}
    8582
    86 static inline long atomic_preinc(atomic_t *val)
     83NO_TRACE static inline atomic_count_t atomic_preinc(atomic_t *val)
    8784{
    88         return atomic_add(val, 1) + 1;
     85        atomic_count_t v;
     86       
     87        asm volatile (
     88                "fetchadd8.rel %[v] = %[count], 1\n"
     89                : [v] "=r" (v),
     90                  [count] "+m" (val->count)
     91        );
     92       
     93        return (v + 1);
    8994}
    9095
    91 static inline long atomic_predec(atomic_t *val)
     96NO_TRACE static inline atomic_count_t atomic_predec(atomic_t *val)
    9297{
    93         return atomic_add(val, -1) - 1;
     98        atomic_count_t v;
     99       
     100        asm volatile (
     101                "fetchadd8.rel %[v] = %[count], -1\n"
     102                : [v] "=r" (v),
     103                  [count] "+m" (val->count)
     104        );
     105       
     106        return (v - 1);
    94107}
    95108
    96 static inline long atomic_postinc(atomic_t *val)
     109NO_TRACE static inline atomic_count_t atomic_postinc(atomic_t *val)
    97110{
    98         return atomic_add(val, 1);
     111        atomic_count_t v;
     112       
     113        asm volatile (
     114                "fetchadd8.rel %[v] = %[count], 1\n"
     115                : [v] "=r" (v),
     116                  [count] "+m" (val->count)
     117        );
     118       
     119        return v;
    99120}
    100121
    101 static inline long atomic_postdec(atomic_t *val)
     122NO_TRACE static inline atomic_count_t atomic_postdec(atomic_t *val)
    102123{
    103         return atomic_add(val, -1);
     124        atomic_count_t v;
     125       
     126        asm volatile (
     127                "fetchadd8.rel %[v] = %[count], -1\n"
     128                : [v] "=r" (v),
     129                  [count] "+m" (val->count)
     130        );
     131       
     132        return v;
    104133}
    105134
Note: See TracChangeset for help on using the changeset viewer.