authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-31 20:10:24-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-31 20:10:24-04:00
log06b64d82bf4baad296ff7c37d7c8ff08ce2bdc69
treea6154a7bbc5cbf6eb8945dc84ebfe689c7a4f41a
parente93ece7514dc9199523f71efe0ac480ef143985e

only export __chkstk for windows

it's a windows only function anyway

1 files changed, 26 insertions(+), 24 deletions(-)

std/special/compiler_rt/index.zig+26-24
......@@ -101,30 +101,32 @@ export nakedcc fn __aeabi_uidivmod() {
101101export nakedcc fn __chkstk() {
102102 @setDebugSafety(this, false);
103103
104 if (comptime builtin.arch == builtin.Arch.x86_64) {
105 asm volatile (
106 \\ push %%rcx
107 \\ cmp $0x1000,%%rax
108 \\ lea 16(%%rsp),%%rcx // rsp before calling this routine -> rcx
109 \\ jb 1f
110 \\ 2:
111 \\ sub $0x1000,%%rcx
112 \\ test %%rcx,(%%rcx)
113 \\ sub $0x1000,%%rax
114 \\ cmp $0x1000,%%rax
115 \\ ja 2b
116 \\ 1:
117 \\ sub %%rax,%%rcx
118 \\ test %%rcx,(%%rcx)
119 \\
120 \\ lea 8(%%rsp),%%rax // load pointer to the return address into rax
121 \\ mov %%rcx,%%rsp // install the new top of stack pointer into rsp
122 \\ mov -8(%%rax),%%rcx // restore rcx
123 \\ push (%%rax) // push return address onto the stack
124 \\ sub %%rsp,%%rax // restore the original value in rax
125 \\ ret
126 );
127 unreachable;
104 if (comptime builtin.os == builtin.Os.windows) {
105 if (comptime builtin.arch == builtin.Arch.x86_64) {
106 asm volatile (
107 \\ push %%rcx
108 \\ cmp $0x1000,%%rax
109 \\ lea 16(%%rsp),%%rcx // rsp before calling this routine -> rcx
110 \\ jb 1f
111 \\ 2:
112 \\ sub $0x1000,%%rcx
113 \\ test %%rcx,(%%rcx)
114 \\ sub $0x1000,%%rax
115 \\ cmp $0x1000,%%rax
116 \\ ja 2b
117 \\ 1:
118 \\ sub %%rax,%%rcx
119 \\ test %%rcx,(%%rcx)
120 \\
121 \\ lea 8(%%rsp),%%rax // load pointer to the return address into rax
122 \\ mov %%rcx,%%rsp // install the new top of stack pointer into rsp
123 \\ mov -8(%%rax),%%rcx // restore rcx
124 \\ push (%%rax) // push return address onto the stack
125 \\ sub %%rsp,%%rax // restore the original value in rax
126 \\ ret
127 );
128 unreachable;
129 }
128130 }
129131
130132 @setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal);