stdint.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <bits/wchar_size.h>
  8. #include <sys/cdefs.h>
  9. __BEGIN_DECLS
  10. typedef __UINT64_TYPE__ uint64_t;
  11. typedef __UINT32_TYPE__ uint32_t;
  12. typedef __UINT16_TYPE__ uint16_t;
  13. typedef __UINT8_TYPE__ uint8_t;
  14. typedef __INT64_TYPE__ int64_t;
  15. typedef __INT32_TYPE__ int32_t;
  16. typedef __INT16_TYPE__ int16_t;
  17. typedef __INT8_TYPE__ int8_t;
  18. typedef __UINT_FAST8_TYPE__ uint_fast8_t;
  19. typedef __UINT_FAST16_TYPE__ uint_fast16_t;
  20. typedef __UINT_FAST32_TYPE__ uint_fast32_t;
  21. typedef __UINT_FAST64_TYPE__ uint_fast64_t;
  22. typedef __INT_FAST8_TYPE__ int_fast8_t;
  23. typedef __INT_FAST16_TYPE__ int_fast16_t;
  24. typedef __INT_FAST32_TYPE__ int_fast32_t;
  25. typedef __INT_FAST64_TYPE__ int_fast64_t;
  26. typedef __UINT_LEAST8_TYPE__ uint_least8_t;
  27. typedef __UINT_LEAST16_TYPE__ uint_least16_t;
  28. typedef __UINT_LEAST32_TYPE__ uint_least32_t;
  29. typedef __UINT_LEAST64_TYPE__ uint_least64_t;
  30. typedef __INT_LEAST8_TYPE__ int_least8_t;
  31. typedef __INT_LEAST16_TYPE__ int_least16_t;
  32. typedef __INT_LEAST32_TYPE__ int_least32_t;
  33. typedef __INT_LEAST64_TYPE__ int_least64_t;
  34. #define __int8_t_defined 1
  35. #define __uint8_t_defined 1
  36. #define __int16_t_defined 1
  37. #define __uint16_t_defined 1
  38. #define __int32_t_defined 1
  39. #define __uint32_t_defined 1
  40. #define __int64_t_defined 1
  41. #define __uint64_t_defined 1
  42. #define INT8_C(x) x
  43. #define UINT8_C(x) x
  44. #define INT16_C(x) x
  45. #define UINT16_C(x) x
  46. #define INT32_C(x) x
  47. #define UINT32_C(x) x##U
  48. #ifdef __clang__
  49. # define __int_c_concat(a, b) a##b
  50. # define __int_c(var, suffix) __int_c_concat(var, suffix)
  51. # define INT64_C(x) __int_c(x, __INT64_C_SUFFIX__)
  52. # define UINT64_C(x) __int_c(x, __UINT64_C_SUFFIX__)
  53. # define INTMAX_C(x) __int_c(x, __INTMAX_C_SUFFIX__)
  54. # define UINTMAX_C(x) __int_c(x, __UINTMAX_C_SUFFIX__)
  55. #else
  56. # define INT64_C(x) __INT64_C(x)
  57. # define UINT64_C(x) __UINT64_C(x)
  58. # define INTMAX_C(x) __INTMAX_C(x)
  59. # define UINTMAX_C(x) __UINTMAX_C(x)
  60. #endif
  61. typedef __UINTPTR_TYPE__ uintptr_t;
  62. typedef __INTPTR_TYPE__ intptr_t;
  63. typedef __UINTMAX_TYPE__ uintmax_t;
  64. #define UINTMAX_MAX __UINTMAX_MAX__
  65. typedef __INTMAX_TYPE__ intmax_t;
  66. #define INTMAX_MAX __INTMAX_MAX__
  67. #define INTMAX_MIN (-INTMAX_MAX - 1)
  68. #define INT8_MIN (-128)
  69. #define INT16_MIN (-32767 - 1)
  70. #define INT32_MIN (-2147483647 - 1)
  71. #define INT64_MIN (-INT64_C(9223372036854775807) - 1)
  72. #define INT8_MAX (127)
  73. #define INT16_MAX (32767)
  74. #define INT32_MAX (2147483647)
  75. #define INT64_MAX (INT64_C(9223372036854775807))
  76. #define UINT8_MAX (255)
  77. #define UINT16_MAX (65535)
  78. #define UINT32_MAX (4294967295U)
  79. #define UINT64_MAX (UINT64_C(18446744073709551615))
  80. #define INTPTR_MAX __INTPTR_MAX__
  81. #define INTPTR_MIN (-INTPTR_MAX - 1)
  82. #define UINTPTR_MAX __UINTPTR_MAX__
  83. #define INT_FAST8_MIN INT8_MIN
  84. #define INT_FAST16_MIN INT16_MIN
  85. #define INT_FAST32_MIN INT32_MIN
  86. #define INT_FAST64_MIN INT64_MIN
  87. #define INT_FAST8_MAX INT8_MAX
  88. #define INT_FAST16_MAX INT16_MAX
  89. #define INT_FAST32_MAX INT32_MAX
  90. #define INT_FAST64_MAX INT64_MAX
  91. #define UINT_FAST8_MAX UINT8_MAX
  92. #define UINT_FAST16_MAX UINT16_MAX
  93. #define UINT_FAST32_MAX UINT32_MAX
  94. #define UINT_FAST64_MAX UINT64_MAX
  95. #define INT_LEAST8_MIN INT8_MIN
  96. #define INT_LEAST16_MIN INT16_MIN
  97. #define INT_LEAST32_MIN INT32_MIN
  98. #define INT_LEAST64_MIN INT64_MIN
  99. #define INT_LEAST8_MAX INT8_MAX
  100. #define INT_LEAST16_MAX INT16_MAX
  101. #define INT_LEAST32_MAX INT32_MAX
  102. #define INT_LEAST64_MAX INT64_MAX
  103. #define UINT_LEAST8_MAX UINT8_MAX
  104. #define UINT_LEAST16_MAX UINT16_MAX
  105. #define UINT_LEAST32_MAX UINT32_MAX
  106. #define UINT_LEAST64_MAX UINT64_MAX
  107. #define SIZE_MAX __SIZE_MAX__
  108. #define PTRDIFF_MAX __PTRDIFF_MAX__
  109. #define PTRDIFF_MIN (-__PTRDIFF_MAX__ - 1)
  110. __END_DECLS