kernel_types.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*************************************************************************/ /*!
  2. @Title C99-compatible types and definitions for Linux kernel code
  3. @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
  4. @License Dual MIT/GPLv2
  5. The contents of this file are subject to the MIT license as set out below.
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. Alternatively, the contents of this file may be used under the terms of
  15. the GNU General Public License Version 2 ("GPL") in which case the provisions
  16. of GPL are applicable instead of those above.
  17. If you wish to allow use of your version of this file only under the terms of
  18. GPL, and not to allow others to use your version of this file under the terms
  19. of the MIT license, indicate your decision by deleting the provisions above
  20. and replace them with the notice and other provisions required by GPL as set
  21. out in the file called "GPL-COPYING" included in this distribution. If you do
  22. not delete the provisions above, a recipient may use your version of this file
  23. under the terms of either the MIT license or GPL.
  24. This License is also included in this distribution in the file called
  25. "MIT-COPYING".
  26. EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
  27. PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
  28. BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  29. PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
  30. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  31. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  32. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  33. */ /**************************************************************************/
  34. #include <linux/kernel.h>
  35. /* Limits of specified-width integer types */
  36. /* S8_MIN, etc were added in kernel version 3.14. The other versions are for
  37. * earlier kernels. They can be removed once older kernels don't need to be
  38. * supported.
  39. */
  40. #ifdef S8_MIN
  41. #define INT8_MIN S8_MIN
  42. #else
  43. #define INT8_MIN (-128)
  44. #endif
  45. #ifdef S8_MAX
  46. #define INT8_MAX S8_MAX
  47. #else
  48. #define INT8_MAX 127
  49. #endif
  50. #ifdef U8_MAX
  51. #define UINT8_MAX U8_MAX
  52. #else
  53. #define UINT8_MAX 0xFF
  54. #endif
  55. #ifdef S16_MIN
  56. #define INT16_MIN S16_MIN
  57. #else
  58. #define INT16_MIN (-32768)
  59. #endif
  60. #ifdef S16_MAX
  61. #define INT16_MAX S16_MAX
  62. #else
  63. #define INT16_MAX 32767
  64. #endif
  65. #ifdef U16_MAX
  66. #define UINT16_MAX U16_MAX
  67. #else
  68. #define UINT16_MAX 0xFFFF
  69. #endif
  70. #ifdef S32_MIN
  71. #define INT32_MIN S32_MIN
  72. #else
  73. #define INT32_MIN (-2147483647 - 1)
  74. #endif
  75. #ifdef S32_MAX
  76. #define INT32_MAX S32_MAX
  77. #else
  78. #define INT32_MAX 2147483647
  79. #endif
  80. #ifdef U32_MAX
  81. #define UINT32_MAX U32_MAX
  82. #else
  83. #define UINT32_MAX 0xFFFFFFFF
  84. #endif
  85. #ifdef S64_MIN
  86. #define INT64_MIN S64_MIN
  87. #else
  88. #define INT64_MIN (-9223372036854775807LL)
  89. #endif
  90. #ifdef S64_MAX
  91. #define INT64_MAX S64_MAX
  92. #else
  93. #define INT64_MAX 9223372036854775807LL
  94. #endif
  95. #ifdef U64_MAX
  96. #define UINT64_MAX U64_MAX
  97. #else
  98. #define UINT64_MAX 0xFFFFFFFFFFFFFFFFULL
  99. #endif
  100. /* Macros for integer constants */
  101. #define INT8_C S8_C
  102. #define UINT8_C U8_C
  103. #define INT16_C S16_C
  104. #define UINT16_C U16_C
  105. #define INT32_C S32_C
  106. #define UINT32_C U32_C
  107. #define INT64_C S64_C
  108. #define UINT64_C U64_C
  109. /* Format conversion of integer types <inttypes.h> */
  110. #define PRIX64 "llX"
  111. #define PRIx64 "llx"
  112. #define PRIu64 "llu"
  113. #define PRId64 "lld"