439f5081ad6795f08223e95295f646e5c7117cd1
[sbcl.git] / src / runtime / x86-arch.h
1 /* FIXME: Aren't preprocessor symbols with underscore prefixes
2  * reserved for the system libraries? If so, it would be tidy to
3  * rename flags like _X86_ARCH_H so their names are in a part of the
4  * namespace that we control. */
5 #ifndef _X86_ARCH_H
6 #define _X86_ARCH_H
7 #ifndef SBCL_GENESIS_CONFIG
8 #error genesis/config.h (or sbcl.h) must be included before this file
9 #endif
10
11 #ifndef SBCL_GENESIS_CONFIG
12 #error genesis/config.h (or sbcl.h) must be included before this file
13 #endif
14
15 #define ARCH_HAS_STACK_POINTER
16
17 /* FIXME: Do we also want
18  *   #define ARCH_HAS_FLOAT_REGISTERS
19  * here? (The answer wasn't obvious to me when merging the
20  * architecture-abstracting patches for CSR's SPARC port. -- WHN
21  * 2002-02-15) */
22
23 #ifdef LISP_FEATURE_SB_THREAD
24
25 extern never_returns lose(char *fmt, ...);
26
27 static inline void 
28 get_spinlock(volatile lispobj *word,long value)
29 {
30     u32 eax=0;
31     if(*word==value) 
32         lose("recursive get_spinlock: 0x%x,%d\n",word,value);
33     do {
34         asm ("xor %0,%0\n\
35               lock cmpxchg %1,%2" 
36              : "=a" (eax)
37              : "r" (value), "m" (*word)
38              : "memory", "cc");
39     } while(eax!=0);
40 }
41
42 static inline void
43 release_spinlock(volatile lispobj *word)
44 {
45     *word=0;
46 }
47
48 #else
49
50 static inline void 
51 get_spinlock(lispobj *word, int value)
52 {
53     *word = value;
54 }
55
56 static inline void
57 release_spinlock(lispobj *word) {
58     *word = 0;
59 }
60
61 #endif /* LISP_FEATURE_SB_THREAD */
62 #endif /* _X86_ARCH_H */