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