longjmp.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. libc_hidden_proto(sigprocmask)
  22. extern int __longjmp(char *env, int val);
  23. libc_hidden_proto(__longjmp)
  24. extern void _longjmp_unwind (jmp_buf env, int val);
  25. /* Set the signal mask to the one specified in ENV, and jump
  26. to the position specified in ENV, causing the setjmp
  27. call there to return VAL, or 1 if VAL is 0. */
  28. void __libc_siglongjmp (sigjmp_buf env, int val)
  29. {
  30. /* Perform any cleanups needed by the frames being unwound. */
  31. _longjmp_unwind (env, val);
  32. if (env[0].__mask_was_saved)
  33. /* Restore the saved signal mask. */
  34. (void) sigprocmask (SIG_SETMASK, &env[0].__saved_mask,
  35. (sigset_t *) NULL);
  36. /* Call the machine-dependent function to restore machine state. */
  37. __longjmp ((char *) env[0].__jmpbuf, val ?: 1);
  38. }
  39. __asm__(".weak longjmp; longjmp = __libc_siglongjmp");
  40. __asm__(".weak _longjmp; _longjmp = __libc_siglongjmp");
  41. __asm__(".weak siglongjmp; siglongjmp = __libc_siglongjmp");
  42. strong_alias(__libc_siglongjmp, __libc_longjmp)