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

  ViewVC Help
Powered by ViewVC 1.1.5