cygwin.asm revision 256281
1239310Sdim/* stuff needed for libgcc on win32. 2239310Sdim * 3239310Sdim * Copyright (C) 1996, 1998, 2001, 2003 Free Software Foundation, Inc. 4239310Sdim * Written By Steve Chamberlain 5239310Sdim * 6239310Sdim * This file is free software; you can redistribute it and/or modify it 7239310Sdim * under the terms of the GNU General Public License as published by the 8239310Sdim * Free Software Foundation; either version 2, or (at your option) any 9239310Sdim * later version. 10239310Sdim * 11239310Sdim * In addition to the permissions in the GNU General Public License, the 12239310Sdim * Free Software Foundation gives you unlimited permission to link the 13239310Sdim * compiled version of this file with other programs, and to distribute 14239310Sdim * those programs without any restriction coming from the use of this 15249423Sdim * file. (The General Public License restrictions do apply in other 16239310Sdim * respects; for example, they cover modification of the file, and 17239310Sdim * distribution when not linked into another program.) 18276479Sdim * 19288943Sdim * This file is distributed in the hope that it will be useful, but 20249423Sdim * WITHOUT ANY WARRANTY; without even the implied warranty of 21249423Sdim * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22276479Sdim * General Public License for more details. 23249423Sdim * 24249423Sdim * You should have received a copy of the GNU General Public License 25239310Sdim * along with this program; see the file COPYING. If not, write to 26239310Sdim * the Free Software Foundation, 51 Franklin Street, Fifth Floor, 27239310Sdim * Boston, MA 02110-1301, USA. 28239310Sdim * 29239310Sdim * As a special exception, if you link this library with files 30276479Sdim * compiled with GCC to produce an executable, this does not cause 31276479Sdim * the resulting executable to be covered by the GNU General Public License. 32239310Sdim * This exception does not however invalidate any other reasons why 33239310Sdim * the executable file might be covered by the GNU General Public License. 34239310Sdim */ 35239310Sdim 36239310Sdim#ifdef L_chkstk 37239310Sdim 38239310Sdim/* Function prologue calls _alloca to probe the stack when allocating more 39239310Sdim than CHECK_STACK_LIMIT bytes in one go. Touching the stack at 4K 40239310Sdim increments is necessary to ensure that the guard pages used 41239310Sdim by the OS virtual memory manger are allocated in correct sequence. */ 42239310Sdim 43239310Sdim .global ___chkstk 44239310Sdim .global __alloca 45249423Sdim___chkstk: 46239310Sdim__alloca: 47239310Sdim pushl %ecx /* save temp */ 48239310Sdim movl %esp,%ecx /* get sp */ 49276479Sdim addl $0x8,%ecx /* and point to return addr */ 50239310Sdim 51276479Sdimprobe: cmpl $0x1000,%eax /* > 4k ?*/ 52288943Sdim jb done 53239310Sdim 54239310Sdim subl $0x1000,%ecx /* yes, move pointer down 4k*/ 55239310Sdim orl $0x0,(%ecx) /* probe there */ 56243830Sdim subl $0x1000,%eax /* decrement count */ 57239310Sdim jmp probe /* and do it again */ 58239310Sdim 59239310Sdimdone: subl %eax,%ecx 60239310Sdim orl $0x0,(%ecx) /* less that 4k, just peek here */ 61239310Sdim 62239310Sdim movl %esp,%eax 63276479Sdim movl %ecx,%esp /* decrement stack */ 64288943Sdim 65239310Sdim movl (%eax),%ecx /* recover saved temp */ 66239310Sdim movl 4(%eax),%eax /* get return address */ 67239310Sdim jmp *%eax 68239310Sdim#endif 69239310Sdim