Mail Archives: cygwin-developers/2001/10/22/22:22:24
On Tue, Oct 23, 2001 at 12:18:05PM +1000, Robert Collins wrote:
>on every call, it checks the stack depth. _everything_ allocated from a
>call point deeper in the stack is reclaimed, and freed (alloca only uses
>the stack to identify when to do stuff, not for storage).
That's what libiberty's alloca does. That is for systems for which a
real alloca is difficult or impossible. That isn't what the builtin
alloca does.
The alloca that cygwin uses is below. This is from
gcc/config/i386/cygwin.asm.
It is possible that a function would call __chkstk when it needed to
allocate space beyond a certain limit. Not every function begins with a
call to __chkstk/alloca, though.
cgf
/* stuff needed for libgcc on win32. */
#ifdef L_chkstk
.global ___chkstk
.global __alloca
___chkstk:
__alloca:
pushl %ecx /* save temp */
movl %esp,%ecx /* get sp */
addl $0x8,%ecx /* and point to return addr */
probe: cmpl $0x1000,%eax /* > 4k ?*/
jb done
subl $0x1000,%ecx /* yes, move pointer down 4k*/
orl $0x0,(%ecx) /* probe there */
subl $0x1000,%eax /* decrement count */
jmp probe /* and do it again */
done: subl %eax,%ecx
orl $0x0,(%ecx) /* less that 4k, just peek here */
movl %esp,%eax
movl %ecx,%esp /* decrement stack */
movl (%eax),%ecx /* recover saved temp */
movl 4(%eax),%eax /* get return address */
jmp *%eax
#endif
- Raw text -