0.6.7.22: removed CVS dollar-Header-dollar tags from sources
[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 (defun software-version ()
22   #!+sb-doc
23   "Return a string describing version of the supporting software, or NIL
24    if not available."
25   #+nil ; won't work until we support RUN-PROGRAM..
26   (unless *software-version*
27     (setf *software-version*
28           (string-trim '(#\newline)
29                        (with-output-to-string (stream)
30                          (run-program "/usr/bin/uname"
31                                       '("-r")
32                                       :output stream)))))
33   nil)
34 \f
35 ;;; OS-COLD-INIT-OR-REINIT initializes our operating-system interface.
36 ;;; It sets the values of the global port variables to what they
37 ;;; should be and calls the functions that set up the argument blocks
38 ;;; for the server interfaces.
39 (defun os-cold-init-or-reinit ()
40   (setf *software-version* nil))
41
42 ;;; Return system time, user time and number of page faults.
43 (defun get-system-info ()
44   (multiple-value-bind (err? utime stime maxrss ixrss idrss
45                              isrss minflt majflt)
46                        (sb!unix:unix-getrusage sb!unix:rusage_self)
47     (declare (ignore maxrss ixrss idrss isrss minflt))
48     (unless err?
49       (error "Unix system call getrusage failed: ~A."
50              (sb!unix:get-unix-error-msg utime)))
51     
52     (values utime stime majflt)))
53
54 ;;; Return the system page size.
55 (defun get-page-size ()
56   ;; FIXME: probably should call getpagesize()
57   4096)