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

Contents of /src/code/lispinit.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.67.2.1 - (show annotations)
Fri Oct 4 23:13:26 2002 UTC (11 years, 6 months ago) by pmai
Branch: UNICODE-BRANCH
Changes since 1.67: +25 -4 lines
Checked in Brian Spilsbury's experimental Unicode, locales, and dialect
support patchset.  This lives on its own branch, so that people can
play with it and tweak it, without disturbing 18e release engineering
on the main branch.  Bootstrapping has only been tried on LINKAGE_TABLE
x86/Linux builds.  A working cross-compile script is checked in under
bootfiles/19a/boot1-cross-unicode.lisp.  The script still leaves you
with some interactive errors, on the cross compile, which you should
answer with 2.  See the mailing list for more information.
1 ;;; -*- Mode: Lisp; Package: Lisp; Log: code.log -*-
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/lispinit.lisp,v 1.67.2.1 2002/10/04 23:13:26 pmai Exp $")
9 ;;;
10 ;;; **********************************************************************
11 ;;;
12 ;;; Initialization stuff for CMU Common Lisp, plus some other random functions
13 ;;; that we don't have any better place for.
14 ;;;
15 ;;; Written by Skef Wholey and Rob MacLachlan.
16 ;;;
17 (in-package :lisp)
18
19 (export '(most-positive-fixnum most-negative-fixnum sleep
20 ++ +++ ** *** // ///))
21
22 (in-package :system)
23 (export '(compiler-version scrub-control-stack))
24
25 (in-package :extensions)
26 (export '(quit *prompt*))
27
28 (in-package :lisp)
29
30 ;;; Make the error system enable interrupts.
31
32 (defconstant most-positive-fixnum #.vm:target-most-positive-fixnum
33 "The fixnum closest in value to positive infinity.")
34
35 (defconstant most-negative-fixnum #.vm:target-most-negative-fixnum
36 "The fixnum closest in value to negative infinity.")
37
38
39 ;;; Random information:
40
41 (defvar *lisp-implementation-version* "4.0(?)")
42
43
44 ;;; Must be initialized in %INITIAL-FUNCTION before the DEFVAR runs...
45 (declaim
46 #-gengc
47 (special *gc-inhibit* *already-maybe-gcing*
48 *need-to-collect-garbage* *gc-verbose*
49 *before-gc-hooks* *after-gc-hooks*
50 #+x86 *pseudo-atomic-atomic*
51 #+x86 *pseudo-atomic-interrupted*
52 unix::*interrupts-enabled*
53 unix::*interrupt-pending*
54 *type-system-initialized*)
55 #+gengc
56 (special *gc-verbose* *before-gc-hooks* *after-gc-hooks*
57 *type-system-initialized*))
58
59
60 ;;;; Random magic specials.
61
62
63 ;;; These are filled in by Genesis.
64
65 #-gengc
66 (progn
67
68 (defvar *current-catch-block*)
69 (defvar *current-unwind-protect-block*)
70 (defvar *free-interrupt-context-index*)
71
72 ); #-gengc progn
73
74
75 ;;;; Random stuff that needs to be in the cold load which would otherwise be
76 ;;;; byte-compiled.
77 ;;;;
78 (defvar hi::*in-the-editor* nil)
79
80 ;;;; Called by defmacro expanders...
81
82 ;;; VERIFY-KEYWORDS -- internal
83 ;;;
84 ;;; Determine if key-list is a valid list of keyword/value pairs. Do not
85 ;;; signal the error directly, 'cause we don't know how it should be signaled.
86 ;;;
87
88 (defun verify-keywords (key-list valid-keys allow-other-keys)
89 (do ((already-processed nil)
90 (unknown-keyword nil)
91 (remaining key-list (cddr remaining)))
92 ((null remaining)
93 (if (and unknown-keyword
94 (not allow-other-keys)
95 (not (lookup-keyword :allow-other-keys key-list)))
96 (values :unknown-keyword (list unknown-keyword valid-keys))
97 (values nil nil)))
98 (cond ((not (and (consp remaining) (listp (cdr remaining))))
99 (return (values :dotted-list key-list)))
100 ((null (cdr remaining))
101 (return (values :odd-length key-list)))
102 #+nil ;; Not ANSI compliant to disallow duplicate keywords.
103 ((member (car remaining) already-processed)
104 (return (values :duplicate (car remaining))))
105 ((or (eq (car remaining) :allow-other-keys)
106 (member (car remaining) valid-keys))
107 (push (car remaining) already-processed))
108 (t
109 (setf unknown-keyword (car remaining))))))
110
111 (defun lookup-keyword (keyword key-list)
112 (do ((remaining key-list (cddr remaining)))
113 ((endp remaining))
114 (when (eq keyword (car remaining))
115 (return (cadr remaining)))))
116 ;;;
117 (defun keyword-supplied-p (keyword key-list)
118 (do ((remaining key-list (cddr remaining)))
119 ((endp remaining))
120 (when (eq keyword (car remaining))
121 (return t))))
122
123 (in-package "CONDITIONS")
124
125 (defvar *break-on-signals* nil
126 "When (typep condition *break-on-signals*) is true, then calls to SIGNAL will
127 enter the debugger prior to signalling that condition.")
128
129 (defun signal (datum &rest arguments)
130 "Invokes the signal facility on a condition formed from datum and arguments.
131 If the condition is not handled, nil is returned. If
132 (TYPEP condition *BREAK-ON-SIGNALS*) is true, the debugger is invoked before
133 any signalling is done."
134 (let ((condition (coerce-to-condition datum arguments
135 'simple-condition 'signal))
136 (*handler-clusters* *handler-clusters*))
137 (let ((obos *break-on-signals*)
138 (*break-on-signals* nil))
139 (when (typep condition obos)
140 (break "~A~%Break entered because of *break-on-signals* (now NIL.)"
141 condition)))
142 (loop
143 (unless *handler-clusters* (return))
144 (let ((cluster (pop *handler-clusters*)))
145 (dolist (handler cluster)
146 (when (typep condition (car handler))
147 (funcall (cdr handler) condition)))))
148 nil))
149
150 ;;; COERCE-TO-CONDITION is used in SIGNAL, ERROR, CERROR, WARN, and
151 ;;; INVOKE-DEBUGGER for parsing the hairy argument conventions into a single
152 ;;; argument that's directly usable by all the other routines.
153 ;;;
154 (defun coerce-to-condition (datum arguments default-type function-name)
155 (cond ((typep datum 'condition)
156 (if arguments
157 (cerror "Ignore the additional arguments."
158 'simple-type-error
159 :datum arguments
160 :expected-type 'null
161 :format-control "You may not supply additional arguments ~
162 when giving ~S to ~S."
163 :format-arguments (list datum function-name)))
164 datum)
165 ((symbolp datum) ;Roughly, (subtypep datum 'condition).
166 (apply #'make-condition datum arguments))
167 ((or (stringp datum) (functionp datum))
168 (make-condition default-type
169 :format-control datum
170 :format-arguments arguments))
171 (t
172 (error 'simple-type-error
173 :datum datum
174 :expected-type '(or symbol string)
175 :format-control "Bad argument to ~S: ~S"
176 :format-arguments (list function-name datum)))))
177
178 (defun error (datum &rest arguments)
179 "Invokes the signal facility on a condition formed from datum and arguments.
180 If the condition is not handled, the debugger is invoked."
181 (kernel:infinite-error-protect
182 (let ((condition (coerce-to-condition datum arguments
183 'simple-error 'error))
184 (debug:*stack-top-hint* debug:*stack-top-hint*))
185 (unless (and (condition-function-name condition) debug:*stack-top-hint*)
186 (multiple-value-bind
187 (name frame)
188 (kernel:find-caller-name)
189 (unless (condition-function-name condition)
190 (setf (condition-function-name condition) name))
191 (unless debug:*stack-top-hint*
192 (setf debug:*stack-top-hint* frame))))
193 (let ((debug:*stack-top-hint* nil))
194 (signal condition))
195 (invoke-debugger condition))))
196
197 ;;; CERROR must take care to not use arguments when datum is already a
198 ;;; condition object.
199 ;;;
200 (defun cerror (continue-string datum &rest arguments)
201 (kernel:infinite-error-protect
202 (with-simple-restart
203 (continue "~A" (apply #'format nil continue-string arguments))
204 (let ((condition (if (typep datum 'condition)
205 datum
206 (coerce-to-condition datum arguments
207 'simple-error 'error)))
208 (debug:*stack-top-hint* debug:*stack-top-hint*))
209 (unless (and (condition-function-name condition)
210 debug:*stack-top-hint*)
211 (multiple-value-bind
212 (name frame)
213 (kernel:find-caller-name)
214 (unless (condition-function-name condition)
215 (setf (condition-function-name condition) name))
216 (unless debug:*stack-top-hint*
217 (setf debug:*stack-top-hint* frame))))
218 (with-condition-restarts condition (list (find-restart 'continue))
219 (let ((debug:*stack-top-hint* nil))
220 (signal condition))
221 (invoke-debugger condition)))))
222 nil)
223
224 (defun break (&optional (datum "Break") &rest arguments)
225 "Prints a message and invokes the debugger without allowing any possibility
226 of condition handling occurring."
227 (kernel:infinite-error-protect
228 (with-simple-restart (continue "Return from BREAK.")
229 (let ((debug:*stack-top-hint*
230 (or debug:*stack-top-hint*
231 (nth-value 1 (kernel:find-caller-name)))))
232 (invoke-debugger
233 (coerce-to-condition datum arguments 'simple-condition 'break)))))
234 nil)
235
236 (defun warn (datum &rest arguments)
237 "Warns about a situation by signalling a condition formed by datum and
238 arguments. While the condition is being signaled, a muffle-warning restart
239 exists that causes WARN to immediately return nil."
240 (kernel:infinite-error-protect
241 (let ((condition (coerce-to-condition datum arguments
242 'simple-warning 'warn)))
243 (check-type condition warning "a warning condition")
244 (restart-case (signal condition)
245 (muffle-warning ()
246 :report "Skip warning."
247 (return-from warn nil)))
248 (format *error-output* "~&~@<Warning: ~3i~:_~A~:>~%" condition)))
249 nil)
250
251 ;;; Utility functions
252
253 (defun simple-program-error (datum &rest arguments)
254 "Invokes the signal facility on a condition formed from datum and arguments.
255 If the condition is not handled, the debugger is invoked. This function
256 is just like error, except that the condition type defaults to the type
257 simple-program-error, instead of program-error."
258 (kernel:infinite-error-protect
259 (let ((condition (coerce-to-condition datum arguments
260 'simple-program-error
261 'simple-program-error))
262 (debug:*stack-top-hint* debug:*stack-top-hint*))
263 (unless (and (condition-function-name condition) debug:*stack-top-hint*)
264 (multiple-value-bind
265 (name frame)
266 (kernel:find-caller-name)
267 (unless (condition-function-name condition)
268 (setf (condition-function-name condition) name))
269 (unless debug:*stack-top-hint*
270 (setf debug:*stack-top-hint* frame))))
271 (let ((debug:*stack-top-hint* nil))
272 (signal condition))
273 (invoke-debugger condition))))
274
275 (in-package "LISP")
276
277
278 ;;; %Initial-Function is called when a cold system starts up. First we zoom
279 ;;; down the *Lisp-Initialization-Functions* doing things that wanted to happen
280 ;;; at "load time." Then we initialize the various subsystems and call the
281 ;;; read-eval-print loop. The top-level Read-Eval-Print loop is executed until
282 ;;; someone (most likely the Quit function) throws to the tag
283 ;;; %End-Of-The-World. We quit this way so that all outstanding cleanup forms
284 ;;; in Unwind-Protects will get executed.
285
286 (declaim (special *lisp-initialization-functions*
287 #+unicode *initial-fdefn-objects*
288 *load-time-values*))
289
290 (eval-when (compile)
291 (defmacro print-and-call (name)
292 `(progn
293 (%primitive print ,(symbol-name name))
294 (,name))))
295
296 (defun hexstr (thing)
297 (let ((addr (kernel:get-lisp-obj-address thing))
298 #-unicode
299 (str (make-string 10))
300 #+unicode
301 (str (make-string 10 :element-type 'base-char)))
302 (setf (char str 0) #\0
303 (char str 1) #\x)
304 (dotimes (i 8)
305 (let* ((nib (ldb (byte 4 0) addr))
306 (chr (char "0123456789abcdef" nib)))
307 (declare (type (unsigned-byte 4) nib)
308 (base-char chr))
309 (setf (char str (- 9 i)) chr
310 addr (ash addr -4))))
311 str))
312
313 (defun %initial-function ()
314 "Gives the world a shove and hopes it spins."
315 (%primitive print "In initial-function, and running.")
316 #-gengc (setf *already-maybe-gcing* t)
317 #-gengc (setf *gc-inhibit* t)
318 #-gengc (setf *need-to-collect-garbage* nil)
319 (setf *gc-verbose* #-gengc t #+gengc nil)
320 (setf *before-gc-hooks* nil)
321 (setf *after-gc-hooks* nil)
322 #-gengc (setf unix::*interrupts-enabled* t)
323 #-gengc (setf unix::*interrupt-pending* nil)
324 (setf *type-system-initialized* nil)
325 (setf *break-on-signals* nil)
326 #+gengc (setf conditions::*handler-clusters* nil)
327
328 ;; Many top-level forms call INFO, (SETF INFO).
329 (print-and-call c::globaldb-init)
330
331 ;; Set up the fdefn database.
332 (print-and-call fdefn-init)
333
334 ;; Some of the random top-level forms call Make-Array, which calls Subtypep
335 (print-and-call typedef-init)
336 (print-and-call class-init)
337 #+unicode
338 (print-and-call char-init)
339 (print-and-call type-init)
340
341 (let ((funs (nreverse *lisp-initialization-functions*)))
342 (%primitive print "Calling top-level forms.")
343 (dolist (fun funs) #+nil (%primitive print (hexstr fun))
344 (typecase fun
345 (function
346 (funcall fun))
347 (cons
348 (case (car fun)
349 (:load-time-value
350 (setf (svref *load-time-values* (third fun))
351 (funcall (second fun))))
352 (:load-time-value-fixup
353 #-gengc
354 (setf (sap-ref-32 (second fun) 0)
355 (get-lisp-obj-address
356 (svref *load-time-values* (third fun))))
357 #+gengc
358 (do-load-time-value-fixup (second fun) (third fun) (fourth fun)))
359 #+(and x86 gencgc)
360 (:load-time-code-fixup
361 (vm::do-load-time-code-fixup (second fun) (third fun) (fourth fun)
362 (fifth fun)))
363 (t
364 (%primitive print
365 "Bogus fixup in *lisp-initialization-functions*")
366 (%halt))))
367 (t
368 (%primitive print
369 "Bogus function in *lisp-initialization-functions*")
370 (%halt)))))
371 (makunbound '*lisp-initialization-functions*) ; So it gets GC'ed.
372 (makunbound '*load-time-values*)
373
374 ;; Only do this after top level forms have run, 'cause thats where
375 ;; deftypes are.
376 (setf *type-system-initialized* t)
377
378 (print-and-call os-init)
379 (print-and-call filesys-init)
380
381 (print-and-call reader-init)
382 ;; Note: sharpm and backq not yet loaded, so this is not the final RT.
383 (setf *readtable* (copy-readtable std-lisp-readtable))
384
385 (print-and-call stream-init)
386 (print-and-call loader-init)
387 (print-and-call package-init)
388 (print-and-call kernel::signal-init)
389 (setf (alien:extern-alien "internal_errors_enabled" boolean) t)
390
391 (set-floating-point-modes :traps '(:overflow #-x86 :underflow :invalid
392 :divide-by-zero))
393 ;; This is necessary because some of the initial top level forms might
394 ;; have changed the compliation policy in strange ways.
395 (print-and-call c::proclaim-init)
396
397 (print-and-call kernel::class-finalize)
398
399 (%primitive print "Done initializing.")
400
401 #-gengc (setf *already-maybe-gcing* nil)
402 #+gengc (setf *gc-verbose* t)
403
404 #+locale ; set up stdio - assuming that we have the external-format loaded
405 (locale:locale-init)
406
407 #+unicode
408 (print-and-call external-format:external-format-init)
409
410 #+dialect
411 (dialect:dialect-init)
412
413 #+unicode ; if :default external-format changed, we need to rebuild stdio
414 (stream-reinit)
415
416 (terpri)
417 (princ "CMU Common Lisp kernel core image ")
418 (princ (lisp-implementation-version))
419 (princ ".")
420 (terpri)
421 (princ "[You are in the LISP package.]")
422 (terpri)
423 (let ((wot
424 (catch '%end-of-the-world
425 (loop
426 (%top-level)
427 (write-line "You're certainly a clever child.")))))
428 (unix:unix-exit wot)))
429
430 #+gengc
431 (defun do-load-time-value-fixup (object offset index)
432 (declare (type index offset))
433 (macrolet ((lose (msg)
434 `(progn
435 (%primitive print ,msg)
436 (%halt))))
437 (let ((value (svref *load-time-values* index)))
438 (typecase object
439 (list
440 (case offset
441 (0 (setf (car object) value))
442 (1 (setf (cdr object) value))
443 (t (lose "Bogus offset in cons cell."))))
444 (instance
445 (setf (%instance-ref object (- offset vm:instance-slots-offset))
446 value))
447 (code-component
448 (setf (code-header-ref object offset) value))
449 (simple-vector
450 (setf (svref object (- offset vm:vector-data-offset)) value))
451 (t
452 (lose "Unknown kind of object for load-time-value fixup."))))))
453
454
455 ;;;; Initialization functions:
456
457 ;;; Print seems to not like x86 NPX denormal floats like
458 ;;; least-negative-single-float, so the :underflow exceptions
459 ;;; is disabled by default. Joe User can explicitly enable them
460 ;;; if desired.
461
462 (defun reinit ()
463 (without-interrupts
464 (without-gcing
465 (os-init)
466 #+locale
467 (locale:locale-init)
468 (stream-reinit)
469 (kernel::signal-init)
470 (gc-init)
471 (setf (alien:extern-alien "internal_errors_enabled" boolean) t)
472 (set-floating-point-modes :traps
473 '(:overflow #-x86 :underflow :invalid
474 :divide-by-zero))
475 ;; Clear pseudo atomic in case this core wasn't compiled with support.
476 #+x86 (setf lisp::*pseudo-atomic-atomic* 0))))
477
478
479 ;;;; Miscellaneous external functions:
480
481 (defvar *cleanup-functions* nil
482 "Functions to be invoked during cleanup at Lisp exit.")
483
484 ;;; Quit gets us out, one way or another.
485
486 (defun quit (&optional recklessly-p)
487 "Terminates the current Lisp. Things are cleaned up unless Recklessly-P is
488 non-Nil."
489 (if recklessly-p
490 (unix:unix-exit 0)
491 (progn
492 (mapc (lambda (fn) (ignore-errors (funcall fn))) *cleanup-functions*)
493 (throw '%end-of-the-world 0))))
494
495
496 #-mp ; Multi-processing version defined in multi-proc.lisp.
497 (defun sleep (n)
498 "This function causes execution to be suspended for N seconds. N may
499 be any non-negative, non-complex number."
500 (when (or (not (realp n))
501 (minusp n))
502 (error 'simple-type-error
503 :format-control
504 "Invalid argument to SLEEP: ~S.~%~
505 Must be a non-negative, non-complex number."
506 :format-arguments (list n)
507 :datum n
508 :expected-type '(real 0)))
509 (multiple-value-bind (sec usec)
510 (if (integerp n)
511 (values n 0)
512 (multiple-value-bind (sec frac) (truncate n)
513 (values sec (truncate frac 1e-6))))
514 (unix:unix-select 0 0 0 0 sec usec))
515 nil)
516
517 ;;;; SCRUB-CONTROL-STACK
518
519
520 (defconstant bytes-per-scrub-unit 2048)
521
522 ;;; Scrub-control-stack.
523 ;;;
524 #-x86
525 (defun scrub-control-stack ()
526 "Zero the unused portion of the control stack so that old objects are not
527 kept alive because of uninitialized stack variables."
528 (declare (optimize (speed 3) (safety 0))
529 (values (unsigned-byte 20)))
530 (labels
531 ((scrub (ptr offset count)
532 (declare (type system-area-pointer ptr)
533 (type (unsigned-byte 16) offset)
534 (type (unsigned-byte 20) count)
535 (values (unsigned-byte 20)))
536 (cond ((= offset bytes-per-scrub-unit)
537 (look (sap+ ptr bytes-per-scrub-unit) 0 count))
538 (t
539 (setf (sap-ref-32 ptr offset) 0)
540 (scrub ptr (+ offset vm:word-bytes) count))))
541 (look (ptr offset count)
542 (declare (type system-area-pointer ptr)
543 (type (unsigned-byte 16) offset)
544 (type (unsigned-byte 20) count)
545 (values (unsigned-byte 20)))
546 (cond ((= offset bytes-per-scrub-unit)
547 count)
548 ((zerop (sap-ref-32 ptr offset))
549 (look ptr (+ offset vm:word-bytes) count))
550 (t
551 (scrub ptr offset (+ count vm:word-bytes))))))
552 (let* ((csp (sap-int (c::control-stack-pointer-sap)))
553 (initial-offset (logand csp (1- bytes-per-scrub-unit))))
554 (declare (type (unsigned-byte 32) csp))
555 (scrub (int-sap (- csp initial-offset))
556 (* (floor initial-offset vm:word-bytes) vm:word-bytes)
557 0))))
558
559 ;;; Scrub-control-stack.
560 ;;;
561 ;;; On the x86 port the stack grows downwards, and to support grow on
562 ;;; demand stacks the stack must be decreased as it is scrubbed.
563 ;;;
564 #+x86
565 (defun scrub-control-stack ()
566 "Zero the unused portion of the control stack so that old objects are not
567 kept alive because of uninitialized stack variables."
568 (scrub-control-stack))
569
570
571 ;;;; TOP-LEVEL loop.
572
573 (defvar / nil
574 "Holds a list of all the values returned by the most recent top-level EVAL.")
575 (defvar // nil "Gets the previous value of / when a new value is computed.")
576 (defvar /// nil "Gets the previous value of // when a new value is computed.")
577 (defvar * nil "Holds the value of the most recent top-level EVAL.")
578 (defvar ** nil "Gets the previous value of * when a new value is computed.")
579 (defvar *** nil "Gets the previous value of ** when a new value is computed.")
580 (defvar + nil "Holds the value of the most recent top-level READ.")
581 (defvar ++ nil "Gets the previous value of + when a new value is read.")
582 (defvar +++ nil "Gets the previous value of ++ when a new value is read.")
583 (defvar - nil "Holds the form curently being evaluated.")
584 (defvar *prompt* "* "
585 "The top-level prompt string. This also may be a function of no arguments
586 that returns a simple-string.")
587 (defvar *in-top-level-catcher* nil
588 "True if we are within the Top-Level-Catcher. This is used by interrupt
589 handlers to see whether it is o.k. to throw.")
590
591 (defun interactive-eval (form)
592 "Evaluate FORM, returning whatever it returns but adjust ***, **, *, +++, ++,
593 +, ///, //, /, and -."
594 (setf - form)
595 (let ((results (multiple-value-list
596 (if (and (fboundp 'commandp)(funcall 'commandp form))
597 (funcall 'invoke-command-interactive form)
598 (eval form)))))
599 (finish-standard-output-streams)
600 (setf /// //
601 // /
602 / results
603 *** **
604 ** *
605 * (car results)))
606 (setf +++ ++
607 ++ +
608 + -)
609 (unless (boundp '*)
610 ;; The bogon returned an unbound marker.
611 (setf * nil)
612 (cerror "Go on with * set to NIL."
613 "EVAL returned an unbound marker."))
614 (values-list /))
615
616
617 (defconstant eofs-before-quit 10)
618
619 (defun %top-level ()
620 "Top-level READ-EVAL-PRINT loop. Do not call this."
621 (let ((* nil) (** nil) (*** nil)
622 (- nil) (+ nil) (++ nil) (+++ nil)
623 (/// nil) (// nil) (/ nil)
624 (magic-eof-cookie (cons :eof nil))
625 (number-of-eofs 0))
626 (loop
627 (with-simple-restart (abort "Return to Top-Level.")
628 (catch 'top-level-catcher
629 (unix:unix-sigsetmask 0)
630 (let ((*in-top-level-catcher* t))
631 (loop
632 (scrub-control-stack)
633 (fresh-line)
634 (princ (if (functionp *prompt*)
635 (funcall *prompt*)
636 *prompt*))
637 (force-output)
638 (let ((form (read *standard-input* nil magic-eof-cookie)))
639 (cond ((not (eq form magic-eof-cookie))
640 (let ((results
641 (multiple-value-list (interactive-eval form))))
642 (dolist (result results)
643 (fresh-line)
644 (prin1 result)))
645 (setf number-of-eofs 0))
646 ((eql (incf number-of-eofs) 1)
647 (if *batch-mode*
648 (quit)
649 (let ((stream (make-synonym-stream '*terminal-io*)))
650 (setf *standard-input* stream)
651 (setf *standard-output* stream)
652 (format t "~&Received EOF on *standard-input*, ~
653 switching to *terminal-io*.~%"))))
654 ((> number-of-eofs eofs-before-quit)
655 (format t "~&Received more than ~D EOFs; Aborting.~%"
656 eofs-before-quit)
657 (quit))
658 (t
659 (format t "~&Received EOF.~%")))))))))))
660
661
662 ;;; %Halt -- Interface
663 ;;;
664 ;;; A convenient way to get into the assembly level debugger.
665 ;;;
666 (defun %halt ()
667 (%primitive halt))

  ViewVC Help
Powered by ViewVC 1.1.5