[comp.sources.wanted] alloca

time@oxtrap.UUCP (Tim Endres) (04/04/89)

I need a version of alloca() for A/UX that works.
One for the 68020 would be welcome as well.

I have much gnu software that doesn't work and
I suspect my alloca(). The one in libPW.a has been
tried as has the gnu emacs alloca. Neither seem
to work for me.

wouk@smoke.BRL.MIL (Dr. Arthur Wouk ) (04/07/89)

The following worked for me on an ATT 3b1 when compiling Bison: it
came over the net:


Originally-From: daveb@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@gonzo.uucp