0.9.2.42:
[sbcl/lichteblau.git] / src / runtime / x86-bsd-os.c
bloba84336436fd36dc8d9cec0cf0035c6e73ac73cb9
1 #include <signal.h>
2 #include "sbcl.h"
3 #include "runtime.h"
4 #include "target-os.h"
6 /* KLUDGE: There is strong family resemblance in the signal context
7 * stuff in FreeBSD and OpenBSD, but in detail they're different in
8 * almost every line of code. It would be nice to find some way to
9 * factor out the commonality better; failing that, it might be best
10 * just to split this generic-BSD code into one variant for each BSD.
12 * KLUDGE II: this split has begun with the addition of the Darwin BSD
13 * flavour, with the cross-architecture complications that this
14 * entails; unfortunately, currently the situation is worse, not
15 * better, than in the above paragraph. */
17 #if defined(__FreeBSD__) || defined(__OpenBSD__)
18 int *
19 os_context_register_addr(os_context_t *context, int offset)
21 switch(offset) {
22 case 0:
23 return CONTEXT_ADDR_FROM_STEM(eax);
24 case 2:
25 return CONTEXT_ADDR_FROM_STEM(ecx);
26 case 4:
27 return CONTEXT_ADDR_FROM_STEM(edx);
28 case 6:
29 return CONTEXT_ADDR_FROM_STEM(ebx);
30 case 8:
31 return CONTEXT_ADDR_FROM_STEM(esp);
32 case 10:
33 return CONTEXT_ADDR_FROM_STEM(ebp);
34 case 12:
35 return CONTEXT_ADDR_FROM_STEM(esi);
36 case 14:
37 return CONTEXT_ADDR_FROM_STEM(edi);
38 default:
39 return 0;
43 int *
44 os_context_sp_addr(os_context_t *context)
46 return CONTEXT_ADDR_FROM_STEM(esp);
49 #endif /* __FreeBSD__ || __OpenBSD__ */
51 #ifdef __NetBSD__
52 int *
53 os_context_register_addr(os_context_t *context, int offset)
55 switch(offset) {
56 case 0:
57 return CONTEXT_ADDR_FROM_STEM(EAX);
58 case 2:
59 return CONTEXT_ADDR_FROM_STEM(ECX);
60 case 4:
61 return CONTEXT_ADDR_FROM_STEM(EDX);
62 case 6:
63 return CONTEXT_ADDR_FROM_STEM(EBX);
64 case 8:
65 return CONTEXT_ADDR_FROM_STEM(ESP);
66 case 10:
67 return CONTEXT_ADDR_FROM_STEM(EBP);
68 case 12:
69 return CONTEXT_ADDR_FROM_STEM(ESI);
70 case 14:
71 return CONTEXT_ADDR_FROM_STEM(EDI);
72 case 16:
73 return CONTEXT_ADDR_FROM_STEM(UESP);
74 default:
75 return 0;
79 int *
80 os_context_sp_addr(os_context_t *context)
82 return &(_UC_MACHINE_SP(context));
85 #endif /* __NetBSD__ */
89 /* FIXME: If this can be a no-op on BSD/x86, then it
90 * deserves a more precise name.
92 * (Perhaps os_prepare_data_area_to_be_executed()?) */
93 void
94 os_flush_icache(os_vm_address_t address, os_vm_size_t length)