setjmp.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*****************************************************************************/
  2. /* setjmp.h v8.2.2 */
  3. /* */
  4. /* Copyright (c) 1993-2017 Texas Instruments Incorporated */
  5. /* http://www.ti.com/ */
  6. /* */
  7. /* Redistribution and use in source and binary forms, with or without */
  8. /* modification, are permitted provided that the following conditions */
  9. /* are met: */
  10. /* */
  11. /* Redistributions of source code must retain the above copyright */
  12. /* notice, this list of conditions and the following disclaimer. */
  13. /* */
  14. /* Redistributions in binary form must reproduce the above copyright */
  15. /* notice, this list of conditions and the following disclaimer in */
  16. /* the documentation and/or other materials provided with the */
  17. /* distribution. */
  18. /* */
  19. /* Neither the name of Texas Instruments Incorporated nor the names */
  20. /* of its contributors may be used to endorse or promote products */
  21. /* derived from this software without specific prior written */
  22. /* permission. */
  23. /* */
  24. /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
  25. /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
  26. /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */
  27. /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
  28. /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
  29. /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
  30. /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
  31. /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */
  32. /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
  33. /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */
  34. /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
  35. /* */
  36. /*****************************************************************************/
  37. #ifndef _SETJMP
  38. #define _SETJMP
  39. #include <linkage.h>
  40. #pragma diag_push
  41. #pragma CHECK_MISRA("-6.3") /* standard types required for standard headers */
  42. #pragma CHECK_MISRA("-19.7") /* macros required for implementation */
  43. #pragma CHECK_MISRA("-20.1") /* standard headers must define standard names */
  44. #pragma CHECK_MISRA("-20.2") /* standard headers must define standard names */
  45. #ifdef __cplusplus
  46. extern "C" namespace std {
  47. #endif
  48. #pragma diag_push
  49. #pragma CHECK_MISRA("-19.4") /* macro oddness */
  50. #if defined(__TMS320C6X__) && defined(__TI_EABI__)
  51. #define setjmp(x) setjmp(x)
  52. #else
  53. #define setjmp(x) _setjmp(x)
  54. #endif
  55. #pragma diag_pop
  56. typedef int jmp_buf[13];
  57. #if defined(__EDG_JMP_BUF_NUM_ELEMENTS)
  58. #if __EDG_JMP_BUF_NUM_ELEMENTS !=13
  59. #error "Front end and runtime disagree on size of jmp_buf"
  60. #endif
  61. #endif
  62. #pragma diag_push
  63. #pragma CHECK_MISRA("-20.7") /* standard headers must define standard names */
  64. #pragma CHECK_MISRA("-5.6") /* macro oddness */
  65. #if defined(__TMS320C6X__) && defined(__TI_EABI__)
  66. _CODE_ACCESS int setjmp(jmp_buf env);
  67. #else
  68. _CODE_ACCESS int _setjmp(jmp_buf env);
  69. #endif
  70. _CODE_ACCESS void longjmp(jmp_buf env, int val);
  71. #pragma diag_pop
  72. #ifdef __cplusplus
  73. } /* extern "C" namespace std */
  74. #endif /* __cplusplus */
  75. #pragma diag_pop
  76. #endif /* _SETJMP */
  77. #pragma diag_push
  78. /* using declarations must occur outside header guard to support including both
  79. C and C++-wrapped version of header; see _CPP_STYLE_HEADER check */
  80. /* this code is for C++ mode only and thus also not relevant for MISRA */
  81. #pragma CHECK_MISRA("-19.15")
  82. #if defined(__cplusplus) && !defined(_CPP_STYLE_HEADER)
  83. using std::jmp_buf;
  84. #if defined(__TMS320C6X__) && defined(__TI_EABI__)
  85. using std::setjmp;
  86. #else
  87. using std::_setjmp;
  88. #endif
  89. using std::longjmp;
  90. #endif /* _CPP_STYLE_HEADER */
  91. #pragma diag_pop