Add clock_nanosleep emulation for macOS
[tinycc.git] / lib / alloca86_64-bt.S
blobc3f4e54c0ec31b1d7ce78c4f8c33fdf2af9a9d9b
1 /* ---------------------------------------------- */
2 /* alloca86_64.S */
4 #ifdef __APPLE__
5 #define __bound_alloca ___bound_alloca
6 #define __bound_alloca_nr ___bound_alloca_nr
7 #define __bound_new_region ___bound_new_region
8 #endif
10 .globl __bound_alloca
11 __bound_alloca:
13 #ifdef _WIN32
14     inc %rcx            # add one extra to separate regions
15     jmp alloca
16 .globl __bound_alloca_nr
17 __bound_alloca_nr:
18     dec     %rcx
19     push    %rax
20     mov     %rcx,%rdx
21     mov     %rax,%rcx
22     sub     $32,%rsp
23     call    __bound_new_region
24     add     $32,%rsp
25     pop     %rax
26     ret
27 #else
28     pop     %rdx
29     mov     %rdi,%rax
30     mov     %rax,%rsi   # size, a second parm to the __bound_new_region
32     add     $15 + 1,%rax  # add one extra to separate regions
33     and     $-16,%rax
34     jz      p3
37     sub     %rax,%rsp
38     mov     %rsp,%rdi   # pointer, a first parm to the __bound_new_region
39     mov     %rsp,%rax
41     push    %rdx
42     push    %rax
43     call   __bound_new_region
44     pop     %rax
45     pop     %rdx
47 p3:
48     push    %rdx
49     ret
50 #endif
52 /* ---------------------------------------------- */