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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef _ASM_OR32_ATOMIC_H
2
#define _ASM_OR32_ATOMIC_H
3
 
4
#include <linux/config.h>
5
#include <asm/system.h>
6
 
7
/*
8
 * Atomic operations that C can't guarantee us.  Useful for
9
 * resource counting etc..
10
 */
11
 
12
typedef int atomic_t;
13
 
14
static __inline__ void atomic_add(atomic_t i, atomic_t *v)
15
{
16
        unsigned long flags;
17
 
18
        save_flags(flags); cli();
19
        *v += i;
20
        restore_flags(flags);
21
}
22
 
23
static __inline__ void atomic_sub(atomic_t i, atomic_t *v)
24
{
25
        unsigned long flags;
26
 
27
        save_flags(flags); cli();
28
        *v -= i;
29
        restore_flags(flags);
30
}
31
 
32
static __inline__ int atomic_sub_and_test(atomic_t i, atomic_t *v)
33
{
34
        unsigned long flags, result;
35
 
36
        save_flags(flags); cli();
37
        *v -= i;
38
        result = (*v == 0);
39
        restore_flags(flags);
40
        return result;
41
}
42
 
43
static __inline__ void atomic_inc(atomic_t *v)
44
{
45
        atomic_add(1, v);
46
}
47
 
48
static __inline__ void atomic_dec(atomic_t *v)
49
{
50
        atomic_sub(1, v);
51
}
52
 
53
static __inline__ int atomic_dec_and_test(atomic_t *v)
54
{
55
        return atomic_sub_and_test(1, v);
56
}
57
 
58
#endif /* _ASM_OR32_ATOMIC_H */

powered by: WebSVN 2.1.0

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