mirror of
https://github.com/reactos/reactos.git
synced 2024-06-28 08:51:29 +00:00
[CRT]
- Implement __chkstk_ms for x86 and amd64 - amd64 code is based on code by Kai Tietz and Richard Henderson - x86 code is based on old __chkstk implementation and code by Kai Tietz and Richard Henderson - Function is required by newer gcc versions svn path=/trunk/; revision=51747
This commit is contained in:
parent
75b8d216e2
commit
c016e5d41e
|
@ -6,6 +6,7 @@
|
|||
<if property="ARCH" value="i386">
|
||||
<directory name="i386">
|
||||
<file>chkstk_asm.s</file>
|
||||
<file>chkstk_ms.s</file>
|
||||
</directory>
|
||||
</if>
|
||||
<if property="ARCH" value="powerpc">
|
||||
|
|
51
reactos/lib/sdk/crt/except/amd64/chkstk_ms.s
Normal file
51
reactos/lib/sdk/crt/except/amd64/chkstk_ms.s
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* PURPOSE: Implementation of _chkstk and _alloca_probe
|
||||
* PROGRAMMERS Richard Henderson <rth@redhat.com>
|
||||
* Kai Tietz <kai.tietz@onevision.com>
|
||||
* Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <asm.inc>
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
.code64
|
||||
|
||||
PUBLIC ___chkstk_ms
|
||||
|
||||
//cfi_startproc()
|
||||
___chkstk_ms:
|
||||
push rcx /* save temps */
|
||||
//cfi_push(%rcx)
|
||||
push rax
|
||||
//cfi_push(%rax)
|
||||
|
||||
cmp rax, PAGE_SIZE /* > 4k ?*/
|
||||
lea rcx, [rsp + 24] /* point past return addr */
|
||||
jb l_LessThanAPage
|
||||
|
||||
.l_MoreThanAPage:
|
||||
sub rcx, PAGE_SIZE /* yes, move pointer down 4k */
|
||||
or rcx, 0 /* probe there */
|
||||
sub rax, PAGE_SIZE /* decrement count */
|
||||
|
||||
cmp rax, PAGE_SIZE
|
||||
ja l_MoreThanAPage /* and do it again */
|
||||
|
||||
.l_LessThanAPage:
|
||||
sub rcx, rax
|
||||
or [rcx], 0 /* less than 4k, just peek here */
|
||||
|
||||
pop rax
|
||||
//cfi_pop(%rax)
|
||||
pop rcx
|
||||
//cfi_pop(%rcx)
|
||||
ret
|
||||
//cfi_endproc()
|
||||
|
||||
END
|
||||
/* EOF */
|
59
reactos/lib/sdk/crt/except/i386/chkstk_ms.s
Normal file
59
reactos/lib/sdk/crt/except/i386/chkstk_ms.s
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: Stack checker
|
||||
* PROGRAMERS: KJK::Hyperion <noog@libero.it>
|
||||
* Richard Henderson <rth@redhat.com>
|
||||
* Kai Tietz <kai.tietz@onevision.com>
|
||||
* Timo Kreuzer <timo.kreuzer@reactos.org>
|
||||
*/
|
||||
|
||||
#include <asm.inc>
|
||||
#include <ks386.inc>
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
PUBLIC ___chkstk_ms
|
||||
.code
|
||||
|
||||
/* Special version, that does only probe and not allocate */
|
||||
___chkstk_ms:
|
||||
|
||||
/* EAX = size to be allocated */
|
||||
/* save the ECX and EAX register */
|
||||
push ecx
|
||||
push eax
|
||||
|
||||
/* ECX = top of the previous stack frame */
|
||||
lea ecx, [esp + 12]
|
||||
|
||||
/* probe the desired memory, page by page */
|
||||
cmp eax, PAGE_SIZE
|
||||
jl .l_LessThanAPage
|
||||
|
||||
.l_MoreThanAPage:
|
||||
|
||||
/* raise the top of the stack by a page and probe */
|
||||
sub ecx, PAGE_SIZE
|
||||
test [ecx], eax
|
||||
|
||||
/* loop if still more than a page must be probed */
|
||||
sub eax, PAGE_SIZE
|
||||
cmp eax, PAGE_SIZE
|
||||
jge .l_MoreThanAPage
|
||||
|
||||
.l_LessThanAPage:
|
||||
|
||||
/* raise the top of the stack by EAX bytes (size % 4096) and probe */
|
||||
sub ecx, eax
|
||||
test [ecx], eax
|
||||
|
||||
/* restore ECX and EAX */
|
||||
pop eax
|
||||
pop ecx
|
||||
|
||||
/* return */
|
||||
ret
|
||||
|
||||
/* EOF */
|
||||
END
|
|
@ -33,6 +33,7 @@
|
|||
<if property="ARCH" value="i386">
|
||||
<directory name="i386">
|
||||
<file>chkstk_asm.s</file>
|
||||
<file>chkstk_ms.s</file>
|
||||
<file>seh.s</file>
|
||||
</directory>
|
||||
</if>
|
||||
|
|
Loading…
Reference in a new issue