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#include <picolibc.h> 12 13#ifndef __x86_64 14#include "../i386/setjmp.S" 15#else 16 17 /* 18 ** jmp_buf: 19 ** rbx rbp r12 r13 r14 r15 rsp rip 20 ** 0 8 16 24 32 40 48 56 21 */ 22 23 #include "x86_64mach.h" 24 25 .global SYM (setjmp) 26 .global SYM (longjmp) 27 SOTYPE_FUNCTION(setjmp) 28 SOTYPE_FUNCTION(longjmp) 29 30SYM (setjmp): 31 movq rbx, 0 (rdi) 32 movq rbp, 8 (rdi) 33 movq r12, 16 (rdi) 34 movq r13, 24 (rdi) 35 movq r14, 32 (rdi) 36 movq r15, 40 (rdi) 37 leaq 8 (rsp), rax 38 movq rax, 48 (rdi) 39 movq (rsp), rax 40 movq rax, 56 (rdi) 41 movq $0, rax 42 ret 43 44SYM (longjmp): 45 movq rsi, rax /* Return value */ 46 /* turn 0 into 1 */ 47 testq rsi, rsi 48 movl $1, edx 49 cmove rdx, rax 50 51 movq 8 (rdi), rbp 52 53 __CLI 54 movq 48 (rdi), rsp 55 pushq 56 (rdi) 56 movq 0 (rdi), rbx 57 movq 16 (rdi), r12 58 movq 24 (rdi), r13 59 movq 32 (rdi), r14 60 movq 40 (rdi), r15 61 __STI 62 63 ret 64 65#if defined(__linux__) && defined(__ELF__) 66.section .note.GNU-stack,"",%progbits 67#endif 68#endif 69 70