1 /* Save current context.
2 Copyright (C) 2012-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 /* Save the preserved registers and the return address. */
29 movem.l %d2-%d7, oGREGS+2*4(%a0)
30 movem.l %a2-%a6, oGREGS+10*4(%a0)
33 move.l (%sp), oPC(%a0)
34 fmovem.l %fpsr/%fpcr/%fpiar, oFPREGS(%a0)
35 fmovem.x %fp2-%fp7, oFP2(%a0)
37 cfi_offset (%d2, oGREGS+2*4)
38 cfi_offset (%d3, oGREGS+3*4)
41 /* Save the current signal mask. */
42 lea oSIGMASK(%a0), %a1
45 move.l #SIG_SETMASK, %d1
46 move.l #__NR_sigprocmask, %d0
48 /* Restore registers. */
49 move.l oGREGS+2*4(%a0), %d2
51 move.l oGREGS+3*4(%a0), %d3
55 cmp.l #-4095, %d0 /* Check %d0 for error. */
56 jcc SYSCALL_ERROR_LABEL /* Jump to error handler. */
58 0: /* All done, return 0 for success. */
61 PSEUDO_END(__getcontext)
63 weak_alias (__getcontext, getcontext)