Add very hacky symbol constant support and function calling.
[sbcl/llvm.git] / src / runtime / x86-arch.h
blob1200ef1435578ad196bda0a0be0f7535799360bd
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
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) */
21 #define COMPILER_BARRIER \
22 do { __asm__ __volatile__ ( "" : : : "memory"); } while (0)
24 static inline void
25 get_spinlock(volatile lispobj *word, unsigned long value)
27 #ifdef LISP_FEATURE_SB_THREAD
28 u32 eax=0;
29 if(*word==value)
30 lose("recursive get_spinlock: 0x%x,%ld\n",word,value);
31 do {
32 #if defined(LISP_FEATURE_DARWIN)
33 asm volatile ("xor %0,%0;\n\
34 lock/cmpxchg %1,%2"
35 : "=a" (eax)
36 : "r" (value), "m" (*word)
37 : "memory", "cc");
38 #else
39 asm volatile ("xor %0,%0\n\
40 lock cmpxchg %1,%2"
41 : "=a" (eax)
42 : "r" (value), "m" (*word)
43 : "memory", "cc");
44 #endif
46 } while(eax!=0);
47 #else
48 *word=value;
49 #endif
52 static inline void
53 release_spinlock(volatile lispobj *word)
55 /* See comment in RELEASE-SPINLOCK in target-thread.lisp. */
56 COMPILER_BARRIER;
57 *word=0;
58 COMPILER_BARRIER;
61 static inline lispobj
62 swap_lispobjs(volatile lispobj *dest, lispobj value)
64 lispobj old_value;
65 #if defined(LISP_FEATURE_DARWIN)
66 asm volatile ("lock/xchg %0,(%1)"
67 : "=r" (old_value)
68 : "r" (dest), "0" (value)
69 : "memory");
70 #else
71 asm volatile ("lock xchg %0,(%1)"
72 : "=r" (old_value)
73 : "r" (dest), "0" (value)
74 : "memory");
75 #endif
76 return old_value;
79 extern void fast_bzero_detect(void *, size_t);
80 extern void (*fast_bzero_pointer)(void *, size_t);
82 #endif /* _X86_ARCH_H */