alpha: create kernel-features.h.
[glibc.git] / sysdeps / m68k / __longjmp.c
blob5ba2478c0c59d91746443b6b2b80a4fc1e77ec40
1 /* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1997, 2009
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <setjmp.h>
21 #include <stdlib.h>
23 /* Jump to the position specified by ENV, causing the
24 setjmp call there to return VAL, or 1 if VAL is 0. */
25 void
26 __longjmp (__jmp_buf env, int val)
28 /* This restores the FP and SP that setjmp's caller had,
29 and puts the return address into A0 and VAL into D0. */
31 #ifdef CHECK_SP
32 CHECK_SP (env[0].__sp);
33 #endif
35 #if defined(__HAVE_68881__) || defined(__HAVE_FPU__)
36 /* Restore the floating-point registers. */
37 asm volatile("fmovem%.x %0, %/fp0-%/fp7" :
38 /* No outputs. */ : "g" (env[0].__fpregs[0]));
39 #elif defined (__mcffpu__)
40 asm volatile("fmovem %0, %/fp0-%/fp7" :
41 /* No outputs. */ : "m" (env[0].__fpregs[0]));
42 #endif
44 /* Put VAL in D0. */
45 asm volatile("move%.l %0, %/d0" : /* No outputs. */ :
46 "g" (val == 0 ? 1 : val) : "d0");
48 asm volatile(/* Restore the data and address registers. */
49 "movem%.l %0, %/d1-%/d7/%/a0-%/a7\n"
50 /* Return to setjmp's caller. */
51 #ifdef __motorola__
52 "jmp (%/a0)"
53 #else
54 "jmp %/a0@"
55 #endif
56 : /* No outputs. */ : "g" (env[0].__dregs[0])
57 /* We don't bother with the clobbers,
58 because this code always jumps out anyway. */
61 /* Avoid `volatile function does return' warnings. */
62 for (;;);