]>
Commit | Line | Data |
---|---|---|
4ee87ecc | 1 | /* Install given context. |
b168057a | 2 | Copyright (C) 2001-2015 Free Software Foundation, Inc. |
4ee87ecc UD |
3 | This file is part of the GNU C Library. |
4 | Contributed by Ulrich Drepper <drepper@redhat.com>, 2001. | |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
7 | modify it under the terms of the GNU Lesser General Public |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
4ee87ecc UD |
10 | |
11 | The GNU C Library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 14 | Lesser General Public License for more details. |
4ee87ecc | 15 | |
41bdb6e2 | 16 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
17 | License along with the GNU C Library; if not, see |
18 | <http://www.gnu.org/licenses/>. */ | |
4ee87ecc UD |
19 | |
20 | #include <sysdep.h> | |
21 | ||
22 | #include "ucontext_i.h" | |
23 | ||
24 | ||
25 | ENTRY(__setcontext) | |
26 | /* Load address of the context data structure. */ | |
27 | movl 4(%esp), %eax | |
28 | ||
29 | /* Get the current signal mask. Note that we preserve EBX in case | |
30 | the system call fails and we return from the function with an | |
31 | error. */ | |
32 | pushl %ebx | |
1ad9da69 | 33 | cfi_adjust_cfa_offset (4) |
4ee87ecc UD |
34 | xorl %edx, %edx |
35 | leal oSIGMASK(%eax), %ecx | |
36 | movl $SIG_SETMASK, %ebx | |
1ad9da69 | 37 | cfi_rel_offset (ebx, 0) |
4ee87ecc | 38 | movl $__NR_sigprocmask, %eax |
097eca29 | 39 | ENTER_KERNEL |
4ee87ecc | 40 | popl %ebx |
1ad9da69 UD |
41 | cfi_adjust_cfa_offset (-4) |
42 | cfi_restore (ebx) | |
4ee87ecc UD |
43 | cmpl $-4095, %eax /* Check %eax for error. */ |
44 | jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */ | |
45 | ||
46 | /* EAX was modified, reload it. */ | |
47 | movl 4(%esp), %eax | |
48 | ||
49 | /* Restore the floating-point context. Not the registers, only the | |
50 | rest. */ | |
51 | movl oFPREGS(%eax), %ecx | |
52 | fldenv (%ecx) | |
53 | ||
e14b1447 UD |
54 | /* Restore the FS segment register. We don't touch the GS register |
55 | since it is used for threads. */ | |
4ee87ecc | 56 | movl oFS(%eax), %ecx |
4ee87ecc UD |
57 | movw %cx, %fs |
58 | ||
a5392bed UD |
59 | /* Fetch the address to return to. */ |
60 | movl oEIP(%eax), %ecx | |
61 | ||
4ee87ecc | 62 | /* Load the new stack pointer. */ |
fee732e5 UD |
63 | cfi_def_cfa (eax, 0) |
64 | cfi_offset (edi, oEDI) | |
65 | cfi_offset (esi, oESI) | |
66 | cfi_offset (ebp, oEBP) | |
67 | cfi_offset (ebx, oEBX) | |
68 | cfi_offset (edx, oEDX) | |
69 | cfi_offset (ecx, oECX) | |
a5392bed UD |
70 | movl oESP(%eax), %esp |
71 | ||
72 | /* Push the return address on the new stack so we can return there. */ | |
73 | pushl %ecx | |
74 | ||
75 | /* Load the values of all the 32-bit registers (except ESP). | |
76 | Since we are loading from EAX, it must be last. */ | |
77 | movl oEDI(%eax), %edi | |
78 | movl oESI(%eax), %esi | |
79 | movl oEBP(%eax), %ebp | |
80 | movl oEBX(%eax), %ebx | |
81 | movl oEDX(%eax), %edx | |
82 | movl oECX(%eax), %ecx | |
83 | movl oEAX(%eax), %eax | |
84 | ||
fee732e5 UD |
85 | /* End FDE here, we fall into another context. */ |
86 | cfi_endproc | |
87 | cfi_startproc | |
88 | ||
a5392bed | 89 | /* The following 'ret' will pop the address of the code and jump |
4ee87ecc UD |
90 | to it. */ |
91 | ||
4ee87ecc UD |
92 | ret |
93 | PSEUDO_END(__setcontext) | |
94 | ||
1ab18a5b | 95 | weak_alias (__setcontext, setcontext) |