0.6.12.18:
[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 (defun os-cold-init-or-reinit ()
35   (setf *software-version* nil)
36   (setf *default-pathname-defaults*
37         (pathname (sb!ext::default-directory))))
38
39 ;;; Return system time, user time and number of page faults.
40 (defun get-system-info ()
41   (multiple-value-bind (err? utime stime maxrss ixrss idrss
42                              isrss minflt majflt)
43                        (sb!unix:unix-getrusage sb!unix:rusage_self)
44     (declare (ignore maxrss ixrss idrss isrss minflt))
45     (unless err?
46       (simple-perror "Unix system call getrusage failed" :errno utime))
47     
48     (values utime stime majflt)))
49
50 ;;; Return the system page size.
51 (defun get-page-size ()
52   ;; FIXME: probably should call getpagesize()
53   4096)