1.0.9.54: clean up old pv updating code
[sbcl/lichteblau.git] / src / runtime / ppc-linux-os.c
blob07124f11c4a56d023c804e2a10bce159eb119496
1 /*
2 * This is the IBM/Motorola/Apple/whoever Linux incarnation of
3 * arch-dependent OS-dependent routines. See also "linux-os.c". */
5 /*
6 * This software is part of the SBCL system. See the README file for
7 * more information.
9 * This software is derived from the CMU CL system, which was
10 * written at Carnegie Mellon University and released into the
11 * public domain. The software is in the public domain and is
12 * provided with absolutely no warranty. See the COPYING and CREDITS
13 * files for more information.
16 /* These header files were lifted wholesale from linux-os.c, some may
17 * be redundant. -- Dan Barlow ca. 2001-05-01 */
18 #include <stdio.h>
19 #include <sys/param.h>
20 #include <sys/file.h>
21 #include "sbcl.h"
22 #include "./signal.h"
23 #include "os.h"
24 #include "arch.h"
25 #include "globals.h"
26 #include "interrupt.h"
27 #include "interr.h"
28 #include "lispregs.h"
29 #include <sys/socket.h>
30 #include <sys/utsname.h>
32 #include <sys/types.h>
33 #include <signal.h>
34 #include <sys/time.h>
35 #include <sys/stat.h>
36 #include <unistd.h>
38 #include "validate.h"
39 #include "ppc-linux-mcontext.h"
41 size_t os_vm_page_size;
43 int arch_os_thread_init(struct thread *thread) {
44 return 1; /* success */
46 int arch_os_thread_cleanup(struct thread *thread) {
47 return 1; /* success */
50 os_context_register_t *
51 os_context_register_addr(os_context_t *context, int offset)
53 #if defined(GLIBC231_STYLE_UCONTEXT)
54 return &((context->uc_mcontext.regs)->gpr[offset]);
55 #elif defined(GLIBC232_STYLE_UCONTEXT)
56 return &((context->uc_mcontext.uc_regs->gregs)[offset]);
57 #endif
60 os_context_register_t *
61 os_context_pc_addr(os_context_t *context)
63 #if defined(GLIBC231_STYLE_UCONTEXT)
64 return &((context->uc_mcontext.regs)->nip);
65 #elif defined(GLIBC232_STYLE_UCONTEXT)
66 return &((context->uc_mcontext.uc_regs->gregs)[PT_NIP]);
67 #endif
70 os_context_register_t *
71 os_context_lr_addr(os_context_t *context)
73 #if defined(GLIBC231_STYLE_UCONTEXT)
74 return &((context->uc_mcontext.regs)->link);
75 #elif defined(GLIBC232_STYLE_UCONTEXT)
76 return &((context->uc_mcontext.uc_regs->gregs)[PT_LNK]);
77 #endif
80 sigset_t *
81 os_context_sigmask_addr(os_context_t *context)
83 #if defined(GLIBC231_STYLE_UCONTEXT)
84 return &context->uc_sigmask;
85 #elif defined(GLIBC232_STYLE_UCONTEXT)
86 return &context->uc_sigmask;
87 #endif
90 unsigned long
91 os_context_fp_control(os_context_t *context)
93 /* So this may look like nice, well behaved code. However, closer
94 inspection reveals that gpr is simply the general purpose
95 registers, and PT_FPSCR is an offset that is larger than 32
96 (the number of ppc registers), but that happens to get the
97 right answer. -- CSR, 2002-07-11 */
98 #if defined(GLIBC231_STYLE_UCONTEXT)
99 return context->uc_mcontext.regs->gpr[PT_FPSCR];
100 #elif defined(GLIBC232_STYLE_UCONTEXT)
101 return context->uc_mcontext.uc_regs->gregs[PT_FPSCR];
102 #endif
105 void
106 os_restore_fp_control(os_context_t *context)
108 unsigned long control;
109 double d;
111 control = os_context_fp_control(context) &
112 /* FIXME: Should we preserve the user's requested rounding mode?
114 Note that doing
116 ~(FLOAT_STICKY_BITS_MASK | FLOAT_EXCEPTIONS_BYTE_MASK)
118 here leads to infinite SIGFPE for invalid operations, as
119 there are bits in the control register that need to be
120 cleared that are let through by that mask. -- CSR, 2002-07-16 */
122 FLOAT_TRAPS_BYTE_MASK;
124 d = *((double *) &control);
125 /* Hmp. Apparently the following doesn't work either:
127 asm volatile ("mtfsf 0xff,%0" : : "f" (d));
129 causing segfaults at the first GC.
133 void
134 os_flush_icache(os_vm_address_t address, os_vm_size_t length)
136 /* see ppc-arch.c */
137 ppc_flush_icache(address,length);