Open MPI logo

Hardware Locality Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Hardware Locality Development mailing list

Subject: Re: [hwloc-devel] [hwloc-svn] svn:hwloc r4409
From: Jeffrey Squyres (jsquyres_at_[hidden])
Date: 2012-03-20 10:51:34


Samuel:

What do you think of this patch? It separates out the individual version checking to make the #define logic a little easier to read.

Index: include/hwloc/autogen/config.h.in
===================================================================
--- include/hwloc/autogen/config.h.in (revision 4414)
+++ include/hwloc/autogen/config.h.in (working copy)
@@ -34,11 +34,40 @@
  * well-known easy cases.
  */
 
+/* Some handy constants to make the logic below a little more readable */
+#if defined(__cplusplus) && \
+ (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR >= 4))
+#define GXX_ABOVE_3_4 1
+#else
+#define GXX_ABOVE_3_4 0
+#endif
+
+#if !defined(__cplusplus) && \
+ (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
+#define GCC_ABOVE_2_95 1
+#else
+#define GCC_ABOVE_2_95 0
+#endif
+
+#if !defined(__cplusplus) && \
+ (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
+#define GCC_ABOVE_2_96 1
+#else
+#define GCC_ABOVE_2_96 0
+#endif
+
+#if !defined(__cplusplus) && \
+ (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
+#define GCC_ABOVE_3_3 1
+#else
+#define GCC_ABOVE_3_3 0
+#endif
+
 /* Maybe before gcc 2.95 too */
 #ifdef HWLOC_HAVE_ATTRIBUTE_UNUSED
 #define __HWLOC_HAVE_ATTRIBUTE_UNUSED HWLOC_HAVE_ATTRIBUTE_UNUSED
 #elif defined(__GNUC__)
-# define __HWLOC_HAVE_ATTRIBUTE_UNUSED ((defined(__cplusplus) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR >= 4))) || (!defined(__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))))
+# define __HWLOC_HAVE_ATTRIBUTE_UNUSED (GXX_ABOVE_3_4 || GCC_ABOVE_2_95)
 #else
 # define __HWLOC_HAVE_ATTRIBUTE_UNUSED 0
 #endif
@@ -51,7 +80,7 @@
 #ifdef HWLOC_HAVE_ATTRIBUTE_MALLOC
 #define __HWLOC_HAVE_ATTRIBUTE_MALLOC HWLOC_HAVE_ATTRIBUTE_MALLOC
 #elif defined(__GNUC__)
-# define __HWLOC_HAVE_ATTRIBUTE_MALLOC ((defined(__cplusplus) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR >= 4))) || (!defined(__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))))
+# define __HWLOC_HAVE_ATTRIBUTE_MALLOC (GXX_ABOVE_3_4 || GCC_ABOVE_2_96)
 #else
 # define __HWLOC_HAVE_ATTRIBUTE_MALLOC 0
 #endif
@@ -64,7 +93,7 @@
 #ifdef HWLOC_HAVE_ATTRIBUTE_CONST
 #define __HWLOC_HAVE_ATTRIBUTE_CONST HWLOC_HAVE_ATTRIBUTE_CONST
 #elif defined(__GNUC__)
-# define __HWLOC_HAVE_ATTRIBUTE_CONST ((defined(__cplusplus) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR >= 4))) || (!defined(__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))))
+# define __HWLOC_HAVE_ATTRIBUTE_CONST (GXX_ABOVE_3_4 || GCC_ABOVE_2_95)
 #else
 # define __HWLOC_HAVE_ATTRIBUTE_CONST 0
 #endif
@@ -77,7 +106,7 @@
 #ifdef HWLOC_HAVE_ATTRIBUTE_PURE
 #define __HWLOC_HAVE_ATTRIBUTE_PURE HWLOC_HAVE_ATTRIBUTE_PURE
 #elif defined(__GNUC__)
-# define __HWLOC_HAVE_ATTRIBUTE_PURE ((defined(__cplusplus) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR >= 4))) || (!defined(__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))))
+# define __HWLOC_HAVE_ATTRIBUTE_PURE (GXX_ABOVE_3_4 || GCC_ABOVE_2_96)
 #else
 # define __HWLOC_HAVE_ATTRIBUTE_PURE 0
 #endif
@@ -90,7 +119,7 @@
 #ifdef HWLOC_HAVE_ATTRIBUTE_DEPRECATED
 #define __HWLOC_HAVE_ATTRIBUTE_DEPRECATED HWLOC_HAVE_ATTRIBUTE_DEPRECATED
 #elif defined(__GNUC__)
-# define __HWLOC_HAVE_ATTRIBUTE_DEPRECATED ((defined(__cplusplus) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR >= 4))) || (!defined(__cplusplus) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))))
+# define __HWLOC_HAVE_ATTRIBUTE_DEPRECATED (GXX_ABOVE_3_4 || GCC_ABOVE_3_3)
 #else
 # define __HWLOC_HAVE_ATTRIBUTE_DEPRECATED 0
 #endif

On Mar 17, 2012, at 7:45 PM, sthibaul_at_[hidden] wrote:

> Author: sthibaul
> Date: 2012-03-17 19:45:42 EDT (Sat, 17 Mar 2012)
> New Revision: 4409
> URL: https://svn.open-mpi.org/trac/hwloc/changeset/4409
>
> Log:
> Disable attribute use with g++ < 3.4, these do not understand them.
> Text files modified:
> trunk/include/hwloc/autogen/config.h.in | 10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
>
> Modified: trunk/include/hwloc/autogen/config.h.in
> ==============================================================================
> --- trunk/include/hwloc/autogen/config.h.in (original)
> +++ trunk/include/hwloc/autogen/config.h.in 2012-03-17 19:45:42 EDT (Sat, 17 Mar 2012)
> @@ -38,7 +38,7 @@
> #ifdef HWLOC_HAVE_ATTRIBUTE_UNUSED
> #define __HWLOC_HAVE_ATTRIBUTE_UNUSED HWLOC_HAVE_ATTRIBUTE_UNUSED
> #elif defined(__GNUC__)
> -# define __HWLOC_HAVE_ATTRIBUTE_UNUSED (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
> +# define __HWLOC_HAVE_ATTRIBUTE_UNUSED ((defined(__cplusplus) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR >= 4))) || (!defined(__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))))
> #else
> # define __HWLOC_HAVE_ATTRIBUTE_UNUSED 0
> #endif
> @@ -51,7 +51,7 @@
> #ifdef HWLOC_HAVE_ATTRIBUTE_MALLOC
> #define __HWLOC_HAVE_ATTRIBUTE_MALLOC HWLOC_HAVE_ATTRIBUTE_MALLOC
> #elif defined(__GNUC__)
> -# define __HWLOC_HAVE_ATTRIBUTE_MALLOC (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
> +# define __HWLOC_HAVE_ATTRIBUTE_MALLOC ((defined(__cplusplus) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR >= 4))) || (!defined(__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))))
> #else
> # define __HWLOC_HAVE_ATTRIBUTE_MALLOC 0
> #endif
> @@ -64,7 +64,7 @@
> #ifdef HWLOC_HAVE_ATTRIBUTE_CONST
> #define __HWLOC_HAVE_ATTRIBUTE_CONST HWLOC_HAVE_ATTRIBUTE_CONST
> #elif defined(__GNUC__)
> -# define __HWLOC_HAVE_ATTRIBUTE_CONST (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
> +# define __HWLOC_HAVE_ATTRIBUTE_CONST ((defined(__cplusplus) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR >= 4))) || (!defined(__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))))
> #else
> # define __HWLOC_HAVE_ATTRIBUTE_CONST 0
> #endif
> @@ -77,7 +77,7 @@
> #ifdef HWLOC_HAVE_ATTRIBUTE_PURE
> #define __HWLOC_HAVE_ATTRIBUTE_PURE HWLOC_HAVE_ATTRIBUTE_PURE
> #elif defined(__GNUC__)
> -# define __HWLOC_HAVE_ATTRIBUTE_PURE (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
> +# define __HWLOC_HAVE_ATTRIBUTE_PURE ((defined(__cplusplus) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR >= 4))) || (!defined(__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))))
> #else
> # define __HWLOC_HAVE_ATTRIBUTE_PURE 0
> #endif
> @@ -90,7 +90,7 @@
> #ifdef HWLOC_HAVE_ATTRIBUTE_DEPRECATED
> #define __HWLOC_HAVE_ATTRIBUTE_DEPRECATED HWLOC_HAVE_ATTRIBUTE_DEPRECATED
> #elif defined(__GNUC__)
> -# define __HWLOC_HAVE_ATTRIBUTE_DEPRECATED (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
> +# define __HWLOC_HAVE_ATTRIBUTE_DEPRECATED ((defined(__cplusplus) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR >= 4))) || (!defined(__cplusplus) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))))
> #else
> # define __HWLOC_HAVE_ATTRIBUTE_DEPRECATED 0
> #endif
> _______________________________________________
> hwloc-svn mailing list
> hwloc-svn_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-svn

-- 
Jeff Squyres
jsquyres_at_[hidden]
For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/