debuggers.hg

view tools/xenpaging/spinlock.h @ 21067:b4a1832a916f

Update Xen version to 4.0.0-rc6
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 09 18:18:05 2010 +0000 (2010-03-09)
parents 47ec2d131c22
children
line source
1 /******************************************************************************
2 * tools/xenpaging/spinlock.h
3 *
4 * Spinlock implementation.
5 *
6 * Copyright (c) 2009 Citrix Systems, Inc. (Patrick Colp)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
24 #ifndef __SPINLOCK_H__
25 #define __SPINLOCK_H__
28 #include "bitops.h"
31 #define SPIN_LOCK_UNLOCKED 0
34 typedef int spinlock_t;
37 static inline void spin_lock(spinlock_t *lock)
38 {
39 while ( test_and_set_bit(1, lock) );
40 }
42 static inline void spin_lock_init(spinlock_t *lock)
43 {
44 *lock = SPIN_LOCK_UNLOCKED;
45 }
47 static inline void spin_unlock(spinlock_t *lock)
48 {
49 *lock = SPIN_LOCK_UNLOCKED;
50 }
52 static inline int spin_trylock(spinlock_t *lock)
53 {
54 return !test_and_set_bit(1, lock);
55 }
58 #endif // __SPINLOCK_H__
61 /*
62 * Local variables:
63 * mode: C
64 * c-set-style: "BSD"
65 * c-basic-offset: 4
66 * tab-width: 4
67 * indent-tabs-mode: nil
68 * End:
69 */