Update copyright dates with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / arc / getcontext.S
blobeb75c8ce028607d372e1bcab2e325b8f4fadd1e8
1 /* Save current context for ARC.
2    Copyright (C) 2020-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/>.  */
19 #include "ucontext-macros.h"
21 /* int getcontext (ucontext_t *ucp)
22    Save machine context in @ucp and return 0 on success, -1 on error
23     - saves callee saved registers only
24     - layout mandated by uncontext_t:uc_mcontext (hence different from setjmp).  */
26 ENTRY (__getcontext)
28         /* Callee saved registers.  */
29         add r2, r0, UCONTEXT_MCONTEXT
30         STR (r13,   r2, 37)
31         STR (r14,   r2, 36)
32         STR (r15,   r2, 35)
33         STR (r16,   r2, 34)
34         STR (r17,   r2, 33)
35         STR (r18,   r2, 32)
36         STR (r19,   r2, 31)
37         STR (r20,   r2, 30)
38         STR (r21,   r2, 29)
39         STR (r22,   r2, 28)
40         STR (r23,   r2, 27)
41         STR (r24,   r2, 26)
43         STR (blink, r2,  7)
44         STR (fp,    r2,  8)
45         STR (gp,    r2,  9)
46         STR (sp,    r2, 23)
48         /* Save 0 in r0 placeholder to return 0 when this @ucp activated.  */
49         mov r9, 0
50         STR (r9,    r2, 22)
52         /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8).  */
53         mov r3, _NSIG8
54         add r2, r0, UCONTEXT_SIGMASK
55         mov r1, 0
56         mov r0, SIG_BLOCK
57         mov r8, __NR_rt_sigprocmask
58         ARC_TRAP_INSN
59         brhi    r0, -1024, L (call_syscall_err)
60         j.d     [blink]
61         mov r0, 0       /* Success, error handled in .Lcall_syscall_err.  */
63 PSEUDO_END (__getcontext)
64 weak_alias (__getcontext, getcontext)