]> git.saurik.com Git - apple/libc.git/blob - x86_64/gen/_setcontext.S
864cdd64b0b92dd96d62e903341789e211e64357
[apple/libc.git] / x86_64 / gen / _setcontext.S
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 LABEL(__setcontext)
42 /* struct mcontext_t * %rdi */
43 #if DEBUG
44 movq MCONTEXT_SS_RSI(%rdi), %rsi
45 movq MCONTEXT_SS_RCX(%rdi), %rcx
46 movq MCONTEXT_SS_R8+00(%rdi), %r8
47 movq MCONTEXT_SS_R8+08(%rdi), %r9
48 movq MCONTEXT_SS_R8+16(%rdi), %r10
49 movq MCONTEXT_SS_R8+24(%rdi), %r11
50 #endif
51 movq MCONTEXT_SS_RBX(%rdi), %rbx
52 movq MCONTEXT_SS_R8+32(%rdi), %r12
53 movq MCONTEXT_SS_R8+40(%rdi), %r13
54 movq MCONTEXT_SS_R8+48(%rdi), %r14
55 movq MCONTEXT_SS_R8+56(%rdi), %r15
56
57 movq MCONTEXT_SS_RSP(%rdi), %rsp
58 movq MCONTEXT_SS_RBP(%rdi), %rbp
59
60 xorl %eax, %eax /* force x=getcontext(); ... setcontext(); to keep x==0 */
61
62 #if DEBUG
63 movq MCONTEXT_SS_RIP(%rdi), %rdx
64 movq MCONTEXT_SS_RDI(%rdi), %rdi
65 jmp *%rdx
66 #else
67 jmp *MCONTEXT_SS_RIP(%rdi)
68 #endif
69
70 #endif /* __x86_64__ */