#ifdef __NetBSD__
netbsd_init();
-#endif /* __NetBSD__ */
-#ifdef __FreeBSD__
+#elif defined(__FreeBSD__)
freebsd_init();
-#endif /* __FreeBSD__ */
+#endif
}
sigset_t *
* The GENCGC needs to be hooked into whatever signal is raised for
* page fault on this OS.
*/
-static void
+
+void
memory_fault_handler(int signal, siginfo_t *siginfo, void *void_context
#if defined(LISP_FEATURE_FREEBSD) && defined(LISP_FEATURE_X86_64)
/* FreeBSD/amd64 stores fault address only in undocumented 4th arg. */
}
}
+#if defined(LISP_FEATURE_MACH_EXCEPTION_HANDLER)
+void
+mach_error_memory_fault_handler(int signal, siginfo_t *siginfo, void *void_context) {
+ lose("Unhandled memory fault. Exiting.");
+}
+#endif
+
void
os_install_interrupt_handlers(void)
{
SHOW("os_install_interrupt_handlers()/bsd-os/defined(GENCGC)");
+#if defined(LISP_FEATURE_MACH_EXCEPTION_HANDLER)
+ undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT,
+ mach_error_memory_fault_handler);
+#else
undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT,
#ifdef LISP_FEATURE_FREEBSD
(__siginfohandler_t *)
#endif
memory_fault_handler);
#endif
+#endif
#ifdef LISP_FEATURE_SB_THREAD
undoably_install_low_level_interrupt_handler(SIG_INTERRUPT_THREAD,
sig_stop_for_gc_handler);
#endif
#endif
-
SHOW("leaving os_install_interrupt_handlers()");
}
return NULL;
return copied_string(path);
}
-#else /* Not DARWIN or FREEBSD */
+#elif defined(LISP_FEATURE_NETBSD)
+char *
+os_get_runtime_executable_path()
+{
+ struct stat sb;
+ char *path = strdup("/proc/curproc/file");
+ if (path && ((stat(path, &sb)) == 0))
+ return path;
+ else {
+ fprintf(stderr, "Couldn't stat /proc/curproc/file; is /proc mounted?\n");
+ return NULL;
+ }
+}
+#else /* Not DARWIN or FREEBSD or NETBSD */
char *
os_get_runtime_executable_path()
{