Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!hp-pcd!hpfcso!mjs From: mjs@hpfcso.HP.COM (Marc Sabatella) Newsgroups: comp.sys.hp Subject: Re: alloca() on the HP9000/300 Message-ID: <7370189@hpfcso.HP.COM> Date: 9 Aug 90 16:26:07 GMT References: <1455@tub.UUCP> Organization: Hewlett-Packard, Fort Collins, CO, USA Lines: 26 >Is it possible to write a "real" alloca() for the HP at all, or is >there some sort of conflict with the C compiler (i.e. does the way >the stack pointer is handled make usage of alloca() impossible)? The conventional alloca() depends on the frame pointer / stack pointer model, in which a function references its local and parameters off of the frame pointer. alloca() diddles the stack pointer and returns, hoping that no one will notice, since all references are off a6 not a7, and a7 will be restored on the unlk. The Series 300 C compiler is smart enough to remove link/unlk pairs and convert references off a6 into references off a7. For this, it needs complete information about a7, and alloca() breaks the basic assumption that the stack pointer is preserved across the call. If you do not optimize (not even with "+O1"), you may be able to get away with using the standard alloca(). But I strongly advise against it. By its very nature, alloca() is non-portable (ie, it won't even work on machines that don't use the fp/sp model), and if one day the "remove link/unlk" feature is moved out of the optimizer and into the compiler proper, it will cease to function on the 300. -------------- Marc Sabatella (marc@hpmonk.fc.hp.com) Disclaimers: 2 + 2 = 3, for suitably small values of 2 Bill and Dave may not always agree with me