[NET]: Relax the reference counting of init_net_ns
[linux-2.6] / include / asm-cris / arch-v32 / atomic.h
1 #ifndef __ASM_CRIS_ARCH_ATOMIC__
2 #define __ASM_CRIS_ARCH_ATOMIC__
3
4 #include <asm/system.h>
5
6 extern void cris_spin_unlock(void *l, int val);
7 extern void cris_spin_lock(void *l);
8 extern int cris_spin_trylock(void* l);
9
10 #ifndef CONFIG_SMP
11 #define cris_atomic_save(addr, flags) local_irq_save(flags);
12 #define cris_atomic_restore(addr, flags) local_irq_restore(flags);
13 #else
14
15 extern spinlock_t cris_atomic_locks[];
16 #define LOCK_COUNT 128
17 #define HASH_ADDR(a) (((int)a) & 127)
18
19 #define cris_atomic_save(addr, flags) \
20   local_irq_save(flags); \
21   cris_spin_lock((void*)&cris_atomic_locks[HASH_ADDR(addr)].lock);
22
23 #define cris_atomic_restore(addr, flags) \
24   { \
25     spinlock_t *lock = (void*)&cris_atomic_locks[HASH_ADDR(addr)]; \
26     __asm__ volatile ("move.d %1,%0" \
27                           : "=m" (lock->lock) \
28                           : "r" (1) \
29                           : "memory"); \
30     local_irq_restore(flags); \
31   }
32
33 #endif
34
35 #endif
36