Simplify (and robustify) regular PACKing
[sbcl.git] / src / runtime / alpha-linux-os.c
1 /*
2  * This is the Compaq/Digital Alpha Linux incarnation of
3  * arch-dependent OS-dependent routines. See also "linux-os.c".  */
4
5 /*
6  * This software is part of the SBCL system. See the README file for
7  * more information.
8  *
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.
14  */
15
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>
31
32 #include <sys/types.h>
33 #include <signal.h>
34 #include <sys/time.h>
35 #include <sys/stat.h>
36 #include <unistd.h>
37 #include <asm/fpu.h>
38
39 #include "validate.h"
40 size_t os_vm_page_size;
41
42 #ifdef LISP_FEATURE_SB_THREAD
43 #error "Define threading support functions"
44 #else
45 int arch_os_thread_init(struct thread *thread) {
46     return 1;                   /* success */
47 }
48 int arch_os_thread_cleanup(struct thread *thread) {
49     return 1;                   /* success */
50 }
51 #endif
52
53
54 os_context_register_t   *
55 os_context_register_addr(os_context_t *context, int offset)
56 {
57     return &context->uc_mcontext.sc_regs[offset];
58 }
59
60 os_context_register_t *
61 os_context_float_register_addr(os_context_t *context, int offset)
62 {
63     return &context->uc_mcontext.sc_fpregs[offset];
64 }
65
66 os_context_register_t *
67 os_context_pc_addr(os_context_t *context)
68 {
69     return &((context->uc_mcontext).sc_pc);
70 }
71
72 sigset_t *
73 os_context_sigmask_addr(os_context_t *context)
74 {
75     return &context->uc_sigmask;
76 }
77
78 unsigned long
79 os_context_fp_control(os_context_t *context)
80 {
81     return ieee_fpcr_to_swcr((context->uc_mcontext).sc_fpcr);
82 }
83
84 void
85 os_restore_fp_control(os_context_t *context)
86 {
87     /* FIXME: 0x7E0000 is defined as something useful in constants.h,
88        but without the UL, which would probably lead to 32/64-bit
89        errors if we simply used it here.  Ugh.  CSR, 2003-09-15 */
90     arch_set_fp_control(os_context_fp_control(context) & ~(0x7e0000UL) &
91                         /* KLUDGE: for some reason that I don't
92                         understand, by the time we get here the
93                         "enable denormalized traps" bit in the fp
94                         control word is set.  Since we really don't
95                         want to tra every time someone types
96                         LEAST-POSITIVE-SINGLE-FLOAT into the repl,
97                         mask that bit out.  -- CSR, 2003-09-15 */
98                         ~(0x1UL<<6));
99 }
100
101 void os_flush_icache(os_vm_address_t address, os_vm_size_t length)
102 {
103     asm volatile ("imb" : : : "memory" );
104 }