/* Note: the literal "most negative int" cannot be written in C -- the rules in the standard (section 6.4.4.1 in C99) will give it an unsigned type, so INT32_MIN (and the most negative member of any larger signed type) must be written via a constant expression. */ #define INT32_MIN (-INT32_MAX-1) #define INT64_MIN (-INT64_MAX-1)
/*===---- limits.h - Standard header for integer sizes --------------------===*\ * * Copyright (c) 2009 Chris Lattner * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * \*===----------------------------------------------------------------------===*/
#ifndef __CLANG_LIMITS_H #define __CLANG_LIMITS_H
/* The system's limits.h may, in turn, try to #include_next GCC's limits.h. Avert this #include_next madness. */ #if defined __GNUC__ && !defined _GCC_LIMITS_H_ #define _GCC_LIMITS_H_ #endif
/* System headers include a number of constants from POSIX in <limits.h>. Include it if we're hosted. */ #if __STDC_HOSTED__ && __has_include_next(<limits.h>) #include_next <limits.h> #endif
/* Many system headers try to "help us out" by defining these. No really, we know how big each datatype is. */ #undef SCHAR_MIN #undef SCHAR_MAX #undef UCHAR_MAX #undef SHRT_MIN #undef SHRT_MAX #undef USHRT_MAX #undef INT_MIN #undef INT_MAX #undef UINT_MAX #undef LONG_MIN #undef LONG_MAX #undef ULONG_MAX
/* C99 5.2.4.2.1: Added long long. C++11 18.3.3.2: same contents as the Standard C Library header <limits.h>. */ #if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. It's too bad that we don't have something like #pragma poison that could be used to deprecate a macro - the code should just use LLONG_MAX and friends. */ #if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)
#define INT8_MIN -128 #define INT16_MIN -32768 /* Note: the literal "most negative int" cannot be written in C -- the rules in the standard (section 6.4.4.1 in C99) will give it an unsigned type, so INT32_MIN (and the most negative member of any larger signed type) must be written via a constant expression. */ #define INT32_MIN (-INT32_MAX-1) #define INT64_MIN (-INT64_MAX-1)
/* WCHAR_MIN should be 0 if wchar_t is an unsigned type and (-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately, it turns out that -fshort-wchar changes the signedness of the type. */ #ifndef WCHAR_MIN # if WCHAR_MAX == 0xffff # define WCHAR_MIN 0 # else # define WCHAR_MIN (-WCHAR_MAX-1) # endif #endif