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>
diff --git a/include/compiler.h b/include/compiler.h
index b074b47..b836dca 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -311,6 +311,13 @@
# 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