compat-3.2.h: Avoid module_platform_driver redefinition
[~tnikolova/compat/.git] / compat / compat_atomic.c
1 #include <linux/spinlock.h>
2 #include <linux/module.h>
3
4 #if !((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) && (defined(CONFIG_UML) || defined(CONFIG_X86))) && !((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) && defined(CONFIG_ARM) && !defined(CONFIG_GENERIC_ATOMIC64))
5
6 static DEFINE_SPINLOCK(lock);
7
8 long long atomic64_read(const atomic64_t *v)
9 {
10     unsigned long flags;
11     long long val;
12
13     spin_lock_irqsave(&lock, flags);
14     val = v->counter;
15     spin_unlock_irqrestore(&lock, flags);
16     return val;
17 }
18 EXPORT_SYMBOL_GPL(atomic64_read);
19
20 long long atomic64_add_return(long long a, atomic64_t *v)
21 {
22     unsigned long flags;
23     long long val;
24
25     spin_lock_irqsave(&lock, flags);
26     val = v->counter += a;
27     spin_unlock_irqrestore(&lock, flags);
28     return val;
29 }
30 EXPORT_SYMBOL_GPL(atomic64_add_return);
31
32 #endif
33