Revert all of my changes to directories & codingstyle.
[tinycc.git] / lib / alloca86_64-bt.S
blobab8629da2368c982e5d5d41b9dd8f6d35047ea70
1 /* ---------------------------------------------- */
2 /* alloca86_64.S */
4 .globl __bound_alloca
5 __bound_alloca:
7 #ifdef TCC_TARGET_PE
8     # bound checking is not implemented
9     pop     %rdx
10     mov     %rcx,%rax
11     add     $15,%rax
12     and     $-16,%rax
13     jz      p3
15 p1:
16     cmp     $4096,%rax
17     jbe     p2
18     test    %rax,-4096(%rsp)
19     sub     $4096,%rsp
20     sub     $4096,%rax
21     jmp p1
22 p2:
24     sub     %rax,%rsp
25     mov     %rsp,%rax
26     add     $32,%rax
28 p3:
29     push    %rdx
30     ret
31 #else
32     pop     %rdx
33     mov     %rdi,%rax
34     movl    %rax,%rsi   # size, a second parm to the __bound_new_region
36     add     $15,%rax
37     and     $-16,%rax
38     jz      p3
41     sub     %rax,%rsp
42     mov     %rsp,%rdi   # pointer, a first parm to the __bound_new_region
43     mov     %rsp,%rax
45     push    %rdx
46     push    %rax
47     call   __bound_new_region
48     pop     %rax
49     pop     %rdx
51 p3:
52     push    %rdx
53     ret
54 #endif
56 /* mark stack as nonexecutable */
57 #if defined __ELF__ && defined __linux__
58     .section    .note.GNU-stack,"",@progbits
59 #endif
60 /* ---------------------------------------------- */