/[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.7 - (show annotations)
Sun Jul 25 19:32:37 2004 UTC (9 years, 9 months ago) by pmai
Branch: MAIN
CVS Tags: release-19b-pre1, release-19b-pre2, snapshot-2004-10, snapshot-2004-08, snapshot-2004-09, snapshot-2004-12, snapshot-2004-11, snapshot-2005-07, snapshot-2005-03, release-19b-base, snapshot-2005-01, snapshot-2005-06, snapshot-2005-05, snapshot-2005-04, ppc_gencgc_snap_2005-05-14, snapshot-2005-02
Branch point for: release-19b-branch, ppc_gencgc_branch
Changes since 1.6: +11 -3 lines
This commit adds the remainder of the outstanding PPC/Darwin port merge.

Besides support for Darwin foreign loading, and updates to the ppc-vm
and bsd-os files, this commit removes unix:unix-errno as a foreign variable
and replaces it with a function named unix-errno, and a (setf unix-errno).
This makes both glibc support cleaner, and enables ports like PPC/Darwin
(and the upcoming win32 port) which have no easy way of accessing errno as
a foreign variable able to support this functionality at all.

The current implementation of this is rather make-shift, it would likely
be much cleaner to go the SBCL way and mediate all access to errno via
defined functions in the C runtime.

As an interim feature, the frobbing of the float-trap-modes is currently
commented out for Darwin because of ongoing breakage.
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.7 2004/07/25 19:32:37 pmai 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 (export '(get-system-info get-page-size os-init))
25
26 (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
34 (setq *software-type* #+OpenBSD "OpenBSD"
35 #+NetBSD "NetBSD"
36 #+FreeBSD "FreeBSD"
37 #+Darwin "Darwin"
38 #-(or FreeBSD NetBSD OpenBSD Darwin) "BSD")
39
40 (defvar *software-version* nil "Version string for supporting software")
41
42 (defun software-version ()
43 "Returns a string describing version of the supporting software."
44 (unless *software-version*
45 (setf *software-version*
46 (string-trim '(#\newline)
47 (with-output-to-string (stream)
48 (run-program "/usr/bin/uname"
49 '("-r")
50 :output stream)))))
51 *software-version*)
52
53
54 ;;; OS-Init initializes our operating-system interface. It sets the values
55 ;;; of the global port variables to what they should be and calls the functions
56 ;;; that set up the argument blocks for the server interfaces.
57
58 (defun os-init ()
59 (setf *software-version* nil))
60
61 ;;; GET-SYSTEM-INFO -- Interface
62 ;;;
63 ;;; Return system time, user time and number of page faults.
64 ;;;
65 (defun get-system-info ()
66 (multiple-value-bind (err? utime stime maxrss ixrss idrss
67 isrss minflt majflt)
68 (unix:unix-getrusage unix:rusage_self)
69 (declare (ignore maxrss ixrss idrss isrss minflt))
70 (unless err?
71 (error "Unix system call getrusage failed: ~A."
72 (unix:get-unix-error-msg utime)))
73
74 (values utime stime majflt)))
75
76
77 ;;; GET-PAGE-SIZE -- Interface
78 ;;;
79 ;;; Return the system page size.
80 ;;;
81 (defun get-page-size ()
82 (multiple-value-bind (val err)
83 (unix:unix-getpagesize)
84 (unless val
85 (error "Getpagesize failed: ~A" (unix:get-unix-error-msg err)))
86 val))
87

  ViewVC Help
Powered by ViewVC 1.1.5