Re: [hwloc-devel] Attribute unsed not regognized

2010-03-26 Thread Samuel Thibault
Bert Wesarg, le Fri 26 Mar 2010 19:39:51 +0100, a écrit :
> On Fri, Mar 26, 2010 at 17:01, Samuel Thibault  
> wrote:
> > Thanks for the idea.
> >
> > Bert Wesarg, le Fri 26 Mar 2010 12:33:00 +0100, a écrit :
> >> +#define HWLOC_HAVE(what) (defined(HWLOC_HAVE_##what) && HWLOC_HAVE_##what)
> >
> > Unfortunately some compilers (such as gcc 2.95) do not accept this
> 
> What topology information do you get on machines that have this old
> compiler installed?

It's not only a question of *that* compiler, but that this kind of
tinkering with macros is quite borderline. I actually do wonder whether
it is C99 compliant. gcc happens to be able to parse it since at least
3.0, but since 2.95 doesn't, I guess there are some other compilers that
won't be able to either.

> For example sysfs attributes are very unlikely.
> the linux kernel should require at least gcc 3. But I haven't checked
> since when.

hwloc is not only about Linux ;)

Samuel


Re: [hwloc-devel] Attribute unsed not regognized

2010-03-26 Thread Samuel Thibault
Bert Wesarg, le Fri 26 Mar 2010 12:43:33 +0100, a écrit :
> FYI: I don't know if this is hwloc or autotools specific, but there is
> no build dependency on
> include/hwloc/config.h.in.

It'd tend to say that it is autotools-specific. For instance, we do not
put anything special for utils/test-hwloc-distrib.sh to be re-generated,
and automake automatically generates a dependency, but it doesn't for
hwloc/config.h.

Samuel


Re: [hwloc-devel] Attribute unsed not regognized

2010-03-26 Thread Samuel Thibault
Samuel Thibault, le Fri 26 Mar 2010 15:49:36 +0100, a écrit :
> All these don't have any problem with the above.

I mean, with putting the attributes after the variable name.

Samuel


Re: [hwloc-devel] Attribute unsed not regognized

2010-03-26 Thread Samuel Thibault
Bert Wesarg, le Fri 26 Mar 2010 11:09:05 +0100, a écrit :
> AFAIK the correct usage would be:
> 
>  int square(int __attribute__ ((__unused__)) arg1, int arg2) {
> return arg2; }
> 
> I.e. the attribute is between type and name.

Do you have a reference on this?  For variables, the gcc manual always
puts them after the name, and in the source code of gcc itself I see it
there almost all the time... Also, there is an issue with e.g.

void f(void * __attribute__((unused)) p) {
}

The following

void f(void __attribute__((unused)) * p) {
}

does pass, but looks odd to me: it's not the data pointed by p that we
want to qualify as unused... Which ones of the above pass with your gcc?

> Configured with: ../src/configure -v --with-pkgversion='Ubuntu
> 4.4.1-4ubuntu9'

€ gcc --version
gcc (Debian 4.4.2-9) 4.4.3 20100108 (prerelease)
€ gcc --version
gcc (Debian 4.3.4-5) 4.3.4
€ gcc-4.5 --version
gcc-4.5 (Debian 4.5-20100202-1) 4.5.0 20100202 (experimental) [trunk revision 
156452]
$ gcc --version
gcc (GCC) 3.4.6 (on solaris)
$ gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
$ gcc --version
gcc (GCC) 4.0.2 (on AIX)

All these don't have any problem with the above.  This really looks
to me like a bug introduced by Ubuntu, probably along their agressive
fortifying policies.

Samuel


Re: [hwloc-devel] Attribute unsed not regognized

2010-03-26 Thread Bert Wesarg
On Fri, Mar 26, 2010 at 11:57, Brice Goglin  wrote:
> Bert Wesarg wrote:
>> There is also a problem, that these __hwloc_attributes defines don't
>> get through after install:
>>
>
> Are you using the embedding stuff ? Or only including our headers ?
>
> There's no guarantee that your external application will use the same
> compiler, so unless the embedding stuff re-runs the checks when
> configuring your external applications, there's no easy solution.

Thats true, sadly. I don't use it in the embedded mode. Maybe provide
fallbacks for known gcc compilers. Like this PoC patch:

Index: include/hwloc/config.h.in
===
--- include/hwloc/config.h.in   (revision 1847)
+++ include/hwloc/config.h.in   (working copy)
@@ -19,52 +19,34 @@
 # endif
 #endif

