ia64/xen-unstable

view extras/mini-os/include/spinlock.h @ 16520:a583f3a7eafc

Revert 16498:d2bef6551c1263e457aef75ce403ba53652a803f.
author Keir Fraser <keir.fraser@citrix.com>
date Tue Dec 04 22:54:58 2007 +0000 (2007-12-04)
parents b631e7885b5f
children 707e10c9a487
line source
1 #ifndef __ASM_SPINLOCK_H
2 #define __ASM_SPINLOCK_H
4 #include <lib.h>
6 /*
7 * Your basic SMP spinlocks, allowing only a single CPU anywhere
8 */
10 typedef struct {
11 volatile unsigned int slock;
12 } spinlock_t;
15 #include "arch_spinlock.h"
18 #define SPINLOCK_MAGIC 0xdead4ead
20 #define SPIN_LOCK_UNLOCKED ARCH_SPIN_LOCK_UNLOCKED
22 #define spin_lock_init(x) do { *(x) = SPIN_LOCK_UNLOCKED; } while(0)
24 /*
25 * Simple spin lock operations. There are two variants, one clears IRQ's
26 * on the local processor, one does not.
27 *
28 * We make no fairness assumptions. They have a cost.
29 */
31 #define spin_is_locked(x) arch_spin_is_locked(x)
33 #define spin_unlock_wait(x) do { barrier(); } while(spin_is_locked(x))
36 #define _spin_trylock(lock) ({_raw_spin_trylock(lock) ? \
37 1 : ({ 0;});})
39 #define _spin_lock(lock) \
40 do { \
41 _raw_spin_lock(lock); \
42 } while(0)
44 #define _spin_unlock(lock) \
45 do { \
46 _raw_spin_unlock(lock); \
47 } while (0)
50 #define spin_lock(lock) _spin_lock(lock)
51 #define spin_unlock(lock) _spin_unlock(lock)
53 #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
55 #endif