mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 06:05:48 +00:00
Create a branch for header work.
svn path=/branches/header-work/; revision=45691
This commit is contained in:
parent
14fe274b1c
commit
9ea495ba33
19538 changed files with 0 additions and 1063950 deletions
66
lib/sdk/crt/except/i386/chkstk_asm.s
Normal file
66
lib/sdk/crt/except/i386/chkstk_asm.s
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* $Id$
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: Stack checker
|
||||
* FILE: lib/ntdll/rtl/i386/chkstk.s
|
||||
* PROGRAMER: KJK::Hyperion <noog@libero.it>
|
||||
*/
|
||||
|
||||
.globl __chkstk
|
||||
.globl __alloca_probe
|
||||
|
||||
/*
|
||||
_chkstk() is called by all stack allocations of more than 4 KB. It grows the
|
||||
stack in areas of 4 KB each, trying to access each area. This ensures that the
|
||||
guard page for the stack is hit, and the stack growing triggered
|
||||
*/
|
||||
__chkstk:
|
||||
__alloca_probe:
|
||||
|
||||
/* EAX = size to be allocated */
|
||||
/* save the ECX register */
|
||||
pushl %ecx
|
||||
|
||||
/* ECX = top of the previous stack frame */
|
||||
leal 8(%esp), %ecx
|
||||
|
||||
/* probe the desired memory, page by page */
|
||||
cmpl $0x1000, %eax
|
||||
jge .l_MoreThanAPage
|
||||
jmp .l_LessThanAPage
|
||||
|
||||
.l_MoreThanAPage:
|
||||
|
||||
/* raise the top of the stack by a page and probe */
|
||||
subl $0x1000, %ecx
|
||||
testl %eax, 0(%ecx)
|
||||
|
||||
/* loop if still more than a page must be probed */
|
||||
subl $0x1000, %eax
|
||||
cmpl $0x1000, %eax
|
||||
jge .l_MoreThanAPage
|
||||
|
||||
.l_LessThanAPage:
|
||||
|
||||
/* raise the top of the stack by EAX bytes (size % 4096) and probe */
|
||||
subl %eax, %ecx
|
||||
testl %eax, 0(%ecx)
|
||||
|
||||
/* EAX = top of the stack */
|
||||
movl %esp, %eax
|
||||
|
||||
/* allocate the memory */
|
||||
movl %ecx, %esp
|
||||
|
||||
/* restore ECX */
|
||||
movl 0(%eax), %ecx
|
||||
|
||||
/* restore the return address */
|
||||
movl 4(%eax), %eax
|
||||
pushl %eax
|
||||
|
||||
/* return */
|
||||
ret
|
||||
|
||||
/* EOF */
|
Loading…
Add table
Add a link
Reference in a new issue