-#ifdef HWLOC_HAVE_ATTRIBUTE_UNUSED
-# if HWLOC_HAVE_ATTRIBUTE_UNUSED
-#  define __hwloc_attribute_unused __attribute__((__unused__))
-# else
-#  define __hwloc_attribute_unused
-# endif
+#define HWLOC_HAVE(what) (defined(HWLOC_HAVE_##what) && HWLOC_HAVE_##what)
+
+#if HWLOC_HAVE(ATTRIBUTE_UNUSED) || defined(__GNUC__)
+# define __hwloc_attribute_unused __attribute__((__unused__))
 #else
 # define __hwloc_attribute_unused
 #endif

-#ifdef HWLOC_HAVE_ATTRIBUTE_MALLOC
-# if HWLOC_HAVE_ATTRIBUTE_MALLOC
-#  define __hwloc_attribute_malloc __attribute__((__malloc__))
-# else
-#  define __hwloc_attribute_malloc
-# endif
+#if HWLOC_HAVE(ATTRIBUTE_MALLOC)
+# define __hwloc_attribute_malloc __attribute__((__malloc__))
 #else
 # define __hwloc_attribute_malloc
 #endif

-#ifdef HWLOC_HAVE_ATTRIBUTE_CONST
-# if HWLOC_HAVE_ATTRIBUTE_CONST
-#  define __hwloc_attribute_const __attribute__((__const__))
-# else
-#  define __hwloc_attribute_const
-# endif
+#if HWLOC_HAVE(ATTRIBUTE_CONST) || defined(__GNUC__)
+# define __hwloc_attribute_const __attribute__((__const__))
 #else
 # define __hwloc_attribute_const
 #endif

-#ifdef HWLOC_HAVE_ATTRIBUTE_PURE
-# if HWLOC_HAVE_ATTRIBUTE_PURE
-#  define __hwloc_attribute_pure __attribute__((__pure__))
-# else
-#  define __hwloc_attribute_pure
-# endif
+#if HWLOC_HAVE(ATTRIBUTE_PURE) || defined(__GNUC__)
+# define __hwloc_attribute_pure __attribute__((__pure__))
 #else
 # define __hwloc_attribute_pure
 #endif

-#ifdef HWLOC_HAVE_ATTRIBUTE_DEPRECATED
-# if HWLOC_HAVE_ATTRIBUTE_DEPRECATED
-#  define __hwloc_attribute_deprecated __attribute__((__deprecated__))
-# else
-#  define __hwloc_attribute_deprecated
-# endif
+#if HWLOC_HAVE(ATTRIBUTE_DEPRECATED) || defined(__GNUC__)
+# define __hwloc_attribute_deprecated __attribute__((__deprecated__))
 #else
 # define __hwloc_attribute_deprecated
 #endif

Regards,
Bert

>
> Brice
>
> ___
> hwloc-devel mailing list
> hwloc-de...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-devel
>


Re: [hwloc-devel] Attribute unsed not regognized

2010-03-26 Thread Bert Wesarg
There is also a problem, that these __hwloc_attributes defines don't
get through after install:

$ gcc -DHAVE_CONFIG_H -I.
-DSYSCONFDIR=\"/home/wesarg/opt/htop-dev/etc\"
-I/home/wesarg/opt/hwloc-dev/include   -W -Wunused-parameter -Wall
-std=gnu99 -D_XOPEN_SOURCE_EXTENDED -g -O2 -MT htop-AffinityPanel.o
-MD -MP -MF .deps/htop-AffinityPanel.Tpo -c -o htop-AffinityPanel.o
`test -f 'AffinityPanel.c' || echo './'`AffinityPanel.c
In file included from /home/wesarg/opt/hwloc-dev/include/hwloc.h:856,
 from Process.h:35,
 from ProcessList.h:17,
 from AffinityPanel.h:9,
 from AffinityPanel.c:1:
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h: In function
‘hwloc_get_ancestor_obj_by_depth’:
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h:95: warning: unused
parameter ‘topology’
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h: In function
‘hwloc_get_ancestor_obj_by_type’:
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h:107: warning: unused
parameter ‘topology’
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h: In function
‘hwloc_get_next_child’:
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h:168: warning: unused
parameter ‘topology’
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h: In function
‘hwloc_get_common_ancestor_obj’:
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h:179: warning: unused
parameter ‘topology’
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h: In function
‘hwloc_obj_is_in_subtree’:
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h:195: warning: unused
parameter ‘topology’
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h: In function
‘hwloc_get_child_covering_cpuset’:
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h:356: warning: unused
parameter ‘topology’
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h: In function
‘hwloc_get_shared_cache_covering_obj’:
/home/wesarg/opt/hwloc-dev/include/hwloc/helper.h:472: warning: unused
parameter ‘topology’

