Move all files into ports/ subdirectory in preparation for merge with glibc
[glibc.git] / ports / sysdeps / m68k / __longjmp.c
blob290c974bedd19834bc580551f47b926764656d9d
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, see
17 <http://www.gnu.org/licenses/>. */
19 #include <setjmp.h>
20 #include <stdlib.h>
22 /* Jump to the position specified by ENV, causing the
23 setjmp call there to return VAL, or 1 if VAL is 0. */
24 void
25 __longjmp (__jmp_buf env, int val)
27 /* This restores the FP and SP that setjmp's caller had,
28 and puts the return address into A0 and VAL into D0. */
30 #ifdef CHECK_SP
31 CHECK_SP (env[0].__sp);
32 #endif
34 #if defined(__HAVE_68881__) || defined(__HAVE_FPU__)
35 /* Restore the floating-point registers. */
36 asm volatile("fmovem%.x %0, %/fp0-%/fp7" :
37 /* No outputs. */ : "g" (env[0].__fpregs[0]));
38 #elif defined (__mcffpu__)
39 asm volatile("fmovem %0, %/fp0-%/fp7" :
40 /* No outputs. */ : "m" (env[0].__fpregs[0]));
41 #endif
43 /* Put VAL in D0. */
44 asm volatile("move%.l %0, %/d0" : /* No outputs. */ :
45 "g" (val == 0 ? 1 : val) : "d0");
47 asm volatile(/* Restore the data and address registers. */
48 "movem%.l %0, %/d1-%/d7/%/a0-%/a7\n"
49 /* Return to setjmp's caller. */
50 #ifdef __motorola__
51 "jmp (%/a0)"
52 #else
53 "jmp %/a0@"
54 #endif
55 : /* No outputs. */ : "g" (env[0].__dregs[0])
56 /* We don't bother with the clobbers,
57 because this code always jumps out anyway. */
60 /* Avoid `volatile function does return' warnings. */
61 for (;;);