1/* Copyright (C) 1997-2022 Free Software Foundation, Inc.
2
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 License as
7   published by the Free Software Foundation; either version 2.1 of the
8   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/* This source produces 3 functions:
22   __sigsetjmp (jmpbuf,savemask)
23   setjmp (jmpbuf) - equivalent to __sigsetjump (jmpbuf, 1)
24   _setjmp (jmpbuf) - equivalent to __sigsetjump (jmpbuf, 0)
25*/
26
27#ifndef setjmp_name
28# define setjmp_name __sigsetjmp
29# define SET_MASK_ARG
30#else
31# define SET_MASK_ARG    addik r6,r0,SAVEMASK
32#endif
33
34ENTRY (setjmp_name)
35    swi   r1,r5,0
36    swi   r2,r5,4
37    swi   r13,r5,8
38    swi   r14,r5,12
39    swi   r15,r5,16
40    swi   r16,r5,20
41    swi   r17,r5,24
42    swi   r18,r5,28
43    swi   r19,r5,32
44    swi   r20,r5,36
45    swi   r21,r5,40
46    swi   r22,r5,44
47    swi   r23,r5,48
48    swi   r24,r5,52
49    swi   r25,r5,56
50    swi   r26,r5,60
51    swi   r27,r5,64
52    swi   r28,r5,68
53    swi   r29,r5,72
54    swi   r30,r5,76
55    swi   r31,r5,80
56
57    SET_MASK_ARG
58
59    /* Make a tail call to __sigjmp_save; it takes the same args.  */
60#ifdef	PIC
61    /* We cannot use the PLT, because it requires that r20 be set, but
62       we can't save and restore our caller's value.  Instead, we do an
63       indirect jump through the GOT, using the temporary register
64       %ecx, which is call-clobbered.  */
65    mfs   r12,rpc
66    addik r12,r12,_GLOBAL_OFFSET_TABLE_+8
67    lwi   r12,r12,__sigjmp_save@GOT
68    brad  r12
69#else
70    brid  __sigjmp_save
71#endif
72    nop
73END (setjmp_name)
74
75libc_hidden_def (setjmp_name)
76