Initial revision
[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 (file-comment
15   "$Header$")
16
17 ;;; Check that target machine features are set up consistently with this file.
18 #!-linux (error "missing :LINUX feature")
19
20 (defun software-type ()
21   #!+sb-doc
22   "Return a string describing the supporting software."
23   (values "Linux"))
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   ;; The old CMU CL code is NILed out here. If we wanted to do this, we should
30   ;; probably either use "/bin/uname -r", but since in any case we don't have
31   ;; RUN-PROGRAM working right now (sbcl-0.6.4), for now we just punt,
32   ;; returning NIL.
33   #+nil
34   (string-trim '(#\newline)
35                (with-output-to-string (stream)
36                  (run-program "/usr/cs/etc/version" ; Site dependent???
37                               nil :output stream)))
38   nil)
39
40 ;;; OS-COLD-INIT-OR-REINIT initializes our operating-system interface.
41 ;;; It sets the values of the global port variables to what they
42 ;;; should be and calls the functions that set up the argument blocks
43 ;;; for the server interfaces.
44 (defun os-cold-init-or-reinit () ; KLUDGE: don't know what to do here
45   #!+sparc ;; Can't use #x20000000 thru #xDFFFFFFF, but mach tries to let us.
46   (sb!sys:allocate-system-memory-at (sb!sys:int-sap #x20000000) #xc0000000))
47
48 ;;; Return system time, user time and number of page faults.
49 (defun get-system-info ()
50   (multiple-value-bind
51       (err? utime stime maxrss ixrss idrss isrss minflt majflt)
52       (sb!unix:unix-getrusage sb!unix:rusage_self)
53     (declare (ignore maxrss ixrss idrss isrss minflt))
54     (unless err? ; FIXME: nonmnemonic (reversed) name for ERR?
55       (error "Unix system call getrusage failed: ~A."
56              (sb!unix:get-unix-error-msg utime)))
57
58     (values utime stime majflt)))
59
60 ;;; Return the system page size.
61 (defun get-page-size ()
62   ;; probably should call getpagesize()
63   ;; FIXME: Or we could just get rid of this, since the uses of it look
64   ;; disposable.
65   4096)