From 35258bf1fbf54cd0405755be0bf5a7e422a58fc1 Mon Sep 17 00:00:00 2001 From: axel Date: Tue, 3 Feb 2009 09:20:49 +1000 Subject: [PATCH] Make proper autoconf test for availability of posix nan function instead of fudging with the NAN macro. darcs-hash:20090202232049-ac50b-0176955677ff39fdd05eeefa20dca883863c34e6.gz --- common.c | 2 +- configure.ac | 1 + fallback.c | 9 ++++++++- fallback.h | 5 +++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/common.c b/common.c index 4a21dbb71..193783c63 100644 --- a/common.c +++ b/common.c @@ -1815,7 +1815,7 @@ double timef() if( time_res ) { - return NAN; + return nan(0); } return (double)tv.tv_sec + 0.000001*tv.tv_usec; diff --git a/configure.ac b/configure.ac index cbdac650f..8c54717d4 100644 --- a/configure.ac +++ b/configure.ac @@ -505,6 +505,7 @@ LIBS="" AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] ) AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] ) AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] ) +AC_SEARCH_LIBS( [nan], [m], [AC_DEFINE( [HAVE_NAN], [1], [Define to 1 if you have the nan function])] ) LIBS_SHARED=$LIBS LIBS=$LIBS_COMMON diff --git a/fallback.c b/fallback.c index af719cf51..004e198fe 100644 --- a/fallback.c +++ b/fallback.c @@ -1183,5 +1183,12 @@ long sysconf(int name) return -1; } - #endif + +#ifndef HAVE_NAN +double nan(char *tagp) +{ + return 0.0/0.0; +} +#endif + diff --git a/fallback.h b/fallback.h index 68bbcff44..e4813fb2f 100644 --- a/fallback.h +++ b/fallback.h @@ -469,8 +469,9 @@ long sysconf(int name); #endif -#ifndef NAN -#define NAN (0.0/0.0) +#ifndef HAVE_NAN +double nan(char *tagp); #endif + #endif