I have attached the -E output for this AffinityPanel.c file.

Regards,
Bert
# 1 "AffinityPanel.c"
# 1 "/home/wesarg/dev/htop/htop//"
# 1 ""
#define __STDC__ 1
#define __STDC_VERSION__ 199901L
#define __STDC_HOSTED__ 1
#define __GNUC__ 4
#define __GNUC_MINOR__ 4
#define __GNUC_PATCHLEVEL__ 1
#define __SIZE_TYPE__ long unsigned int
#define __PTRDIFF_TYPE__ long int
#define __WCHAR_TYPE__ int
#define __WINT_TYPE__ unsigned int
#define __INTMAX_TYPE__ long int
#define __UINTMAX_TYPE__ long unsigned int
#define __CHAR16_TYPE__ short unsigned int
#define __CHAR32_TYPE__ unsigned int
#define __GXX_ABI_VERSION 1002
#define __SCHAR_MAX__ 127
#define __SHRT_MAX__ 32767
#define __INT_MAX__ 2147483647
#define __LONG_MAX__ 9223372036854775807L
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define __WCHAR_MAX__ 2147483647
#define __CHAR_BIT__ 8
#define __INTMAX_MAX__ 9223372036854775807L
#define __FLT_EVAL_METHOD__ 0
#define __DEC_EVAL_METHOD__ 2
#define __FLT_RADIX__ 2
#define __FLT_MANT_DIG__ 24
#define __FLT_DIG__ 6
#define __FLT_MIN_EXP__ (-125)
#define __FLT_MIN_10_EXP__ (-37)
#define __FLT_MAX_EXP__ 128
#define __FLT_MAX_10_EXP__ 38
#define __FLT_MAX__ 3.40282347e+38F
#define __FLT_MIN__ 1.17549435e-38F
#define __FLT_EPSILON__ 1.19209290e-7F
#define __FLT_DENORM_MIN__ 1.40129846e-45F
#define __FLT_HAS_DENORM__ 1
#define __FLT_HAS_INFINITY__ 1
#define __FLT_HAS_QUIET_NAN__ 1
#define __DBL_MANT_DIG__ 53
#define __DBL_DIG__ 15
#define __DBL_MIN_EXP__ (-1021)
#define __DBL_MIN_10_EXP__ (-307)
#define __DBL_MAX_EXP__ 1024
#define __DBL_MAX_10_EXP__ 308
#define __DBL_MAX__ 1.7976931348623157e+308
#define __DBL_MIN__ 2.2250738585072014e-308
#define __DBL_EPSILON__ 2.2204460492503131e-16
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __DBL_HAS_DENORM__ 1
#define __DBL_HAS_INFINITY__ 1
#define __DBL_HAS_QUIET_NAN__ 1
#define __LDBL_MANT_DIG__ 64
#define __LDBL_DIG__ 18
#define __LDBL_MIN_EXP__ (-16381)
#define __LDBL_MIN_10_EXP__ (-4931)
#define __LDBL_MAX_EXP__ 16384
#define __LDBL_MAX_10_EXP__ 4932
#define __DECIMAL_DIG__ 21
#define __LDBL_MAX__ 1.18973149535723176502e+4932L
#define __LDBL_MIN__ 3.36210314311209350626e-4932L
#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
#define __LDBL_HAS_DENORM__ 1
#define __LDBL_HAS_INFINITY__ 1
#define __LDBL_HAS_QUIET_NAN__ 1
#define __DEC32_MANT_DIG__ 7
#define __DEC32_MIN_EXP__ (-94)
#define __DEC32_MAX_EXP__ 97
#define __DEC32_MIN__ 1E-95DF
#define __DEC32_MAX__ 9.99E96DF
#define __DEC32_EPSILON__ 1E-6DF
#define __DEC32_SUBNORMAL_MIN__ 0.01E-95DF
#define __DEC64_MANT_DIG__ 16
#define __DEC64_MIN_EXP__ (-382)
#define __DEC64_MAX_EXP__ 385
#define __DEC64_MIN__ 1E-383DD
#define __DEC64_MAX__ 9.999E384DD
#define __DEC64_EPSILON__ 1E-15DD
#define __DEC64_SUBNORMAL_MIN__ 0.001E-383DD
#define __DEC128_MANT_DIG__ 34
#define __DEC128_MIN_EXP__ (-6142)
#define __DEC128_MAX_EXP__ 6145
#define __DEC128_MIN__ 1E-6143DL
#define __DEC128_MAX__