1 ;;;; Environment query functions, DOCUMENTATION and DRIBBLE.
3 ;;;; FIXME: If there are exactly three things in here, it could be
4 ;;;; exactly three files named e.g. equery.lisp, doc.lisp, and dribble.lisp.
6 ;;;; This software is part of the SBCL system. See the README file for
9 ;;;; This software is derived from the CMU CL system, which was
10 ;;;; written at Carnegie Mellon University and released into the
11 ;;;; public domain. The software is in the public domain and is
12 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
13 ;;;; files for more information.
15 (in-package "SB!IMPL")
17 ;;; cobbled from stuff in describe.lisp.
18 (defun function-doc (x)
21 (#.sb!vm:closure-header-widetag
22 (%simple-fun-name (%closure-fun x)))
23 ((#.sb!vm:simple-fun-header-widetag
24 #.sb!vm:closure-fun-header-widetag)
26 (#.sb!vm:funcallable-instance-header-widetag
28 (funcallable-instance-fun x))))))
29 (when (and name (typep name '(or symbol cons)))
30 (values (info :function :documentation name)))))
32 (defvar *features* '#.sb-cold:*shebang-features*
34 "a list of symbols that describe features provided by the
37 ;;; various environment inquiries
39 (defun machine-instance ()
41 "Return a string giving the name of the local machine."
42 (sb!unix:unix-gethostname))
44 ;;; FIXME: Don't forget to set these in a sample site-init file.
45 ;;; FIXME: Perhaps the functions could be SETFable instead of having the
46 ;;; interface be through special variables? As far as I can tell
47 ;;; from ANSI 11.1.2.1.1 "Constraints on the COMMON-LISP Package
48 ;;; for Conforming Implementations" it is kosher to add a SETF function for
49 ;;; a symbol in COMMON-LISP..
50 (defvar *short-site-name* nil
52 "The value of SHORT-SITE-NAME.")
53 (defvar *long-site-name* nil
54 #!+sb-doc "the value of LONG-SITE-NAME")
55 (defun short-site-name ()
57 "Return a string with the abbreviated site name, or NIL if not known."
59 (defun long-site-name ()
61 "Return a string with the long form of the site name, or NIL if not known."
66 ;;; Each time we start dribbling to a new stream, we put it in
67 ;;; *DRIBBLE-STREAM*, and push a list of *DRIBBLE-STREAM*, *STANDARD-INPUT*,
68 ;;; *STANDARD-OUTPUT* and *ERROR-OUTPUT* in *PREVIOUS-DRIBBLE-STREAMS*.
69 ;;; *STANDARD-OUTPUT* and *ERROR-OUTPUT* is changed to a broadcast stream that
70 ;;; broadcasts to *DRIBBLE-STREAM* and to the old values of the variables.
71 ;;; *STANDARD-INPUT* is changed to an echo stream that echos input from the old
72 ;;; value of standard input to *DRIBBLE-STREAM*.
74 ;;; When dribble is called with no arguments, *DRIBBLE-STREAM* is closed,
75 ;;; and the values of *DRIBBLE-STREAM*, *STANDARD-INPUT*, and
76 ;;; *STANDARD-OUTPUT* are popped from *PREVIOUS-DRIBBLE-STREAMS*.
78 (defvar *previous-dribble-streams* nil)
79 (defvar *dribble-stream* nil)
81 (defun dribble (&optional pathname &key (if-exists :append))
83 "With a file name as an argument, dribble opens the file and sends a
84 record of further I/O to that file. Without an argument, it closes
85 the dribble file, and quits logging."
87 (let* ((new-dribble-stream
91 :if-does-not-exist :create))
93 (make-broadcast-stream *standard-output* new-dribble-stream))
95 (make-broadcast-stream *error-output* new-dribble-stream))
97 (make-echo-stream *standard-input* new-dribble-stream)))
98 (push (list *dribble-stream* *standard-input* *standard-output*
100 *previous-dribble-streams*)
101 (setf *dribble-stream* new-dribble-stream)
102 (setf *standard-input* new-standard-input)
103 (setf *standard-output* new-standard-output)
104 (setf *error-output* new-error-output)))
105 ((null *dribble-stream*)
106 (error "not currently dribbling"))
108 (let ((old-streams (pop *previous-dribble-streams*)))
109 (close *dribble-stream*)
110 (setf *dribble-stream* (first old-streams))
111 (setf *standard-input* (second old-streams))
112 (setf *standard-output* (third old-streams))
113 (setf *error-output* (fourth old-streams)))))
116 (defun %byte-blt (src src-start dst dst-start dst-end)
117 (%byte-blt src src-start dst dst-start dst-end))