_stdint.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*-
  2. * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
  3. * Copyright (c) 2001 The NetBSD Foundation, Inc.
  4. * All rights reserved.
  5. *
  6. * This code is derived from software contributed to The NetBSD Foundation
  7. * by Klaus Klein.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  19. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  20. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  21. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  22. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  23. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  24. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  25. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  26. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  28. * POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef _MACHINE__STDINT_H_
  31. #define _MACHINE__STDINT_H_
  32. #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
  33. #define INT8_C(c) (c)
  34. #define INT16_C(c) (c)
  35. #define INT32_C(c) (c)
  36. #define INT64_C(c) (c ## L)
  37. #define UINT8_C(c) (c)
  38. #define UINT16_C(c) (c)
  39. #define UINT32_C(c) (c ## U)
  40. #define UINT64_C(c) (c ## UL)
  41. #define INTMAX_C(c) INT64_C(c)
  42. #define UINTMAX_C(c) UINT64_C(c)
  43. #endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
  44. #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
  45. /*
  46. * ISO/IEC 9899:1999
  47. * 7.18.2.1 Limits of exact-width integer types
  48. */
  49. /* Minimum values of exact-width signed integer types. */
  50. #define INT8_MIN (-0x7f-1)
  51. #define INT16_MIN (-0x7fff-1)
  52. #define INT32_MIN (-0x7fffffff-1)
  53. #define INT64_MIN (-0x7fffffffffffffffL-1)
  54. /* Maximum values of exact-width signed integer types. */
  55. #define INT8_MAX 0x7f
  56. #define INT16_MAX 0x7fff
  57. #define INT32_MAX 0x7fffffff
  58. #define INT64_MAX 0x7fffffffffffffffL
  59. /* Maximum values of exact-width unsigned integer types. */
  60. #define UINT8_MAX 0xff
  61. #define UINT16_MAX 0xffff
  62. #define UINT32_MAX 0xffffffffU
  63. #define UINT64_MAX 0xffffffffffffffffUL
  64. /*
  65. * ISO/IEC 9899:1999
  66. * 7.18.2.2 Limits of minimum-width integer types
  67. */
  68. /* Minimum values of minimum-width signed integer types. */
  69. #define INT_LEAST8_MIN INT8_MIN
  70. #define INT_LEAST16_MIN INT16_MIN
  71. #define INT_LEAST32_MIN INT32_MIN
  72. #define INT_LEAST64_MIN INT64_MIN
  73. /* Maximum values of minimum-width signed integer types. */
  74. #define INT_LEAST8_MAX INT8_MAX
  75. #define INT_LEAST16_MAX INT16_MAX
  76. #define INT_LEAST32_MAX INT32_MAX
  77. #define INT_LEAST64_MAX INT64_MAX
  78. /* Maximum values of minimum-width unsigned integer types. */
  79. #define UINT_LEAST8_MAX UINT8_MAX
  80. #define UINT_LEAST16_MAX UINT16_MAX
  81. #define UINT_LEAST32_MAX UINT32_MAX
  82. #define UINT_LEAST64_MAX UINT64_MAX
  83. /*
  84. * ISO/IEC 9899:1999
  85. * 7.18.2.3 Limits of fastest minimum-width integer types
  86. */
  87. /* Minimum values of fastest minimum-width signed integer types. */
  88. #define INT_FAST8_MIN INT32_MIN
  89. #define INT_FAST16_MIN INT32_MIN
  90. #define INT_FAST32_MIN INT32_MIN
  91. #define INT_FAST64_MIN INT64_MIN
  92. /* Maximum values of fastest minimum-width signed integer types. */
  93. #define INT_FAST8_MAX INT32_MAX
  94. #define INT_FAST16_MAX INT32_MAX
  95. #define INT_FAST32_MAX INT32_MAX
  96. #define INT_FAST64_MAX INT64_MAX
  97. /* Maximum values of fastest minimum-width unsigned integer types. */
  98. #define UINT_FAST8_MAX UINT32_MAX
  99. #define UINT_FAST16_MAX UINT32_MAX
  100. #define UINT_FAST32_MAX UINT32_MAX
  101. #define UINT_FAST64_MAX UINT64_MAX
  102. /*
  103. * ISO/IEC 9899:1999
  104. * 7.18.2.4 Limits of integer types capable of holding object pointers
  105. */
  106. #define INTPTR_MIN INT64_MIN
  107. #define INTPTR_MAX INT64_MAX
  108. #define UINTPTR_MAX UINT64_MAX
  109. /*
  110. * ISO/IEC 9899:1999
  111. * 7.18.2.5 Limits of greatest-width integer types
  112. */
  113. #define INTMAX_MIN INT64_MIN
  114. #define INTMAX_MAX INT64_MAX
  115. #define UINTMAX_MAX UINT64_MAX
  116. /*
  117. * ISO/IEC 9899:1999
  118. * 7.18.3 Limits of other integer types
  119. */
  120. /* Limits of ptrdiff_t. */
  121. #define PTRDIFF_MIN INT64_MIN
  122. #define PTRDIFF_MAX INT64_MAX
  123. /* Limits of sig_atomic_t. */
  124. #define SIG_ATOMIC_MIN INT64_MIN
  125. #define SIG_ATOMIC_MAX INT64_MAX
  126. /* Limit of size_t. */
  127. #define SIZE_MAX UINT64_MAX
  128. /* Limits of wint_t. */
  129. #define WINT_MIN INT32_MIN
  130. #define WINT_MAX INT32_MAX
  131. #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
  132. #endif /* !_MACHINE__STDINT_H_ */