limits.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /****************************************************************************
  2. * arch/risc-v/include/limits.h
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __ARCH_RISCV_INCLUDE_LIMITS_H
  21. #define __ARCH_RISCV_INCLUDE_LIMITS_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. /****************************************************************************
  26. * Pre-processor Definitions
  27. ****************************************************************************/
  28. #define CHAR_BIT 8
  29. #define SCHAR_MIN (-SCHAR_MAX - 1)
  30. #define SCHAR_MAX 127
  31. #define UCHAR_MAX 255
  32. /* These could be different on machines where char is unsigned */
  33. #ifdef __CHAR_UNSIGNED__
  34. #define CHAR_MIN 0
  35. #define CHAR_MAX UCHAR_MAX
  36. #else
  37. #define CHAR_MIN SCHAR_MIN
  38. #define CHAR_MAX SCHAR_MAX
  39. #endif
  40. #define SHRT_MIN (-SHRT_MAX - 1)
  41. #define SHRT_MAX 32767
  42. #define USHRT_MAX 65535U
  43. #define INT_MIN (-INT_MAX - 1)
  44. #define INT_MAX 2147483647
  45. #define UINT_MAX 4294967295U
  46. /* These change on 32-bit and 64-bit platforms */
  47. #if defined(CONFIG_ARCH_RV32IM) || defined(CONFIG_ARCH_RV32I)
  48. #define LONG_MIN (-LONG_MAX - 1)
  49. #define LONG_MAX 2147483647L
  50. #define ULONG_MAX 4294967295UL
  51. #define LLONG_MIN (-LLONG_MAX - 1)
  52. #define LLONG_MAX 9223372036854775807LL
  53. #define ULLONG_MAX 18446744073709551615ULL
  54. /* A pointer is 4 bytes */
  55. #define PTR_MIN (-PTR_MAX - 1)
  56. #define PTR_MAX 2147483647
  57. #define UPTR_MAX 4294967295U
  58. #endif /* defined(CONFIG_ARCH_32IM) || defined(CONFIG_ARCH_32I) */
  59. #if defined(CONFIG_ARCH_RV64GC)
  60. #define LONG_MIN (-LONG_MAX - 1)
  61. #define LONG_MAX 9223372036854775807L
  62. #define ULONG_MAX 18446744073709551615UL
  63. #define LLONG_MIN (-LLONG_MAX - 1)
  64. #define LLONG_MAX 9223372036854775807LL
  65. #define ULLONG_MAX 18446744073709551615ULL
  66. #define PTR_MIN (-PTR_MAX - 1)
  67. #define PTR_MAX 9223372036854775807
  68. #define UPTR_MAX 18446744073709551615U
  69. #endif
  70. #endif /* __ARCH_RISCV_INCLUDE_LIMITS_H */