0.9.2.45:
[sbcl/lichteblau.git] / src / code / bsd-os.lisp
blobed8d8686abec06b2e20121269ffee2e5147a83b0
1 ;;;; OS interface functions for CMU CL under BSD Unix.
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.
7 (in-package "SB!SYS")
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."))
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 #!+NetBSD "NetBSD"
21 #!+Darwin "Darwin"))
23 (defvar *software-version* nil)
25 (defun software-version ()
26 #!+sb-doc
27 "Return a string describing version of the supporting software, or NIL
28 if not available."
29 (or *software-version*
30 (setf *software-version*
31 (string-trim '(#\newline)
32 (with-output-to-string (stream)
33 (sb!ext:run-program "/usr/bin/uname" `("-r")
34 :output stream))))))
36 (defun os-cold-init-or-reinit ()
37 (setf *software-version* nil)
38 (setf *default-pathname-defaults*
39 ;; (temporary value, so that #'PATHNAME won't blow up when
40 ;; we call it below:)
41 (make-trivial-default-pathname)
42 *default-pathname-defaults*
43 ;; (final value, constructed using #'PATHNAME:)
44 (pathname (sb!unix:posix-getcwd/))))
46 ;;; Return system time, user time and number of page faults.
47 (defun get-system-info ()
48 (multiple-value-bind (err? utime stime maxrss ixrss idrss
49 isrss minflt majflt)
50 (sb!unix:unix-getrusage sb!unix:rusage_self)
51 (declare (ignore maxrss ixrss idrss isrss minflt))
52 (unless err?
53 (simple-perror "Unix system call getrusage() failed" :errno utime))
55 (values utime stime majflt)))
57 ;;; Return the system page size.
58 (defun get-page-size ()
59 ;; FIXME: probably should call getpagesize()
60 4096)