/[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.15 - (hide annotations)
Mon Apr 19 02:18:03 2010 UTC (4 years ago) by rtoy
Branch: MAIN
Changes since 1.14: +3 -3 lines
Remove _N"" reader macro from docstrings when possible.
1 ram 1.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 rtoy 1.15 "$Header: /tiger/var/lib/cvsroots/cmucl/src/code/bsd-os.lisp,v 1.15 2010/04/19 02:18:03 rtoy Exp $")
9 ram 1.1 ;;;
10     ;;; **********************************************************************
11     ;;;
12 pw 1.2 ;;; OS interface functions for CMU CL under BSD Unix.
13 ram 1.1 ;;;
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 pw 1.2 ;;; Hacked into (Free)bsd-os.lisp by Paul Werkowski.
18 pmai 1.4 ;;; Generalized a bit for OpenBSD by Pierre R. Mai.
19 pmai 1.5 ;;; Support for NetBSD by Pierre R. Mai.
20 pmai 1.7 ;;; Support for Darwin by Pierre R. Mai.
21 ram 1.1
22     (in-package "SYSTEM")
23     (use-package "EXTENSIONS")
24 rtoy 1.14
25     (intl:textdomain "cmucl-bsd-os")
26    
27 ram 1.1 (export '(get-system-info get-page-size os-init))
28    
29 pmai 1.7 (register-lisp-feature :bsd)
30    
31     (register-lisp-feature #+OpenBSD :OpenBSD
32     #+NetBSD :NetBSD
33 agoncharov 1.13 #+freebsd :freebsd
34 pmai 1.7 #+Darwin :Darwin
35 agoncharov 1.13 #-(or freebsd NetBSD OpenBSD Darwin) :bsd)
36 rtoy 1.8
37     #+elf
38     (register-lisp-feature :elf)
39 cshapiro 1.9 #+mach-o
40     (register-lisp-feature :mach-o)
41 ram 1.1
42 fgilham 1.10 #+freebsd
43 fgilham 1.11 (register-lisp-runtime-feature :executable)
44 fgilham 1.10
45 pmai 1.4 (setq *software-type* #+OpenBSD "OpenBSD"
46 pmai 1.5 #+NetBSD "NetBSD"
47 agoncharov 1.13 #+freebsd "FreeBSD"
48 pmai 1.7 #+Darwin "Darwin"
49 agoncharov 1.13 #-(or freebsd NetBSD OpenBSD Darwin) "BSD")
50 ram 1.1
51 rtoy 1.15 (defvar *software-version* nil "Version string for supporting software")
52 dtc 1.3
53 ram 1.1 (defun software-version ()
54 rtoy 1.15 "Returns a string describing version of the supporting software."
55 dtc 1.3 (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 ram 1.1
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 dtc 1.3 (setf *software-version* nil))
71 ram 1.1
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 rtoy 1.14 (error _"Unix system call getrusage failed: ~A."
83 ram 1.1 (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 toy 1.6 (multiple-value-bind (val err)
94     (unix:unix-getpagesize)
95     (unless val
96 rtoy 1.14 (error _"Getpagesize failed: ~A" (unix:get-unix-error-msg err)))
97 toy 1.6 val))

  ViewVC Help
Powered by ViewVC 1.1.5