Ignore:
Timestamp:
2010-03-07T15:11:56Z (14 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aadf01e
Parents:
2e99277 (diff), 137691a (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, revision 308

File:
1 edited

Legend:

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

    r2e99277 raa85487  
    4646 *
    4747 * @param val Atomic variable.
    48  * @param i Signed value to be added.
     48 * @param i   Signed value to be added.
    4949 *
    5050 * @return Value of the atomic variable as it existed before addition.
     51 *
    5152 */
    52 static inline long atomic_add(atomic_t *val, int i)
     53static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
    5354{
    54         uint64_t a, b;
    55 
     55        atomic_count_t a;
     56        atomic_count_t b;
     57       
    5658        do {
    57                 volatile uintptr_t x = (uint64_t) &val->count;
    58 
    59                 a = *((uint64_t *) x);
     59                volatile uintptr_t ptr = (uintptr_t) &val->count;
     60               
     61                a = *((atomic_count_t *) ptr);
    6062                b = a + i;
    61                 asm volatile ("casx %0, %2, %1\n" : "+m" (*((uint64_t *)x)), "+r" (b) : "r" (a));
     63               
     64                asm volatile (
     65                        "casx %0, %2, %1\n"
     66                        : "+m" (*((atomic_count_t *) ptr)),
     67                          "+r" (b)
     68                        : "r" (a)
     69                );
    6270        } while (a != b);
    63 
     71       
    6472        return a;
    6573}
    6674
    67 static inline long atomic_preinc(atomic_t *val)
     75static inline atomic_count_t atomic_preinc(atomic_t *val)
    6876{
    6977        return atomic_add(val, 1) + 1;
    7078}
    7179
    72 static inline long atomic_postinc(atomic_t *val)
     80static inline atomic_count_t atomic_postinc(atomic_t *val)
    7381{
    7482        return atomic_add(val, 1);
    7583}
    7684
    77 static inline long atomic_predec(atomic_t *val)
     85static inline atomic_count_t atomic_predec(atomic_t *val)
    7886{
    7987        return atomic_add(val, -1) - 1;
    8088}
    8189
    82 static inline long atomic_postdec(atomic_t *val)
     90static inline atomic_count_t atomic_postdec(atomic_t *val)
    8391{
    8492        return atomic_add(val, -1);
Note: See TracChangeset for help on using the changeset viewer.