1/* Save current context. 2 Copyright (C) 2012-2022 Free Software Foundation, Inc. 3 This file is part of the GNU C Library. 4 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. 9 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. 14 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/>. */ 18 19#include <sysdep.h> 20 21#include "ucontext_i.h" 22 23 24ENTRY(__getcontext) 25 /* Load address of the context data structure. */ 26 move.l 4(%sp), %a0 27 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) 31 lea 4(%sp), %a1 32 move.l %a1, oSP(%a0) 33 move.l (%sp), oPC(%a0) 34 fmovem.l %fpsr/%fpcr/%fpiar, oFPREGS(%a0) 35 fmovem.x %fp2-%fp7, oFP2(%a0) 36 cfi_def_cfa (%a0, 0) 37 cfi_offset (%d2, oGREGS+2*4) 38 cfi_offset (%d3, oGREGS+3*4) 39 cfi_offset (%pc, oPC) 40 41 /* Save the current signal mask. */ 42 lea oSIGMASK(%a0), %a1 43 move.l %a1, %d3 44 clr.l %d2 45 move.l #SIG_SETMASK, %d1 46 move.l #__NR_sigprocmask, %d0 47 trap #0 48 /* Restore registers. */ 49 move.l oGREGS+2*4(%a0), %d2 50 cfi_restore (%d2) 51 move.l oGREGS+3*4(%a0), %d3 52 cfi_restore (%d3) 53 cfi_def_cfa (%sp, 4) 54 cfi_offset (%pc, -4) 55 cmp.l #-4095, %d0 /* Check %d0 for error. */ 56 jcc SYSCALL_ERROR_LABEL /* Jump to error handler. */ 57 580: /* All done, return 0 for success. */ 59 clr.l %d0 60 rts 61PSEUDO_END(__getcontext) 62 63weak_alias (__getcontext, getcontext) 64