From: Juho S. <js...@us...> - 2006-02-21 23:40:52
|
Update of /cvsroot/sbcl/sbcl/src/runtime In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20507/src/runtime Modified Files: bsd-os.c linux-os.c sunos-os.c Log Message: 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). Index: bsd-os.c =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/bsd-os.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- bsd-os.c 21 Feb 2006 22:59:32 -0000 1.35 +++ bsd-os.c 21 Feb 2006 23:40:36 -0000 1.36 @@ -53,6 +53,7 @@ #ifdef __FreeBSD__ #include <sys/sysctl.h> +#include <osreldate.h> static void freebsd_init(); #endif /* __FreeBSD__ */ @@ -339,35 +340,35 @@ #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: linux-os.c =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/linux-os.c,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- linux-os.c 5 Feb 2006 22:03:00 -0000 1.59 +++ linux-os.c 21 Feb 2006 23:40:36 -0000 1.60 @@ -377,7 +377,7 @@ 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: sunos-os.c =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/sunos-os.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- sunos-os.c 5 Feb 2006 22:03:00 -0000 1.16 +++ sunos-os.c 21 Feb 2006 23:40:36 -0000 1.17 @@ -245,5 +245,12 @@ 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); } |