-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvp_lock.h
More file actions
45 lines (36 loc) · 815 Bytes
/
vp_lock.h
File metadata and controls
45 lines (36 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright (C) yajin 2008<yajinzhou@gmail.com >
*
* This file is part of the virtualmips distribution.
* See LICENSE file for terms of the license.
*
*/
#ifndef __VP_LOCK_H__
#define __VP_LOCK_H__
/*testandset from QEMU*/
#ifdef __i386__
static inline int testandset (int *p)
{
long int readval = 0;
__asm__ __volatile__ ("lock; cmpxchgl %2, %0":"+m" (*p),
"+a" (readval):"r" (1):"cc");
return readval;
}
#endif
#ifdef __x86_64__
static inline int testandset (int *p)
{
long int readval = 0;
__asm__ __volatile__ ("lock; cmpxchgl %2, %0":"+m" (*p),
"+a" (readval):"r" (1):"cc");
return readval;
}
#endif
#ifdef __ia64
#include <ia64intrin.h>
static inline int testandset (int *p)
{
return __sync_lock_test_and_set (p, 1);
}
#endif
#endif