limits.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* limits.h */
  2. /*
  3. * Copyright (c) 2014 Wind River Systems, Inc.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. */
  7. #ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_LIMITS_H_
  8. #define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_LIMITS_H_
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #if __CHAR_BIT__ == 8
  13. #define UCHAR_MAX 0xFFU
  14. #else
  15. #error "unexpected __CHAR_BIT__ value"
  16. #endif
  17. #define SCHAR_MAX __SCHAR_MAX__
  18. #define SCHAR_MIN (-SCHAR_MAX - 1)
  19. #ifdef __CHAR_UNSIGNED__
  20. /* 'char' is an unsigned type */
  21. #define CHAR_MAX UCHAR_MAX
  22. #define CHAR_MIN 0
  23. #else
  24. /* 'char' is a signed type */
  25. #define CHAR_MAX SCHAR_MAX
  26. #define CHAR_MIN SCHAR_MIN
  27. #endif
  28. #define CHAR_BIT __CHAR_BIT__
  29. #define LONG_BIT (__SIZEOF_LONG__ * CHAR_BIT)
  30. #define WORD_BIT (__SIZEOF_POINTER__ * CHAR_BIT)
  31. #define INT_MAX __INT_MAX__
  32. #define SHRT_MAX __SHRT_MAX__
  33. #define LONG_MAX __LONG_MAX__
  34. #define LLONG_MAX __LONG_LONG_MAX__
  35. #define INT_MIN (-INT_MAX - 1)
  36. #define SHRT_MIN (-SHRT_MAX - 1)
  37. #define LONG_MIN (-LONG_MAX - 1L)
  38. #define LLONG_MIN (-LLONG_MAX - 1LL)
  39. #if __SIZE_MAX__ == __UINT32_MAX__
  40. #define SSIZE_MAX __INT32_MAX__
  41. #elif __SIZE_MAX__ == __UINT64_MAX__
  42. #define SSIZE_MAX __INT64_MAX__
  43. #else
  44. #error "unexpected __SIZE_MAX__ value"
  45. #endif
  46. #if __SIZEOF_SHORT__ == 2
  47. #define USHRT_MAX 0xFFFFU
  48. #else
  49. #error "unexpected __SIZEOF_SHORT__ value"
  50. #endif
  51. #if __SIZEOF_INT__ == 4
  52. #define UINT_MAX 0xFFFFFFFFU
  53. #else
  54. #error "unexpected __SIZEOF_INT__ value"
  55. #endif
  56. #if __SIZEOF_LONG__ == 4
  57. #define ULONG_MAX 0xFFFFFFFFUL
  58. #elif __SIZEOF_LONG__ == 8
  59. #define ULONG_MAX 0xFFFFFFFFFFFFFFFFUL
  60. #else
  61. #error "unexpected __SIZEOF_LONG__ value"
  62. #endif
  63. #if __SIZEOF_LONG_LONG__ == 8
  64. #define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL
  65. #else
  66. #error "unexpected __SIZEOF_LONG_LONG__ value"
  67. #endif
  68. #define PATH_MAX 256
  69. #ifdef __cplusplus
  70. }
  71. #endif
  72. #endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_LIMITS_H_ */