source: branches/lispworks/load-wood.lisp@ 38

Last change on this file since 38 was 37, checked in by Gail Zacharias, 9 years ago

Restore changeset:8

  • Property svn:eol-style set to native
File size: 11.8 KB
Line 
1;;;-*- Mode: Lisp; Package: (WOOD) -*-
2
3;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4;;
5;; load-wood.lisp
6;; Load this file and evaluate (wood::load-wood)
7;; You may need to edit the definition of the "wood" logical host.
8;;
9;; Portions Copyright © 2006 Clozure Associates
10;; Copyright © 1996 Digitool, Inc.
11;; Copyright © 1992-1995 Apple Computer, Inc.
12;; All rights reserved.
13;; Permission is given to use, copy, and modify this software provided
14;; that Digitool is given credit in all derivative works.
15;; This software is provided "as is". Digitool makes no warranty or
16;; representation, either express or implied, with respect to this software,
17;; its quality, accuracy, merchantability, or fitness for a particular
18;; purpose.
19;;
20
21;;;;;;;;;;;;;;;;;;;;;;;;;;
22;;
23;; Modification History
24;;
25;; 02/01/06 gz LispWorks port
26;; 04/11/97 bill compile-and-load checks for "Wrong PFSL version" as well
27;; as "Wrong FASL version".
28;; ------------- 0.961
29;; 09/20/96 bill The WOOD package definition mentions the imported symbols as symbols,
30;; not strings, for versions of MCL that don't already include them (e.g. 3.9).
31;; ------------- 0.96
32;; 07/20/96 bill import databases-locked-p, with-databases-unlocked, funcall-with-databases-unlocked
33;; from CCL.
34;; Don't load break-loop-patch if ccl::databases-locked-p is fbound
35;; 07/09/96 bill AlanR's fix to (setf (logical-pathname-translations "wood") ...)
36;; (pathname-directory ...) -> (or (pathname-directory ...) '(:absolute))
37;; ------------- 0.95
38;; 06/04/96 bill load-wood loads break-loop-patch
39;; 05/09/96 bill export with-databases-unlocked and databases-locked-p
40;; ------------- 0.94 = MCL-PPC 3.9
41;; 03/21/96 bill compile-and-load resignals any error it doesn't recognize
42;; 03/09/96 bill say ccl::*.fasl-pathname* instead of ".fasl".
43;; ------------- 0.93
44;; 08/11/95 bill translate this file's pathname to a physical one when
45;; defining the "wood" logical pathname to prevent
46;; a recursive definition.
47;; 08/11/95 bill compile-and-load deletes fasl files for other MCL versions.
48;; 08/11/95 bill load-wood loads big-io-buffer-patch if necessary
49;; 08/10/95 bill export p-assoc & p-do-btree
50;; 05/31/95 bill export make-shared-buffer, make-shared-buffer-pool
51;; 05/25/95 bill add disk-page-hash to *wood-files*
52;; ------------- 0.9
53;; 01/17/95 bill export p-store-pptr, pptr-pointer, pptr-pheap,
54;; with-transaction, start-transaction, commit-transaction,
55;; abort-transaction
56;; 11/02/94 ows export pptr, pheap-pathname
57;; 10/25/94 bill export pptr-p, p-loaded?, p-stored?,
58;; wood-disk-resident-slot-names, define-disk-resident-slots
59;; 03/14/94 bill Don't push anything onto *module-search-path*
60;; -------------- 0.8
61;; 12/27/93 bill export p-btree-count, p-hash-table-count, initialize-persistent-instance
62;; 12/17/93 bill Use "wood:wood;..." instead of "wood:..." to prevent
63;; bogus default directories.
64;; Add "version-control" to *wood-files*
65;; 03/29/93 bill Add "q" and "wood-gc" to *wood-files*
66;; -------------- 0.6
67;; 12/16/92 bill p-btree-clear -> p-clear-btree
68;; 10/21/92 bill p-nth, p-nthcdr
69;; 08/31/92 bill export p-make-load-function, p-make-load-function
70;; 08/06/92 bill (provide "WOOD")
71;; 07/30/92 bill export p-btree-p and p-hash-table-p
72;; -------------- 0.5
73;; 07/27/92 bill Export all documented symbols.
74;;
75
76(defpackage :wood
77 #+ppc-target
78 (:import-from "CCL"
79 ccl::databases-locked-p
80 ccl::funcall-with-databases-unlocked
81 ccl::with-databases-unlocked)
82 (:export #:load-wood
83 #:open-pheap #:close-pheap #:with-open-pheap #:root-object #:flush-pheap
84 #:make-shared-buffer #:make-shared-buffer-pool
85 #:pheap #:p-loading-pheap
86 #:p-load #:p-store #:p-stored? #:p-loaded?
87 #:p-make-area #:with-consing-area
88 #:p-cons #:p-list #:p-list-in-area #:p-make-list
89 #:p-make-uvector #:p-make-array #:p-vector
90 #:p-listp #:p-consp #:p-atom #:p-uvectorp #:p-packagep #:p-symbolp
91 #:p-stringp #:p-simple-string-p #:p-vectorp #:p-simple-vector-p #:p-arrayp
92 #:pload-barrier-p
93 #:p-car #:p-cdr #:p-caar #:p-cadr #:p-cdar #:p-cddr
94 #:p-caaar #:p-caadr #:p-cadar #:p-caddr #:p-cdaar #:p-cdadr #:p-cddar
95 #:p-cdddr #:p-caaaar #:p-caaadr #:p-caadar #:p-caaddr #:p-cadaar
96 #:p-cadadr #:p-caddar #:p-cadddr #:p-cdaaar #:p-cdaadr #:p-cdadar
97 #:p-cdaddr #:p-cddaar #:p-cddadr #:p-cdddar #:p-cddddr
98 #:p-nth #:p-nthcdr #:p-last #:p-delq #:p-dolist #:p-assoc
99 #:p-instance-class #:p-slot-value
100 #:p-uvsize #:p-uvref #:p-uvector-subtype-p #:p-svref #:p-%svref #:p-length
101 #:p-aref #:p-array-rank #:p-array-dimensions #:p-array-dimension
102 #:p-intern #:p-find-symbol #:p-find-package #:p-make-package
103 #:p-symbol-name #:p-symbol-package #:p-symbol-value
104 #:p-package-name #:p-package-nicknames
105 #:p-make-btree #:p-btree-p #:p-btree-lookup #:p-btree-store #:p-btree-delete
106 #:p-clear-btree #:p-map-btree #:p-do-btree #:p-btree-count #:p-map-btree-keystrings
107 #:p-make-hash-table #:p-hash-table-p #:p-gethash #:p-remhash #:p-clrhash
108 #:p-hash-table-size #:p-maphash #:p-hash-table-count
109 #:wood-slot-names-vector #:wood-slot-value #:initialize-persistent-instance
110 #:p-make-load-function #:p-make-load-function-object #:p-make-load-function-using-pheap
111 #:p-make-load-function-saving-slots #:progn-load-functions #:progn-init-functions
112 #:p-store-pptr #:opened-pheap
113 #:p-make-pload-barrier #:p-load-through-barrier
114 #:gc-pheap-file #:clear-memory<->disk-tables
115 #:with-egc #:*avoid-cons-caching*
116 #:pptr-p #:pptr #:pptr-pointer #:pptr-pheap
117 #:wood-disk-resident-slot-names #:define-disk-resident-slots
118 #:pheap-pathname #:move-pheap-file
119 #:with-databases-locked #:with-databases-unlocked #:databases-locked-p
120 #:with-transaction #:start-transaction #:commit-transaction #:abort-transaction
121 ))
122
123(in-package :wood)
124
125; Assume fixnum addresses.
126; Comment out this form to compile Wood for files larger than 256 megs (8 Megs in LWW)
127;#-LispWorks4 ;; LWW4 fixnums are tiny.
128#+Lispworks5
129(eval-when (:compile-toplevel :execute :load-toplevel)
130 (pushnew :wood-fixnum-addresses *features*))
131
132;; For simpler conditionalizations
133#+(and ccl (not ppc-target))
134(eval-when (:compile-toplevel :execute :load-toplevel)
135 (pushnew :ccl-68k-target *features*))
136
137#|
138#+LispWorks
139(eval-when (:compile-toplevel :execute :load-toplevel)
140 ;; For some reason, in lispworks the SYSTEM package has the nickname :CCL, which makes it harder
141 ;; to catch porting errors here. This can be removed once the port is complete.
142 (let ((pkg (find-package "CCL")))
143 (when pkg
144 (rename-package pkg (package-name pkg) (remove "CCL" (package-nicknames pkg) :test #'equal)))))
145|#
146
147
148;; #+ccl (... #_Foo ...) errs out because #_ is undefined.
149#+LispWorks
150(eval-when (:compile-toplevel :execute :load-toplevel)
151 (when (null (get-dispatch-macro-character #\# #\_))
152 (set-dispatch-macro-character #\# #\_
153 #'(lambda(s c n)
154 (declare (ignore c n))
155 (read s nil nil t)
156 nil))))
157
158(setf (logical-pathname-translations "wood")
159 (let ((path (or *load-pathname* #+ccl *loading-file-source-file*
160 #+LispWorks dspec:*source-pathname*
161 #+LispWorks system:*current-pathname*)))
162 (if path
163 (let* ((dest-dir (make-pathname :device (pathname-device path)
164 :host (pathname-host path)
165 :directory (append
166 (or (pathname-directory path)
167 '(:absolute))
168 '(:wild-inferiors))
169 :name :wild
170 :type :wild))
171 (physical-dir (translate-logical-pathname dest-dir)))
172 ; This is what you'll get if you load this file
173 ; or evaluate this form from this buffer.
174 `(("wood;**;*.*" ,physical-dir)
175 ("**;*.*" ,physical-dir)))
176 ; This is what you'll get if you evalute this form
177 ; from the listener.
178 '(("wood;**;*.*" "ccl:wood;**;*.*")))))
179
180(defun fasl-pathname (pathname)
181 (merge-pathnames pathname
182 #+ccl ccl::*.fasl-pathname*
183 #+lispworks (make-pathname :type system:*binary-file-type*)))
184
185(defvar *debug-wood* nil)
186
187(defun compile-if-needed (file &optional force)
188 (let ((lisp (merge-pathnames file ".lisp"))
189 (fasl (fasl-pathname file)))
190 (when (or force
191 (not (probe-file fasl))
192 (> (file-write-date lisp) (file-write-date fasl)))
193 #+LispWorks
194 (compiler:with-optimization-level
195 (if *debug-wood*
196 (compiler::set-optimization-level :safety 3 :debug 3)
197 (compiler::set-optimization-level :speed 3 :safety 0 :debug 0 :float 0))
198 (compile-file lisp :verbose t))
199 #-LispWorks
200 (compile-file lisp :verbose t))))
201
202(defun compile-and-load (file &optional force-compile)
203 (compile-if-needed file force-compile)
204 (handler-bind ((simple-error
205 #'(lambda (condition)
206 (if (member (simple-condition-format-string condition)
207 '("Wrong FASL version." "Wrong PFSL version.")
208 :test 'equalp)
209 (progn
210 (format t "~&;Deleting FASL file from other MCL version...")
211 (delete-file (fasl-pathname file))
212 (return-from compile-and-load (compile-and-load file force-compile)))
213 (error condition)))))
214 (load file :verbose t)))
215
216(defparameter *wood-files*
217 '("compat"
218 #+ccl "block-io-mcl" #+ccl "split-lfun"
219 "q"
220 "disk-page-hash" "disk-cache" "woodequ" "disk-cache-accessors"
221 #+ccl "disk-cache-inspector" #+LispWorks "lw-inspector"
222 "persistent-heap" "version-control"
223 "btrees" "persistent-clos"
224 ;; Not ported yet
225 #-LispWorks "recovery" #-LispWorks "wood-gc"))
226
227(defun load-wood (&optional force-compile)
228 (with-compilation-unit ()
229 (compile-if-needed "wood:wood;load-wood")
230 #-lispworks (unless (boundp 'ccl::*elements-per-buffer*)
231 (compile-and-load "wood:patches;big-io-buffer-patch"))
232 (dolist (file *wood-files*)
233 (compile-and-load (merge-pathnames file "wood:wood;") force-compile))
234 #+ppc-target
235 (unless (fboundp 'ccl::databases-locked-p)
236 (compile-and-load "wood:patches;break-loop-patch" force-compile))
237 (provide "WOOD")))
238
239; This should be called only after load-wood.
240; It compiles the changed files
241(defun compile-wood ()
242 (with-compilation-unit ()
243 (compile-if-needed "wood:wood;load-wood")
244 (dolist (file *wood-files*)
245 (compile-if-needed (merge-pathnames file "wood:wood;")))))
246;;; 1 3/10/94 bill 1.8d247
247;;; 2 3/23/94 bill 1.8d277
248;;; 3 7/26/94 Derek 1.9d027
249;;; 4 9/19/94 Cassels 1.9d061
250;;; 5 11/01/94 Derek 1.9d085 Bill's Saving Library Task
251;;; 6 11/05/94 kab 1.9d087
252;;; 7 11/21/94 gsb 1.9d100
253;;; 2 2/18/95 RŽti 1.10d019
254;;; 3 3/23/95 bill 1.11d010
255;;; 4 4/19/95 bill 1.11d021
256;;; 5 6/02/95 bill 1.11d040
Note: See TracBrowser for help on using the repository browser.