OSDN Git Service

2006-01-26 Paolo Bonzini <bonzini@gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / cygwin.asm
1 /* stuff needed for libgcc on win32.
2  *
3  *   Copyright (C) 1996, 1998, 2001, 2003 Free Software Foundation, Inc.
4  *   Written By Steve Chamberlain
5  * 
6  * This file is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation; either version 2, or (at your option) any
9  * later version.
10  * 
11  * In addition to the permissions in the GNU General Public License, the
12  * Free Software Foundation gives you unlimited permission to link the
13  * compiled version of this file with other programs, and to distribute
14  * those programs without any restriction coming from the use of this
15  * file.  (The General Public License restrictions do apply in other
16  * respects; for example, they cover modification of the file, and
17  * distribution when not linked into another program.)
18  * 
19  * This file is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22  * General Public License for more details.
23  * 
24  * You should have received a copy of the GNU General Public License
25  * along with this program; see the file COPYING.  If not, write to
26  * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
27  * Boston, MA 02110-1301, USA.
28  * 
29  *    As a special exception, if you link this library with files
30  *    compiled with GCC to produce an executable, this does not cause
31  *    the resulting executable to be covered by the GNU General Public License.
32  *    This exception does not however invalidate any other reasons why
33  *    the executable file might be covered by the GNU General Public License.
34  */
35
36 #ifdef L_chkstk
37
38 /* Function prologue calls _alloca to probe the stack when allocating more
39    than CHECK_STACK_LIMIT bytes in one go.  Touching the stack at 4K
40    increments is necessary to ensure that the guard pages used
41    by the OS virtual memory manger are allocated in correct sequence.  */
42
43         .global ___chkstk
44         .global __alloca
45 ___chkstk:
46 __alloca:
47         pushl  %ecx             /* save temp */
48         movl   %esp,%ecx        /* get sp */
49         addl   $0x8,%ecx        /* and point to return addr */
50
51 probe:  cmpl   $0x1000,%eax     /* > 4k ?*/
52         jb    done              
53
54         subl   $0x1000,%ecx             /* yes, move pointer down 4k*/
55         orl    $0x0,(%ecx)              /* probe there */
56         subl   $0x1000,%eax             /* decrement count */
57         jmp    probe                    /* and do it again */
58
59 done:   subl   %eax,%ecx           
60         orl    $0x0,(%ecx)      /* less that 4k, just peek here */
61
62         movl   %esp,%eax
63         movl   %ecx,%esp        /* decrement stack */
64
65         movl   (%eax),%ecx      /* recover saved temp */
66         movl   4(%eax),%eax     /* get return address */
67         jmp    *%eax    
68 #endif