1 /* Save current context.
2 Copyright (C) 2001-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
21 #include "ucontext_i.h"
25 /* Load address of the context data structure. */
28 /* Return value of getcontext. EAX is the only register whose
29 value is not preserved. */
32 /* Save the 32-bit register values and the return address. */
40 leal 4(%esp), %ecx /* Exclude the return address. */
44 /* Save the FS segment register. We don't touch the GS register
45 since it is used for threads. */
50 leal oFPREGS(%eax), %ecx
51 /* Save the floating-point context. */
53 /* And load it right back since the processor changes the mask.
54 Intel thought this opcode to be used in interrupt handlers which
55 would block all exceptions. */
58 /* Save the current signal mask. */
60 cfi_adjust_cfa_offset (12)
61 leal oSIGMASK(%eax), %eax
64 movl $SIG_BLOCK, (%esp)
65 call HIDDEN_JUMPTARGET (__sigprocmask)
67 cfi_adjust_cfa_offset (-12)
68 /* Propagate %eax (and errno, in case). */
71 PSEUDO_END(__getcontext)
73 weak_alias (__getcontext, getcontext)