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/sparc64/include/atomic.h

    rb50b5af2 r04803bf  
    3636#define LIBC_sparc64_ATOMIC_H_
    3737
     38#define LIBC_ARCH_ATOMIC_H_
     39
     40#include <atomicdflt.h>
    3841#include <sys/types.h>
    3942
     
    4346 *
    4447 * @param val Atomic variable.
    45  * @param i Signed value to be added.
     48 * @param i   Signed value to be added.
    4649 *
    4750 * @return Value of the atomic variable as it existed before addition.
     51 *
    4852 */
    49 static inline long atomic_add(atomic_t *val, int i)
     53static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
    5054{
    51         uint64_t a, b;
    52 
     55        atomic_count_t a;
     56        atomic_count_t b;
     57       
    5358        do {
    54                 volatile uintptr_t x = (uint64_t) &val->count;
    55 
    56                 a = *((uint64_t *) x);
     59                volatile uintptr_t ptr = (uintptr_t) &val->count;
     60               
     61                a = *((atomic_count_t *) ptr);
    5762                b = a + i;
    58                 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                );
    5970        } while (a != b);
    60 
     71       
    6172        return a;
    6273}
    6374
    64 static inline long atomic_preinc(atomic_t *val)
     75static inline atomic_count_t atomic_preinc(atomic_t *val)
    6576{
    6677        return atomic_add(val, 1) + 1;
    6778}
    6879
    69 static inline long atomic_postinc(atomic_t *val)
     80static inline atomic_count_t atomic_postinc(atomic_t *val)
    7081{
    7182        return atomic_add(val, 1);
    7283}
    7384
    74 static inline long atomic_predec(atomic_t *val)
     85static inline atomic_count_t atomic_predec(atomic_t *val)
    7586{
    7687        return atomic_add(val, -1) - 1;
    7788}
    7889
    79 static inline long atomic_postdec(atomic_t *val)
     90static inline atomic_count_t atomic_postdec(atomic_t *val)
    8091{
    8192        return atomic_add(val, -1);
Note: See TracChangeset for help on using the changeset viewer.