]>
Commit | Line | Data |
---|---|---|
4ee87ecc | 1 | /* Install given context. |
a334319f | 2 | Copyright (C) 2001, 2002, 2003 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 AJ |
16 | You should have received a copy of the GNU Lesser General Public |
17 | License along with the GNU C Library; if not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
19 | 02111-1307 USA. */ | |
4ee87ecc UD |
20 | |
21 | #include <sysdep.h> | |
22 | ||
23 | #include "ucontext_i.h" | |
24 | ||
25 | ||
26 | ENTRY(__setcontext) | |
27 | /* Load address of the context data structure. */ | |
28 | movl 4(%esp), %eax | |
29 | ||
30 | /* Get the current signal mask. Note that we preserve EBX in case | |
31 | the system call fails and we return from the function with an | |
32 | error. */ | |
33 | pushl %ebx | |
34 | xorl %edx, %edx | |
35 | leal oSIGMASK(%eax), %ecx | |
36 | movl $SIG_SETMASK, %ebx | |
37 | movl $__NR_sigprocmask, %eax | |
097eca29 | 38 | ENTER_KERNEL |
4ee87ecc UD |
39 | popl %ebx |
40 | cmpl $-4095, %eax /* Check %eax for error. */ | |
41 | jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */ | |
42 | ||
43 | /* EAX was modified, reload it. */ | |
44 | movl 4(%esp), %eax | |
45 | ||
46 | /* Restore the floating-point context. Not the registers, only the | |
47 | rest. */ | |
48 | movl oFPREGS(%eax), %ecx | |
49 | fldenv (%ecx) | |
50 | ||
e14b1447 UD |
51 | /* Restore the FS segment register. We don't touch the GS register |
52 | since it is used for threads. */ | |
4ee87ecc | 53 | movl oFS(%eax), %ecx |
4ee87ecc UD |
54 | movw %cx, %fs |
55 | ||
a5392bed UD |
56 | /* Fetch the address to return to. */ |
57 | movl oEIP(%eax), %ecx | |
58 | ||
4ee87ecc | 59 | /* Load the new stack pointer. */ |
a5392bed UD |
60 | movl oESP(%eax), %esp |
61 | ||
62 | /* Push the return address on the new stack so we can return there. */ | |
63 | pushl %ecx | |
64 | ||
65 | /* Load the values of all the 32-bit registers (except ESP). | |
66 | Since we are loading from EAX, it must be last. */ | |
67 | movl oEDI(%eax), %edi | |
68 | movl oESI(%eax), %esi | |
69 | movl oEBP(%eax), %ebp | |
70 | movl oEBX(%eax), %ebx | |
71 | movl oEDX(%eax), %edx | |
72 | movl oECX(%eax), %ecx | |
73 | movl oEAX(%eax), %eax | |
74 | ||
75 | /* The following 'ret' will pop the address of the code and jump | |
4ee87ecc UD |
76 | to it. */ |
77 | ||
78 | L(pseudo_end): | |
79 | ret | |
80 | PSEUDO_END(__setcontext) | |
81 | ||
a334319f | 82 | weak_alias(__setcontext, setcontext) |