diff --git a/ChangeLog b/ChangeLog index ee1c031..d70d354 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-02-09 Alexei Sheplyakov + Richard B. Kreckel + + Avoid compiler warning about ignored 'flatten' attribute directive: + * m4/cc.m4 (CL_ATTRIBUTE_FLATTEN): New macro... + * configure.ac: ...used here... + * include/cln/config.h.in: ...defining CL_HAVE_ATTRIBUTE_FLATTEN,... + * src/base/cl_maybe_inline.h: ...used to prevent a warning here. + 2007-02-07 Richard B. Kreckel * include/cln/integer.h: Enable modifying operators by default. diff --git a/configure.ac b/configure.ac index 2c90a92..e5e06de 100644 --- a/configure.ac +++ b/configure.ac @@ -147,6 +147,8 @@ CL_RUSAGE dnl DEFS HAVE_SYS_RESOURCE_H, HAVE_GETRUSAGE, HAVE_SYS_TIMES_H CL_PERROR dnl DEFS HAVE_PERROR_DECL +CL_ATTRIBUTE_FLATTEN + dnl DEFS CL_HAVE_ATTRIBUTE_FLATTEN dnl dnl checks for compiler characteristics dnl diff --git a/include/cln/config.h.in b/include/cln/config.h.in index ec00f5e..b1b1ebd 100644 --- a/include/cln/config.h.in +++ b/include/cln/config.h.in @@ -148,6 +148,10 @@ #ifndef CL_GLOBAL_CONSTRUCTOR_SUFFIX_NOPIC #undef CL_GLOBAL_CONSTRUCTOR_SUFFIX_NOPIC #endif +/* Define if the compiler knows about __attribute__((flatten)). */ +#ifndef CL_HAVE_ATTRIBUTE_FLATTEN +#undef CL_HAVE_ATTRIBUTE_FLATTEN +#endif /* CL_CHAR_UNSIGNED */ #ifndef __CHAR_UNSIGNED__ diff --git a/m4/cc.m4 b/m4/cc.m4 index ec6c5e8..0925662 100644 --- a/m4/cc.m4 +++ b/m4/cc.m4 @@ -67,3 +67,24 @@ EOF fi AC_SUBST(ASMFLAGS) ]) + + +dnl Checks whether the compiler supports __attribute__((flatten)). +AC_DEFUN([CL_ATTRIBUTE_FLATTEN],[ +AC_REQUIRE([AC_PROG_CXX]) +AC_CACHE_CHECK([whether the compiler supports __attribute__((flatten))], cl_cv_have_attr_flatten, [dnl + cat > conftest.cc </dev/null 2>conftest.out) +if grep -i "warning" conftest.out > /dev/null; then + cl_cv_have_attr_flatten=no +else + cl_cv_have_attr_flatten=yes +fi +rm -f conftest* +]) +if test $cl_cv_have_attr_flatten = yes; then + AC_DEFINE(CL_HAVE_ATTRIBUTE_FLATTEN) +fi +]) diff --git a/src/base/cl_maybe_inline.h b/src/base/cl_maybe_inline.h index 316cc5b..4f7a982 100644 --- a/src/base/cl_maybe_inline.h +++ b/src/base/cl_maybe_inline.h @@ -3,6 +3,8 @@ #ifndef _CL_MAYBE_INLINE_H #define _CL_MAYBE_INLINE_H +#include "cln/config.h" + /* * Selectively inline a function in *some* translation units. * @@ -100,7 +102,7 @@ * a function. * 2. It's ignored if the optimization is switched off. */ -#ifdef __GNUC__ +#if defined(__GNUC__) && defined(CL_ATTRIBUTE_FLATTEN) #define CL_FLATTEN __attribute__((flatten)) #else #define CL_FLATTEN