only export __chkstk for windows

it's a windows only function anyway
This commit is contained in:
Andrew Kelley 2017-08-31 20:10:24 -04:00
parent e93ece7514
commit 06b64d82bf

View File

@ -101,30 +101,32 @@ export nakedcc fn __aeabi_uidivmod() {
export nakedcc fn __chkstk() { export nakedcc fn __chkstk() {
@setDebugSafety(this, false); @setDebugSafety(this, false);
if (comptime builtin.arch == builtin.Arch.x86_64) { if (comptime builtin.os == builtin.Os.windows) {
asm volatile ( if (comptime builtin.arch == builtin.Arch.x86_64) {
\\ push %%rcx asm volatile (
\\ cmp $0x1000,%%rax \\ push %%rcx
\\ lea 16(%%rsp),%%rcx // rsp before calling this routine -> rcx \\ cmp $0x1000,%%rax
\\ jb 1f \\ lea 16(%%rsp),%%rcx // rsp before calling this routine -> rcx
\\ 2: \\ jb 1f
\\ sub $0x1000,%%rcx \\ 2:
\\ test %%rcx,(%%rcx) \\ sub $0x1000,%%rcx
\\ sub $0x1000,%%rax \\ test %%rcx,(%%rcx)
\\ cmp $0x1000,%%rax \\ sub $0x1000,%%rax
\\ ja 2b \\ cmp $0x1000,%%rax
\\ 1: \\ ja 2b
\\ sub %%rax,%%rcx \\ 1:
\\ test %%rcx,(%%rcx) \\ sub %%rax,%%rcx
\\ \\ test %%rcx,(%%rcx)
\\ lea 8(%%rsp),%%rax // load pointer to the return address into rax \\
\\ mov %%rcx,%%rsp // install the new top of stack pointer into rsp \\ lea 8(%%rsp),%%rax // load pointer to the return address into rax
\\ mov -8(%%rax),%%rcx // restore rcx \\ mov %%rcx,%%rsp // install the new top of stack pointer into rsp
\\ push (%%rax) // push return address onto the stack \\ mov -8(%%rax),%%rcx // restore rcx
\\ sub %%rsp,%%rax // restore the original value in rax \\ push (%%rax) // push return address onto the stack
\\ ret \\ sub %%rsp,%%rax // restore the original value in rax
); \\ ret
unreachable; );
unreachable;
}
} }
@setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal); @setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal);