1/* Copyright (C) 1992-2022 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <https://www.gnu.org/licenses/>. */
17
18#define __ASSEMBLY__
19
20#include <sysdep.h>
21#include <jmpbuf-offsets.h>
22
23 .ent __sigsetjmp
24 .global __sigsetjmp
25__sigsetjmp:
26 ldgp gp, 0(pv)
27
28$sigsetjmp_local:
29#ifndef PIC
30#define FRAME 16
31 subq sp, FRAME, sp
32 .frame sp, FRAME, ra, 0
33 stq ra, 0(sp)
34 .mask 0x04000000, -FRAME
35#else
36#define FRAME 0
37 .frame sp, FRAME, ra, 0
38#endif
39#ifdef PROF
40 .set noat
41 lda AT, _mcount
42 jsr AT, (AT), _mcount
43 .set at
44#endif
45 .prologue 1
46
47 stq s0, JB_S0*8(a0)
48 stq s1, JB_S1*8(a0)
49 stq s2, JB_S2*8(a0)
50 stq s3, JB_S3*8(a0)
51 stq s4, JB_S4*8(a0)
52 stq s5, JB_S5*8(a0)
53#ifdef PTR_MANGLE
54 PTR_MANGLE(t1, ra, t0)
55 stq t1, JB_PC*8(a0)
56#else
57 stq ra, JB_PC*8(a0)
58#endif
59#if defined(PTR_MANGLE) && FRAME == 0
60 PTR_MANGLE2(t1, sp, t0)
61#else
62 addq sp, FRAME, t1
63# ifdef PTR_MANGLE
64 PTR_MANGLE2(t1, t1, t0)
65# endif
66#endif
67 stq t1, JB_SP*8(a0)
68#ifdef PTR_MANGLE
69 PTR_MANGLE2(t1, fp, t0)
70 stq t1, JB_FP*8(a0)
71#else
72 stq fp, JB_FP*8(a0)
73#endif
74 stt $f2, JB_F2*8(a0)
75 stt $f3, JB_F3*8(a0)
76 stt $f4, JB_F4*8(a0)
77 stt $f5, JB_F5*8(a0)
78 stt $f6, JB_F6*8(a0)
79 stt $f7, JB_F7*8(a0)
80 stt $f8, JB_F8*8(a0)
81 stt $f9, JB_F9*8(a0)
82
83#ifndef PIC
84 /* Call to C to (potentially) save our signal mask. */
85 jsr ra, __sigjmp_save
86 ldq ra, 0(sp)
87 addq sp, 16, sp
88 ret
89#elif IS_IN (rtld)
90 /* In ld.so we never save the signal mask. */
91 mov 0, v0
92 ret
93#else
94 /* Tailcall to save the signal mask. */
95 br $31, __sigjmp_save !samegp
96#endif
97
98END(__sigsetjmp)
99hidden_def (__sigsetjmp)
100
101/* Put these traditional entry points in the same file so that we can
102 elide much of the nonsense in trying to jmp to the real function. */
103
104ENTRY(_setjmp)
105 ldgp gp, 0(pv)
106 .prologue 1
107 mov 0, a1
108 br $sigsetjmp_local
109END(_setjmp)
110libc_hidden_def (_setjmp)
111
112ENTRY(setjmp)
113 ldgp gp, 0(pv)
114 .prologue 1
115 mov 1, a1
116 br $sigsetjmp_local
117END(setjmp)
118
119weak_extern(_setjmp)
120weak_extern(setjmp)
121

source code of glibc/sysdeps/alpha/setjmp.S