1.0.9.44: clean up PV-TABLE constructor
[sbcl.git] / src / runtime / bsd-os.c
index 6d16790..8c97396 100644 (file)
@@ -52,7 +52,8 @@ os_vm_size_t os_vm_page_size;
 #include <sys/sysctl.h>
 #include <string.h>
 #include <sys/stat.h> /* For the stat-family wrappers. */
-
+#include <dirent.h>   /* For the opendir()/readdir() wrappers */
+#include <sys/socket.h> /* For the socket() wrapper */
 static void netbsd_init();
 #endif /* __NetBSD__ */
 
@@ -151,16 +152,17 @@ boolean
 is_valid_lisp_addr(os_vm_address_t addr)
 {
     struct thread *th;
-    if(in_range_p(addr, READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE) ||
-       in_range_p(addr, STATIC_SPACE_START   , STATIC_SPACE_SIZE) ||
-       in_range_p(addr, DYNAMIC_SPACE_START  , dynamic_space_size))
+
+    if (in_range_p(addr, READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE) ||
+        in_range_p(addr, STATIC_SPACE_START, STATIC_SPACE_SIZE) ||
+        in_range_p(addr, DYNAMIC_SPACE_START, dynamic_space_size))
         return 1;
     for_each_thread(th) {
-        if(((os_vm_address_t)th->control_stack_start <= addr) &&
-           (addr < (os_vm_address_t)th->control_stack_end))
+        if (((os_vm_address_t)th->control_stack_start <= addr) &&
+            (addr < (os_vm_address_t)th->control_stack_end))
             return 1;
-        if(in_range_p(addr, (lispobj)th->binding_stack_start,
-                      BINDING_STACK_SIZE))
+        if (in_range_p(addr, (lispobj) th->binding_stack_start,
+                       BINDING_STACK_SIZE))
             return 1;
     }
     return 0;
@@ -206,7 +208,7 @@ memory_fault_handler(int signal, siginfo_t *siginfo, void *void_context
 #ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
             lisp_memory_fault_error(context, fault_addr);
 #else
-            if (!interrupt_maybe_gc_int(signal, siginfo, context)) {
+            if (!maybe_gc(context)) {
                 interrupt_handle_now(signal, siginfo, context);
             }
 #if defined(LISP_FEATURE_DARWIN)
@@ -265,12 +267,14 @@ static void
 sigsegv_handler(int signal, siginfo_t *info, void* void_context)
 {
     os_context_t *context = arch_os_get_context(&void_context);
+#if 0
     unsigned int pc =  (unsigned int *)(*os_context_pc_addr(context));
+#endif
     os_vm_address_t addr;
 
-    addr = arch_get_bad_addr(signal,info,context);
-    if(!interrupt_maybe_gc(signal, info, context))
-        if(!handle_guard_page_triggered(context,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);
@@ -327,24 +331,44 @@ The system may fail to start.\n",
     }
 }
 
-/* The stat() routines in NetBSD's C library are compatibility
-   wrappers for some very old version of the stat buffer structure.
-   Programs must be processed by the C toolchain in order to get an
-   up-to-date definition of the stat() routine.  These wrappers are
-   used only in sb-posix, as of 2006-10-15. -- RMK */
-int _stat(const char *path, struct stat *sb) {
-  return (stat(path, sb));
+/* 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
+_lstat(const char *path, struct stat *sb)
+{
+    return lstat(path, sb);
 }
-
-int _fstat(int fd, struct stat *sb) {
-  return (fstat(fd, 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__