alloca() portability
Stephen Clamage
steve at taumet.com
Sat Nov 3 03:24:11 AEST 1990
russ at groucho.ucar.edu (Russ Rew) writes:
>Comments in Doug Gwyn's "(mostly) portable public-domain implementation" of
>alloca say
> It should work under any C implementation that uses an
> actual procedure stack (as opposed to a linked list of
> frames).
>What common platforms do not provide an alloca or cannot use Doug Gwyn's
>alloca because they don't use a procedure stack? In other words, if we
>decide to use alloca despite the warnings about its portability, what
>platforms are we precluding?
There is more to it than the target machine. Some compilers get a
performance win by omitting frame pointers and leveling the stack only
when actually needed. The compiler keeps track of the top of the
stack, and parameter and local variable references are relative to the
current TOS rather than to the FP. Upon return from a function, the
stack is not necessarily popped -- it gets leveled only when different
flow paths converge. With such a stack management strategy, alloca
cannot be implemented as a library routine -- it would have to be built
into the compiler.
--
Steve Clamage, TauMetric Corp, steve at taumet.com
More information about the Comp.lang.c
mailing list