[BACK]Return to atomic.h CVS log [TXT][DIR] Up to [Development] / linux-2.6-xfs / include / asm-cris / arch-v32

File: [Development] / linux-2.6-xfs / include / asm-cris / arch-v32 / atomic.h (download)

Revision 1.2, Tue Feb 26 16:44:40 2008 UTC (9 years, 7 months ago) by lachlan.longdrop.melbourne.sgi.com
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +5 -5 lines

Merge up to 2.6.25-rc3
Merge of 2.6.x-xfs-melb:linux:30555a by kenmcd.

#ifndef __ASM_CRIS_ARCH_ATOMIC__
#define __ASM_CRIS_ARCH_ATOMIC__

#include <linux/spinlock_types.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)].raw_lock.slock);

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

#endif

#endif