1 /* Save and set 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 swapcontext (ucontext_t *oucp, const ucontext_t *ucp). */
25 /* Save context into @oucp pointed to by r0. */
27 add r2, r0, UCONTEXT_MCONTEXT
46 /* Save 0 in r0 placeholder to return 0 when @oucp activated. */
50 /* Load context from @ucp. */
52 mov r9, r1 /* Safekeep @ucp across syscall. */
54 /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, &oucp->uc_sigmask, _NSIG8) */
56 add r2, r0, UCONTEXT_SIGMASK
57 add r1, r1, UCONTEXT_SIGMASK
59 mov r8, __NR_rt_sigprocmask
61 brhi r0, -1024, L (call_syscall_err)
63 add r9, r9, UCONTEXT_MCONTEXT
93 PSEUDO_END (__swapcontext)
94 weak_alias (__swapcontext, swapcontext)