/[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.10 - (hide annotations)
Sat Jul 7 17:17:40 2007 UTC (6 years, 9 months ago) by fgilham
Branch: MAIN
Changes since 1.9: +4 -1 lines
Add executable feature, conditionalize stuff
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 fgilham 1.10 "$Header: /tiger/var/lib/cvsroots/cmucl/src/code/bsd-os.lisp,v 1.10 2007/07/07 17:17:40 fgilham 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     (export '(get-system-info get-page-size os-init))
25    
26 pmai 1.7 (register-lisp-feature :bsd)
27    
28     (register-lisp-feature #+OpenBSD :OpenBSD
29     #+NetBSD :NetBSD
30     #+FreeBSD :FreeBSD
31     #+Darwin :Darwin
32     #-(or FreeBSD NetBSD OpenBSD Darwin) :bsd)
33 rtoy 1.8
34     #+freebsd4
35     (register-lisp-feature :freebsd4)
36     #+elf
37     (register-lisp-feature :elf)
38 cshapiro 1.9 #+mach-o
39     (register-lisp-feature :mach-o)
40 ram 1.1
41 fgilham 1.10 #+freebsd
42     (register-lisp-feature :executable)
43    
44 pmai 1.4 (setq *software-type* #+OpenBSD "OpenBSD"
45 pmai 1.5 #+NetBSD "NetBSD"
46 pmai 1.4 #+FreeBSD "FreeBSD"
47 pmai 1.7 #+Darwin "Darwin"
48     #-(or FreeBSD NetBSD OpenBSD Darwin) "BSD")
49 ram 1.1
50 dtc 1.3 (defvar *software-version* nil "Version string for supporting software")
51    
52 ram 1.1 (defun software-version ()
53     "Returns a string describing version of the supporting software."
54 dtc 1.3 (unless *software-version*
55     (setf *software-version*
56     (string-trim '(#\newline)
57     (with-output-to-string (stream)
58     (run-program "/usr/bin/uname"
59     '("-r")
60     :output stream)))))
61     *software-version*)
62 ram 1.1
63    
64     ;;; OS-Init initializes our operating-system interface. It sets the values
65     ;;; of the global port variables to what they should be and calls the functions
66     ;;; that set up the argument blocks for the server interfaces.
67    
68     (defun os-init ()
69 dtc 1.3 (setf *software-version* nil))
70 ram 1.1
71     ;;; GET-SYSTEM-INFO -- Interface
72     ;;;
73     ;;; Return system time, user time and number of page faults.
74     ;;;
75     (defun get-system-info ()
76     (multiple-value-bind (err? utime stime maxrss ixrss idrss
77     isrss minflt majflt)
78     (unix:unix-getrusage unix:rusage_self)
79     (declare (ignore maxrss ixrss idrss isrss minflt))
80     (unless err?
81     (error "Unix system call getrusage failed: ~A."
82     (unix:get-unix-error-msg utime)))
83    
84     (values utime stime majflt)))
85    
86    
87     ;;; GET-PAGE-SIZE -- Interface
88     ;;;
89     ;;; Return the system page size.
90     ;;;
91     (defun get-page-size ()
92 toy 1.6 (multiple-value-bind (val err)
93     (unix:unix-getpagesize)
94     (unless val
95     (error "Getpagesize failed: ~A" (unix:get-unix-error-msg err)))
96     val))
97    

  ViewVC Help
Powered by ViewVC 1.1.5