jmpbuf-offsets.h 1008 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Private macros for accessing __jmp_buf contents. kvx version.
  3. * This file is subject to the terms and conditions of the LGPL V2.1
  4. * License. See the file "COPYING" in the main directory of this archive
  5. * for more details.
  6. *
  7. * Copyright (C) 2019 Kalray Inc.
  8. */
  9. #include <bits/wordsize.h>
  10. #if __WORDSIZE == 64
  11. /* We only need to save callee-saved registers plus stackpointer */
  12. # define JB_R12 0 /* stack pointer */
  13. # define JB_R14 1 /* frame pointer */
  14. # define JB_R18 2
  15. # define JB_R19 3
  16. # define JB_R20 4
  17. # define JB_R21 5
  18. # define JB_R22 6
  19. # define JB_R23 7
  20. # define JB_R24 8
  21. # define JB_R25 9
  22. # define JB_R26 10
  23. # define JB_R27 11
  24. # define JB_R28 12
  25. # define JB_R29 13
  26. # define JB_R30 14
  27. # define JB_R31 15
  28. #ifndef __ASSEMBLER__
  29. #include <setjmp.h>
  30. #include <stdint.h>
  31. #include <sysdep.h>
  32. static inline uintptr_t __attribute__ ((unused))
  33. _jmpbuf_sp (__jmp_buf jmpbuf)
  34. {
  35. uintptr_t sp = jmpbuf[0].regs[JB_R12];
  36. return sp;
  37. }
  38. #endif
  39. #else
  40. #error unsupported 32 bit wordsize
  41. #endif