Reid Kleckner | c27de5b | 2015-07-17 16:31:59 +0000 | [diff] [blame] | 1 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 2 | // Source Licenses. See LICENSE.TXT for details. |
| 3 | |
| 4 | #include "../assembly.h" |
| 5 | |
| 6 | // _chkstk routine |
| 7 | // This routine is windows specific |
| 8 | // http://msdn.microsoft.com/en-us/library/ms648426.aspx |
| 9 | |
| 10 | #ifdef __i386__ |
| 11 | |
| 12 | .text |
| 13 | .balign 4 |
| 14 | DEFINE_COMPILERRT_FUNCTION(__chkstk_ms) |
| 15 | push %ecx |
| 16 | push %eax |
| 17 | cmp $0x1000,%eax |
| 18 | lea 12(%esp),%ecx |
| 19 | jb 1f |
| 20 | 2: |
| 21 | sub $0x1000,%ecx |
Martell Malone | 40eb83b | 2015-11-03 15:46:23 +0000 | [diff] [blame] | 22 | test %ecx,(%ecx) |
Reid Kleckner | c27de5b | 2015-07-17 16:31:59 +0000 | [diff] [blame] | 23 | sub $0x1000,%eax |
| 24 | cmp $0x1000,%eax |
| 25 | ja 2b |
| 26 | 1: |
| 27 | sub %eax,%ecx |
Martell Malone | 40eb83b | 2015-11-03 15:46:23 +0000 | [diff] [blame] | 28 | test %ecx,(%ecx) |
Reid Kleckner | c27de5b | 2015-07-17 16:31:59 +0000 | [diff] [blame] | 29 | pop %eax |
| 30 | pop %ecx |
| 31 | ret |
| 32 | END_COMPILERRT_FUNCTION(__chkstk_ms) |
| 33 | |
| 34 | #endif // __i386__ |