alloca for V.4?

Dick Dunn rcd at ico.isc.com
Fri Oct 19 06:00:15 AEST 1990


davidsen at sixhub.UUCP (Wm E. Davidsen Jr) had posted a while back asking for
alloca() on V.4.  I answered via email, but the topic's back again so maybe
it needs a posting...

vrs at lint.hf.intel.com.ogi.edu writes:
> [Davidsen]
> >  Has anyone written an alloca for V.4? In spite of all the work done
> >for compatibility, there doesn't seem to be any library which has one.
...
> I suspect (not know, but suspect) not...

alloca() is there; it's just not obvious.

>...The compiler in V.4 is so optimizing
> that the output code doesn't resemble the input source all that much...

In a practical sense, the V.4 compiler seems to be about the same level of
optimization as the V.3.2 compiler (and gee, I'd really rather the output
code didn't resemble the input source that much, anyway...that's what I'm
paying the compiler for:-) except for one area...

>...In
> particular, the compiler plays fast and loose with stack frames, especially
> when inlining...

It doesn't play "fast and loose."  It simply doesn't maintain the frame
pointer (%ebp) unless it needs to.  This is a big win for programs with
lots of small, frequently-invoked functions.

> ...It just happens that
> the compiler on V.3 was not so smart, and alloca was still possible...

The compiler on V.4 is smart enough (unless you've got one from a fairly
early drop), and alloca() is possible.  The compiler generates proper
frame-pointer handling code in functions which reference alloca(); it's a
special case in the compiler.

It's about the same as what gcc does on the 386.

alloca() can be found in /usr/ucblib/libucb.a.  This isn't a perfect
solution; just adding the library to the compilation may alter other bits
of reality.  But you could extract alloca.o from the library to dodge
that.
-- 
Dick Dunn     rcd at ico.isc.com -or- ico!rcd       Boulder, CO   (303)449-2870
   ...Never offend with style when you can offend with substance.



More information about the Comp.unix.sysv386 mailing list