jmpbuf-unwind.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* Copyright (C) 2011-2018 Free Software Foundation, Inc.
  2. The GNU C Library is free software; you can redistribute it and/or
  3. modify it under the terms of the GNU Lesser General Public
  4. License as published by the Free Software Foundation; either
  5. version 2.1 of the License, or (at your option) any later version.
  6. The GNU C Library is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  9. Lesser General Public License for more details.
  10. You should have received a copy of the GNU Lesser General Public
  11. License along with the GNU C Library. If not, see
  12. <http://www.gnu.org/licenses/>. */
  13. #include <setjmp.h>
  14. #include <jmpbuf-offsets.h>
  15. #include <stdint.h>
  16. #include <unwind.h>
  17. #include <sysdep.h>
  18. /* Test if longjmp to JMPBUF would unwind the frame
  19. containing a local variable at ADDRESS. */
  20. #define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
  21. ((void *) (address) < (void *) demangle ((jmpbuf)[JB_SP]))
  22. #define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
  23. _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) (long) _Unwind_GetCFA (_context), _adj)
  24. static inline uintptr_t __attribute__ ((unused))
  25. _jmpbuf_sp (__jmp_buf regs)
  26. {
  27. uintptr_t sp = regs[JB_SP];
  28. return sp;
  29. }
  30. #define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
  31. ((uintptr_t) (_address) - (_adj) < _jmpbuf_sp (_jmpbuf) - (_adj))
  32. /* We use the normal longjmp for unwinding. */
  33. #define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)