1 /* Copyright (c) 2002 Jeff Johnston <jjohnstn@redhat.com> */ 2 #ifndef _LIBC_LIMITS_H_ 3 # define _LIBC_LIMITS_H_ 1 4 5 #include <sys/cdefs.h> 6 #include <sys/syslimits.h> 7 8 #ifndef _MB_LEN_MAX 9 # ifdef _MB_CAPABLE 10 # define _MB_LEN_MAX 8 11 # else 12 # define _MB_LEN_MAX 1 13 # endif 14 #endif 15 #define MB_LEN_MAX _MB_LEN_MAX 16 17 /* Maximum number of positional arguments, if _WANT_IO_POS_ARGS. */ 18 # ifndef NL_ARGMAX 19 # define NL_ARGMAX 32 20 # endif 21 22 /* if do not have #include_next support, then we 23 have to define the limits here. */ 24 # if !defined __GNUC__ || __GNUC__ < 2 25 26 # ifndef _LIMITS_H 27 # define _LIMITS_H 1 28 29 /* Number of bits in a `char'. */ 30 # undef CHAR_BIT 31 # define CHAR_BIT 8 32 33 /* Minimum and maximum values a `signed char' can hold. */ 34 # undef SCHAR_MIN 35 # define SCHAR_MIN (-128) 36 # undef SCHAR_MAX 37 # define SCHAR_MAX 127 38 39 /* Maximum value an `unsigned char' can hold. (Minimum is 0). */ 40 # undef UCHAR_MAX 41 # define UCHAR_MAX 255 42 43 /* Minimum and maximum values a `char' can hold. */ 44 # ifdef __CHAR_UNSIGNED__ 45 # undef CHAR_MIN 46 # define CHAR_MIN 0 47 # undef CHAR_MAX 48 # define CHAR_MAX 255 49 # else 50 # undef CHAR_MIN 51 # define CHAR_MIN (-128) 52 # undef CHAR_MAX 53 # define CHAR_MAX 127 54 # endif 55 56 /* Minimum and maximum values a `signed short int' can hold. */ 57 # undef SHRT_MIN 58 /* For the sake of 16 bit hosts, we may not use -32768 */ 59 # define SHRT_MIN (-32767-1) 60 # undef SHRT_MAX 61 # define SHRT_MAX 32767 62 63 /* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ 64 # undef USHRT_MAX 65 # define USHRT_MAX 65535 66 67 /* Minimum and maximum values a `signed int' can hold. */ 68 # ifndef __INT_MAX__ 69 # define __INT_MAX__ 2147483647 70 # endif 71 # undef INT_MIN 72 # define INT_MIN (-INT_MAX-1) 73 # undef INT_MAX 74 # define INT_MAX __INT_MAX__ 75 76 /* Maximum value an `unsigned int' can hold. (Minimum is 0). */ 77 # undef UINT_MAX 78 # define UINT_MAX (INT_MAX * 2U + 1) 79 80 /* Minimum and maximum values a `signed long int' can hold. 81 (Same as `int'). */ 82 # ifndef __LONG_MAX__ 83 # if defined (__alpha__) || (defined (__sparc__) && defined(__arch64__)) || defined (__sparcv9) 84 # define __LONG_MAX__ 9223372036854775807L 85 # else 86 # define __LONG_MAX__ 2147483647L 87 # endif /* __alpha__ || sparc64 */ 88 # endif 89 # undef LONG_MIN 90 # define LONG_MIN (-LONG_MAX-1) 91 # undef LONG_MAX 92 # define LONG_MAX __LONG_MAX__ 93 94 /* Maximum value an `unsigned long int' can hold. (Minimum is 0). */ 95 # undef ULONG_MAX 96 # define ULONG_MAX (LONG_MAX * 2UL + 1) 97 98 # ifndef __LONG_LONG_MAX__ 99 # define __LONG_LONG_MAX__ 9223372036854775807LL 100 # endif 101 102 # if __ISO_C_VISIBLE >= 1999 103 /* Minimum and maximum values a `signed long long int' can hold. */ 104 # undef LLONG_MIN 105 # define LLONG_MIN (-LLONG_MAX-1) 106 # undef LLONG_MAX 107 # define LLONG_MAX __LONG_LONG_MAX__ 108 109 /* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ 110 # undef ULLONG_MAX 111 # define ULLONG_MAX (LLONG_MAX * 2ULL + 1) 112 # endif 113 114 # if __GNU_VISIBLE 115 /* Minimum and maximum values a `signed long long int' can hold. */ 116 # undef LONG_LONG_MIN 117 # define LONG_LONG_MIN (-LONG_LONG_MAX-1) 118 # undef LONG_LONG_MAX 119 # define LONG_LONG_MAX __LONG_LONG_MAX__ 120 121 /* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ 122 # undef ULONG_LONG_MAX 123 # define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1) 124 # endif 125 126 # endif /* _LIMITS_H */ 127 # endif /* GCC 2. */ 128 129 #endif /* !_LIBC_LIMITS_H_ */ 130 131 /* 132 * Placing this outside of the above condition means that this will 133 * get run even from another picolibc provided limits.h file down the 134 * include chain. This also to see if the compiler limits.h has 135 * already been included as some clang configurations do that. 136 */ 137 #if defined __GNUC__ && !defined _GCC_LIMITS_H_ 138 #ifdef __clang__ 139 #ifndef __GLIBC_USE 140 #define __GLIBC_USE(x) 1 141 #endif 142 #endif 143 # include_next <limits.h> 144 #endif /* __GNUC__ && !_GCC_LIMITS_H_ */ 145