/[cmucl]/src/code/bsd-os.lisp
ViewVC logotype

Contents of /src/code/bsd-os.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13.4.4 - (show annotations)
Fri Feb 26 15:32:48 2010 UTC (4 years, 1 month ago) by rtoy
Branch: intl-branch
CVS Tags: intl-branch-2010-03-18-1300
Changes since 1.13.4.3: +2 -2 lines
Put these files in their own domain since they are only compiled on the
appropriate architecture and OS.
1 ;;; -*- Package: SYSTEM -*-
2 ;;;
3 ;;; **********************************************************************
4 ;;; This code was written as part of the CMU Common Lisp project at
5 ;;; Carnegie Mellon University, and has been placed in the public domain.
6 ;;;
7 (ext:file-comment
8 "$Header: /tiger/var/lib/cvsroots/cmucl/src/code/bsd-os.lisp,v 1.13.4.4 2010/02/26 15:32:48 rtoy Exp $")
9 ;;;
10 ;;; **********************************************************************
11 ;;;
12 ;;; OS interface functions for CMU CL under BSD Unix.
13 ;;;
14 ;;; Written and maintained mostly by Skef Wholey and Rob MacLachlan.
15 ;;; Scott Fahlman, Dan Aronson, and Steve Handerson did stuff here, too.
16 ;;;
17 ;;; Hacked into (Free)bsd-os.lisp by Paul Werkowski.
18 ;;; Generalized a bit for OpenBSD by Pierre R. Mai.
19 ;;; Support for NetBSD by Pierre R. Mai.
20 ;;; Support for Darwin by Pierre R. Mai.
21
22 (in-package "SYSTEM")
23 (use-package "EXTENSIONS")
24
25 (intl:textdomain "cmucl-bsd-os")
26
27 (export '(get-system-info get-page-size os-init))
28
29 (register-lisp-feature :bsd)
30
31 (register-lisp-feature #+OpenBSD :OpenBSD
32 #+NetBSD :NetBSD
33 #+freebsd :freebsd
34 #+Darwin :Darwin
35 #-(or freebsd NetBSD OpenBSD Darwin) :bsd)
36
37 #+elf
38 (register-lisp-feature :elf)
39 #+mach-o
40 (register-lisp-feature :mach-o)
41
42 #+freebsd
43 (register-lisp-runtime-feature :executable)
44
45 (setq *software-type* #+OpenBSD "OpenBSD"
46 #+NetBSD "NetBSD"
47 #+freebsd "FreeBSD"
48 #+Darwin "Darwin"
49 #-(or freebsd NetBSD OpenBSD Darwin) "BSD")
50
51 (defvar *software-version* nil _N"Version string for supporting software")
52
53 (defun software-version ()
54 _N"Returns a string describing version of the supporting software."
55 (unless *software-version*
56 (setf *software-version*
57 (string-trim '(#\newline)
58 (with-output-to-string (stream)
59 (run-program "/usr/bin/uname"
60 '("-r")
61 :output stream)))))
62 *software-version*)
63
64
65 ;;; OS-Init initializes our operating-system interface. It sets the values
66 ;;; of the global port variables to what they should be and calls the functions
67 ;;; that set up the argument blocks for the server interfaces.
68
69 (defun os-init ()
70 (setf *software-version* nil))
71
72 ;;; GET-SYSTEM-INFO -- Interface
73 ;;;
74 ;;; Return system time, user time and number of page faults.
75 ;;;
76 (defun get-system-info ()
77 (multiple-value-bind (err? utime stime maxrss ixrss idrss
78 isrss minflt majflt)
79 (unix:unix-getrusage unix:rusage_self)
80 (declare (ignore maxrss ixrss idrss isrss minflt))
81 (unless err?
82 (error _"Unix system call getrusage failed: ~A."
83 (unix:get-unix-error-msg utime)))
84
85 (values utime stime majflt)))
86
87
88 ;;; GET-PAGE-SIZE -- Interface
89 ;;;
90 ;;; Return the system page size.
91 ;;;
92 (defun get-page-size ()
93 (multiple-value-bind (val err)
94 (unix:unix-getpagesize)
95 (unless val
96 (error _"Getpagesize failed: ~A" (unix:get-unix-error-msg err)))
97 val))

  ViewVC Help
Powered by ViewVC 1.1.5