stdint.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (c) 2022 Agustina Arzille.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef STDINT_H
  18. #define STDINT_H
  19. #include <stddef.h>
  20. /* This is a simplified implementation of the standard 'stdint' file.
  21. * The reason it exists is to provide definitions that can be managed
  22. * explicitly by the kernel when the standard presents ambiguities while
  23. * also leaving out unneeded stuff (i.e: the intXXXfast_t types). */
  24. typedef __INT8_TYPE__ int8_t;
  25. typedef __UINT8_TYPE__ uint8_t;
  26. typedef __INT16_TYPE__ int16_t;
  27. typedef __UINT16_TYPE__ uint16_t;
  28. typedef int int32_t;
  29. typedef unsigned int uint32_t;
  30. typedef long long int64_t;
  31. typedef unsigned long long uint64_t;
  32. #define INT8_C __INT8_C
  33. #define INT16_C __INT16_C
  34. #define INT32_C __INT32_C
  35. #define INT64_C(x) x ## ll
  36. #define UINT8_C(x) x
  37. #define UINT16_C(x) x
  38. #define UINT32_C(x) x ## u
  39. #define UINT64_C(x) x ## ull
  40. #define INT8_MIN (-128)
  41. #define INT8_MAX (0x7f)
  42. #define INT16_MIN (-32767 - 1)
  43. #define INT16_MAX (32767)
  44. #define INT32_MIN (-2147483647 - 1)
  45. #define INT32_MAX (2147483647)
  46. #define INT64_MIN (- INT64_C (9223372036854775807) - 1)
  47. #define INT64_MAX (INT64_C (9223372036854775807))
  48. #define UINT8_MAX (0xff)
  49. #define UINT16_MAX (0xffff)
  50. #define UINT32_MAX (UINT32_C (0xffffffff))
  51. #define UINT64_MAX (UINT64_C (0xffffffffffffffff))
  52. typedef unsigned long uintptr_t;
  53. typedef long intptr_t;
  54. #if __WORDSIZE == 64
  55. #define UINTPTR_MAX UINT64_MAX
  56. #define INTPTR_MIN INT64_MIN
  57. #define INTPTR_MAX INT64_MAX
  58. #else
  59. #define UINTPTR_MAX UINT32_MAX
  60. #define INTPTR_MIN INT32_MIN
  61. #define INTPTR_MAX INT32_MAX
  62. #endif
  63. #ifndef SIZE_MAX
  64. #define SIZE_MAX UINTPTR_MAX
  65. #endif
  66. #endif