stdint.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* -*-comment-start: "//";comment-end:""-*-
  2. * GNU Mes --- Maxwell Equations of Software
  3. * Copyright © 2017,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  4. * Copyright © 2018 Peter De Wachter <pdewacht@gmail.com>
  5. *
  6. * This file is part of GNU Mes.
  7. *
  8. * GNU Mes is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or (at
  11. * your option) any later version.
  12. *
  13. * GNU Mes is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef __MES_STDINT_H
  22. #define __MES_STDINT_H 1
  23. #if SYSTEM_LIBC
  24. #ifndef _GNU_SOURCE
  25. #define _GNU_SOURCE
  26. #endif
  27. #undef __MES_STDINT_H
  28. #include_next <stdint.h>
  29. #else // ! SYSTEM_LIBC
  30. #undef unsigned
  31. #undef uint8_t
  32. #undef int8_t
  33. #undef uint16_t
  34. #undef int16_t
  35. #undef uint32_t
  36. #undef int32_t
  37. #undef uint64_t
  38. #undef int64_t
  39. #undef uintptr_t
  40. #undef intmax_t
  41. #undef intptr_t
  42. #undef uintmax_t
  43. #undef ptrdiff_t
  44. typedef unsigned char uint8_t;
  45. typedef char int8_t;
  46. typedef unsigned short uint16_t;
  47. typedef short int16_t;
  48. typedef unsigned uint32_t;
  49. typedef int int32_t;
  50. #if __SIZEOF_LONG_LONG__ == 8
  51. typedef unsigned long long uint64_t;
  52. typedef long long int64_t;
  53. #endif // __SIZEOF_LONG_LONG__ == 8
  54. typedef int intmax_t;
  55. typedef unsigned uintmax_t;
  56. #include <sys/types.h>
  57. #define CHAR_BIT 8
  58. #define CHAR_MAX 255
  59. #define UCHAR_MAX 255
  60. #define INT8_MAX 127
  61. #define INT8_MIN (-INT8_MAX-1)
  62. #define UINT8_MAX 255
  63. #define INT16_MAX 32767
  64. #define INT16_MIN (-INT16_MAX-1)
  65. #define UINT16_MAX 65535
  66. #define INT32_MAX 2147483647
  67. #define INT32_MIN (-INT32_MAX-1)
  68. #define UINT32_MAX 4294967295U
  69. #define INT64_MAX 9223372036854775807LL
  70. #define INT64_MIN (-INT64_MAX-1)
  71. #define UINT64_MAX 18446744073709551615ULL
  72. #define INT_MIN -2147483648
  73. #define INT_MAX 2147483647
  74. #if __i386__ || __arm__
  75. #define LONG_MIN INT_MIN
  76. #define LONG_MAX INT_MAX
  77. #define UINT_MAX UINT32_MAX
  78. #define ULONG_MAX UINT32_MAX
  79. #define LLONG_MIN INT64_MIN
  80. #define LLONG_MAX INT64_MAX
  81. #define SIZE_MAX UINT32_MAX
  82. #elif __x86_64__
  83. #define LONG_MIN INT64_MIN
  84. #define LONG_MAX INT64_MAX
  85. #define UINT_MAX UINT32_MAX
  86. #define ULONG_MAX UINT64_MAX
  87. #define LLONG_MIN INT64_MIN
  88. #define LLONG_MAX INT64_MAX
  89. #define SIZE_MAX UINT64_MAX
  90. #endif
  91. #endif // ! SYSTEM_LIBC
  92. #endif // __MES_STDINT_H