From 09f84e7e5fbacd3f7f8f381b74a483795d8daffd Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Mon, 2 Aug 2021 23:40:01 +0100 Subject: Port XL C updates into compiler-tests.h. [skip appveyor] Since CI is using XL C 16.1, it is better to keep the macro in shape. --- pcap/compiler-tests.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pcap/compiler-tests.h') diff --git a/pcap/compiler-tests.h b/pcap/compiler-tests.h index a69c2b09..1ee06eac 100644 --- a/pcap/compiler-tests.h +++ b/pcap/compiler-tests.h @@ -133,11 +133,20 @@ * * The version number in __xlC__ has the major version in the * upper 8 bits and the minor version in the lower 8 bits. + * On AIX __xlC__ is always defined, __ibmxl__ becomes defined in XL C 16.1. + * On Linux since XL C 13.1.6 __xlC__ is not defined by default anymore, but + * __ibmxl__ is defined since at least XL C 13.1.1. */ #if ! defined(__xlC__) +#if ! defined(__ibmxl__) #define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0 #else +#define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ + (__ibmxl_version__ > (major) || \ + (__ibmxl_version__ == (major) && __ibmxl_release__ >= (minor))) +#endif /* ! __ibmxl__ */ +#else /* ! __xlC__ */ #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ (__xlC__ >= (((major) << 8) | (minor))) #endif -- cgit v1.2.3 From 01f4fd5e82f5956d9a237e28740c29108ce766ff Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 10 Aug 2021 19:36:45 -0700 Subject: Add comments and indentation to make the tests easier to read. This is especially useful for XL C, where the tests aren't a simple single "XL vs. not XL C" test. --- pcap/compiler-tests.h | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'pcap/compiler-tests.h') diff --git a/pcap/compiler-tests.h b/pcap/compiler-tests.h index 1ee06eac..0857eaed 100644 --- a/pcap/compiler-tests.h +++ b/pcap/compiler-tests.h @@ -80,9 +80,11 @@ */ #if ! defined(__GNUC__) -#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) 0 + /* Not GCC and not "just like GCC" */ + #define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) 0 #else -#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \ + /* GCC or "just like GCC" */ + #define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \ (__GNUC__ > (major) || \ (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) #endif @@ -92,9 +94,11 @@ */ #if !defined(__clang__) -#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) 0 + /* Not Clang */ + #define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) 0 #else -#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) \ + /* Clang */ + #define PCAP_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 PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) 0 + /* Not Sun/Oracle C */ + #define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) 0 #else -#define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \ + /* Sun/Oracle C */ + #define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \ (((minor) >= 10) ? \ (((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \ (((major) << 8) | ((minor) << 4))) -#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) \ + #define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) \ (__SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD((major), (minor))) #endif @@ -139,15 +145,26 @@ */ #if ! defined(__xlC__) -#if ! defined(__ibmxl__) -#define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0 -#else -#define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ + /* + * Either not XL C at all or 3.1.6 or later on Linux. + */ + #if ! defined(__ibmxl__) + /* Not XL C */ + #define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0 + #else + /* + * Later Linux version of XL C; use __ibmxl_version__ to test + * the version. + */ + #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ (__ibmxl_version__ > (major) || \ (__ibmxl_version__ == (major) && __ibmxl_release__ >= (minor))) -#endif /* ! __ibmxl__ */ + #endif /* ! __ibmxl__ */ #else /* ! __xlC__ */ -#define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ + /* + * XL C with __xlC__ defined; use that to test the version. + */ + #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ (__xlC__ >= (((major) << 8) | (minor))) #endif @@ -163,9 +180,11 @@ */ #if ! defined(__HP_aCC) -#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) 0 + /* Not HP C */ + #define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) 0 #else -#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) \ + /* HP C */ + #define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) \ (__HP_aCC >= ((major)*10000 + (minor)*100)) #endif -- cgit v1.2.3 From 0ccc80aba83744762181205d5c9b1ff73a7abc2c Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 10 Aug 2021 20:02:27 -0700 Subject: Handle XL C a bit more like the other compilers. The first test is "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. That makes it a bit easier to read. --- pcap/compiler-tests.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'pcap/compiler-tests.h') diff --git a/pcap/compiler-tests.h b/pcap/compiler-tests.h index 0857eaed..91f92711 100644 --- a/pcap/compiler-tests.h +++ b/pcap/compiler-tests.h @@ -144,14 +144,12 @@ * __ibmxl__ is defined since at least XL C 13.1.1. */ -#if ! defined(__xlC__) - /* - * Either not XL C at all or 3.1.6 or later on Linux. - */ - #if ! defined(__ibmxl__) - /* Not XL C */ - #define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0 - #else +#if ! defined(__xlC__) && ! defined(__ibmxl__) + /* Not XL C */ + #define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0 +#else + /* XL C */ + #if defined(__ibmxl__) /* * Later Linux version of XL C; use __ibmxl_version__ to test * the version. @@ -159,13 +157,13 @@ #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ (__ibmxl_version__ > (major) || \ (__ibmxl_version__ == (major) && __ibmxl_release__ >= (minor))) - #endif /* ! __ibmxl__ */ -#else /* ! __xlC__ */ - /* - * XL C with __xlC__ defined; use that to test the version. - */ - #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ + #else /* __ibmxl__ */ + /* + * __ibmxl__ not defined; use __xlC__ to test the version. + */ + #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ (__xlC__ >= (((major) << 8) | (minor))) + #endif /* ! __ibmxl__ */ #endif /* -- cgit v1.2.3 From cb1e879664b393dc92e390eea2ce80f84a2e59d7 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 11 Aug 2021 01:06:34 -0700 Subject: Correct a comment. [skip ci] --- pcap/compiler-tests.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pcap/compiler-tests.h') diff --git a/pcap/compiler-tests.h b/pcap/compiler-tests.h index 91f92711..2d98a707 100644 --- a/pcap/compiler-tests.h +++ b/pcap/compiler-tests.h @@ -163,7 +163,7 @@ */ #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ (__xlC__ >= (((major) << 8) | (minor))) - #endif /* ! __ibmxl__ */ + #endif /* __ibmxl__ */ #endif /* -- cgit v1.2.3