Remove useless cross-compiler output
[sbcl.git] / src / code / linux-os.lisp
bloba44775ad378c85f2988c1d730d3b339b622b834a
1 ;;;; OS interface functions for SBCL under Linux
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
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.
12 (in-package "SB!SYS")
14 ;;; Check that target machine features are set up consistently with
15 ;;; this file.
16 #!-linux (error "missing :LINUX feature")
18 (defun software-type ()
19 "Return a string describing the supporting software."
20 "Linux")
22 ;;; FIXME: More duplicated logic here vrt. other oses. Abstract into
23 ;;; uname-software-version?
24 (defun software-version ()
25 "Return a string describing version of the supporting software, or NIL
26 if not available."
27 (or *software-version*
28 (setf *software-version*
29 (string-trim '(#\newline)
30 (sb!kernel:with-simple-output-to-string (stream)
31 (run-program "/bin/uname" `("-r")
32 :output stream))))))
34 ;;; Return user time, system time, and number of page faults.
35 (defun get-system-info ()
36 (multiple-value-bind
37 (err? utime stime maxrss ixrss idrss isrss minflt majflt)
38 (sb!unix:unix-getrusage sb!unix:rusage_self)
39 (declare (ignore maxrss ixrss idrss isrss minflt))
40 (unless err? ; FIXME: nonmnemonic (reversed) name for ERR?
41 (error "Unix system call getrusage failed: ~A." (strerror utime)))
42 (values utime stime majflt)))
44 ;;; Return the system page size.
45 (defun get-page-size ()
46 sb!c:*backend-page-bytes*)
48 ;;; support for CL:MACHINE-VERSION defined OAOO elsewhere
49 (defun get-machine-version ()
50 (or
51 #!+(and mips little-endian)
52 "little-endian"
53 #!+(and mips big-endian)
54 "big-endian"
55 (let ((marker
56 ;; hoping "cpu" exists and gives something useful in
57 ;; all relevant Linuxen...
59 ;; from Lars Brinkhoff sbcl-devel 26 Jun 2003:
60 ;; I examined different versions of Linux/PPC at
61 ;; http://lxr.linux.no/ (the file that outputs
62 ;; /proc/cpuinfo is arch/ppc/kernel/setup.c, if
63 ;; you want to check), and all except 2.0.x
64 ;; seemed to do the same thing as far as the
65 ;; "cpu" field is concerned, i.e. it always
66 ;; starts with the (C-syntax) string "cpu\t\t: ".
67 #!+ppc "cpu"
68 ;; The field "model name" exists on kernel 2.4.21-rc6-ac1
69 ;; anyway, with values e.g.
70 ;; "AMD Athlon(TM) XP 2000+"
71 ;; "Intel(R) Pentium(R) M processor 1300MHz"
72 ;; which seem comparable to the information in the example
73 ;; in the MACHINE-VERSION page of the ANSI spec.
74 #!+(or x86 x86-64) "model name"
75 #!+(or arm arm64) "Processor"))
76 (when marker
77 (with-open-file (stream "/proc/cpuinfo"
78 ;; Even on Linux it's an option to build
79 ;; kernels without /proc filesystems, so
80 ;; degrade gracefully.
81 :if-does-not-exist nil)
82 (loop with line while (setf line (read-line stream nil))
83 when (eql (search marker line) 0)
84 return (string-trim " " (subseq line (1+ (position #\: line))))))))))