Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / m68k / setjmp.c
blobcf742eecd020482559d85e99055d1c1bcdc843b3
1 /* Copyright (C) 1991-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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/>. */
18 #include <setjmp.h>
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
34 /* Save data registers D1 through D7. */
35 asm volatile ("movem%.l %/d1-%/d7, %0"
36 : : "m" (env[0].__jmpbuf[0].__dregs[0]));
38 /* Save return address in place of register A0. */
39 env[0].__jmpbuf[0].__aregs[0] = __builtin_return_address (0);
41 /* Save address registers A1 through A5. */
42 asm volatile ("movem%.l %/a1-%/a5, %0"
43 : : "m" (env[0].__jmpbuf[0].__aregs[1]));
45 /* Save caller's FP, not our own. */
46 env[0].__jmpbuf[0].__fp = *(int **) __builtin_frame_address (0);
48 /* Save caller's SP, not our own. */
49 env[0].__jmpbuf[0].__sp = (int *) __builtin_frame_address (0) + 2;
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
60 #if defined NOT_IN_libc && defined 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
68 #if !defined BSD_SETJMP && !defined BSD__SETJMP
69 libc_hidden_def (__sigsetjmp)
70 #endif