From b8d578ff919a22600262af9474203474693bedd4 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Sun, 20 Feb 2011 10:33:43 +0000 Subject: [PATCH] 1.0.46.6: better MACHINE-VERSION on Darwin Patch by Josh Elsasser. Use machdep.cpu.brand_string instead of hw.model. lp#668332 --- NEWS | 1 + src/code/bsd-os.lisp | 33 +++++++++++++++++++++++++++++---- tools-for-build/ldso-stubs.lisp | 2 ++ version.lisp-expr | 2 +- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 7cb8194..ccb69b6 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ changes relative to sbcl-1.0.46: * enhancement: --script muffles style-warnings and compiler notes. (lp#677779) * enhancement: redefinition warnings for macros from different files. (lp#434657) + * enhancement: better MACHINE-VERSION on Darwin x86 and x86-64. (lp#668332) * bug fix: SB-DEBUG:BACKTRACE-AS-LIST guards against potentially leaking stack-allocated values out of their dynamic-extent. (lp#310175) * bug fix: attempts to use SB-SPROF for wallclock profiling on threaded diff --git a/src/code/bsd-os.lisp b/src/code/bsd-os.lisp index dca2b6f..1b1633d 100644 --- a/src/code/bsd-os.lisp +++ b/src/code/bsd-os.lisp @@ -20,6 +20,14 @@ (newp (* t)) (newlen sb!unix:size-t)) +#!+darwin +(define-alien-routine ("sysctlbyname" %sysctlbyname) int + (name c-string) + (oldp (* t)) + (oldlenp (* sb!unix:size-t)) + (newp (* t)) + (newlen sb!unix:size-t)) + (defun sysctl (type &rest name) #!+sb-doc "Retrieves an integer or string value with the given name." @@ -46,6 +54,25 @@ (free-alien result) (sb!unix::newcharstar-string result))))))))) +#!+darwin +(defun sysctlbyname (type name) + #!+sb-doc + "Retrieves an integer or string value with the given name." + (with-alien ((result-len sb!unix:size-t)) + (ecase type + (:int + (with-alien ((result int)) + (setf result-len (alien-size int :bytes)) + (unless (minusp (%sysctlbyname name (addr result) + (addr result-len) nil 0)) + result))) + (:str + (unless (minusp (%sysctlbyname name nil (addr result-len) nil 0)) + (with-alien ((result (* char) (make-alien char result-len))) + (if (minusp (%sysctlbyname name result (addr result-len) nil 0)) + (free-alien result) + (sb!unix::newcharstar-string result)))))))) + (defun software-type () #!+sb-doc "Return a string describing the supporting software." @@ -76,7 +103,5 @@ ;;; support for CL:MACHINE-VERSION defined OAOO elsewhere (defun get-machine-version () - ;; FIXME: on Darwin we would prefer machdep.cpu.brand_string -- but I can't - ;; seem to grab it using sysctl() -- but the shell tool finds it. When - ;; someone has the time, check out how Darwin shell sysctl does it. - (sysctl :str ctl-hw hw-model)) + (or #!+darwin (sysctlbyname :str "machdep.cpu.brand_string") + (sysctl :str ctl-hw hw-model))) diff --git a/tools-for-build/ldso-stubs.lisp b/tools-for-build/ldso-stubs.lisp index 471859e..f698e79 100644 --- a/tools-for-build/ldso-stubs.lisp +++ b/tools-for-build/ldso-stubs.lisp @@ -332,6 +332,8 @@ ldso_stub__ ## fct: ; \\ "dlsym") #!+bsd '("sysctl") + #!+darwin + '("sysctlbyname") #!+os-provides-dladdr '("dladdr") #!-sunos ;; !defined(SVR4) diff --git a/version.lisp-expr b/version.lisp-expr index 2095a60..7e0791f 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -20,4 +20,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".) -"1.0.46.5" +"1.0.46.6" -- 1.7.10.4