]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/m68k/setjmp.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / m68k / setjmp.c
CommitLineData
04277e02 1/* Copyright (C) 1991-2019 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
c70d76bb
AS
22#if defined BSD_SETJMP
23# undef setjmp
dfc1be7a 24# define savemask 1
c70d76bb
AS
25setjmp (jmp_buf env)
26#elif defined BSD__SETJMP
27# undef _setjmp
dfc1be7a 28# define savemask 0
c70d76bb
AS
29_setjmp (jmp_buf env)
30#else
1f58923f 31__sigsetjmp (jmp_buf env, int savemask)
c70d76bb 32#endif
61de1372
RM
33{
34 /* Save data registers D1 through D7. */
69c85398
RM
35 asm volatile ("movem%.l %/d1-%/d7, %0"
36 : : "m" (env[0].__jmpbuf[0].__dregs[0]));
61de1372
RM
37
38 /* Save return address in place of register A0. */
23cd7e44 39 env[0].__jmpbuf[0].__aregs[0] = __builtin_return_address (0);
61de1372
RM
40
41 /* Save address registers A1 through A5. */
69c85398
RM
42 asm volatile ("movem%.l %/a1-%/a5, %0"
43 : : "m" (env[0].__jmpbuf[0].__aregs[1]));
61de1372
RM
44
45 /* Save caller's FP, not our own. */
23cd7e44 46 env[0].__jmpbuf[0].__fp = *(int **) __builtin_frame_address (0);
61de1372
RM
47
48 /* Save caller's SP, not our own. */
23cd7e44 49 env[0].__jmpbuf[0].__sp = (int *) __builtin_frame_address (0) + 2;
61de1372 50
c70d76bb 51#if defined __HAVE_68881__ || defined __HAVE_FPU__
61de1372 52 /* Save floating-point (68881) registers FP0 through FP7. */
69c85398 53 asm volatile ("fmovem%.x %/fp0-%/fp7, %0"
fd339eec 54 : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
9c986f87
AS
55#elif defined (__mcffpu__)
56 asm volatile ("fmovem %/fp0-%/fp7, %0"
57 : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
61de1372
RM
58#endif
59
a3848485 60#if IS_IN (rtld)
23cd7e44
AS
61 /* In ld.so we never save the signal mask. */
62 return 0;
63#else
4afe5be0
RM
64 /* Save the signal mask if requested. */
65 return __sigjmp_save (env, savemask);
23cd7e44 66#endif
61de1372 67}
3dc8a4b2 68#if !defined BSD_SETJMP && !defined BSD__SETJMP
9c986f87 69libc_hidden_def (__sigsetjmp)
3dc8a4b2 70#endif