50ae48e583226985b2bea034b90970d5f90e459a
[sbcl.git] / src / code / linux-os.lisp
1 ;;;; OS interface functions for CMU CL under Linux
2
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.
11
12 (in-package "SB!SYS")
13
14 ;;; Check that target machine features are set up consistently with
15 ;;; this file.
16 #!-linux (error "missing :LINUX feature")
17
18 (defun software-type ()
19   #!+sb-doc
20   "Return a string describing the supporting software."
21   (values "Linux"))
22
23 (defvar *software-version* nil)
24
25 (defun software-version ()
26   #!+sb-doc
27   "Return a string describing version of the supporting software, or NIL
28   if not available."
29   (or *software-version*
30       (setf *software-version*
31             (string-trim '(#\newline)
32                          (with-output-to-string (stream)
33                            (sb!ext:run-program "/bin/uname" `("-r")
34                                                :output stream))))))
35
36 ;;; OS-COLD-INIT-OR-REINIT initializes our operating-system interface.
37 ;;; It sets the values of the global port variables to what they
38 ;;; should be and calls the functions that set up the argument blocks
39 ;;; for the server interfaces.
40 (defun os-cold-init-or-reinit () ; KLUDGE: don't know what to do here
41   #!+sparc ;; Can't use #x20000000 thru #xDFFFFFFF, but mach tries to let us.
42   (sb!sys:allocate-system-memory-at (sb!sys:int-sap #x20000000) #xc0000000))
43
44 ;;; Return system time, user time and number of page faults.
45 (defun get-system-info ()
46   (multiple-value-bind
47       (err? utime stime maxrss ixrss idrss isrss minflt majflt)
48       (sb!unix:unix-getrusage sb!unix:rusage_self)
49     (declare (ignore maxrss ixrss idrss isrss minflt))
50     (unless err? ; FIXME: nonmnemonic (reversed) name for ERR?
51       (error "Unix system call getrusage failed: ~A."
52              (sb!unix:get-unix-error-msg utime)))
53
54     (values utime stime majflt)))
55
56 ;;; Return the system page size.
57 (defun get-page-size ()
58   ;; probably should call getpagesize()
59   ;; FIXME: Or we could just get rid of this, since the uses of it look
60   ;; disposable.
61   4096)