alloca(), Anyone have a version that works?
Dr. Arthur Wouk
wouk at smoke.BRL.MIL
Fri Apr 7 08:27:59 AEST 1989
The following worked for me on an ATT 3b1 when compiling Bison: it
came over the net:
Originally-From: daveb at gonzo.UUCP (Dave Brower)
Subject: Re: Problems compiling gcc on Unix-pc
Date: 27 Feb 89 17:29:07 GMT
...
I _did_ need to get an alloca from the GNU emacs distribution in
order to boot using the at&t compiler. Since few people have
room for both gcc and emacs source resident at the same time,
here is a crib. The GNU copyleft applies. Put this in alloca.s
say "make alloca.o", and fill in ALLOCA=alloca.o in the
Makefile.
file "alloca.s"
global alloca
global _alloca
_alloca:
alloca:
mov.l (%sp)+,%a1 # pop return addr from top of stack
mov.l (%sp)+,%d0 # pop size in bytes from top of stack
add.l &R%1,%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
tst.b P%1(%sp) # stack probe to allocate pages
mov.l %sp,%a0 # return pointer as pointer
mov.l %sp,%d0 # return pointer as int to avoid disaster
add.l &-4,%sp # new top of stack
jmp (%a1) # not a normal return
set S%1,64 # safety factor for C compiler scratch
set R%1,3+S%1 # add to size for rounding
set P%1,-132 # probe this far below current top of stack
Next weekend, g++!
-dB
--
"I came here for an argument." "Oh. This is getting hit on the head"
{sun,mtxinu,amdahl,hoptoad}!rtech!gonzo!daveb daveb at gonzo.uucp
More information about the Comp.unix.aux
mailing list