1/* Implementation for gcc's internal stack-allocation routines. */ 2#if defined(__i386__) || defined(__x86_64__) 3.global ___chkstk 4.global __alloca 5 6.global ___chkstk_ms 7___chkstk_ms: 8#ifdef _WIN64 9 pushq %rax 10 pushq %rcx 11 cmpq $0x1000, %rax 12 leaq 24(%rsp), %rcx 13 jb .Lchkstk_ms_end 14.Lchkstk_ms_loop: 15 subq $0x1000, %rcx 16 subq $0x1000, %rax 17 orq $0x0, (%rcx) 18 cmpq $0x1000, %rax 19 ja .Lchkstk_ms_loop 20.Lchkstk_ms_end: 21 subq %rax, %rcx 22 orq $0x0, (%rcx) 23 popq %rcx 24 popq %rax 25 ret 26#else 27 pushl %eax 28 pushl %ecx 29 cmpl $0x1000, %eax 30 leal 12(%esp), %ecx 31 jb chkstk_ms_end 32chkstk_ms_loop: 33 subl $0x1000, %ecx 34 subl $0x1000, %eax 35 orl $0x0, (%ecx) 36 cmpl $0x1000, %eax 37 ja chkstk_ms_loop 38chkstk_ms_end: 39 subl %eax, %ecx 40 orl $0x0, (%ecx) 41 popl %ecx 42 popl %eax 43 ret 44#endif 45 46#ifdef _WIN64 47__alloca: 48 movq %rcx, %rax 49.align 4 50___chkstk: 51 popq %r11 52 movq %rsp, %r10 53 cmpq $0x1000, %rax 54 jb .Lchkstk_end 55.Lchkstk_loop: 56 subq $0x1000, %r10 57 subq $0x1000, %rax 58 orl $0x0, (%r10) 59 cmpq $0x1000, %rax 60 ja .Lchkstk_loop 61.Lchkstk_end: 62 subq %rax, %r10 63 movq %rsp, %rax 64 orl $0x0, (%r10) 65 movq %r10, %rsp 66 pushq %r11 67 ret 68#else 69___chkstk: 70__alloca: 71 pushl %ecx 72 leal 8(%esp), %ecx 73 cmpl $0x1000, %eax /* > 4k ?*/ 74 jb chkstk_end 75chkstk_loop: 76 subl $0x1000, %ecx 77 subl $0x1000, %eax 78 orl $0x0, (%ecx) 79 cmpl $0x1000, %eax 80 ja chkstk_loop 81chkstk_end: 82 subl %eax, %ecx 83 orl $0x0, (%ecx) 84 movl %esp, %eax 85 movl %ecx, %esp 86 movl (%eax), %ecx 87 pushl 4(%eax) 88 ret 89#endif 90#endif 91