0.9.9.12:
[sbcl.git] / src / runtime / bsd-os.c
index 3199a86..9b25e7b 100644 (file)
@@ -51,13 +51,23 @@ os_vm_size_t os_vm_page_size;
 static void netbsd_init();
 #endif /* __NetBSD__ */
 
-void os_init(void)
+#ifdef __FreeBSD__
+#include <sys/sysctl.h>
+
+static void freebsd_init();
+#endif /* __FreeBSD__ */
+
+void
+os_init(char *argv[], char *envp[])
 {
     os_vm_page_size = getpagesize();
 
 #ifdef __NetBSD__
     netbsd_init();
 #endif /* __NetBSD__ */
+#ifdef __FreeBSD__
+    freebsd_init();
+#endif /* __FreeBSD__ */
 }
 
 int *os_context_pc_addr(os_context_t *context)
@@ -125,7 +135,7 @@ os_map(int fd, int offset, os_vm_address_t addr, os_vm_size_t len)
 
     if (addr == MAP_FAILED) {
         perror("mmap");
-        lose("unexpected mmap(..) failure");
+        lose("unexpected mmap(..) failure\n");
     }
 
     return addr;
@@ -203,6 +213,10 @@ os_install_interrupt_handlers(void)
     SHOW("os_install_interrupt_handlers()/bsd-os/defined(GENCGC)");
     undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT,
                                                  memory_fault_handler);
+#ifdef SIG_MEMORY_FAULT2
+    undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT2,
+                                                 memory_fault_handler);
+#endif
     SHOW("leaving os_install_interrupt_handlers()");
 }
 
@@ -229,6 +243,10 @@ os_install_interrupt_handlers(void)
     SHOW("os_install_interrupt_handlers()/bsd-os/!defined(GENCGC)");
     undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT,
                                                  sigsegv_handler);
+#ifdef SIG_MEMORY_FAULT2
+    undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT2,
+                                                 sigsegv_handler);
+#endif
 }
 
 #endif /* defined GENCGC */
@@ -270,6 +288,29 @@ The system may fail to start.\n",
     }
 }
 #endif /* __NetBSD__ */
+
+#ifdef __FreeBSD__
+static void freebsd_init()
+{
+    /* Quote from sbcl-devel (NIIMI Satoshi): "Some OSes, like FreeBSD
+     * 4.x with GENERIC kernel, does not enable SSE support even on
+     * SSE capable CPUs". Detect this situation and skip the
+     * fast_bzero sse/base selection logic that's normally done in
+     * x86-assem.S.
+     */
+#ifdef LISP_FEATURE_X86
+    size_t len;
+    int instruction_sse;
+
+    len = sizeof(instruction_sse);
+    if (sysctlbyname("hw.instruction_sse", &instruction_sse, &len, NULL, 0) == 0
+        && instruction_sse != 0) {
+        /* Use the SSE detector */
+        fast_bzero_pointer = fast_bzero_detect;
+    }
+#endif /* LISP_FEATURE_X86 */
+}
+#endif /* __FreeBSD__ */
 \f
 /* threads */
 
@@ -294,3 +335,11 @@ int arch_os_thread_cleanup(struct thread *thread) {
     return 1;                  /* success */
 }
 #endif
+
+#ifndef LISP_FEATURE_DARWIN   /* defined in ppc-darwin-os.c instead */
+char *
+os_get_runtime_executable_path()
+{
+    return NULL;
+}
+#endif