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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [include/] [asm-sparc/] [atomic.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/* atomic.h: These really suck for now.
2
 *
3
 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
4
 */
5
 
6
#ifndef __ARCH_SPARC_ATOMIC__
7
#define __ARCH_SPARC_ATOMIC__
8
 
9
#ifdef __SMP__
10
#include <asm/smp.h>
11
#include <asm/smp_lock.h>
12
#endif
13
 
14
typedef int atomic_t;
15
 
16
static __inline__ void atomic_add(atomic_t i, atomic_t *v)
17
{
18
        unsigned long flags;
19
 
20
        save_flags(flags); cli();
21
        *v += i;
22
        restore_flags(flags);
23
}
24
 
25
static __inline__ void atomic_sub(atomic_t i, atomic_t *v)
26
{
27
        unsigned long flags;
28
 
29
        save_flags(flags); cli();
30
        *v -= i;
31
        restore_flags(flags);
32
}
33
 
34
static __inline__ int atomic_sub_and_test(atomic_t i, atomic_t *v)
35
{
36
        unsigned long flags, result;
37
 
38
        save_flags(flags); cli();
39
        *v -= i;
40
        result = (*v == 0);
41
        restore_flags(flags);
42
        return result;
43
}
44
 
45
static __inline__ void atomic_inc(atomic_t *v)
46
{
47
        atomic_add(1, v);
48
}
49
 
50
static __inline__ void atomic_dec(atomic_t *v)
51
{
52
        atomic_sub(1, v);
53
}
54
 
55
static __inline__ int atomic_dec_and_test(atomic_t *v)
56
{
57
        return atomic_sub_and_test(1, v);
58
}
59
 
60
#endif /* !(__ARCH_SPARC_ATOMIC__) */

powered by: WebSVN 2.1.0

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