Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!dartvax!eleazar.dartmouth.edu!earleh From: earleh@eleazar.dartmouth.edu (Earle R. Horton) Newsgroups: comp.sys.mac.programmer Subject: Re: Question about Bison Summary: Alloca() source! Message-ID: <10329@dartvax.Dartmouth.EDU> Date: 10 Oct 88 01:18:38 GMT References: <8246@cit-vax.Caltech.Edu> Sender: news@dartvax.Dartmouth.EDU Reply-To: earleh@eleazar.dartmouth.edu (Earle R. Horton) Organization: Thayer School of Engineering Lines: 52 In article <8246@cit-vax.Caltech.Edu> janin@tybalt.caltech.edu (Adam L. Janin) writes: >I just installed Bison on a Mac II and I'm having a problem when linking. >Using bison.simple, I get a link error (missing functions alloca and bcopy). >When I use bison.hairy (using the %semantic_parser command), I get other link >errors (several missing functions). I assume I should simply replace >alloca with NewPtr and bcopy with MemCopy. Is this correct? Also, under >what conditions would I want to use bison.hairy as apposed to bison.simple? Alloca() is a non-portable function that allocates storage in the local stack frame of the caller. Said storage vanishes when the caller of alloca() returns. The stack frame convention used in MPW high level languages makes implementation of alloca() trivial, as shown below. Bcopy() is similar to BlockMove() and to memcpy(). Memcpy() is more portable to use because I think it is in ANSI C(?). I compiled the original GNU sources for Bison from prep.ai.mit.edu on my Mac II with little difficulty. However, I have yet to use the "%semantic_parser" command or to figure out what it is for, although I did notice that it generates link errors. I also got the posted sources by Pierce T. Wetter, and compiled them. I notice that bison.hairy does not work there either. My feeling is that Pierce did not get it working, but you might ask him, since his mail address is also at Tybalt.Caltech.Edu. This is the assembler source to alloca() for use with Macintosh Programmer's Workshop C. Notice that it must be assembled with MPW assembler. If you do not have the assembler, then I can whip up a C version using InLines if you like. ;; ;; Alloca() for Macintosh Programmer's Workshop C. ;; alloca(n) allocates n bytes of storage in the stack ;; frame of the caller. ;; CASE ON alloca PROC EXPORT move.l (sp)+,a0 ; pop return address move.l (sp)+,d0 ; pop parameter = size in bytes add.l #3,d0 ; round size up to long word and.l #-4,d0 ; mask out lower two bits of size sub.l d0,sp ; allocate by moving stack pointer move.l sp,d0 ; return pointer add.l #-4,sp ; new top of stack jmp (a0) ; return to caller ENDP END Earle R. Horton. 23 Fletcher Circle, Hanover, NH 03755 (603) 643-4109 Sorry, no fancy stuff, since this program limits my .signature to three