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 ___chkstk_ms 20PUBLIC __alloca_probe 21 22__alloca_probe: 23___chkstk_ms: 24.PROC __chkstk 25 26 push rcx /* save temps */ 27 .pushreg rcx 28 push rax 29 .pushreg rax 30 .endprolog 31 32 cmp rax, PAGE_SIZE /* > 4k ?*/ 33 lea rcx, [rsp + 24] /* point past return addr */ 34 jb l_LessThanAPage 35 36l_MoreThanAPage: 37 sub rcx, PAGE_SIZE /* yes, move pointer down 4k */ 38 or byte ptr [rcx], 0 /* probe there */ 39 sub rax, PAGE_SIZE /* decrement count */ 40 41 cmp rax, PAGE_SIZE 42 ja l_MoreThanAPage /* and do it again */ 43 44l_LessThanAPage: 45 sub rcx, rax 46 or byte ptr [rcx], 0 /* less than 4k, just peek here */ 47 48 pop rax 49 pop rcx 50 ret 51 52.ENDP 53 54END 55/* EOF */ 56