X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fbsd-os.c;h=7e9d51f3b4c1e93a071db81da56e4aa769621434;hb=e6aef26131543d369edf107df8fb94053646d1f4;hp=2c84a10f59cc4b262a14d0a5f442410c84ba26ec;hpb=e76b59734a46d1fdd9cbb4d7c561f10f5d8d29fa;p=sbcl.git diff --git a/src/runtime/bsd-os.c b/src/runtime/bsd-os.c index 2c84a10..7e9d51f 100644 --- a/src/runtime/bsd-os.c +++ b/src/runtime/bsd-os.c @@ -299,16 +299,14 @@ static void freebsd_init() * x86-assem.S. */ #ifdef LISP_FEATURE_X86 - extern void fast_bzero_base(void *, size_t); - extern void (*fast_bzero_pointer)(void *, size_t); size_t len; int instruction_sse; len = sizeof(instruction_sse); - if (sysctlbyname("hw.instruction_sse", &instruction_sse, &len, NULL, 0) != 0 - || instruction_sse == 0) { - /* Use the non-SSE version*/ - fast_bzero_pointer = fast_bzero_base; + if (sysctlbyname("hw.instruction_sse", &instruction_sse, &len, NULL, 0) == 0 + && instruction_sse != 0) { + /* Use the SSE detector */ + fast_bzero_pointer = fast_bzero_detect; } #endif /* LISP_FEATURE_X86 */ } @@ -337,3 +335,45 @@ int arch_os_thread_cleanup(struct thread *thread) { return 1; /* success */ } #endif + +#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() +{ + return NULL; +} +#endif