This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: isinf


On Thu, Jul 14, 2005 at 06:27:06PM +0900, Hiroshi Fujishima wrote:
> Andreas Schwab <schwab@suse.de> writes:
> 
> > Why not just use AC_HAVE_FUNCS(isinf)?  IIUC this is part of a configure
> > script, although whether it is autoconf generated is not clear so far.
> 
> Though I don't know the why, rrdtool-1.2.10/configure.ac has the
> following macro.
> 
> dnl HP-UX 11.00 does not have finite but does have isfinite as a macro so we need
> dnl actual code to check if this works
> AC_CHECK_FUNCS(fpclassify, ,
>   [AC_MSG_CHECKING(for fpclassify with <math.h>)
>     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[float f = 0.0; fpclassify(f)]])],[AC_MSG_RESULT(yes)
>       AC_DEFINE(HAVE_FPCLASSIFY)],[AC_MSG_RESULT(no)])])
> AC_CHECK_FUNCS(finite, ,
>   [AC_CHECK_FUNCS(isfinite, ,
>     [AC_MSG_CHECKING(for isfinite with <math.h>)
>     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[float f = 0.0; isfinite(f)]])],[AC_MSG_RESULT(yes)
>       AC_DEFINE(HAVE_ISFINITE)],[AC_MSG_RESULT(no)])])])
> AC_CHECK_FUNCS(isinf, ,
>   [AC_MSG_CHECKING(for isinf with <math.h>)
>     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[float f = 0.0; int x = isinf(f)]])],[AC_MSG_RESULT(yes)
>       AC_DEFINE(HAVE_ISINF)],[AC_MSG_RESULT(no)])])

Guess that's because AC_HAVE_FUNCS(isinf) is wrong.
isinf/isfinite/fpclassify are all documented as macros in ISO C99.
So
   [AC_MSG_CHECKING(for isinf with <math.h>)
     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>
volatile int x; volatile float f;]], [[x = isinf(f)]])],[AC_MSG_RESULT(yes)
       AC_DEFINE(HAVE_ISINF)],[AC_MSG_RESULT(no)])])
should be reasonably safe for now.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]