1// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2// See https://llvm.org/LICENSE.txt for license information.
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#include "../assembly.h"
6
7// _chkstk routine
8// This routine is windows specific
9// http://msdn.microsoft.com/en-us/library/ms648426.aspx
10
11#ifdef __i386__
12
13.text
14.balign 4
15DEFINE_COMPILERRT_FUNCTION(__chkstk_ms)
16        push   %ecx
17        push   %eax
18        cmp    $0x1000,%eax
19        lea    12(%esp),%ecx
20        jb     1f
212:
22        sub    $0x1000,%ecx
23        test   %ecx,(%ecx)
24        sub    $0x1000,%eax
25        cmp    $0x1000,%eax
26        ja     2b
271:
28        sub    %eax,%ecx
29        test   %ecx,(%ecx)
30        pop    %eax
31        pop    %ecx
32        ret
33END_COMPILERRT_FUNCTION(__chkstk_ms)
34
35#endif // __i386__
36