X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Flinux-os.lisp;h=2efe31b1c2b9af0e07ee0302ed04b7d0280cbf28;hb=026be5a30130cdb1bc4648fa7daea8e1180a6e46;hp=52610c7cbc004d022a8659ad2764a5ccf46eb3ba;hpb=4f9d842fc0a23394dbf5fc5b1916fe98a3ac7cbe;p=sbcl.git diff --git a/src/code/linux-os.lisp b/src/code/linux-os.lisp index 52610c7..2efe31b 100644 --- a/src/code/linux-os.lisp +++ b/src/code/linux-os.lisp @@ -1,4 +1,4 @@ -;;;; OS interface functions for CMU CL under Linux +;;;; OS interface functions for SBCL under Linux ;;;; This software is part of the SBCL system. See the README file for ;;;; more information. @@ -20,33 +20,20 @@ "Return a string describing the supporting software." (values "Linux")) -(defvar *software-version* nil) - +;;; FIXME: More duplicated logic here vrt. other oses. Abstract into +;;; uname-software-version? (defun software-version () #!+sb-doc "Return a string describing version of the supporting software, or NIL if not available." (or *software-version* (setf *software-version* - (string-trim '(#\newline) - (with-output-to-string (stream) - (sb!ext:run-program "/bin/uname" `("-r") - :output stream)))))) - -(defun os-cold-init-or-reinit () ; KLUDGE: don't know what to do here - (/show "entering linux-os.lisp OS-COLD-INIT-OR-REINIT") - (setf *software-version* nil) - (/show "setting *DEFAULT-PATHNAME-DEFAULTS*") - (setf *default-pathname-defaults* - ;; (temporary value, so that #'PATHNAME won't blow up when - ;; we call it below:) - (make-trivial-default-pathname) - *default-pathname-defaults* - ;; (final value, constructed using #'PATHNAME:) - (pathname (sb!unix:posix-getcwd/))) - (/show "leaving linux-os.lisp OS-COLD-INIT-OR-REINIT")) + (string-trim '(#\newline) + (with-output-to-string (stream) + (sb!ext:run-program "/bin/uname" `("-r") + :output stream)))))) -;;; Return system time, user time and number of page faults. +;;; Return user time, system time, and number of page faults. (defun get-system-info () (multiple-value-bind (err? utime stime maxrss ixrss idrss isrss minflt majflt) @@ -58,7 +45,41 @@ ;;; Return the system page size. (defun get-page-size () - ;; probably should call getpagesize() - ;; FIXME: Or we could just get rid of this, since the uses of it look - ;; disposable. - 4096) + 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))))))))))