+#else /* Currently PPC/Darwin/Cheney only */
+
+static void
+sigsegv_handler(int signal, siginfo_t *info, void* void_context)
+{
+ os_context_t *context = arch_os_get_context(&void_context);
+ unsigned int pc = (unsigned int *)(*os_context_pc_addr(context));
+ os_vm_address_t addr;
+
+ addr = arch_get_bad_addr(signal, info, context);
+ if (!cheneygc_handle_wp_violation(context, addr))
+ if (!handle_guard_page_triggered(context, addr))
+ interrupt_handle_now(signal, info, context);
+ /* Work around G5 bug; fix courtesy gbyers */
+ DARWIN_FIX_CONTEXT(context);
+}
+
+void
+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 */
+
+#ifdef __NetBSD__
+static void netbsd_init()
+{
+ struct rlimit rl;
+ int mib[2], osrev;
+ size_t len;
+
+ /* Are we running on a sufficiently functional kernel? */
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_OSREV;
+
+ len = sizeof(osrev);
+ sysctl(mib, 2, &osrev, &len, NULL, 0);
+
+ /* If we're older than 2.0... */
+ if (osrev < 200000000) {
+ fprintf(stderr, "osrev = %d (needed at least 200000000).\n", osrev);
+ lose("NetBSD kernel too old to run sbcl.\n");
+ }
+
+ /* NetBSD counts mmap()ed space against the process's data size limit,
+ * so yank it up. This might be a nasty thing to do? */
+ getrlimit (RLIMIT_DATA, &rl);
+ /* Amazingly for such a new port, the provenance and meaning of
+ this number are unknown. It might just mean REALLY_BIG_LIMIT,
+ or possibly it should be calculated from dynamic space size.
+ -- CSR, 2004-04-08 */
+ rl.rlim_cur = 1073741824;
+ if (setrlimit (RLIMIT_DATA, &rl) < 0) {
+ fprintf (stderr,
+ "RUNTIME WARNING: unable to raise process data size limit:\n\
+ %s.\n\
+The system may fail to start.\n",
+ strerror(errno));
+ }
+}
+
+/* Various routines in NetBSD's C library are compatibility wrappers
+ for old versions. Programs must be processed by the C toolchain in
+ order to get up-to-date definitions of such routines. */
+/* The stat-family, opendir, and readdir are used only in sb-posix, as
+ of 2007-01-16. -- RMK */
+int
+_stat(const char *path, struct stat *sb)
+{
+ return stat(path, sb);
+}
+int
+_lstat(const char *path, struct stat *sb)
+{
+ return lstat(path, sb);
+}
+int
+_fstat(int fd, struct stat *sb)
+{
+ return fstat(fd, sb);
+}
+
+DIR *
+_opendir(const char *filename)
+{
+ return opendir(filename);
+}
+struct dirent *
+_readdir(DIR *dirp)
+{
+ return readdir(dirp);
+}
+
+/* Used in sb-bsd-sockets. */
+int
+_socket(int domain, int type, int protocol)
+{
+ return socket(domain, type, protocol);
+}
+#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__ */
+
+#ifdef LISP_FEATURE_DARWIN
+/* defined in ppc-darwin-os.c instead */
+#elif defined(LISP_FEATURE_FREEBSD)
+#ifndef KERN_PROC_PATHNAME
+#define KERN_PROC_PATHNAME 12
+#endif
+
+extern int getosreldate(void);
+
+char *
+os_get_runtime_executable_path()
+{
+ char path[PATH_MAX + 1];
+
+ if (getosreldate() >= 600024) {
+ /* KERN_PROC_PATHNAME is available */
+ size_t len = PATH_MAX + 1;
+ int mib[4];
+
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_PATHNAME;
+ mib[3] = -1;
+ if (sysctl(mib, 4, &path, &len, NULL, 0) != 0)
+ return NULL;
+ } else {
+ int size;
+ size = readlink("/proc/curproc/file", path, sizeof(path) - 1);
+ if (size < 0)
+ return NULL;
+ path[size] = '\0';
+ }
+ if (strcmp(path, "unknown") == 0)
+ return NULL;
+ return copied_string(path);
+}
+#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()
+{
+ return NULL;
+}
+#endif