]>
Commit | Line | Data |
---|---|---|
a678c13b | 1 | /* Install given context. |
2b778ceb | 2 | Copyright (C) 2001-2021 Free Software Foundation, Inc. |
a678c13b TS |
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 | |
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. | |
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 | |
14 | Lesser General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public | |
17 | License along with the GNU C Library; if not, see | |
18 | <https://www.gnu.org/licenses/>. */ | |
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. */ | |
30 | subl $12, %esp | |
31 | cfi_adjust_cfa_offset (12) | |
32 | movl $0, 8(%esp) | |
33 | leal oSIGMASK(%eax), %eax | |
34 | movl %eax, 4(%esp) | |
35 | movl $SIG_SETMASK, (%esp) | |
36 | call HIDDEN_JUMPTARGET (__sigprocmask) | |
37 | addl $12, %esp | |
38 | cfi_adjust_cfa_offset (-12) | |
39 | testl %eax, %eax | |
40 | jne L(pseudo_end) | |
41 | ||
42 | /* EAX was modified, reload it. */ | |
43 | movl 4(%esp), %eax | |
44 | ||
45 | /* Restore the floating-point context. Not the registers, only the | |
46 | rest. */ | |
47 | leal oFPREGS(%eax), %ecx | |
48 | fldenv (%ecx) | |
49 | ||
50 | /* Restore the FS segment register. We don't touch the GS register | |
51 | since it is used for threads. */ | |
52 | movl oFS(%eax), %ecx | |
53 | movw %cx, %fs | |
54 | ||
55 | /* Fetch the address to return to. */ | |
56 | movl oEIP(%eax), %ecx | |
57 | ||
58 | /* Load the new stack pointer. */ | |
59 | cfi_def_cfa (eax, 0) | |
60 | cfi_offset (edi, oEDI) | |
61 | cfi_offset (esi, oESI) | |
62 | cfi_offset (ebp, oEBP) | |
63 | cfi_offset (ebx, oEBX) | |
64 | cfi_offset (edx, oEDX) | |
65 | cfi_offset (ecx, oECX) | |
66 | movl oESP(%eax), %esp | |
67 | ||
68 | /* Push the return address on the new stack so we can return there. */ | |
69 | pushl %ecx | |
70 | ||
71 | /* Load the values of all the 32-bit registers (except ESP). | |
72 | Since we are loading from EAX, it must be last. */ | |
73 | movl oEDI(%eax), %edi | |
74 | movl oESI(%eax), %esi | |
75 | movl oEBP(%eax), %ebp | |
76 | movl oEBX(%eax), %ebx | |
77 | movl oEDX(%eax), %edx | |
78 | movl oECX(%eax), %ecx | |
79 | movl oEAX(%eax), %eax | |
80 | ||
81 | /* End FDE here, we fall into another context. */ | |
82 | cfi_endproc | |
83 | cfi_startproc | |
84 | ||
85 | /* The following 'ret' will pop the address of the code and jump | |
86 | to it. */ | |
87 | ||
88 | L(pseudo_end): | |
89 | ret | |
90 | PSEUDO_END(__setcontext) | |
91 | libc_hidden_def (__setcontext) | |
92 | ||
93 | weak_alias (__setcontext, setcontext) |