1.0.14.38: build runtime with -Wsign-compare, and clean warnings on x86/Linux
[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 #include "interr.h"                     /* for declaration of lose() */
13
14 #define ARCH_HAS_STACK_POINTER
15
16 /* FIXME: Do we also want
17  *   #define ARCH_HAS_FLOAT_REGISTERS
18  * here? (The answer wasn't obvious to me when merging the
19  * architecture-abstracting patches for CSR's SPARC port. -- WHN 2002-02-15) */
20
21 #include "interr.h"
22
23 static inline void
24 get_spinlock(volatile lispobj *word, unsigned long value)
25 {
26 #ifdef LISP_FEATURE_SB_THREAD
27     u32 eax=0;
28     if(*word==value)
29         lose("recursive get_spinlock: 0x%x,%ld\n",word,value);
30     do {
31 #if defined(LISP_FEATURE_DARWIN)
32         asm ("xor %0,%0;\n\
33               lock/cmpxchg %1,%2"
34              : "=a" (eax)
35              : "r" (value), "m" (*word)
36              : "memory", "cc");
37 #else
38         asm ("xor %0,%0\n\
39               lock cmpxchg %1,%2"
40              : "=a" (eax)
41              : "r" (value), "m" (*word)
42              : "memory", "cc");
43 #endif
44
45     } while(eax!=0);
46 #else
47     *word=value;
48 #endif
49 }
50
51 static inline void
52 release_spinlock(volatile lispobj *word)
53 {
54     *word=0;
55 }
56
57 #include <stdio.h>
58
59 static inline lispobj
60 swap_lispobjs(volatile lispobj *dest, lispobj value)
61 {
62     lispobj old_value;
63 #if defined(LISP_FEATURE_DARWIN)
64     asm ("lock/xchg %0,(%1)"
65          : "=r" (old_value)
66          : "r" (dest), "0" (value)
67          : "memory");
68 #else
69     asm ("lock xchg %0,(%1)"
70          : "=r" (old_value)
71          : "r" (dest), "0" (value)
72          : "memory");
73 #endif
74     return old_value;
75 }
76
77 extern void fast_bzero_detect(void *, size_t);
78 extern void (*fast_bzero_pointer)(void *, size_t);
79
80 #endif /* _X86_ARCH_H */