Blame sysdeps/m68k/__longjmp.c

Packit 6c4009
/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library.  If not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <setjmp.h>
Packit 6c4009
#include <stdlib.h>
Packit 6c4009
Packit 6c4009
/* Jump to the position specified by ENV, causing the
Packit 6c4009
   setjmp call there to return VAL, or 1 if VAL is 0.  */
Packit 6c4009
void
Packit 6c4009
__longjmp (__jmp_buf env, int val)
Packit 6c4009
{
Packit 6c4009
  /* This restores the FP and SP that setjmp's caller had,
Packit 6c4009
     and puts the return address into A0 and VAL into D0. */
Packit 6c4009
Packit 6c4009
#ifdef CHECK_SP
Packit 6c4009
  CHECK_SP (env[0].__sp);
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#if	defined(__HAVE_68881__) || defined(__HAVE_FPU__)
Packit 6c4009
  /* Restore the floating-point registers.  */
Packit 6c4009
  asm volatile("fmovem%.x %0, %/fp0-%/fp7" :
Packit 6c4009
	       /* No outputs.  */ : "g" (env[0].__fpregs[0]));
Packit 6c4009
#elif defined (__mcffpu__)
Packit 6c4009
  asm volatile("fmovem %0, %/fp0-%/fp7" :
Packit 6c4009
	       /* No outputs.  */ : "m" (env[0].__fpregs[0]));
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
  /* Put VAL in D0.  */
Packit 6c4009
  asm volatile("move%.l %0, %/d0" : /* No outputs.  */ :
Packit 6c4009
	       "g" (val == 0 ? 1 : val) : "d0");
Packit 6c4009
Packit 6c4009
  asm volatile(/* Restore the data and address registers.  */
Packit 6c4009
	       "movem%.l %0, %/d1-%/d7/%/a0-%/a7\n"
Packit 6c4009
	       /* Return to setjmp's caller.  */
Packit 6c4009
#ifdef __motorola__
Packit 6c4009
	       "jmp (%/a0)"
Packit 6c4009
#else
Packit 6c4009
	       "jmp %/a0@"
Packit 6c4009
#endif
Packit 6c4009
	       : /* No outputs.  */ : "g" (env[0].__dregs[0])
Packit 6c4009
	       /* We don't bother with the clobbers,
Packit 6c4009
		  because this code always jumps out anyway.  */
Packit 6c4009
	       );
Packit 6c4009
Packit 6c4009
  /* Avoid `volatile function does return' warnings.  */
Packit 6c4009
  for (;;);
Packit 6c4009
}