Path: utzoo!attcan!uunet!mcsun!hp4nl!ruuinf!piet From: piet@cs.ruu.nl (Piet van Oostrum) Newsgroups: comp.sys.hp Subject: Re: How to make gcc and g++ on HP-UX 7.0. (Summary) Message-ID: <3568@ruuinf.cs.ruu.nl> Date: 4 Jul 90 17:25:53 GMT References: <1583@kuling.UUCP> Sender: news@ruuinf.cs.ruu.nl Reply-To: piet@cs.ruu.nl (Piet van Oostrum) Organization: Dept of Computer Science, Utrecht University, The Netherlands Lines: 46 In-reply-to: jand@kuling.UUCP (Jan Dj{rv) The alloca() from libPW does indeed give performance problems, as does the portable one supplied by GNU. There is an assembler alloca in gnu emacs, but that one is broken. It can lead to stack corruption during a signal handler. I have a patch for that, and I also have rewritten it from scratch. Here follows a free one: # This assembly routine implements alloca (n) # The HP compiler does "move.m (%sp)" to save registers, # so we must copy the possibly saved registers to the top of stack. # The stack layout at entry is: # possibly saved regs # n # return address <--- sp set MAXREG,22 # d2-d7, a2-a5, fp2-fp7 may have been saved text global _alloca _alloca: move.l (%sp)+,%a0 # save return addess move.l %sp,%d0 # old stack pointer sub.l (%sp)+,%d0 # subtract number of bytes requested or.l &3,%d0 # prepare for longword alignment # now d0 = return value - 1! sub.l &MAXREG*4-1,%d0 # allocate space for saving registers move.l %sp,%a1 # source for reg copy move.l %a2,%d1 # save reg a2 move.l %d0,%a2 # dest for reg copy move.l %d0,%sp # save new value of sp move.w &MAXREG-1,%d0 # loop counter copy: # save possibly saved registers move.l (%a1)+,(%a2)+ dbra %d0,copy move.l %a2,%d0 # return value move.l %d1,%a2 # restore reg a2 add.l &-4,%sp # this compensates for add.l &4,%sp # generated by the compiler jmp (%a0) # rts -- Piet* van Oostrum, Dept of Computer Science, Utrecht University, Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands. Telephone: +31-30-531806 Uucp: uunet!mcsun!ruuinf!piet Telefax: +31-30-513791 Internet: piet@cs.ruu.nl (*`Pete')