[comp.sys.mac.programmer] MFTemp calls in LSC?

carlton@ji.Berkeley.EDU (Mike Carlton) (03/16/89)

Can anyone tell me if the Multifinder temporary memory allocation routines 
have been implemented yet in LSC?  They've existed for at least a year, but 
LSC 3.01p4 doesn't recognize MFTempNewHandle or any of the other new routines 
I've tried.

For now I've implemented them myself with a little bit of assembly, but they
should be built in or available in a library.  Are they known by some other
name or hidden in some library?

thanks,
mike   (carlton@ji.berkeley.edu      ...!ucbvax!ji!carlton)

siegel@endor.harvard.edu (Rich Siegel) (03/16/89)

In article <28414@ucbvax.BERKELEY.EDU> carlton@ji.Berkeley.EDU (Mike Carlton) writes:
>Can anyone tell me if the Multifinder temporary memory allocation routines 
>have been implemented yet in LSC?  They've existed for at least a year, but 
>LSC 3.01p4 doesn't recognize MFTempNewHandle or any of the other new routines 
>I've tried.

	They don't seem to be in any of the headers or libraries; they'll
probably be in the next release. In the meantime, your own glue should work
OK.

		--Rich




Rich Siegel
Staff Software Developer
THINK Technologies Division, Symantec Corp.
Internet: siegel@endor.harvard.edu
UUCP: ..harvard!endor!siegel
Phone: (617) 275-4800 x305

ech@pegasus.ATT.COM (Edward C Horvath) (03/17/89)

In article <28414@ucbvax.BERKELEY.EDU> carlton@ji.Berkeley.EDU (Mike Carlton) writes:
>Can anyone tell me if the Multifinder temporary memory allocation routines 
>have been implemented yet in LSC?  They've existed for at least a year, but 
>LSC 3.01p4 doesn't recognize MFTempNewHandle or any of the other new routines 
>I've tried.

From article <1426@husc6.harvard.edu>, by siegel@endor.harvard.edu (Rich Siegel):
> 	They don't seem to be in any of the headers or libraries; they'll
> probably be in the next release. In the meantime, your own glue should work
> OK.

You're a prince, Rich; for those without access to MPW source this is a
tad difficult to manage.  Herewith an extract from Aztec C's Memory.h
(ca 3-88):

------ cut here ------
	/* MultiFinder dispatch trap */
#define OSDISPATCH		0xA88F
	/* Routine selector values */
#define mfMaxMemSel		21
#define mfFreeMemSel		24
#define mfTempNewHandleSel	29
#define mfTempHLockSel		30
#define mfTempHUnLockSel	31
#define mfTempDisposHandleSel	32

#define MFMaxMem(grow) \
	cMFMaxMem(grow,mfMaxMemSel)
#define MFFreeMem() \
	cMFFreeMem(mfFreeMemSel)
#define MFTempNewHandle(logicalSize,resultCode) \
	cMFTempNewHandle(logicalSize,resultCode,mfTempNewHandleSel)
#define MFTempHLock(h,resultCode) \
	cMFTempHLock(h,resultCode,mfTempHLockSel)
#define MFTempHUnLock(h,resultCode) \
	cMFTempHUnLock(h,resultCode,mfTempHUnLockSel)
#define MFTempDisposHandle(h,resultCode) \
	cMFTempDisposHandle(h,resultCode,mfTempDisposHandleSel)

pascal long cMFMaxMem( /*
	long *grow,
	short SW
	*/ ) = OSDISPATCH;
pascal Size cMFFreeMem( /*
	short SW
	*/ ) = OSDISPATCH;
pascal Handle cMFTempNewHandle( /*
	unsigned long logicalSize,
	short *resultCode,
	short SW
	*/ ) = OSDISPATCH;
pascal void cMFTempHLock( /*
	Handle h,
	short *resultCode,
	short SW
	*/ ) = OSDISPATCH;
pascal void cMFTempHUnLock( /*
	Handle h,
	short *resultCode,
	short SW
	*/ ) = OSDISPATCH;
pascal void cMFTempDisposHandle( /*
	Handle h,
	short *resultCode,
	short SW
	*/ ) = OSDISPATCH;

--- end extract ---

When I put this into an LSC 3.01p4 window and punched cmd-Y it generated no
diagnostics; I presume that means All OK (I did NOT attempt to actually use
any of this with LSC).  Remove the /* and */ in the cXXX definitions to
create appropriate prototypes.  In any event, you can use this info to
generate appropriate glue.  As a simple (untested) example, you might
implement MFTempHLock as:

pascal void MFTempHLock (h, resultCode)
	Handle h;
	short *resultCode;
{
	asm {
		move.l	(sp)+,a0	; save return address
		move.w	#30,-(sp)	; routine selector
		move.l	a0,-(sp)	; replace return address
		dc.w	0xAC8F		; OSDISPATCH + AUTOPOP
	}
}

The others differ only in the selector used.  The advantage of the #define
hacks above is that they (should) generate all the code inline, saving the
overhead of the jsr and the shenanigans in the sample glue.

Good luck,

=Ned Horvath=
Disclaimer: I don't work for Manx any more.  I'll use whatever compiler
(including LSC) gets me through the night...