File: atomic.h

package info (click to toggle)
linux-kernel-headers 2.6.18-7
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 38,648 kB
  • ctags: 300,882
  • sloc: ansic: 461,192; asm: 1,555; cpp: 340; makefile: 312; sh: 110
file content (36 lines) | stat: -rw-r--r-- 895 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef __ASM_CRIS_ARCH_ATOMIC__
#define __ASM_CRIS_ARCH_ATOMIC__

#include <asm/system.h>

extern void cris_spin_unlock(void *l, int val);
extern void cris_spin_lock(void *l);
extern int cris_spin_trylock(void* l);

#ifndef CONFIG_SMP
#define cris_atomic_save(addr, flags) local_irq_save(flags);
#define cris_atomic_restore(addr, flags) local_irq_restore(flags);
#else

extern spinlock_t cris_atomic_locks[];
#define LOCK_COUNT 128
#define HASH_ADDR(a) (((int)a) & 127)

#define cris_atomic_save(addr, flags) \
  local_irq_save(flags); \
  cris_spin_lock((void*)&cris_atomic_locks[HASH_ADDR(addr)].lock);

#define cris_atomic_restore(addr, flags) \
  { \
    spinlock_t *lock = (void*)&cris_atomic_locks[HASH_ADDR(addr)]; \
    __asm__ volatile ("move.d %1,%0" \
	                  : "=m" (lock->lock) \
			  : "r" (1) \
			  : "memory"); \
    local_irq_restore(flags); \
  }

#endif

#endif