diff options
Diffstat (limited to 'std/special')
| -rw-r--r-- | std/special/compiler_rt/index.zig | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/std/special/compiler_rt/index.zig b/std/special/compiler_rt/index.zig index 73272706ab..319a72d001 100644 --- 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); |
