2 * Copyright (c) 2007,2009 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #if defined(__x86_64__)
26 #include <architecture/i386/asm_help.h>
28 #define MCONTEXT_SS_RAX 16
29 #define MCONTEXT_SS_RBX 24
30 #define MCONTEXT_SS_RCX 32
31 #define MCONTEXT_SS_RDX 40
32 #define MCONTEXT_SS_RDI 48
33 #define MCONTEXT_SS_RSI 56
34 #define MCONTEXT_SS_RBP 64
35 #define MCONTEXT_SS_RSP 72
36 #define MCONTEXT_SS_R8 80
37 #define MCONTEXT_SS_RIP 144
38 #define MCONTEXT_SS_RFLAGS 152
41 .private_extern __setcontext
43 /* struct mcontext_t * %rdi */
45 movq MCONTEXT_SS_RSI(%rdi), %rsi
46 movq MCONTEXT_SS_RCX(%rdi), %rcx
47 movq MCONTEXT_SS_R8+0(%rdi), %r8
48 movq MCONTEXT_SS_R8+8(%rdi), %r9
49 movq MCONTEXT_SS_R8+16(%rdi), %r10
50 movq MCONTEXT_SS_R8+24(%rdi), %r11
52 movq MCONTEXT_SS_RBX(%rdi), %rbx
53 movq MCONTEXT_SS_R8+32(%rdi), %r12
54 movq MCONTEXT_SS_R8+40(%rdi), %r13
55 movq MCONTEXT_SS_R8+48(%rdi), %r14
56 movq MCONTEXT_SS_R8+56(%rdi), %r15
58 movq MCONTEXT_SS_RSP(%rdi), %rsp
59 movq MCONTEXT_SS_RBP(%rdi), %rbp
61 xorl %eax, %eax /* force x=getcontext(); ... setcontext(); to keep x==0 */
64 movq MCONTEXT_SS_RIP(%rdi), %rdx
65 movq MCONTEXT_SS_RDI(%rdi), %rdi
68 jmp *MCONTEXT_SS_RIP(%rdi)
71 #endif /* __x86_64__ */