1/* Swap to new context.
2 Copyright (C) 2008-2024 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#include "ucontext_i.h"
21
22 .text
23ENTRY(__swapcontext)
24
25 /* Copy rp to ret0 (r28). */
26 copy %rp,%ret0
27
28 /* Create a frame. */
29 ldo 64(%sp),%sp
30 .cfi_def_cfa_offset -64
31
32 /* Save the current machine context to oucp. */
33 bl __getcontext,%rp
34
35 /* Copy oucp to register ret1 (r29). __getcontext saves and
36 restores it on a normal return. It is restored from oR29
37 on reactivation. */
38 copy %r26,%ret1
39
40 /* Pop frame. */
41 ldo -64(%sp),%sp
42 .cfi_def_cfa_offset 0
43
44 /* Load return pointer from oR28. */
45 ldw oR28(%ret1),%rp
46
47 /* Return if error. */
48 or,= %r0,%ret0,%r0
49 bv,n %r0(%rp)
50
51 /* Load sc_sar flag. */
52 ldb oSAR(%ret1),%r20
53
54 /* Return if oucp context has been reactivated. */
55 or,= %r0,%r20,%r0
56 bv,n %r0(%rp)
57
58 /* Mark sc_sar flag. */
59 ldi 1,%r20
60 stb %r20,oSAR(%ret1)
61
62 /* Activate the machine context in ucp. */
63 bl __setcontext,%rp
64 ldw oR25(%ret1),%r26
65
66 /* Load return pointer. */
67 ldw oR28(%ret1),%rp
68 bv,n %r0(%rp)
69
70END(__swapcontext)
71
72weak_alias (__swapcontext, swapcontext)
73

source code of glibc/sysdeps/unix/sysv/linux/hppa/swapcontext.S