X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Flinux-os.lisp;h=2efe31b1c2b9af0e07ee0302ed04b7d0280cbf28;hb=0f3a5f2e8886d18d0b4f6485c38a42be629422ae;hp=134ca54347a26746c455713236f41f679371250b;hpb=2db410feb35e7e30c95af8f20f67e6177fa92488;p=sbcl.git diff --git a/src/code/linux-os.lisp b/src/code/linux-os.lisp index 134ca54..2efe31b 100644 --- a/src/code/linux-os.lisp +++ b/src/code/linux-os.lisp @@ -46,3 +46,40 @@ ;;; Return the system page size. (defun get-page-size () sb!c:*backend-page-bytes*) + +;;; support for CL:MACHINE-VERSION defined OAOO elsewhere +(defun get-machine-version () + (or + #!+(and mips little-endian) + "little-endian" + #!+(and mips big-endian) + "big-endian" + (let ((marker + ;; hoping "cpu" exists and gives something useful in + ;; all relevant Linuxen... + ;; + ;; from Lars Brinkhoff sbcl-devel 26 Jun 2003: + ;; I examined different versions of Linux/PPC at + ;; http://lxr.linux.no/ (the file that outputs + ;; /proc/cpuinfo is arch/ppc/kernel/setup.c, if + ;; you want to check), and all except 2.0.x + ;; seemed to do the same thing as far as the + ;; "cpu" field is concerned, i.e. it always + ;; starts with the (C-syntax) string "cpu\t\t: ". + #!+ppc "cpu" + ;; 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. + #!+(or x86 x86-64) "model name")) + (when marker + (with-open-file (stream "/proc/cpuinfo" + ;; Even on Linux it's an option to build + ;; kernels without /proc filesystems, so + ;; degrade gracefully. + :if-does-not-exist nil) + (loop with line while (setf line (read-line stream nil)) + when (eql (search marker line) 0) + return (string-trim " " (subseq line (1+ (position #\: line))))))))))