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.

(cherry picked from commit 1912902e96)
This commit is contained in:
Guy Harris 2021-08-11 01:05:52 -07:00
parent 5eec529b4b
commit 83d4b79552

View File

@ -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) \
#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) \
#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) \
#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