compiler.h: add is_constant()

Add macro is_constant() to return true if and only if the value is a
compile-time constant.  It may never return true, however.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
H. Peter Anvin 2017-11-29 16:05:05 -08:00
parent e5033dfd1c
commit cb7da7e7f6

View File

@ -311,6 +311,13 @@ size_t strnlen(const char *s, size_t maxlen);
# define pure_func
#endif
/* Determine probabilistically if something is a compile-time constant */
#ifdef HAVE__BUILTIN_CONSTANT_P
# define is_constant(x) __builtin_constant_p(x)
#else
# define is_constant(x) false
#endif
/* Watcom doesn't handle switch statements with 64-bit types, hack around it */
#ifdef __WATCOMC__
# define BOGUS_CASE 0x76543210