authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-30 13:39:18-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-30 13:39:37-04:00
log53aa72b58a72b5d557488ea6a4ea7e0827445fcd
treeab72aacedee5a964f86ce4b30318b1d1c14c164e
parent09369b6a434a594e8cd41a17b6356fae049d6d41

add ___chkstk_ms compiler-rt function


1 files changed, 32 insertions(+), 1 deletions(-)

std/special/compiler_rt/index.zig+32-1
......@@ -98,7 +98,7 @@ export nakedcc fn __aeabi_uidivmod() {
9898 @setGlobalLinkage(__aeabi_uidivmod, builtin.GlobalLinkage.Internal);
9999}
100100
101export nakedcc fn __chkstk() {
101export nakedcc fn __chkstk() align 4 {
102102 @setDebugSafety(this, false);
103103
104104 if (comptime builtin.os == builtin.Os.windows) {
......@@ -132,6 +132,37 @@ export nakedcc fn __chkstk() {
132132 @setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal);
133133}
134134
135export nakedcc fn ___chkstk_ms() align 4 {
136 @setDebugSafety(this, false);
137
138 if (comptime builtin.os == builtin.Os.windows) {
139 if (comptime builtin.arch == builtin.Arch.x86_64) {
140 asm volatile (
141 \\ push %%rcx
142 \\ push %%rax
143 \\ cmp $0x1000,%%rax
144 \\ lea 24(%%rsp),%%rcx
145 \\ jb 1f
146 \\2:
147 \\ sub $0x1000,%%rcx
148 \\ test %%rcx,(%%rcx)
149 \\ sub $0x1000,%%rax
150 \\ cmp $0x1000,%%rax
151 \\ ja 2b
152 \\1:
153 \\ sub %%rax,%%rcx
154 \\ test %%rcx,(%%rcx)
155 \\ pop %%rax
156 \\ pop %%rcx
157 \\ ret
158 );
159 unreachable;
160 }
161 }
162
163 @setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal);
164}
165
135166export fn __udivmodsi4(a: u32, b: u32, rem: &u32) -> u32 {
136167 @setDebugSafety(this, is_test);
137168 @setGlobalLinkage(__udivmodsi4, builtin.GlobalLinkage.LinkOnce);