Ignore:
File:
1 edited

Legend:

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

    r228666c r986c24c  
    2727 */
    2828
    29 /** @addtogroup sparc64
     29/** @addtogroup sparc64 
    3030 * @{
    3131 */
     
    4545 *
    4646 * @param val Atomic variable.
    47  * @param i   Signed value to be added.
     47 * @param i Signed value to be added.
    4848 *
    4949 * @return Value of the atomic variable as it existed before addition.
    50  *
    5150 */
    52 static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
     51static inline long atomic_add(atomic_t *val, int i)
    5352{
    54         atomic_count_t a;
    55         atomic_count_t b;
    56        
     53        uint64_t a, b;
     54
    5755        do {
    58                 volatile uintptr_t ptr = (uintptr_t) &val->count;
    59                
    60                 a = *((atomic_count_t *) ptr);
     56                volatile uintptr_t x = (uint64_t) &val->count;
     57
     58                a = *((uint64_t *) x);
    6159                b = a + i;
    62                
    63                 asm volatile (
    64                         "casx %0, %2, %1\n"
    65                         : "+m" (*((atomic_count_t *) ptr)),
    66                       "+r" (b)
    67                     : "r" (a)
    68                 );
     60                asm volatile ("casx %0, %2, %1\n" : "+m" (*((uint64_t *)x)),
     61                    "+r" (b) : "r" (a));
    6962        } while (a != b);
    70        
     63
    7164        return a;
    7265}
    7366
    74 static inline atomic_count_t atomic_preinc(atomic_t *val)
     67static inline long atomic_preinc(atomic_t *val)
    7568{
    7669        return atomic_add(val, 1) + 1;
    7770}
    7871
    79 static inline atomic_count_t atomic_postinc(atomic_t *val)
     72static inline long atomic_postinc(atomic_t *val)
    8073{
    8174        return atomic_add(val, 1);
    8275}
    8376
    84 static inline atomic_count_t atomic_predec(atomic_t *val)
     77static inline long atomic_predec(atomic_t *val)
    8578{
    8679        return atomic_add(val, -1) - 1;
    8780}
    8881
    89 static inline atomic_count_t atomic_postdec(atomic_t *val)
     82static inline long atomic_postdec(atomic_t *val)
    9083{
    9184        return atomic_add(val, -1);
     
    10295}
    10396
    104 static inline atomic_count_t test_and_set(atomic_t *val)
     97static inline long test_and_set(atomic_t *val)
    10598{
    106         atomic_count_t v = 1;
    107         volatile uintptr_t ptr = (uintptr_t) &val->count;
    108        
    109         asm volatile (
    110                 "casx %0, %2, %1\n"
    111                 : "+m" (*((atomic_count_t *) ptr)),
    112               "+r" (v)
    113             : "r" (0)
    114         );
    115        
     99        uint64_t v = 1;
     100        volatile uintptr_t x = (uint64_t) &val->count;
     101
     102        asm volatile ("casx %0, %2, %1\n" : "+m" (*((uint64_t *) x)),
     103            "+r" (v) : "r" (0));
     104
    116105        return v;
    117106}
     
    119108static inline void atomic_lock_arch(atomic_t *val)
    120109{
    121         atomic_count_t tmp1 = 1;
    122         atomic_count_t tmp2 = 0;
    123        
    124         volatile uintptr_t ptr = (uintptr_t) &val->count;
    125        
     110        uint64_t tmp1 = 1;
     111        uint64_t tmp2 = 0;
     112
     113        volatile uintptr_t x = (uint64_t) &val->count;
     114
    126115        preemption_disable();
    127        
     116
    128117        asm volatile (
    129                 "0:\n"
    130                         "casx %0, %3, %1\n"
    131                         "brz %1, 2f\n"
    132                         "nop\n"
    133                 "1:\n"
    134                         "ldx %0, %2\n"
    135                         "brz %2, 0b\n"
    136                         "nop\n"
    137                         "ba %%xcc, 1b\n"
    138                         "nop\n"
    139                 "2:\n"
    140                 : "+m" (*((atomic_count_t *) ptr)),
    141                   "+r" (tmp1),
    142                   "+r" (tmp2)
    143                 : "r" (0)
     118        "0:\n"
     119                "casx %0, %3, %1\n"
     120                "brz %1, 2f\n"
     121                "nop\n"
     122        "1:\n"
     123                "ldx %0, %2\n"
     124                "brz %2, 0b\n"
     125                "nop\n"
     126                "ba %%xcc, 1b\n"
     127                "nop\n"
     128        "2:\n"
     129                : "+m" (*((uint64_t *) x)), "+r" (tmp1), "+r" (tmp2) : "r" (0)
    144130        );
    145131       
Note: See TracChangeset for help on using the changeset viewer.