summaryrefslogtreecommitdiff
path: root/compiler-tests.h
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2021-08-11 01:05:52 -0700
committerGuy Harris <gharris@sonic.net>2021-08-11 01:05:52 -0700
commit1912902e96bcb1729d58225541c5e5b75345886a (patch)
tree9c565ad9703311e6d3bb63c020a45ccfdb5709c1 /compiler-tests.h
parentf139f17ba91ac60b36a0db424db01fbedf23a798 (diff)
downloadtcpdump-1912902e96bcb1729d58225541c5e5b75345886a.tar.gz
Make the tests a bit easier to read.
Add comments and indentation. Handle XL C a bit more like the other compilers. Make the first test be "is this someting that's not XL C", as is the case for other compilers; that test is done as "are both __xlC__ and __ibmxl__ undefined". If either of them are defined, use __ibmxl_version__ if __ibmxl__ is defined, and use __xlC__ otherwise.
Diffstat (limited to 'compiler-tests.h')
-rw-r--r--compiler-tests.h63
1 files changed, 40 insertions, 23 deletions
diff --git a/compiler-tests.h b/compiler-tests.h
index 78fca01e..d4fe177b 100644
--- a/compiler-tests.h
+++ b/compiler-tests.h
@@ -80,9 +80,11 @@
*/
#if ! defined(__GNUC__)
-#define ND_IS_AT_LEAST_GNUC_VERSION(major, minor) 0
+ /* Not GCC and not "just like GCC" */
+ #define ND_IS_AT_LEAST_GNUC_VERSION(major, minor) 0
#else
-#define ND_IS_AT_LEAST_GNUC_VERSION(major, minor) \
+ /* GCC or "just like GCC" */
+ #define ND_IS_AT_LEAST_GNUC_VERSION(major, minor) \
(__GNUC__ > (major) || \
(__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
#endif
@@ -92,9 +94,11 @@
*/
#if !defined(__clang__)
-#define ND_IS_AT_LEAST_CLANG_VERSION(major, minor) 0
+ /* Not Clang */
+ #define ND_IS_AT_LEAST_CLANG_VERSION(major, minor) 0
#else
-#define ND_IS_AT_LEAST_CLANG_VERSION(major, minor) \
+ /* Clang */
+ #define ND_IS_AT_LEAST_CLANG_VERSION(major, minor) \
(__clang_major__ > (major) || \
(__clang_major__ == (major) && __clang_minor__ >= (minor)))
#endif
@@ -118,13 +122,15 @@
*/
#if ! defined(__SUNPRO_C)
-#define ND_IS_AT_LEAST_SUNC_VERSION(major,minor) 0
+ /* Not Sun/Oracle C */
+ #define ND_IS_AT_LEAST_SUNC_VERSION(major,minor) 0
#else
-#define ND_SUNPRO_VERSION_TO_BCD(major, minor) \
+ /* Sun/Oracle C */
+ #define ND_SUNPRO_VERSION_TO_BCD(major, minor) \
(((minor) >= 10) ? \
(((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \
(((major) << 8) | ((minor) << 4)))
-#define ND_IS_AT_LEAST_SUNC_VERSION(major,minor) \
+ #define ND_IS_AT_LEAST_SUNC_VERSION(major,minor) \
(__SUNPRO_C >= ND_SUNPRO_VERSION_TO_BCD((major), (minor)))
#endif
@@ -138,24 +144,33 @@
* __ibmxl__ is defined since at least XL C 13.1.1.
*/
-#if ! defined(__xlC__)
-#if ! defined(__ibmxl__)
-#define ND_IS_AT_LEAST_XL_C_VERSION(major,minor) 0
-#define ND_IS_AT_LEAST_XL_C_MODFIX(modification, fixlevel) 0
+#if ! defined(__xlC__) && ! defined(__ibmxl__)
+ /* Not XL C */
+ #define ND_IS_AT_LEAST_XL_C_VERSION(major,minor) 0
+ #define ND_IS_AT_LEAST_XL_C_MODFIX(modification, fixlevel) 0
#else
-#define ND_IS_AT_LEAST_XL_C_VERSION(major, minor) \
+ /* XL C */
+ #if defined(__ibmxl__)
+ /*
+ * Later Linux version of XL C; use __ibmxl_version__ to test
+ * the version.
+ */
+ #define ND_IS_AT_LEAST_XL_C_VERSION(major, minor) \
(__ibmxl_version__ > (major) || \
(__ibmxl_version__ == (major) && __ibmxl_release__ >= (minor)))
-#define ND_IS_AT_LEAST_XL_C_MODFIX(modification, fixlevel) \
- (__ibmxl_modification__ > (modification) || \
- (__ibmxl_modification__ == (modification) && \
- __ibmxl_ptf_fix_level__ >= (fixlevel)))
-#endif /* ! __ibmxl__ */
-#else /* ! __xlC__ */
-#define ND_IS_AT_LEAST_XL_C_VERSION(major, minor) \
+ #define ND_IS_AT_LEAST_XL_C_MODFIX(modification, fixlevel) \
+ (__ibmxl_modification__ > (modification) || \
+ (__ibmxl_modification__ == (modification) && \
+ __ibmxl_ptf_fix_level__ >= (fixlevel)))
+ #else /* __ibmxl__ */
+ /*
+ * __ibmxl__ not defined; use __xlC__ to test the version.
+ */
+ #define ND_IS_AT_LEAST_XL_C_VERSION(major, minor) \
(__xlC__ >= (((major) << 8) | (minor)))
-#define ND_IS_AT_LEAST_XL_C_MODFIX(modification, fixlevel) \
- ((((modification) << 8) | (fixlevel)) >= __xlC_ver__)
+ #define ND_IS_AT_LEAST_XL_C_MODFIX(modification, fixlevel) \
+ ((((modification) << 8) | (fixlevel)) >= __xlC_ver__)
+ #endif /* __ibmxl__ */
#endif
/*
@@ -170,9 +185,11 @@
*/
#if ! defined(__HP_aCC)
-#define ND_IS_AT_LEAST_HP_C_VERSION(major,minor) 0
+ /* Not HP C */
+ #define ND_IS_AT_LEAST_HP_C_VERSION(major,minor) 0
#else
-#define ND_IS_AT_LEAST_HP_C_VERSION(major,minor) \
+ /* HP C */
+ #define ND_IS_AT_LEAST_HP_C_VERSION(major,minor) \
(__HP_aCC >= ((major)*10000 + (minor)*100))
#endif