1 ;;;; OS interface functions for SBCL under Linux
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
14 ;;; Check that target machine features are set up consistently with
16 #!-linux
(error "missing :LINUX feature")
18 (defun software-type ()
20 "Return a string describing the supporting software."
23 ;;; FIXME: More duplicated logic here vrt. other oses. Abstract into
24 ;;; uname-software-version?
25 (defun software-version ()
27 "Return a string describing version of the supporting software, or NIL
29 (or *software-version
*
30 (setf *software-version
*
31 (string-trim '(#\newline
)
32 (sb!kernel
:with-simple-output-to-string
(stream)
33 (run-program "/bin/uname" `("-r")
36 ;;; Return user time, system time, and number of page faults.
37 (defun get-system-info ()
39 (err? utime stime maxrss ixrss idrss isrss minflt majflt
)
40 (sb!unix
:unix-getrusage sb
!unix
:rusage_self
)
41 (declare (ignore maxrss ixrss idrss isrss minflt
))
42 (unless err?
; FIXME: nonmnemonic (reversed) name for ERR?
43 (error "Unix system call getrusage failed: ~A." (strerror utime
)))
44 (values utime stime majflt
)))
46 ;;; Return the system page size.
47 (defun get-page-size ()
48 sb
!c
:*backend-page-bytes
*)
50 ;;; support for CL:MACHINE-VERSION defined OAOO elsewhere
51 (defun get-machine-version ()
53 #!+(and mips little-endian
)
55 #!+(and mips big-endian
)
58 ;; hoping "cpu" exists and gives something useful in
59 ;; all relevant Linuxen...
61 ;; from Lars Brinkhoff sbcl-devel 26 Jun 2003:
62 ;; I examined different versions of Linux/PPC at
63 ;; http://lxr.linux.no/ (the file that outputs
64 ;; /proc/cpuinfo is arch/ppc/kernel/setup.c, if
65 ;; you want to check), and all except 2.0.x
66 ;; seemed to do the same thing as far as the
67 ;; "cpu" field is concerned, i.e. it always
68 ;; starts with the (C-syntax) string "cpu\t\t: ".
70 ;; The field "model name" exists on kernel 2.4.21-rc6-ac1
71 ;; anyway, with values e.g.
72 ;; "AMD Athlon(TM) XP 2000+"
73 ;; "Intel(R) Pentium(R) M processor 1300MHz"
74 ;; which seem comparable to the information in the example
75 ;; in the MACHINE-VERSION page of the ANSI spec.
76 #!+(or x86 x86-64
) "model name"
79 (with-open-file (stream "/proc/cpuinfo"
80 ;; Even on Linux it's an option to build
81 ;; kernels without /proc filesystems, so
82 ;; degrade gracefully.
83 :if-does-not-exist nil
)
84 (loop with line while
(setf line
(read-line stream nil
))
85 when
(eql (search marker line
) 0)
86 return
(string-trim " " (subseq line
(1+ (position #\
: line
))))))))))