9 #include <sys/utsname.h>
15 #include "interrupt.h"
18 #include "target-arch-os.h"
20 #ifdef LISP_FEATURE_GENCGC
21 #error gencgc not ported to hpux
24 #ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
25 #error C_STACK_IS_CONTROL_STACK isnt supported
28 size_t os_vm_page_size
;
31 os_init(char *argv
[], char *envp
[])
33 os_vm_page_size
= BACKEND_PAGE_BYTES
;
37 os_validate(os_vm_address_t addr
, os_vm_size_t len
)
39 os_vm_address_t actual
;
40 int flags
= MAP_PRIVATE
| MAP_ANONYMOUS
;
41 if (addr
) flags
|= MAP_FIXED
;
43 actual
= mmap(addr
, len
, OS_VM_PROT_ALL
, flags
, -1, 0);
45 if (actual
== MAP_FAILED
) {
47 lose("os_validate(): mmap() failure\n");
50 if (addr
&& (addr
!=actual
)) {
51 fprintf(stderr
, "mmap: wanted %lu bytes at %p, actually mapped at %p\n",
52 (unsigned long) len
, addr
, actual
);
60 os_invalidate(os_vm_address_t addr
, os_vm_size_t len
)
62 if (munmap(addr
,len
) == -1) {
64 lose("os_invalidate(): mmap() failure\n");
69 os_map(int fd
, int offset
, os_vm_address_t addr
, os_vm_size_t len
)
71 os_vm_address_t actual
;
72 actual
= mmap(addr
, len
,
74 MAP_PRIVATE
| MAP_FILE
| MAP_FIXED
,
76 if (actual
== MAP_FAILED
|| (addr
&& (addr
!= actual
))) {
78 lose("os_map(): mmap() failure\n");
84 os_protect(os_vm_address_t addr
, os_vm_size_t len
, os_vm_prot_t prot
)
86 if (mprotect(addr
, len
, prot
) == -1) {
92 is_valid_lisp_addr(os_vm_address_t addr
)
95 size_t ad
= (size_t) addr
;
97 if ((READ_ONLY_SPACE_START
<= ad
&& ad
< READ_ONLY_SPACE_END
)
98 || (STATIC_SPACE_START
<= ad
&& ad
< STATIC_SPACE_END
)
99 || (DYNAMIC_0_SPACE_START
<= ad
&& ad
< DYNAMIC_0_SPACE_END
)
100 || (DYNAMIC_1_SPACE_START
<= ad
&& ad
< DYNAMIC_1_SPACE_END
)
103 for_each_thread(th
) {
104 if((size_t)(th
->control_stack_start
) <= ad
105 && ad
< (size_t)(th
->control_stack_end
))
107 if((size_t)(th
->binding_stack_start
) <= ad
108 && ad
< (size_t)(th
->binding_stack_start
+ BINDING_STACK_SIZE
))
115 * any OS-dependent special low-level handling for signals
119 sigsegv_handler(int signal
, siginfo_t
*info
, os_context_t
*context
)
121 os_vm_address_t addr
= arch_get_bad_addr(signal
, info
, context
);
123 if (!cheneygc_handle_wp_violation(context
, addr
))
124 if (!handle_guard_page_triggered(context
, addr
))
125 lisp_memory_fault_error(context
, addr
);
126 *((os_context_register_t
*) &((ucontext_t
*) context
)->uc_mcontext
.ss_flags
)
131 os_install_interrupt_handlers(void)
133 undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT
,
138 os_get_runtime_executable_path(int external
)
143 /* when inside call_into_lisp, we will first jump to the stub
144 * and then the stub will jump into the lisp function. Then
145 * the lisp function will return to the stub function and
146 * the stub will return to the call_into_lisp function.
148 void *return_from_lisp_stub
;
150 setup_return_from_lisp_stub (void *addr
)
152 return_from_lisp_stub
= addr
;