1.0.3.46: De-pessimized x86 sub-byte DATA-VECTOR-SET/* VOPs.
[sbcl.git] / src / runtime / bsd-os.c
index cfd7c31..1b01396 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__ */
 
@@ -327,24 +328,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__
@@ -406,7 +427,20 @@ os_get_runtime_executable_path()
         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()
 {