From 1b15661b8e51917d9738ec091d3498860889e1b1 Mon Sep 17 00:00:00 2001 From: Juho Snellman Date: Sun, 5 Feb 2006 22:22:01 +0000 Subject: [PATCH] 0.9.9.13: Support for finding the executable path on FreeBSD. (thanks to NIIMI Satoshi) --- NEWS | 2 +- src/runtime/bsd-os.c | 36 +++++++++++++++++++++++++++++++++++- version.lisp-expr | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index daa7a7a..4f2c743 100644 --- a/NEWS +++ b/NEWS @@ -3,7 +3,7 @@ changes in sbcl-0.9.10 relative to sbcl-0.9.9: * new feature: new SAVE-LISP-AND-DIE keyword argument :EXECUTABLE can be used for bundling the runtime and the core file into one executable binary. This feature is not currently supported on all SBCL - platforms. (thanks to James Bielman) + platforms. (thanks to James Bielman and NIIMI Satoshi) * minor incompatible change: the method by which SBCL finds its contributed modules has changed; it no longer relies on symbolic links from an $SBCL_HOME/systems directory, but searches directly diff --git a/src/runtime/bsd-os.c b/src/runtime/bsd-os.c index 9b25e7b..7e9d51f 100644 --- a/src/runtime/bsd-os.c +++ b/src/runtime/bsd-os.c @@ -336,7 +336,41 @@ int arch_os_thread_cleanup(struct thread *thread) { } #endif -#ifndef LISP_FEATURE_DARWIN /* defined in ppc-darwin-os.c instead */ +#ifdef LISP_FEATURE_DARWIN +/* defined in ppc-darwin-os.c instead */ +#elif defined(LISP_FEATURE_FREEBSD) +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 (strcmp(path, "unknown") == 0) + return NULL; +#endif + return copied_string(path); +} +#else /* Not DARWIN or FREEBSD */ char * os_get_runtime_executable_path() { diff --git a/version.lisp-expr b/version.lisp-expr index c7c54a5..6a70567 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.12" +"0.9.9.13" -- 1.7.10.4