3574f271d6ae7234b5bfe8ccd8783963f82ccad7
[projects/cmucl/cmucl.git] / src / lisp / x86-lispregs.h
1 /* x86-lispregs.h -*- Mode: C; -*-
2  * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-lispregs.h,v 1.16 2010/12/24 06:01:34 rtoy Exp $
3  */
4
5 #ifndef _X86_LISPREGS_H_
6 #define _X86_LISPREGS_H_
7
8 /* These register names and offsets correspond to definitions
9  * in compiler/x86/vm.lisp. They map into accessors in the
10  * os dependent <machine/signal.h> structure via the sc_reg
11  * os dependent function.
12  */
13
14 #define NREGS   (8)
15
16 #ifdef LANGUAGE_ASSEMBLY
17 #define REG(num) $ ## num
18 #else
19 #define REG(num) num
20 #endif
21
22 #define reg_EAX REG( 0)
23 #define reg_ECX REG( 2)
24 #define reg_EDX REG( 4)
25 #define reg_EBX REG( 6)
26 #define reg_ESP REG( 8)
27 #define reg_EBP REG(10)
28 #define reg_ESI REG(12)
29 #define reg_EDI REG(14)
30
31 #define reg_SP reg_ESP
32 #define reg_FP reg_EBP
33 #define reg_NARGS reg_ECX
34
35 #define REGNAMES "EAX", "ECX", "EDX", "EBX", "ESP", "EBP", "ESI", "EDI"
36
37 /* These registers can contain lisp object pointers */
38 #define BOXED_REGISTERS {\
39   reg_EAX, reg_ECX, reg_EDX, reg_EBX, reg_ESI, reg_EDI \
40   }
41
42 /* N is offset in storage class (SC) as defined in vm.lisp.
43  * Ordering in sigcontext is probably os dependent so let
44  * xxx-os.c handle it.
45  */
46
47 #define SC_REG(scp, offset) (*os_sigcontext_reg(scp, offset))
48 #define SC_PC(scp) (*os_sigcontext_pc(scp))
49 #define SC_SP(scp) SC_REG(scp, reg_ESP)
50
51 #if defined(DARWIN)
52 #if __DARWIN_UNIX03
53 /* For 10.5 */
54 #define SC_EFLAGS(sc) ((sc)->uc_mcontext->__ss.__eflags)
55 #else
56 /* For 10.4 */
57 #define SC_EFLAGS(sc) ((sc)->uc_mcontext->ss.eflags)
58 #endif
59 #elif defined(__linux__)
60 #define SC_EFLAGS(sc) ((sc)->uc_mcontext.gregs[REG_EFL])
61 #elif defined(__NetBSD__)
62 #define SC_EFLAGS(sc) ((sc)->uc_mcontext.__gregs[_REG_EFL])
63 #elif defined(SOLARIS)
64 /*
65  * Solaris/x86 has access the the eflags value, but this doesn't
66  * currently work.  It seems that when we set the EFLAG to enable
67  * single-stepping, we never actually step the new instruction but we
68  * stop at exactly the same place.  This is not how it works on other
69  * OSes where we do step an instruction.  I (rtoy) do not know why.
70  * Some more work needs to be done in x86-arch.c to make this work.
71  * But the default code there works fine on Solaris/x86.
72  */
73 /* #define SC_EFLAGS(sc) ((sc)->uc_mcontext.gregs[EFL])*/
74 #endif
75
76 #endif /* _X86_LISPREGS_H_ */