0.8.3.1
[sbcl.git] / src / runtime / sparc-sunos-os.c
1 /*
2  * This is the SPARC Linux incarnation of arch-dependent OS-dependent
3  * routines. See also "linux-os.c".
4  */
5
6 /*
7  * This software is part of the SBCL system. See the README file for
8  * more information.
9  *
10  * This software is derived from the CMU CL system, which was
11  * written at Carnegie Mellon University and released into the
12  * public domain. The software is in the public domain and is
13  * provided with absolutely no warranty. See the COPYING and CREDITS
14  * files for more information.
15  */
16
17 #include <stdio.h>
18 #include <sys/param.h>
19 #include <sys/file.h>
20 #include "./signal.h"
21 #include "os.h"
22 #include "arch.h"
23 #include "globals.h"
24 #include "interrupt.h"
25 #include "interr.h"
26 #include "lispregs.h"
27 #include "sbcl.h"
28 #include <sys/socket.h>
29 #include <sys/utsname.h>
30
31 #include <sys/types.h>
32 #include <signal.h>
33 #include <sys/time.h>
34 #include <sys/stat.h>
35 #include <unistd.h>
36
37 #include "validate.h"
38
39 #ifdef LISP_FEATURE_SB_THREAD
40 #error "Define threading support functions"
41 #else
42 struct thread *arch_os_get_current_thread() {
43     return all_threads;
44 }
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 os_context_register_t   *
54 os_context_register_addr(os_context_t *context, int offset)
55 {
56     if (offset == 0) {
57         static int zero;
58         zero = 0;
59         return &zero;
60     } else if (offset < 16) {
61         return &context->uc_mcontext.gregs[offset+3];
62     } else if (offset < 32) {
63         /* FIXME: You know, this (int *) stuff looks decidedly
64            dubious */
65         int *sp = (int*) context->uc_mcontext.gregs[REG_SP];
66         return &(sp[offset-16]);
67     } else {
68         return 0;
69     }
70 }
71
72 os_context_register_t *
73 os_context_pc_addr(os_context_t *context)
74 {
75     return &(context->uc_mcontext.gregs[REG_PC]);
76 }
77
78 os_context_register_t *
79 os_context_npc_addr(os_context_t *context)
80 {
81     return &(context->uc_mcontext.gregs[REG_nPC]);
82 }
83
84 sigset_t *
85 os_context_sigmask_addr(os_context_t *context)
86 {
87     return &(context->uc_sigmask);
88 }
89
90 unsigned long
91 os_context_fp_control(os_context_t *context)
92 {
93     return (context->uc_mcontext.fpregs.fpu_fsr);
94 }
95
96 void os_flush_icache(os_vm_address_t address, os_vm_size_t length)
97 {
98     /* see sparc-assem.S */
99     sparc_flush_icache(address, length);
100 }