How about something like this?
Index: src/code/ppc-vm.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/ppc-vm.lisp,v
retrieving revision 1.6
diff -u -r1.6 ppc-vm.lisp
--- src/code/ppc-vm.lisp 10 Oct 2002 16:55:07 -0000 1.6
+++ src/code/ppc-vm.lisp 25 Jun 2003 18:04:13 -0000
@@ -14,9 +14,25 @@
"Returns a string describing the type of the local machine."
"PowerPC")
+(defun get-machine-version ()
+ #!+linux
+ (with-open-file (stream "/proc/cpuinfo" :if-does-not-exist "who-knows?")
+ (loop
+ (let ((line (read-line stream nil)))
+ (when (null line)
+ (return-from get-machine-version "who-knows?"))
+ (when (eql (search "cpu" line) 0)
+ (return-from get-machine-version
+ (string-trim " " (subseq line (1+ (position #\: line)))))))))
+ #!-linux
+ "who-knows?")
+
+(defvar *machine-version* nil)
+
(defun machine-version ()
"Returns a string describing the version of the local machine."
- "who-knows?")
+ (or *machine-version*
+ (setf *machine-version* (get-machine-version))))
On Thu, Jun 26, 2003 at 10:11:10AM -0500, William Harold Newman wrote:
> > (defun get-machine-version ()
> > #!+linux
> > (with-open-file (stream "/proc/cpuinfo" :if-does-not-exist nil)
> > (loop with line while (setf line (read-line stream nil))
> > when (eql (search "cpu" line) 0)
> > return (string-trim " " (subseq line (1+ (position #\: line))))))
> > #!-linux
> > nil)
> >
> > (defvar *machine-version* :unset)
> >
> > (defun machine-version ()
> > "Returns a string describing the version of the local machine."
> > (if (eq *machine-version* :unset)
> > (setf *machine-version* (get-machine-version))
> > *machine-version*))
>
> I don't plan to do anything with the PPC code unless someone sends me
> a nice PPC machine to play with, or at least a killer PPC shell
> account, since I only have X86s and I dislike checking in code I can't
> test directly. However, other maintainers have PPCs; and I myself plan
> to borrow the basic idea for the x86 implementation of
> MACHINE-VERSION.
After offers on #lisp to test it, I decided to change the PPC code as
well as the X86 code, and now both are in CVS.
> Thank you.
again
--
William Harold Newman <william.newman@...>
Saying that taste is just personal preference is a good way to prevent
disputes. The trouble is, it's not true. You feel this when you start
to design things. -- <>
PGP key fingerprint 85 CE 1C BA 79 8D 51 8C B9 25 FB EE E0 C3 E5 7C
William Harold Newman <william.newman@...> writes:
> After offers on #lisp to test it, I decided to change the PPC code as
> well as the X86 code, and now both are in CVS.
Excellent!
> + ;; The field "model name" exists on kernel 2.4.21-rc6-ac1
> + ;; anyway, with values e.g.
> + ;; "AMD Athlon(TM) XP 2000+"
> + ;; "Intel(R) Pentium(R) M processor 1300MHz"
> + ;; which seem comparable to the information in the example
> + ;; in the MACHINE-VERSION page of the ANSI spec.
According to
there was no "model name" field in ancient Linux version, but it
existed in kernels considered quite old now:
.
Lars Brinkhoff <lars@...> writes:
> William Harold Newman <william.newman@...> writes:
>> After offers on #lisp to test it, I decided to change the PPC code as
>> well as the X86 code, and now both are in CVS.
>
> Excellent!
You know, something just occurred to me about this; I think the
uname(2) system call is defined by POSIX to operate on struct utsname
objects that contain a machine field; it had "sun4u" and "i686" on the
sparc/SunOS and x86/Linux machines I just tried it on. If we can live
with the loss of detail, we could make MACHINE-VERSION use uname()
instead, which would enable it to be a general, not machine-specific,
function.
Cheers,
Christophe
-- +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge)