1 /* Install given context.
2 Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
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.
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.
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
23 #include "ucontext_i.h"
27 /* Load address of the context data structure. */
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
34 cfi_adjust_cfa_offset (4)
36 leal oSIGMASK(%eax), %ecx
37 movl $SIG_SETMASK, %ebx
38 cfi_rel_offset (ebx, 0)
39 movl $__NR_sigprocmask, %eax
42 cfi_adjust_cfa_offset (-4)
44 cmpl $-4095, %eax /* Check %eax for error. */
45 jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
47 /* EAX was modified, reload it. */
50 /* Restore the floating-point context. Not the registers, only the
52 movl oFPREGS(%eax), %ecx
55 /* Restore the FS segment register. We don't touch the GS register
56 since it is used for threads. */
60 /* Fetch the address to return to. */
63 /* Load the new stack pointer. */
65 cfi_offset (edi, oEDI)
66 cfi_offset (esi, oESI)
67 cfi_offset (ebp, oEBP)
68 cfi_offset (ebx, oEBX)
69 cfi_offset (edx, oEDX)
70 cfi_offset (ecx, oECX)
73 /* Push the return address on the new stack so we can return there. */
76 /* Load the values of all the 32-bit registers (except ESP).
77 Since we are loading from EAX, it must be last. */
86 /* End FDE here, we fall into another context. */
90 /* The following 'ret' will pop the address of the code and jump
95 PSEUDO_END(__setcontext)
97 weak_alias (__setcontext, setcontext)