[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MCL 1.3 and System 7

>Date: Mon, 24 Feb 92 09:09:10 GMT
>From: mf@arco.NA.CNR.IT (Mario Furnari)
>Subject: MCL 1.3 and System 7
>To: info-mcl@cambridge.apple.com
>X-Envelope-To: info-mcl@cambridge.apple.com
>Hi people
>Does anybody know if it is possible to run MACL 1.3 with System 7 ?
>I trid it but MCL quit istantly

>Date: Fri, 21 Feb 92 19:53:11
>From: cfry@MIT.EDU (Christopher Fry)
>To: info-mcl@cambridge.apple.com
>Subject: Running 1.3.2 in System 7
>Is this suppose to work?
>Looks like most of my code works, but when I make a stand-alone app
>in system 7, I have problems with a menu item that calls the standard 
>file dialog for choosing a file. It immediately quits the lisp.
>I guess my real question is, is this the one thing that I need to fix or 
>the tip of an iceberg?
>Plans to convert to Lisp 2.0 are underway in any case, but A quick fix 
>would be convenient.

Officially, 1.3.2 does not work with System 7.

Unofficially, you can make it run if you install the following patch
and heed its warnings.

You also need to wrap WITHOUT-INTERRUPTS around calls to the standard
file dialog (Lisp functions CHOOSE-FILE-DIALOG & CHOOSE-NEW-FILE-DIALOG).

There may also be some problems with windoids (If you click
on a windoid when MCL is garbage collecting, you will likely crash).

Greg Wilcox <wilcox@cmns.think.com> has been working on this and
may have discovered a few more kluges. Greg?


; sys7growzone-patch.lisp

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*)