Initial revision
[sbcl.git] / src / code / bsd-os.lisp
1 ;;;; OS interface functions for CMU CL under BSD Unix.
2
3 ;;;; This code was written as part of the CMU Common Lisp project at
4 ;;;; Carnegie Mellon University, and has been placed in the public
5 ;;;; domain.
6
7 (sb!int:file-comment
8   "$Header$")
9
10 (in-package "SB!SYS")
11
12 ;;;; Check that target machine features are set up consistently with
13 ;;;; this file.
14 #!-bsd (eval-when (:compile-toplevel :load-toplevel :execute)
15          (error "The :BSD feature is missing, we shouldn't be doing this code."))
16
17 (defun software-type ()
18   #!+sb-doc
19   "Return a string describing the supporting software."
20   (the string ; (to force error in case of unsupported BSD variant)
21        #!+FreeBSD "FreeBSD"
22        #!+OpenBSD "OpenBSD"))
23
24 (defun software-version ()
25   #!+sb-doc
26   "Return a string describing version of the supporting software, or NIL
27    if not available."
28   #+nil ; won't work until we support RUN-PROGRAM..
29   (unless *software-version*
30     (setf *software-version*
31           (string-trim '(#\newline)
32                        (with-output-to-string (stream)
33                          (run-program "/usr/bin/uname"
34                                       '("-r")
35                                       :output stream)))))
36   nil)
37 \f
38 ;;; OS-COLD-INIT-OR-REINIT initializes our operating-system interface.
39 ;;; It sets the values of the global port variables to what they
40 ;;; should be and calls the functions that set up the argument blocks
41 ;;; for the server interfaces.
42 (defun os-cold-init-or-reinit ()
43   (setf *software-version* nil))
44
45 ;;; Return system time, user time and number of page faults.
46 (defun get-system-info ()
47   (multiple-value-bind (err? utime stime maxrss ixrss idrss
48                              isrss minflt majflt)
49                        (sb!unix:unix-getrusage sb!unix:rusage_self)
50     (declare (ignore maxrss ixrss idrss isrss minflt))
51     (unless err?
52       (error "Unix system call getrusage failed: ~A."
53              (sb!unix:get-unix-error-msg utime)))
54     
55     (values utime stime majflt)))
56
57 ;;; Return the system page size.
58 (defun get-page-size ()
59   ;; FIXME: probably should call getpagesize()
60   4096)