jmpbuf-unwind.h 853 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * Copyright (C) 2016 Andes Technology, Inc.
  3. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  4. */
  5. #include <setjmp.h>
  6. #include <jmpbuf-offsets.h>
  7. #include <stdint.h>
  8. #include <unwind.h>
  9. #include <sysdep.h>
  10. /* Test if longjmp to JMPBUF would unwind the frame
  11. containing a local variable at ADDRESS. */
  12. #define _JMPBUF_UNWINDS(jmpbuf, address) \
  13. ((void *) (address) < &(jmpbuf)[0].__regs[__JMP_BUF_SP])
  14. #define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
  15. _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
  16. static inline uintptr_t __attribute__ ((unused))
  17. _jmpbuf_sp (__jmp_buf regs)
  18. {
  19. uintptr_t sp = (uintptr_t) &(regs)[0].__regs[__JMP_BUF_SP];
  20. return sp;
  21. }
  22. #define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
  23. ((uintptr_t) (_address) - (_adj) < _jmpbuf_sp (_jmpbuf) - (_adj))