8e30939c61a042a6b2255dd616429470e40460d3
[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 (in-package "SB!SYS")
8
9 ;;;; Check that target machine features are set up consistently with
10 ;;;; this file.
11 #!-bsd (eval-when (:compile-toplevel :load-toplevel :execute)
12          (error "The :BSD feature is missing, we shouldn't be doing this code."))
13
14 (defun software-type ()
15   #!+sb-doc
16   "Return a string describing the supporting software."
17   (the string ; (to force error in case of unsupported BSD variant)
18        #!+FreeBSD "FreeBSD"
19        #!+OpenBSD "OpenBSD"))
20
21 (defvar *software-version* nil)
22
23 (defun software-version ()
24   #!+sb-doc
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                          (with-output-to-string (stream)
31                            (sb!ext:run-program "/usr/bin/uname" `("-r")
32                                                :output stream))))))
33 \f
34 ;;; OS-COLD-INIT-OR-REINIT initializes our operating-system interface.
35 ;;; It sets the values of the global port variables to what they
36 ;;; should be and calls the functions that set up the argument blocks
37 ;;; for the server interfaces.
38 (defun os-cold-init-or-reinit ()
39   (setf *software-version* nil))
40
41 ;;; Return system time, user time and number of page faults.
42 (defun get-system-info ()
43   (multiple-value-bind (err? utime stime maxrss ixrss idrss
44                              isrss minflt majflt)
45                        (sb!unix:unix-getrusage sb!unix:rusage_self)
46     (declare (ignore maxrss ixrss idrss isrss minflt))
47     (unless err?
48       (simple-perror "Unix system call getrusage failed" :errno utime))
49     
50     (values utime stime majflt)))
51
52 ;;; Return the system page size.
53 (defun get-page-size ()
54   ;; FIXME: probably should call getpagesize()
55   4096)