mirror of
https://github.com/ziglang/zig.git
synced 2025-12-16 03:03:09 +00:00
only export __chkstk for windows
it's a windows only function anyway
This commit is contained in:
parent
e93ece7514
commit
06b64d82bf
@ -101,30 +101,32 @@ export nakedcc fn __aeabi_uidivmod() {
|
||||
export nakedcc fn __chkstk() {
|
||||
@setDebugSafety(this, false);
|
||||
|
||||
if (comptime builtin.arch == builtin.Arch.x86_64) {
|
||||
asm volatile (
|
||||
\\ push %%rcx
|
||||
\\ cmp $0x1000,%%rax
|
||||
\\ lea 16(%%rsp),%%rcx // rsp before calling this routine -> 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)
|
||||
\\
|
||||
\\ lea 8(%%rsp),%%rax // load pointer to the return address into rax
|
||||
\\ mov %%rcx,%%rsp // install the new top of stack pointer into rsp
|
||||
\\ mov -8(%%rax),%%rcx // restore rcx
|
||||
\\ push (%%rax) // push return address onto the stack
|
||||
\\ sub %%rsp,%%rax // restore the original value in rax
|
||||
\\ ret
|
||||
);
|
||||
unreachable;
|
||||
if (comptime builtin.os == builtin.Os.windows) {
|
||||
if (comptime builtin.arch == builtin.Arch.x86_64) {
|
||||
asm volatile (
|
||||
\\ push %%rcx
|
||||
\\ cmp $0x1000,%%rax
|
||||
\\ lea 16(%%rsp),%%rcx // rsp before calling this routine -> 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)
|
||||
\\
|
||||
\\ lea 8(%%rsp),%%rax // load pointer to the return address into rax
|
||||
\\ mov %%rcx,%%rsp // install the new top of stack pointer into rsp
|
||||
\\ mov -8(%%rax),%%rcx // restore rcx
|
||||
\\ push (%%rax) // push return address onto the stack
|
||||
\\ sub %%rsp,%%rax // restore the original value in rax
|
||||
\\ ret
|
||||
);
|
||||
unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
@setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user