2011-05-14 19:12:09 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2018-01-29 17:37:09 +00:00
|
|
|
PUBLIC __chkstk
|
|
|
|
PUBLIC __alloca_probe
|
|
|
|
|
|
|
|
__alloca_probe:
|
|
|
|
.PROC __chkstk
|
2011-05-14 19:12:09 +00:00
|
|
|
|
|
|
|
push rcx /* save temps */
|
2018-01-29 17:37:09 +00:00
|
|
|
.pushreg rcx
|
2011-05-14 19:12:09 +00:00
|
|
|
push rax
|
2018-01-29 17:37:09 +00:00
|
|
|
.pushreg rax
|
|
|
|
.endprolog
|
2011-05-14 19:12:09 +00:00
|
|
|
|
|
|
|
cmp rax, PAGE_SIZE /* > 4k ?*/
|
|
|
|
lea rcx, [rsp + 24] /* point past return addr */
|
|
|
|
jb l_LessThanAPage
|
|
|
|
|
2011-06-26 22:57:12 +00:00
|
|
|
l_MoreThanAPage:
|
2011-05-14 19:12:09 +00:00
|
|
|
sub rcx, PAGE_SIZE /* yes, move pointer down 4k */
|
2011-06-26 22:57:12 +00:00
|
|
|
or byte ptr [rcx], 0 /* probe there */
|
2011-05-14 19:12:09 +00:00
|
|
|
sub rax, PAGE_SIZE /* decrement count */
|
|
|
|
|
|
|
|
cmp rax, PAGE_SIZE
|
|
|
|
ja l_MoreThanAPage /* and do it again */
|
|
|
|
|
2011-06-26 22:57:12 +00:00
|
|
|
l_LessThanAPage:
|
2011-05-14 19:12:09 +00:00
|
|
|
sub rcx, rax
|
2011-06-26 22:57:12 +00:00
|
|
|
or byte ptr [rcx], 0 /* less than 4k, just peek here */
|
2011-05-14 19:12:09 +00:00
|
|
|
|
|
|
|
pop rax
|
|
|
|
pop rcx
|
|
|
|
ret
|
2018-01-29 17:37:09 +00:00
|
|
|
|
|
|
|
.ENDP
|
2011-05-14 19:12:09 +00:00
|
|
|
|
|
|
|
END
|
|
|
|
/* EOF */
|