macos: ldd does not exit, use otool instead
[tinycc.git] / lib / alloca86_64.S
blob5195eca5e61d9ab6f0153ea9894ef8a21d419af4
1 /* ---------------------------------------------- */
2 /* alloca86_64.S */
4 #ifdef __leading_underscore
5 # define _(s) _##s
6 #else
7 # define _(s) s
8 #endif
10 .globl _(alloca)
11 _(alloca):
12     pop     %rdx
13 #ifdef _WIN32
14     mov     %rcx,%rax
15 #else
16     mov     %rdi,%rax
17 #endif
18     add     $15,%rax
19     and     $-16,%rax
20     jz      p3
22 #ifdef _WIN32
23 p1:
24     cmp     $4096,%rax
25     jbe     p2
26     test    %rax,-4096(%rsp)
27     sub     $4096,%rsp
28     sub     $4096,%rax
29     jmp p1
30 p2:
31 #endif
32     sub     %rax,%rsp
33     mov     %rsp,%rax
34 p3:
35     push    %rdx
36     ret
38 /* ---------------------------------------------- */