longjmp.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Copyright (C) 1991, 92, 94, 95, 97, 98, 2000 Free Software Foundation, Inc.
  2. Copyright (C) 2001 Hewlett-Packard Australia
  3. This program is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU Library General Public License as published by the Free
  5. Software Foundation; either version 2 of the License, or (at your option) any
  6. later version.
  7. This program is distributed in the hope that it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
  10. details.
  11. You should have received a copy of the GNU Library General Public License
  12. along with this program; if not, write to the Free Software Foundation, Inc.,
  13. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  14. Derived in part from the Linux-8086 C library, the GNU C Library, and several
  15. other sundry sources. Files within this library are copyright by their
  16. respective copyright holders.
  17. */
  18. #include <stddef.h>
  19. #include <setjmp.h>
  20. #include <signal.h>
  21. /* Set the signal mask to the one specified in ENV, and jump
  22. to the position specified in ENV, causing the setjmp
  23. call there to return VAL, or 1 if VAL is 0. */
  24. void __libc_siglongjmp (sigjmp_buf env, int val)
  25. {
  26. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  27. /* Perform any cleanups needed by the frames being unwound. */
  28. _longjmp_unwind (env, val);
  29. #endif
  30. if (env[0].__mask_was_saved)
  31. /* Restore the saved signal mask. */
  32. (void) sigprocmask (SIG_SETMASK, &env[0].__saved_mask,
  33. (sigset_t *) NULL);
  34. /* Call the machine-dependent function to restore machine state. */
  35. __longjmp ((char *) env[0].__jmpbuf, val ?: 1);
  36. }
  37. __asm__(".weak longjmp; longjmp = __libc_siglongjmp");
  38. __asm__(".weak _longjmp; _longjmp = __libc_siglongjmp");
  39. __asm__(".weak siglongjmp; siglongjmp = __libc_siglongjmp");
  40. strong_alias(__libc_siglongjmp, __libc_longjmp)