1/* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS system libraries 4 * PURPOSE: Implementation of _chkstk and _alloca_probe 5 * PROGRAMMERS Richard Henderson <rth@redhat.com> 6 * Kai Tietz <kai.tietz@onevision.com> 7 * Timo Kreuzer (timo.kreuzer@reactos.org) 8 */ 9 10/* INCLUDES ******************************************************************/ 11 12#include <asm.inc> 13#define PAGE_SIZE 4096 14 15/* CODE **********************************************************************/ 16.code64 17 18PUBLIC __chkstk 19PUBLIC __alloca_probe 20 21__alloca_probe: 22.PROC __chkstk 23 24 push rcx /* save temps */ 25 .pushreg rcx 26 push rax 27 .pushreg rax 28 .endprolog 29 30 cmp rax, PAGE_SIZE /* > 4k ?*/ 31 lea rcx, [rsp + 24] /* point past return addr */ 32 jb l_LessThanAPage 33 34l_MoreThanAPage: 35 sub rcx, PAGE_SIZE /* yes, move pointer down 4k */ 36 or byte ptr [rcx], 0 /* probe there */ 37 sub rax, PAGE_SIZE /* decrement count */ 38 39 cmp rax, PAGE_SIZE 40 ja l_MoreThanAPage /* and do it again */ 41 42l_LessThanAPage: 43 sub rcx, rax 44 or byte ptr [rcx], 0 /* less than 4k, just peek here */ 45 46 pop rax 47 pop rcx 48 ret 49 50.ENDP 51 52END 53/* EOF */ 54