97814f2cc8c742958d5ee0ccbb0c1775e6923b0d
[sbcl.git] / src / code / bsd-os.lisp
1 ;;;; OS interface functions for SBCL 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 (in-package "SB!SYS")
8
9 ;;;; Check that target machine features are set up consistently with
10 ;;;; this file.
11 #!-bsd
12 (eval-when (:compile-toplevel :load-toplevel :execute)
13   (error "The :BSD feature is missing, we shouldn't be doing this code."))
14
15 (defun software-type ()
16   #!+sb-doc
17   "Return a string describing the supporting software."
18   (the string ; (to force error in case of unsupported BSD variant)
19        #!+FreeBSD "FreeBSD"
20        #!+OpenBSD "OpenBSD"
21        #!+NetBSD "NetBSD"
22        #!+Darwin "Darwin"))
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   (or *software-version*
29       (setf *software-version*
30             (string-trim '(#\newline)
31                          (with-output-to-string (stream)
32                            (sb!ext:run-program "/usr/bin/uname" `("-r")
33                                                :output stream))))))
34 \f
35 ;;; Return system time, user time and number of page faults.
36 (defun get-system-info ()
37   (multiple-value-bind (err? utime stime maxrss ixrss idrss
38                              isrss minflt majflt)
39                        (sb!unix:unix-getrusage sb!unix:rusage_self)
40     (declare (ignore maxrss ixrss idrss isrss minflt))
41     (unless err?
42       (simple-perror "Unix system call getrusage() failed" :errno utime))
43
44     (values utime stime majflt)))
45
46 ;;; Return the system page size.
47 (defun get-page-size ()
48   ;; FIXME: probably should call getpagesize()
49   4096)