__longjmp.c 2.0 KB

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