longjmp.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. if (env[0].__mask_was_saved)
  27. /* Restore the saved signal mask. */
  28. (void) __sigprocmask (SIG_SETMASK, &env[0].__saved_mask,
  29. (sigset_t *) NULL);
  30. /* Call the machine-dependent function to restore machine state. */
  31. __longjmp (env[0].__jmpbuf, val ?: 1);
  32. }
  33. __asm__(".weak longjmp; longjmp = __libc_siglongjmp");
  34. __asm__(".weak _longjmp; _longjmp = __libc_siglongjmp");
  35. __asm__(".weak siglongjmp; siglongjmp = __libc_siglongjmp");
  36. __asm__(".weak __sigprocmask; __sigprocmask = sigprocmask");