0.9.9.37:
authorJuho Snellman <jsnell@iki.fi>
Tue, 21 Feb 2006 23:40:36 +0000 (23:40 +0000)
committerJuho Snellman <jsnell@iki.fi>
Tue, 21 Feb 2006 23:40:36 +0000 (23:40 +0000)
        Implement os_get_runtime_exexutable_path() on Solaris
        (patch by Daisuke Homma).

        Move the os_get_runtime_exexutable_path() FreeBSD version
        check from compile-time to runtime (patch by NIIMI Satoshi).

src/runtime/bsd-os.c
src/runtime/linux-os.c
src/runtime/sunos-os.c
version.lisp-expr

index 9b496c3..0b2a338 100644 (file)
@@ -53,6 +53,7 @@ static void netbsd_init();
 
 #ifdef __FreeBSD__
 #include <sys/sysctl.h>
+#include <osreldate.h>
 
 static void freebsd_init();
 #endif /* __FreeBSD__ */
@@ -339,35 +340,35 @@ int arch_os_thread_cleanup(struct thread *thread) {
 #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
+
 char *
 os_get_runtime_executable_path()
 {
     char path[PATH_MAX + 1];
-    /* Defined on FreeBSD 6 and later. -- JES, 2006-02-06. */
-#ifdef KERN_PROC_PATHNAME
-    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)
-        /* FIXME: Should we rather fall back into the /proc/-based
-         * code below, so that an SBCL executable core made on
-         * FreeBSD 6 would have at least some chance of working on
-         * FreeBSD 4? -- JES, 2006-02-06.
-         */
-        return NULL;
-#else
-    int size;
-    size = readlink("/proc/curproc/file", path, sizeof(path) - 1);
-    if (size < 0)
-        return NULL;
-    path[size] = '\0';
+    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;
-#endif
     return copied_string(path);
 }
 #else /* Not DARWIN or FREEBSD */
index 51bef4d..345ff48 100644 (file)
@@ -377,7 +377,7 @@ os_get_runtime_executable_path()
     char path[PATH_MAX + 1];
     int size;
 
-    size = readlink("/proc/self/exe", path, sizeof(path));
+    size = readlink("/proc/self/exe", path, sizeof(path)-1);
     if (size < 0)
         return NULL;
     else
index 1f2581b..48623d3 100644 (file)
@@ -245,5 +245,12 @@ os_install_interrupt_handlers()
 char *
 os_get_runtime_executable_path()
 {
-    return NULL;
+    int ret;
+    char path[] = "/proc/self/object/a.out";
+
+    ret = access(path, R_OK);
+    if (ret == -1)
+        return NULL;
+
+    return copied_string(path);
 }
index 047b3ac..9ee4e44 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.9.9.36"
+"0.9.9.37"