]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/m68k/setjmp.c
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / m68k / setjmp.c
CommitLineData
2b778ceb 1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
36e28152
UD
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
3214b89b
AJ
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.
36e28152
UD
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
3214b89b 12 Lesser General Public License for more details.
36e28152 13
3214b89b 14 You should have received a copy of the GNU Lesser General Public
ab84e3ff 15 License along with the GNU C Library. If not, see
5a82c748 16 <https://www.gnu.org/licenses/>. */
61de1372 17
61de1372
RM
18#include <setjmp.h>
19
61de1372
RM
20/* Save the current program position in ENV and return 0. */
21int
6eb7e1da 22inhibit_stack_protector
c70d76bb
AS
23#if defined BSD_SETJMP
24# undef setjmp
dfc1be7a 25# define savemask 1
c70d76bb
AS
26setjmp (jmp_buf env)
27#elif defined BSD__SETJMP
28# undef _setjmp
dfc1be7a 29# define savemask 0
c70d76bb
AS
30_setjmp (jmp_buf env)
31#else
1f58923f 32__sigsetjmp (jmp_buf env, int savemask)
c70d76bb 33#endif
61de1372
RM
34{
35 /* Save data registers D1 through D7. */
69c85398
RM
36 asm volatile ("movem%.l %/d1-%/d7, %0"
37 : : "m" (env[0].__jmpbuf[0].__dregs[0]));
61de1372
RM
38
39 /* Save return address in place of register A0. */
23cd7e44 40 env[0].__jmpbuf[0].__aregs[0] = __builtin_return_address (0);
61de1372
RM
41
42 /* Save address registers A1 through A5. */
69c85398
RM
43 asm volatile ("movem%.l %/a1-%/a5, %0"
44 : : "m" (env[0].__jmpbuf[0].__aregs[1]));
61de1372
RM
45
46 /* Save caller's FP, not our own. */
23cd7e44 47 env[0].__jmpbuf[0].__fp = *(int **) __builtin_frame_address (0);
61de1372
RM
48
49 /* Save caller's SP, not our own. */
23cd7e44 50 env[0].__jmpbuf[0].__sp = (int *) __builtin_frame_address (0) + 2;
61de1372 51
c70d76bb 52#if defined __HAVE_68881__ || defined __HAVE_FPU__
61de1372 53 /* Save floating-point (68881) registers FP0 through FP7. */
69c85398 54 asm volatile ("fmovem%.x %/fp0-%/fp7, %0"
fd339eec 55 : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
9c986f87
AS
56#elif defined (__mcffpu__)
57 asm volatile ("fmovem %/fp0-%/fp7, %0"
58 : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
61de1372
RM
59#endif
60
a3848485 61#if IS_IN (rtld)
23cd7e44
AS
62 /* In ld.so we never save the signal mask. */
63 return 0;
64#else
4afe5be0
RM
65 /* Save the signal mask if requested. */
66 return __sigjmp_save (env, savemask);
23cd7e44 67#endif
61de1372 68}
3dc8a4b2 69#if !defined BSD_SETJMP && !defined BSD__SETJMP
9c986f87 70libc_hidden_def (__sigsetjmp)
3dc8a4b2 71#endif