win32/include/winapi changes from https://github.com/run4flat/tinycc.git
[tinycc.git] / lib / alloca86_64.S
blob4a74104773cbddb72eadab851a038d3c9c2d8198
1 /* ---------------------------------------------- */
2 /* alloca86_64.S */
4 .globl alloca
6 alloca:
7     pop     %rdx
8 #ifdef TCC_TARGET_PE
9     mov     %rcx,%rax
10 #else
11     mov     %rdi,%rax
12 #endif
13     add     $15,%rax
14     and     $-16,%rax
15     jz      p3
17 #ifdef TCC_TARGET_PE
18 p1:
19     cmp     $4096,%rax
20     jbe     p2
21     test    %rax,-4096(%rsp)
22     sub     $4096,%rsp
23     sub     $4096,%rax
24     jmp p1
25 p2:
26 #endif
28     sub     %rax,%rsp
29     mov     %rsp,%rax
30 #ifdef TCC_TARGET_PE
31     add     $32,%rax
32 #endif
34 p3:
35     push    %rdx
36     ret
38 /* mark stack as nonexecutable */
39 #if defined __ELF__ && defined __linux__
40     .section    .note.GNU-stack,"",@progbits
41 #endif
42 /* ---------------------------------------------- */