1 /* Install given context.
2 Copyright (C) 2002-2016 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, see
18 <http://www.gnu.org/licenses/>. */
22 #include "ucontext_i.h"
25 /* int __setcontext (const ucontext_t *ucp)
27 Restores the machine context in UCP and thereby resumes execution
30 This implementation is intended to be used for *synchronous* context
31 switches only. Therefore, it does not have to restore anything
32 other than the PRESERVED state. */
35 /* Save argument since syscall will destroy it. */
37 cfi_adjust_cfa_offset(8)
39 /* Set the signal mask with
40 rt_sigprocmask (SIG_SETMASK, mask, NULL, _NSIG/8). */
41 leaq oSIGMASK(%rdi), %rsi
43 movl $SIG_SETMASK, %edi
45 movl $__NR_rt_sigprocmask, %eax
47 popq %rdi /* Reload %rdi, adjust stack. */
48 cfi_adjust_cfa_offset(-8)
49 cmpq $-4095, %rax /* Check %rax for error. */
50 jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
52 /* Restore the floating-point context. Not the registers, only the
54 movq oFPREGS(%rdi), %rcx
59 /* Load the new stack pointer, the preserved registers and
60 registers used for passing args. */
79 /* The following ret should return to the address set with
80 getcontext. Therefore push the address on the stack. */
90 /* Setup finally %rdi. */
93 /* End FDE here, we fall into another context. */
97 /* Clear rax to indicate success. */
100 PSEUDO_END(__setcontext)
102 weak_alias (__setcontext, setcontext)