1/* 2 * ==================================================== 3 * Copyright (C) 2007 by Ellips BV. All rights reserved. 4 * 5 * Permission to use, copy, modify, and distribute this 6 * software is freely granted, provided that this notice 7 * is preserved. 8 * ==================================================== 9 */ 10 11#ifndef __x86_64 12#include "../i386/setjmp.S" 13#else 14 15 /* 16 ** jmp_buf: 17 ** rbx rbp r12 r13 r14 r15 rsp rip 18 ** 0 8 16 24 32 40 48 56 19 */ 20 21 #include "x86_64mach.h" 22 23 .global SYM (setjmp) 24 .global SYM (longjmp) 25 SOTYPE_FUNCTION(setjmp) 26 SOTYPE_FUNCTION(longjmp) 27 28SYM (setjmp): 29 movq rbx, 0 (rdi) 30 movq rbp, 8 (rdi) 31 movq r12, 16 (rdi) 32 movq r13, 24 (rdi) 33 movq r14, 32 (rdi) 34 movq r15, 40 (rdi) 35 leaq 8 (rsp), rax 36 movq rax, 48 (rdi) 37 movq (rsp), rax 38 movq rax, 56 (rdi) 39 movq $0, rax 40 ret 41 42SYM (longjmp): 43 movq rsi, rax /* Return value */ 44 /* turn 0 into 1 */ 45 testq rsi, rsi 46 movl $1, edx 47 cmove rdx, rax 48 49 movq 8 (rdi), rbp 50 51 __CLI 52 movq 48 (rdi), rsp 53 pushq 56 (rdi) 54 movq 0 (rdi), rbx 55 movq 16 (rdi), r12 56 movq 24 (rdi), r13 57 movq 32 (rdi), r14 58 movq 40 (rdi), r15 59 __STI 60 61 ret 62 63#if defined(__linux__) && defined(__ELF__) 64.section .note.GNU-stack,"",%progbits 65#endif 66#endif 67 68