Compile disassembler inst-printers in warm load. lp#1543840
[sbcl.git] / src / runtime / x86-arch.h
blobad87f45acd9f72cb392c30688594e66896b80aef
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
8 #ifndef SBCL_GENESIS_CONFIG
9 #error genesis/config.h (or sbcl.h) must be included before this file
10 #endif
12 #include "interr.h" /* for declaration of lose() */
14 #define ARCH_HAS_STACK_POINTER
15 #define ALIEN_STACK_GROWS_DOWNWARD
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 2002-02-15) */
22 #define COMPILER_BARRIER \
23 do { __asm__ __volatile__ ( "" : : : "memory"); } while (0)
25 #ifdef LISP_FEATURE_WIN32
26 extern int os_number_of_processors;
27 #define yield_on_uniprocessor() \
28 do { if (os_number_of_processors<=1) SwitchToThread(); } while(0)
29 #else
30 /* Stubs are better than ifdef EVERYWHERE. */
31 #define yield_on_uniprocessor() \
32 do {} while(0)
33 #endif
36 static inline void
37 get_spinlock(volatile lispobj *word, unsigned long value)
39 #ifdef LISP_FEATURE_SB_THREAD
40 u32 eax=0;
41 if(*word==value)
42 lose("recursive get_spinlock: 0x%x,%ld\n",word,value);
43 do {
44 #if defined(LISP_FEATURE_DARWIN)
45 asm volatile ("xor %0,%0;\n\
46 lock/cmpxchg %1,%2"
47 : "=a" (eax)
48 : "r" (value), "m" (*word)
49 : "memory", "cc");
50 #else
51 if (eax!=0) {
52 asm volatile("rep; nop");
54 asm volatile ("xor %0,%0\n\
55 lock cmpxchg %1,%2"
56 : "=a" (eax)
57 : "r" (value), "m" (*word)
58 : "memory", "cc");
59 #endif
60 yield_on_uniprocessor();
61 } while(eax!=0);
62 #else
63 *word=value;
64 #endif
67 static inline void
68 release_spinlock(volatile lispobj *word)
70 /* See comment in RELEASE-SPINLOCK in target-thread.lisp. */
71 COMPILER_BARRIER;
72 *word=0;
73 COMPILER_BARRIER;
76 static inline lispobj
77 swap_lispobjs(volatile lispobj *dest, lispobj value)
79 lispobj old_value;
80 #if defined(LISP_FEATURE_DARWIN)
81 asm volatile ("lock/xchg %0,(%1)"
82 : "=r" (old_value)
83 : "r" (dest), "0" (value)
84 : "memory");
85 #else
86 asm volatile ("lock xchg %0,(%1)"
87 : "=r" (old_value)
88 : "r" (dest), "0" (value)
89 : "memory");
90 #endif
91 return old_value;
94 extern void fast_bzero_detect(void *, size_t);
95 extern void (*fast_bzero_pointer)(void *, size_t);
97 #endif /* _X86_ARCH_H */