]>
Commit | Line | Data |
---|---|---|
ada7c492 A |
1 | /* |
2 | * Copyright (c) 2007,2009 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
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 | |
11 | * file. | |
12 | * | |
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. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | ||
24 | #if defined(__x86_64__) | |
25 | ||
26 | #include <architecture/i386/asm_help.h> | |
27 | ||
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 | |
39 | ||
40 | TEXT | |
41 | .private_extern __setcontext | |
42 | LABEL(__setcontext) | |
43 | /* struct mcontext_t * %rdi */ | |
44 | #if DEBUG | |
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 | |
51 | #endif | |
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 | |
57 | ||
58 | movq MCONTEXT_SS_RSP(%rdi), %rsp | |
59 | movq MCONTEXT_SS_RBP(%rdi), %rbp | |
60 | ||
61 | xorl %eax, %eax /* force x=getcontext(); ... setcontext(); to keep x==0 */ | |
62 | ||
63 | #if DEBUG | |
64 | movq MCONTEXT_SS_RIP(%rdi), %rdx | |
65 | movq MCONTEXT_SS_RDI(%rdi), %rdi | |
66 | jmp *%rdx | |
67 | #else | |
68 | jmp *MCONTEXT_SS_RIP(%rdi) | |
69 | #endif | |
70 | ||
71 | #endif /* __x86_64__ */ |