>Sorry if this is a FAQ, but is there any generalized means of making an
>application created with mcl 1.3.2 compatable with sys7? Unfortunately I
>don't know what the exact problems are, but i've been told that after opening
>the application, the intro-window appears (that contains the name of the
>app), and the machine goes into gc and just crashes.
Gary Byers sent out a patch quite a while ago that fixes one of the
problems and explains why MCL 1.3.2 is generally not compatible with
system 7. Others who have had problems have discovered that you need
to wrap WITHOUT-INTERRUPTS around calls to CHOOSE-FILE-DIALOG and
CHOOSE-NEW-FILE-DIALOG.
I know that Greg Wilcox <wilcox@cmns.think.com> played with running
1.3.2 under System 7 for a while. He may have a few more pointers.
Here's Gary's explanation and patch:
-------------------------------------------------------------------------
1.3.2 is generally -not- compatible with System 7:
1) It won't work at all in 32-bit mode; it assumes a 24-bit memory manager.
2) The entire Multifinder partition has to reside in the first 8MB of
memory. With VM enabled, Multifinder may try to load the lisp into
higher addresses; one may have to launch other applications first and/or
adjust the lisp's suggested memory size in order to ensure that the lisp
loads into the low 8MB.
3) Most seriously, the lisp's "growzone" function - the function which the
Mac Memory Manager calls when it can't otherwise satisfy a memory
allocation request - erroneously assumes that it doesn't need to
preserve the registers that it modifies. (Prior to System 7.0, the
Memory Manager code that called an application's "growzone" function
saved and restored all registers around the call, but that doesn't seem
to have been its documented behavior.)
The enclosed patch seems to fix this problem, which would seem to
be responsible for the "crashes sometimes during GC" behavior you
reported. The patch assumes version 1.3.2; I'm not sure whether
it would work in older versions, and it has nothing to do with 2.0.
4) There are almost certainly other bugs; those that I'm aware of are more
cosmetic than fatal (e.g., drawing into the wrong grafport when windoids
are active.)
It's unfortunate that whatever claims of 1.3.2's 7.0 compatibility have been
made were based on misinformation.
-------------------------------------------------------------------------------
(in-package :ccl)
(eval-when (compile eval)
(require "TRAPS"))
(defun fix-sys7-growzone ()
(let* ((code '(#x202F #x4 ; move.l 4(sp),d0
#x48E7 #x1F3E ; movem.l d3-d7/a2-a6,-(sp)
#x2F38 #x904 ; move.l currentA5,-(sp)
#x42A7 ; clr.l -(sp)
#x2F00 ; move.l d0,-(sp)
#x2A7C #x123 #x4567 ; move.l #$01234567,a5 (fixed below)
#x21CD #x904 ; move.l a5,currentA5
#x4EAD #x1112 ; jsr lispgrowzone(a5)
#x201F ; move.l (sp)+,d0
#x21df #x904 ; move.l (sp)+,currentA5
#x4CDF #x7CF8 ; movem.l (sp)+,d3-d7/a2-a6
#x205F ; move.l (sp)+,a0
#x584F ; addq #4,sp
#x2E80 ; move.l d0,(sp)
#x4ED0)) ; jmp (a0)
(code-length (length code))
(ptr (_NewPtr :errchk :d0 (* 2 code-length) :a0))
(a5Now (%get-ptr (%int-to-ptr #x904))))
(dotimes (i code-length)
(%put-word ptr (pop code) (+ i i)))
; Fix the reference to A5
(%put-ptr ptr a5now 18) ; replace #x01234567 with "real" A5
(_SetGrowZone :a0 ptr)))
; Install the growzone patch, unless it's already there. Make sure it's run
; whenever a saved image is restored.
(unless (member 'fix-sys7-growzone *restore-lisp-functions*
:key #'ccl::function-name)
(push #'fix-sys7-growzone *restore-lisp-functions*)
(fix-sys7-growzone))