jmpbuf-unwind.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  3. *
  4. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  5. */
  6. #include <setjmp.h>
  7. /* Test if longjmp to JMPBUF would unwind the frame
  8. containing a local variable at ADDRESS. */
  9. #define _JMPBUF_UNWINDS(jmpbuf, address) \
  10. ((void *) (address) < (void *) (jmpbuf)[0].__sp)
  11. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  12. #include <stdint.h>
  13. #include <unwind.h>
  14. /* Test if longjmp to JMPBUF would unwind the frame
  15. containing a local variable at ADDRESS. */
  16. #undef _JMPBUF_UNWINDS
  17. #define _JMPBUF_UNWINDS(jmpbuf, address) \
  18. ((void *) (address) < (void *) (jmpbuf)[0].__sp)
  19. #define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
  20. _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
  21. static inline uintptr_t __attribute__ ((unused))
  22. _jmpbuf_sp (__jmp_buf regs)
  23. {
  24. void *sp = (void *) regs[0].__sp;
  25. return (uintptr_t) sp;
  26. }
  27. #define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
  28. ((uintptr_t) (_address) - (_adj) < _jmpbuf_sp (_jmpbuf) - (_adj))
  29. #endif