back to the (ivory) tower

Jack Jansen jack at cwi.nl
Sun Jun 12 01:00:52 AEST 1988


I think alloca() should be implementable on all architectures, even
those with a 'virtual stackpointer' (i.e. those where the compiler
knows that the stackpointer will always be fp+NNN (or the other way
around, for that matter)).

I trick I once used was to allocate the memory on the heap,
allocate two extra words, use one of them to build a linked list of
all alloca-blocks within the scope and (here comes the trick) store the
original return address in the other one, and replace the return address
by the address of a routine that will free alloca() blocks and then
really return.

The only problem is setjump/longjump, but these can probably be
massaged to handle the alloca blocks.
-- 
	Jack Jansen, jack at cwi.nl (or jack at mcvax.uucp)
	The shell is my oyster.



More information about the Comp.unix.wizards mailing list