OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-i960/] [atomic.h] - Blame information for rev 1633

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef __ARCH_I960_ATOMIC__
2
#define __ARCH_I960_ATOMIC__
3
 
4
/*
5
 * Atomic operations that C can't guarantee us.  Useful for
6
 * resource counting etc..
7
 */
8
 
9
typedef long atomic_t;
10
 
11
static __inline__ atomic_t atomic_add(atomic_t i, atomic_t *v)
12
{
13
        atomic_t r;
14
        __asm__ __volatile__("atadd     %3, %2, %1"
15
                             : "=m" (*v), "=d" (r)
16
                             : "dI" (i), "d" (v), "m"(*v));
17
        return r;
18
}
19
 
20
static __inline__ atomic_t atomic_sub(atomic_t i, atomic_t *v)
21
{
22
        atomic_t tmp, retval;
23
        __asm__ __volatile__("subo      %4, 0, %2\n\t"
24
                             "atadd     %5, %6, %1\n\t"
25
                             : "=m"(*v), "=d" (retval), "=d" (tmp)
26
                             : "m" (*v), "dI" (i), "d" (v), "2" (tmp));
27
        return retval;
28
}
29
 
30
static __inline__ atomic_t atomic_inc(atomic_t *v)
31
{
32
        atomic_t retval;
33
        __asm__ __volatile__("atadd     %2, 1, %1"
34
                             : "=m"(*v), "=d"(retval)
35
                             : "d" (v), "m"(*v));
36
        return retval;
37
}
38
 
39
static __inline__ atomic_t atomic_dec(atomic_t *v)
40
{
41
        return(atomic_add(-1, v));
42
}
43
 
44
static __inline__ atomic_t atomic_dec_and_test(atomic_t *v)
45
{
46
        return atomic_dec(v) == 1;
47
}
48
 
49
#endif /* __ARCH_I960_ATOMIC __ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.