setjmp.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*-------------------------------------------------------------------------
  2. setjmp.h - header file for setjmp & longjmp ANSI routines
  3. Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net
  4. This library is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 2, or (at your option) any
  7. later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this library; see the file COPYING. If not, write to the
  14. Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  15. MA 02110-1301, USA.
  16. As a special exception, if you link this library with other files,
  17. some of which are compiled with SDCC, to produce an executable,
  18. this library does not by itself cause the resulting executable to
  19. be covered by the GNU General Public License. This exception does
  20. not however invalidate any other reasons why the executable file
  21. might be covered by the GNU General Public License.
  22. -------------------------------------------------------------------------*/
  23. #ifndef __SDCC_SETJMP_H
  24. #define __SDCC_SETJMP_H
  25. #define SP_SIZE 1
  26. #ifdef __SDCC_STACK_AUTO
  27. #define BP_SIZE SP_SIZE
  28. #else
  29. #define BP_SIZE 0
  30. #endif
  31. #ifdef __SDCC_USE_XSTACK
  32. #define SPX_SIZE 1
  33. #else
  34. #define SPX_SIZE 0
  35. #endif
  36. #define BPX_SIZE SPX_SIZE
  37. #ifdef __SDCC_MODEL_HUGE
  38. #define RET_SIZE 3
  39. #else
  40. #define RET_SIZE 2
  41. #endif
  42. #if defined (__SDCC_z80) || defined (__SDCC_z180) || defined (__SDCC_r2k) || defined (__SDCC_r3ka)
  43. typedef unsigned char jmp_buf[6]; // 2 for the stack pointer, 2 for the return address, 2 for the frame pointer.
  44. #else
  45. typedef unsigned char jmp_buf[RET_SIZE + SP_SIZE + BP_SIZE + SPX_SIZE + BPX_SIZE];
  46. #endif
  47. int __setjmp (jmp_buf);
  48. // C99 might require setjmp to be a macro. The standard seems self-contradicting on this issue.
  49. #define setjmp(jump_buf) __setjmp(jump_buf)
  50. #ifndef __SDCC_HIDE_LONGJMP
  51. _Noreturn void longjmp(jmp_buf, int);
  52. #endif
  53. #undef RET_SIZE
  54. #undef SP_SIZE
  55. #undef BP_SIZE
  56. #undef SPX_SIZE
  57. #undef BPX_SIZE
  58. #endif