/[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.17 - (hide annotations)
Fri Jul 30 22:51:58 2010 UTC (3 years, 8 months ago) by rtoy
Branch: MAIN
CVS Tags: release-20b-pre1, release-20b-pre2, GIT-CONVERSION, cross-sol-x86-merged, RELEASE_20b, cross-sol-x86-base, snapshot-2010-12, snapshot-2010-11, snapshot-2011-09, snapshot-2011-06, snapshot-2011-07, snapshot-2011-04, snapshot-2011-02, snapshot-2011-03, snapshot-2011-01, snapshot-2010-08, cross-sol-x86-2010-12-20, cross-sparc-branch-base, HEAD
Branch point for: cross-sparc-branch, RELEASE-20B-BRANCH, cross-sol-x86-branch
Changes since 1.16: +4 -4 lines
First cut at executable images on Darwin/x86.  The resulting
executable appears to work!

bootfiles/20a/boot-2010-07-1.lisp:
o Add :executable for darwin/x86.

code/bsd-os.lisp:
o Make :elf and :mach-o runtime features too.
o Register :executable of :executable is defined.

lisp/Config.x86_darwin:
o Need mach-o.c
o Add exec-final.c

lisp/lisp.c:
o Don't include elf.h if we're on Darwin since Darwin uses Mach-O, not
  ELF.
o For Darwin, we get the initial function address from
  initial_function_addr, not from &initial_function_addr, like for
  Linux.

lisp/save.c
o Don't include libgen.h and elf.h on Darwin.

tools/linker-x86.sh:
o Update to support Darwin.

tools/make-main-dist.sh:
o Add support for executables on Darwin.

lisp/mach-o.c:
o Initial support for writing Mach-O files for the Lisp spaces.
o Initial support for reading a Mach-O executable to find and map the
  Lisp spaces.
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.17 "$Header: /tiger/var/lib/cvsroots/cmucl/src/code/bsd-os.lisp,v 1.17 2010/07/30 22:51:58 rtoy Rel $")
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 rtoy 1.17 (register-lisp-runtime-feature :elf)
39 cshapiro 1.9 #+mach-o
40 rtoy 1.17 (register-lisp-runtime-feature :mach-o)
41 ram 1.1
42 rtoy 1.17 #+executable
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.16 (error (intl:gettext "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.16 (error (intl:gettext "Getpagesize failed: ~A") (unix:get-unix-error-msg err)))
97 toy 1.6 val))

  ViewVC Help
Powered by ViewVC 1.1.5