commit 53aa72b58a72b5d557488ea6a4ea7e0827445fcd (tree)
parent 09369b6a434a594e8cd41a17b6356fae049d6d41
Author: Andrew Kelley <superjoe30@gmail.com>
Date: Sat, 30 Sep 2017 13:39:18 -0400
add ___chkstk_ms compiler-rt function
Diffstat:
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/std/special/compiler_rt/index.zig b/std/special/compiler_rt/index.zig
@@ -98,7 +98,7 @@ export nakedcc fn __aeabi_uidivmod() {
@setGlobalLinkage(__aeabi_uidivmod, builtin.GlobalLinkage.Internal);
}
-export nakedcc fn __chkstk() {
+export nakedcc fn __chkstk() align 4 {
@setDebugSafety(this, false);
if (comptime builtin.os == builtin.Os.windows) {
@@ -132,6 +132,37 @@ export nakedcc fn __chkstk() {
@setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal);
}
+export nakedcc fn ___chkstk_ms() align 4 {
+ @setDebugSafety(this, false);
+
+ if (comptime builtin.os == builtin.Os.windows) {
+ if (comptime builtin.arch == builtin.Arch.x86_64) {
+ asm volatile (
+ \\ push %%rcx
+ \\ push %%rax
+ \\ cmp $0x1000,%%rax
+ \\ lea 24(%%rsp),%%rcx
+ \\ jb 1f
+ \\2:
+ \\ sub $0x1000,%%rcx
+ \\ test %%rcx,(%%rcx)
+ \\ sub $0x1000,%%rax
+ \\ cmp $0x1000,%%rax
+ \\ ja 2b
+ \\1:
+ \\ sub %%rax,%%rcx
+ \\ test %%rcx,(%%rcx)
+ \\ pop %%rax
+ \\ pop %%rcx
+ \\ ret
+ );
+ unreachable;
+ }
+ }
+
+ @setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal);
+}
+
export fn __udivmodsi4(a: u32, b: u32, rem: &u32) -> u32 {
@setDebugSafety(this, is_test);
@setGlobalLinkage(__udivmodsi4, builtin.GlobalLinkage.LinkOnce);