stddef.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*****************************************************************************/
  2. /* stddef.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 _STDDEF
  38. #define _STDDEF
  39. #pragma diag_push
  40. #pragma CHECK_MISRA("-19.7") /* macros required for implementation */
  41. #pragma CHECK_MISRA("-20.1") /* standard headers must define standard names */
  42. #pragma CHECK_MISRA("-20.2") /* standard headers must define standard names */
  43. #ifdef __cplusplus
  44. extern "C" namespace std {
  45. #endif
  46. #ifndef NULL
  47. #define NULL 0
  48. #endif
  49. typedef __PTRDIFF_T_TYPE__ ptrdiff_t;
  50. #ifndef _SIZE_T
  51. #define _SIZE_T
  52. typedef __SIZE_T_TYPE__ size_t;
  53. #endif
  54. #ifndef __cplusplus
  55. #ifndef _WCHAR_T
  56. #define _WCHAR_T
  57. typedef __WCHAR_T_TYPE__ wchar_t;
  58. #endif /* _WCHAR_T */
  59. #endif /* ! __cplusplus */
  60. #pragma diag_push
  61. #pragma CHECK_MISRA("-19.10") /* need types as macro arguments */
  62. #ifdef __TI_LLVM__
  63. # define offsetof(_type, _ident) __builtin_offsetof(_type, _ident)
  64. #else
  65. # ifdef __cplusplus
  66. # define offsetof(_type, _ident) \
  67. ((std::size_t)__intaddr__(&(((_type *)0)->_ident)))
  68. # else
  69. # define offsetof(_type, _ident) \
  70. ((size_t)__intaddr__(&(((_type *)0)->_ident)))
  71. # endif
  72. #endif
  73. #ifdef __cplusplus
  74. } /* extern "C" namespace std */
  75. #endif /* __cplusplus */
  76. #pragma diag_pop
  77. #endif /* _STDDEF */
  78. #if defined(__cplusplus) && !defined(_CPP_STYLE_HEADER)
  79. using std::ptrdiff_t;
  80. using std::size_t;
  81. /*using std::wchar_t;*/
  82. #endif /* _CPP_STYLE_HEADER */
  83. #pragma diag_push
  84. #pragma CHECK_MISRA("-19.15") /* code outside guard; see below comment */
  85. /*-----------------------------------------------------------------------*/
  86. /* Define _win_t, for compiling GCC libraries with the TI compiler. */
  87. /* GCC's library (newlib) expects wint_t to be defined here, in stddef.h,*/
  88. /* which is arguably incorrect, but we go along for compatibility. */
  89. /* This is outside the _STDDEF guard in case this file has already */
  90. /* been included without __need_wint_t. */
  91. /*-----------------------------------------------------------------------*/
  92. #if defined(__need_wint_t) && !defined(_WINT_T)
  93. #if (__STDC_VERSION__ >= 199901L || !__TI_STRICT_ANSI_MODE__)
  94. #undef __need_wint_t
  95. #define _WINT_T
  96. #ifdef __cplusplus
  97. extern "C" namespace std {
  98. #endif /* __cplusplus */
  99. typedef unsigned int wint_t;
  100. #ifdef __cplusplus
  101. } /* extern "C" namespace std { */
  102. #endif /* __cplusplus */
  103. #if defined(__cplusplus) && !defined(_CPP_STYLE_HEADER)
  104. using std::wint_t;
  105. #endif /* _CPP_STYLE_HEADER */
  106. #endif /* __STDC_VERSION__ >= 199901L */
  107. #endif
  108. #pragma diag_pop