7fe1aa053f8f9d6e0d01c2cae0c6333fd8159215
[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
8 #ifndef SBCL_GENESIS_CONFIG
9 #error genesis/config.h (or sbcl.h) must be included before this file
10 #endif
11
12 #define ARCH_HAS_STACK_POINTER
13
14 /* FIXME: Do we also want
15  *   #define ARCH_HAS_FLOAT_REGISTERS
16  * here? (The answer wasn't obvious to me when merging the
17  * architecture-abstracting patches for CSR's SPARC port. -- WHN 2002-02-15) */
18
19 #include "interr.h"
20
21 static inline void
22 get_spinlock(volatile lispobj *word,long value)
23 {
24 #ifdef LISP_FEATURE_SB_THREAD
25     u32 eax=0;
26     if(*word==value)
27         lose("recursive get_spinlock: 0x%x,%ld\n",word,value);
28     do {
29         asm ("xor %0,%0\n\
30               lock cmpxchg %1,%2"
31              : "=a" (eax)
32              : "r" (value), "m" (*word)
33              : "memory", "cc");
34     } while(eax!=0);
35 #else
36     *word=value;
37 #endif
38 }
39
40 static inline void
41 release_spinlock(volatile lispobj *word)
42 {
43     *word=0;
44 }
45
46 #include <stdio.h>
47
48 static inline lispobj
49 swap_lispobjs(volatile lispobj *dest, lispobj value)
50 {
51     lispobj old_value;
52     asm ("lock xchg %0,(%1)"
53          : "=r" (old_value)
54          : "r" (dest), "0" (value)
55          : "memory");
56     return old_value;
57 }
58
59 extern void fast_bzero_detect(void *, size_t);
60 extern void (*fast_bzero_pointer)(void *, size_t);
61
62 #endif /* _X86_ARCH_H */