1 /* Save current context.
2 Copyright (C) 2002, 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"
25 /* int __getcontext (ucontext_t *ucp)
27 Saves the machine context in UCP such that when it is activated,
28 it appears as if __getcontext() returned again.
30 This implementation is intended to be used for *synchronous* context
31 switches only. Therefore, it does not have to save anything
32 other than the PRESERVED state. */
36 /* Save the preserved registers, the registers used for passing
37 args, and the return address. */
54 leaq 8(%rsp), %rcx /* Exclude the return address. */
57 /* We have separate floating-point register content memory on the
58 stack. We use the __fpregs_mem block in the context. Set the
59 links up correctly. */
61 leaq oFPREGSMEM(%rdi), %rcx
62 movq %rcx, oFPREGS(%rdi)
63 /* Save the floating-point environment. */
67 /* Save the current signal mask with
68 rt_sigprocmask (SIG_BLOCK, NULL, set,_NSIG/8). */
69 leaq oSIGMASK(%rdi), %rdx
77 movl $__NR_rt_sigprocmask, %eax
79 cmpq $-4095, %rax /* Check %rax for error. */
80 jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
82 /* All done, return 0 for success. */
86 PSEUDO_END(__getcontext)
88 weak_alias (__getcontext, getcontext)