1 /* Install given context.
2 Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Andreas Jaeger <aj@suse.de>, 2002.
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"
26 /* int __setcontext (const ucontext_t *ucp)
28 Restores the machine context in UCP and thereby resumes execution
31 This implementation is intended to be used for *synchronous* context
32 switches only. Therefore, it does not have to restore anything
33 other than the PRESERVED state. */
36 /* Save argument since syscall will destroy it. */
38 cfi_adjust_cfa_offset(8)
40 /* Set the signal mask with
41 rt_sigprocmask (SIG_SETMASK, mask, NULL, _NSIG/8). */
42 leaq oSIGMASK(%rdi), %rsi
44 movl $SIG_SETMASK, %edi
46 movl $__NR_rt_sigprocmask, %eax
48 popq %rdi /* Reload %rdi, adjust stack. */
49 cfi_adjust_cfa_offset(-8)
50 cmpq $-4095, %rax /* Check %rax for error. */
51 jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
53 /* Restore the floating-point context. Not the registers, only the
55 movq oFPREGS(%rdi), %rcx
60 /* Load the new stack pointer, the preserved registers and
61 registers used for passing args. */
80 /* The following ret should return to the address set with
81 getcontext. Therefore push the address on the stack. */
91 /* Setup finally %rdi. */
94 /* End FDE here, we fall into another context. */
98 /* Clear rax to indicate success. */
103 PSEUDO_END(__setcontext)
105 weak_alias (__setcontext, setcontext)