Statistics
| Branch: | Revision:

root / qemu-lock.h @ a74cdab4

History | View | Annotate | Download (1.6 kB)

1 d5975363 pbrook
/*
2 d5975363 pbrook
 *  Copyright (c) 2003 Fabrice Bellard
3 d5975363 pbrook
 *
4 d5975363 pbrook
 * This library is free software; you can redistribute it and/or
5 d5975363 pbrook
 * modify it under the terms of the GNU Lesser General Public
6 d5975363 pbrook
 * License as published by the Free Software Foundation; either
7 d5975363 pbrook
 * version 2 of the License, or (at your option) any later version.
8 d5975363 pbrook
 *
9 d5975363 pbrook
 * This library is distributed in the hope that it will be useful,
10 d5975363 pbrook
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 d5975363 pbrook
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 d5975363 pbrook
 * Lesser General Public License for more details.
13 d5975363 pbrook
 *
14 d5975363 pbrook
 * You should have received a copy of the GNU Lesser General Public
15 8167ee88 Blue Swirl
 * License along with this library; if not, see <http://www.gnu.org/licenses/>
16 d5975363 pbrook
 */
17 d5975363 pbrook
18 02615337 Peter Maydell
/* configure guarantees us that we have pthreads on any host except
19 02615337 Peter Maydell
 * mingw32, which doesn't support any of the user-only targets.
20 02615337 Peter Maydell
 * So we can simply assume we have pthread mutexes here.
21 02615337 Peter Maydell
 */
22 02615337 Peter Maydell
#if defined(CONFIG_USER_ONLY)
23 d5975363 pbrook
24 d5975363 pbrook
#include <pthread.h>
25 d5975363 pbrook
#define spin_lock pthread_mutex_lock
26 d5975363 pbrook
#define spin_unlock pthread_mutex_unlock
27 c227f099 Anthony Liguori
#define spinlock_t pthread_mutex_t
28 d5975363 pbrook
#define SPIN_LOCK_UNLOCKED PTHREAD_MUTEX_INITIALIZER
29 d5975363 pbrook
30 d5975363 pbrook
#else
31 d5975363 pbrook
32 02615337 Peter Maydell
/* Empty implementations, on the theory that system mode emulation
33 02615337 Peter Maydell
 * is single-threaded. This means that these functions should only
34 02615337 Peter Maydell
 * be used from code run in the TCG cpu thread, and cannot protect
35 02615337 Peter Maydell
 * data structures which might also be accessed from the IO thread
36 02615337 Peter Maydell
 * or from signal handlers.
37 02615337 Peter Maydell
 */
38 c227f099 Anthony Liguori
typedef int spinlock_t;
39 d5975363 pbrook
#define SPIN_LOCK_UNLOCKED 0
40 d5975363 pbrook
41 c227f099 Anthony Liguori
static inline void spin_lock(spinlock_t *lock)
42 d5975363 pbrook
{
43 d5975363 pbrook
}
44 d5975363 pbrook
45 c227f099 Anthony Liguori
static inline void spin_unlock(spinlock_t *lock)
46 d5975363 pbrook
{
47 d5975363 pbrook
}
48 d5975363 pbrook
49 d5975363 pbrook
#endif