/[cmucl]/src/code/save.lisp
ViewVC logotype

Contents of /src/code/save.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.4 - (show annotations) (vendor branch)
Fri Jul 13 20:38:56 1990 UTC (23 years, 9 months ago) by wlott
Changes since 1.1.1.3: +13 -2 lines
Added two functions, assert-user-package and initial-init-function, for
use by worldload.
1 ;;; -*- Mode: Lisp; Package: Lisp; Log: code.log -*-
2 ;;;
3 ;;; **********************************************************************
4 ;;; This code was written as part of the Spice Lisp project at
5 ;;; Carnegie-Mellon University, and has been placed in the public domain.
6 ;;; Spice Lisp is currently incomplete and under active development.
7 ;;; If you want to use this code or any part of Spice Lisp, please contact
8 ;;; Scott Fahlman (FAHLMAN@CMUC).
9 ;;; **********************************************************************
10 ;;;
11 ;;; $Header: /tiger/var/lib/cvsroots/cmucl/src/code/save.lisp,v 1.1.1.4 1990/07/13 20:38:56 wlott Exp $
12 ;;;
13 ;;; Dump the current lisp image into a core file. All the real work is done
14 ;;; be C.
15 ;;;
16 ;;; Written by William Lott.
17 ;;;
18 ;;;
19 (in-package "LISP")
20
21 (in-package "EXTENSIONS")
22 (export '(print-herald save-lisp *before-save-initializations*
23 *after-save-initializations* *environment-list* *editor-lisp-p*))
24 (in-package "LISP")
25
26 (defvar *before-save-initializations* nil
27 "This is a list of functions which are called before creating a saved core
28 image. These functions are executed in the child process which has no ports,
29 so they cannot do anything that tries to talk to the outside world.")
30
31 (defvar *after-save-initializations* nil
32 "This is a list of functions which are called when a saved core image starts
33 up. The system itself should be initialized at this point, but applications
34 might not be.")
35
36 (defvar *environment-list* nil
37 "An alist mapping environment variables (as keywords) to either values")
38
39 (defvar *editor-lisp-p* nil
40 "This is true if and only if the lisp was started with the -edit switch.")
41
42
43
44 ;;; Filled in by the startup code.
45 (defvar lisp-environment-list)
46
47
48 (def-c-routine "save" (boolean)
49 (file (pointer simple-string)))
50
51
52 (defun save-lisp (core-file-name &key
53 (purify t)
54 (root-structures ())
55 (init-function
56 #'(lambda ()
57 (throw 'top-level-catcher nil)))
58 (load-init-file t)
59 (print-herald t)
60 (process-command-line t))
61 "Saves a CMU Common Lisp core image in the file of the specified name. The
62 following keywords are defined:
63
64 :purify
65 If true, do a purifying GC which moves all dynamically allocated
66 objects into static space so that they stay pure. This takes somewhat
67 longer than the normal GC which is otherwise done, but GC's will done
68 less often and take less time in the resulting core file.
69
70 :root-structures
71 This should be a list of the main entry points in any newly loaded
72 systems. This need not be supplied, but locality will be better if it
73 is. This is meaningless if :purify is Nil.
74
75 :init-function
76 This is a function which is called when the created core file is
77 resumed. The default function simply aborts to the top level
78 read-eval-print loop. If the function returns it will be the value
79 of Save-Lisp.
80
81 :load-init-file
82 If true, then look for an init.lisp or init.fasl file when the core
83 file is resumed.
84
85 :print-herald
86 If true, print out the lisp system herald when starting."
87
88 (if purify
89 (purify :root-structures root-structures)
90 (gc))
91 (unless (save (namestring core-file-name))
92 (dolist (f *before-save-initializations*) (funcall f))
93 (dolist (f *after-save-initializations*) (funcall f))
94 (reinit)
95 (dolist (ele lisp-environment-list)
96 (let ((=pos (position #\= (the simple-string ele))))
97 (when =pos
98 (push (cons (intern (string-upcase (subseq ele 0 =pos))
99 *keyword-package*)
100 (subseq ele (1+ =pos)))
101 *environment-list*))))
102 (setf (search-list "default:") (list (default-directory)))
103 (setf (search-list "path:") (setup-path-search-list))
104 (when process-command-line (ext::process-command-strings))
105 (setf *editor-lisp-p* nil)
106 (macrolet ((find-switch (name)
107 `(find ,name *command-line-switches*
108 :key #'cmd-switch-name
109 :test #'(lambda (x y)
110 (declare (simple-string x y))
111 (string-equal x y)))))
112 (when (and process-command-line (find-switch "edit"))
113 (setf *editor-lisp-p* t))
114 (when (and load-init-file
115 (not (and process-command-line (find-switch "noinit"))))
116 (let* ((cl-switch (find-switch "init"))
117 (name (or (and cl-switch
118 (or (cmd-switch-value cl-switch)
119 (car (cmd-switch-words cl-switch))
120 "init"))
121 "init")))
122 (load (merge-pathnames name (user-homedir-pathname))
123 :if-does-not-exist nil))))
124 (when print-herald
125 (print-herald))
126 (when process-command-line
127 (ext::invoke-switch-demons *command-line-switches*
128 *command-switch-demons*))
129 (funcall init-function)))
130
131
132 (defun print-herald ()
133 (macrolet ((frob (variable)
134 `(if (boundp ',variable)
135 ,variable
136 "<not loaded>")))
137 (write-string "CMU Common Lisp ")
138 (write-string (lisp-implementation-version))
139 (write-string ", running on ")
140 (write-line (machine-instance))
141 (write-string "Hemlock ")
142 (write-string (frob *hemlock-version*))
143 (write-string ", Compiler ")
144 (write-line (frob compiler-version))
145 (write-line "Send bug reports and questions to Gripe."))
146 (values))
147
148
149 ;;;; Random functions used by worldload.
150
151 (defun assert-user-package ()
152 (unless (eq *package* (find-package "USER"))
153 (error "Change *PACKAGE* to the USER package and try again.")))
154
155 (defun initial-init-function ()
156 (gc-on)
157 (throw 'top-level-catcher nil))
158

  ViewVC Help
Powered by ViewVC 1.1.5