LoongArch: Use "$fcsr0" instead of "$r0" in _FPU_{GET,SET}CW
[glibc.git] / sysdeps / unix / sysv / linux / hppa / swapcontext.S
blobe2fdb774f732a0860ba7396ecfe4e0cb27ac84a9
1 /* Swap to new context.
2    Copyright (C) 2008-2024 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 <sysdep.h>
20 #include "ucontext_i.h"
22         .text
23 ENTRY(__swapcontext)
25         /* Copy rp to ret0 (r28).  */
26         copy %rp,%ret0
28         /* Create a frame.  */
29         ldo 64(%sp),%sp
30         .cfi_def_cfa_offset -64
32         /* Save the current machine context to oucp.  */
33         bl __getcontext,%rp
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
40         /* Pop frame.  */
41         ldo -64(%sp),%sp
42         .cfi_def_cfa_offset 0
44         /* Load return pointer from oR28.  */
45         ldw oR28(%ret1),%rp
47         /* Return if error.  */
48         or,= %r0,%ret0,%r0
49         bv,n %r0(%rp)
51         /* Load sc_sar flag.  */
52         ldb oSAR(%ret1),%r20
54         /* Return if oucp context has been reactivated.  */
55         or,= %r0,%r20,%r0
56         bv,n %r0(%rp)
58         /* Mark sc_sar flag.  */
59         ldi 1,%r20
60         stb %r20,oSAR(%ret1)
62         /* Activate the machine context in ucp.  */
63         bl __setcontext,%rp
64         ldw oR25(%ret1),%r26
66         /* Load return pointer.  */
67         ldw oR28(%ret1),%rp
68         bv,n %r0(%rp)
70 END(__swapcontext)
72 weak_alias (__swapcontext, swapcontext)