Author: tkreuzer
Date: Sat May 14 19:12:09 2011
New Revision: 51747
URL:
http://svn.reactos.org/svn/reactos?rev=51747&view=rev
Log:
[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
Added:
trunk/reactos/lib/sdk/crt/except/amd64/chkstk_ms.s (with props)
trunk/reactos/lib/sdk/crt/except/i386/chkstk_ms.s (with props)
Modified:
trunk/reactos/lib/sdk/crt/crt.rbuild
trunk/reactos/lib/sdk/crt/libcntpr.rbuild
Modified: trunk/reactos/lib/sdk/crt/crt.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/crt.rbuild?rev…
==============================================================================
--- trunk/reactos/lib/sdk/crt/crt.rbuild [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/crt.rbuild [iso-8859-1] Sat May 14 19:12:09 2011
@@ -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">
Added: trunk/reactos/lib/sdk/crt/except/amd64/chkstk_ms.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/except/amd64/c…
==============================================================================
--- trunk/reactos/lib/sdk/crt/except/amd64/chkstk_ms.s (added)
+++ trunk/reactos/lib/sdk/crt/except/amd64/chkstk_ms.s [iso-8859-1] Sat May 14 19:12:09
2011
@@ -1,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(a)redhat.com>
+ * Kai Tietz <kai.tietz(a)onevision.com>
+ * Timo Kreuzer (timo.kreuzer(a)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 */
Propchange: trunk/reactos/lib/sdk/crt/except/amd64/chkstk_ms.s
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/lib/sdk/crt/except/i386/chkstk_ms.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/except/i386/ch…
==============================================================================
--- trunk/reactos/lib/sdk/crt/except/i386/chkstk_ms.s (added)
+++ trunk/reactos/lib/sdk/crt/except/i386/chkstk_ms.s [iso-8859-1] Sat May 14 19:12:09
2011
@@ -1,0 +1,59 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * PURPOSE: Stack checker
+ * PROGRAMERS: KJK::Hyperion <noog(a)libero.it>
+ * Richard Henderson <rth(a)redhat.com>
+ * Kai Tietz <kai.tietz(a)onevision.com>
+ * Timo Kreuzer <timo.kreuzer(a)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
Propchange: trunk/reactos/lib/sdk/crt/except/i386/chkstk_ms.s
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/lib/sdk/crt/libcntpr.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/libcntpr.rbuil…
==============================================================================
--- trunk/reactos/lib/sdk/crt/libcntpr.rbuild [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/libcntpr.rbuild [iso-8859-1] Sat May 14 19:12:09 2011
@@ -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>