From 844e8597d7ca9fda207ab2358ee027db86f6c120 Mon Sep 17 00:00:00 2001 From: Juho Snellman Date: Tue, 21 Feb 2006 23:40:36 +0000 Subject: [PATCH] 0.9.9.37: 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 | 45 +++++++++++++++++++++++---------------------- src/runtime/linux-os.c | 2 +- src/runtime/sunos-os.c | 9 ++++++++- version.lisp-expr | 2 +- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/runtime/bsd-os.c b/src/runtime/bsd-os.c index 9b496c3..0b2a338 100644 --- a/src/runtime/bsd-os.c +++ b/src/runtime/bsd-os.c @@ -53,6 +53,7 @@ static void netbsd_init(); #ifdef __FreeBSD__ #include +#include 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 */ diff --git a/src/runtime/linux-os.c b/src/runtime/linux-os.c index 51bef4d..345ff48 100644 --- a/src/runtime/linux-os.c +++ b/src/runtime/linux-os.c @@ -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 diff --git a/src/runtime/sunos-os.c b/src/runtime/sunos-os.c index 1f2581b..48623d3 100644 --- a/src/runtime/sunos-os.c +++ b/src/runtime/sunos-os.c @@ -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); } diff --git a/version.lisp-expr b/version.lisp-expr index 047b3ac..9ee4e44 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -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" -- 1.7.10.4