1.0.38.10: Support for building on OpenBSD/PPC (patch by Josh Elsasser).
[sbcl.git] / src / runtime / ppc-bsd-os.c
1 #include <signal.h>
2 #include <machine/cpu.h>
3 #include "sbcl.h"
4 #include "runtime.h"
5 #include "thread.h"
6
7
8 int *
9 os_context_register_addr(os_context_t *context, int offset)
10 {
11 #if defined(LISP_FEATURE_NETBSD)
12     return &context->uc_mcontext.__gregs[offset];
13 #elif defined(LISP_FEATURE_OPENBSD)
14     return &context->sc_frame.fixreg[offset];
15 #endif
16 }
17
18 #if defined(ARCH_HAS_STACK_POINTER) /* It's not defined on PPC. */
19 int *
20 os_context_sp_addr(os_context_t *context)
21 {
22 #if defined(LISP_FEATURE_NETBSD)
23     return &(_UC_MACHINE_SP(context));
24 #endif
25 }
26 #endif
27
28
29 int *
30 os_context_pc_addr(os_context_t *context)
31 {
32 #if defined(LISP_FEATURE_NETBSD)
33     return &(_UC_MACHINE_PC(context));
34 #elif defined(LISP_FEATURE_OPENBSD)
35     return &context->sc_frame.srr0;
36 #endif
37 }
38
39 int *
40 os_context_lr_addr(os_context_t *context)
41 {
42 #if defined(LISP_FEATURE_NETBSD)
43     return &context->uc_mcontext.__gregs[_REG_LR];
44 #elif defined(LISP_FEATURE_OPENBSD)
45     return &context->sc_frame.lr;
46 #endif
47 }
48
49 /* FIXME: If this can be a no-op on BSD/x86, then it
50  * deserves a more precise name.
51  *
52  * (Perhaps os_prepare_data_area_to_be_executed()?) */
53 void
54 os_flush_icache(os_vm_address_t address, os_vm_size_t length)
55 {
56    ppc_flush_icache(address, length);
57 }
58
59 int arch_os_thread_init(struct thread *thread) {
60
61 #ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
62     stack_t sigstack;
63
64     /* Signal handlers are run on the control stack, so if it is exhausted
65      * we had better use an alternate stack for whatever signal tells us
66      * we've exhausted it */
67     sigstack.ss_sp=((void *) thread)+dynamic_values_bytes;
68     sigstack.ss_flags=0;
69     sigstack.ss_size = 32*SIGSTKSZ;
70     sigaltstack(&sigstack,0);
71 #endif
72
73     return 1;                  /* success */
74 }
75
76 int arch_os_thread_cleanup(struct thread *thread) {
77
78     return 1;                  /* success */
79 }