ia64/xen-unstable

view extras/mini-os/include/spinlock.h @ 16838:945820bfedb6

minios: POSIX fixes
Fixes some functions which are POSIX. Also make them ifndef HAVE_LIBC.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jan 22 14:20:22 2008 +0000 (2008-01-22)
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