* Need alloca which allocates storage IN the stack frame (Ultrix)
@ 1993-01-19 20:40 Timothy VanFosson
1993-01-20 14:52 ` zrepachol
1993-01-21 11:16 ` Don Stokes
0 siblings, 2 replies; 6+ messages in thread
From: Timothy VanFosson @ 1993-01-19 20:40 UTC (permalink / raw)
Does anyone have an implementation of alloca() which actually
sets aside storage in the stack frame? I'm trying to port
the NIH Class Library and have everything working except the
process classes, and I've narrowed it down to the DEC implementation
of alloca() not being what NIH expects.
Any help would be appreciated.
Thanks,
--tv
--
Timothy VanFosson E-mail : timv@ccad.uiowa.edu
Senior Systems Analyst US Mail : CAD-Research
University of Iowa 228 ERF
Phone: (319) 335-5728 FAX: (319) 335-6061 Iowa City, Iowa 52242
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Need alloca which allocates storage IN the stack frame (Ultrix)
1993-01-19 20:40 Need alloca which allocates storage IN the stack frame (Ultrix) Timothy VanFosson
@ 1993-01-20 14:52 ` zrepachol
1993-01-21 11:16 ` Don Stokes
1 sibling, 0 replies; 6+ messages in thread
From: zrepachol @ 1993-01-20 14:52 UTC (permalink / raw)
In article <1993Jan19.204025.4666@ccad.uiowa.edu>, timv@ccad.uiowa.edu (Timothy VanFosson) writes:
> Does anyone have an implementation of alloca() which actually
> sets aside storage in the stack frame? I'm trying to port
Look at GNUEmacs. It does this. sould have the code in there already. ( and
you get a good editor as a fring benefit )
~Paul
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Need alloca which allocates storage IN the stack frame (Ultrix)
1993-01-19 20:40 Need alloca which allocates storage IN the stack frame (Ultrix) Timothy VanFosson
1993-01-20 14:52 ` zrepachol
@ 1993-01-21 11:16 ` Don Stokes
1993-01-21 16:30 ` Timothy VanFosson
1 sibling, 1 reply; 6+ messages in thread
From: Don Stokes @ 1993-01-21 11:16 UTC (permalink / raw)
timv@ccad.uiowa.edu (Timothy VanFosson) writes:
> Does anyone have an implementation of alloca() which actually
> sets aside storage in the stack frame? I'm trying to port
> the NIH Class Library and have everything working except the
> process classes, and I've narrowed it down to the DEC implementation
> of alloca() not being what NIH expects.
You don't say what system you want this for. It kinda matters, since you
can't really do an alloca() in C.
Anyway, since it's short, here's a VAX MACRO alloca() (code filched from GCC,
comments by me):
.title ALLOCA allocate dynamic storage on stack
.psect $CODE, long,pic,rel,shr,exe,rd,nowrt
.entry ALLOCA, ^M<> ; Entry point, save no general registers.
subl2 4(AP), SP ; Allocate stack space
movl 16(FP), R1 ; Get return address from soon to be redundant
; stack frame (used for returning)
movq 8(FP), AP ; Restore AP & FP from stack frame
bicl #3, SP ; Longword-align stack
addl2 #28, SP ; Deallocate now-redundant frame from stack
; (This is not done until we are finished with
; the frame, since the size of the block
; alloca()ed could be smaller than 28 bytes
; and it would be bad if we were interrupted.)
movl SP, R0 ; Return address of bottom of stack
jmp (R1) ; Return without unwinding stack.
.end
--
Don Stokes, ZL2TNM (DS555) don@zl2tnm.gen.nz (home)
Network Manager, Computing Services Centre don@vuw.ac.nz (work)
Victoria University of Wellington, New Zealand +64-4-495-5052
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Need alloca which allocates storage IN the stack frame (Ultrix)
1993-01-21 11:16 ` Don Stokes
@ 1993-01-21 16:30 ` Timothy VanFosson
1993-01-21 22:58 ` John Wroclawski
0 siblings, 1 reply; 6+ messages in thread
From: Timothy VanFosson @ 1993-01-21 16:30 UTC (permalink / raw)
From article <9915020@zl2tnm.gen.nz>, by don@zl2tnm.gen.nz (Don Stokes):
> timv@ccad.uiowa.edu (Timothy VanFosson) writes:
>> Does anyone have an implementation of alloca() which actually
>> sets aside storage in the stack frame? I'm trying to port
>> the NIH Class Library and have everything working except the
>> process classes, and I've narrowed it down to the DEC implementation
>> of alloca() not being what NIH expects.
>
> You don't say what system you want this for. It kinda matters, since you
> can't really do an alloca() in C.
>
> Anyway, since it's short, here's a VAX MACRO alloca() (code filched from GCC,
> comments by me):
>
Thanks for the response, but (as you point out) I neglected to mention
that this is for a DECStation 5000/200. Thanks also to those who
have suggested GNU Emacs/GCC alloca(), but it works (doesn't work :-)
in the same manner as the DEC alloca() -- the storage allocated is
not IN the stack. I had already tried it before I posted.
I am still looking for an (assembly) version of alloca() which
does manipulate the stack to allocate storage.
--tv
--
Timothy VanFosson E-mail : timv@ccad.uiowa.edu
Senior Systems Analyst US Mail : CAD-Research
University of Iowa 228 ERF
Phone: (319) 335-5728 FAX: (319) 335-6061 Iowa City, Iowa 52242
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Need alloca which allocates storage IN the stack frame (Ultrix)
1993-01-21 16:30 ` Timothy VanFosson
@ 1993-01-21 22:58 ` John Wroclawski
1993-01-22 14:47 ` Marcus J Ranum
0 siblings, 1 reply; 6+ messages in thread
From: John Wroclawski @ 1993-01-21 22:58 UTC (permalink / raw)
From: timv@ccad.uiowa.edu (Timothy VanFosson)
Thanks for the response, but (as you point out) I neglected to mention
that this is for a DECStation 5000/200. Thanks also to those who
have suggested GNU Emacs/GCC alloca(), but it works (doesn't work :-)
in the same manner as the DEC alloca() -- the storage allocated is
not IN the stack. I had already tried it before I posted.
I am still looking for an (assembly) version of alloca() which
does manipulate the stack to allocate storage.
The problem here is that since the Mips calling standard does not
require the use of a frame pointer (and in fact an FP is almost never
used in optimized code), implementing an in-stack alloca requires some
help from the compiler (because you must move the stack pointer, but
the SP is used to reference local variables.
The decstation version of GCC provides this support. So does the
standard Ultrix C compiler, but you must include <alloca.h> or
"#define alloca __builtin_alloca" in any file that needs it. However,
as I recall the version built in to the standard compiler has some
limitations, which are documented in <alloca.h> and perhaps elsewhere.
John Wroclawski
MIT Lab for Computer Science
jtw@lcs.mit.edu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Need alloca which allocates storage IN the stack frame (Ultrix)
1993-01-21 22:58 ` John Wroclawski
@ 1993-01-22 14:47 ` Marcus J Ranum
0 siblings, 0 replies; 6+ messages in thread
From: Marcus J Ranum @ 1993-01-22 14:47 UTC (permalink / raw)
> I am still looking for an (assembly) version of alloca() which
> does manipulate the stack to allocate storage.
This is a language issue that's better flame-broiled in comp.lang.c,
but reasonable arguments can be made that code using alloca() is broken,
and should be fixed. Finding a version of alloca() is a temporary fix for
the bug, but writing code that doesn't depend on it is a better one.
mjr.
--
"guns don't die. people do."
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1993-01-22 14:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-01-19 20:40 Need alloca which allocates storage IN the stack frame (Ultrix) Timothy VanFosson
1993-01-20 14:52 ` zrepachol
1993-01-21 11:16 ` Don Stokes
1993-01-21 16:30 ` Timothy VanFosson
1993-01-21 22:58 ` John Wroclawski
1993-01-22 14:47 ` Marcus J Ranum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox