Changeset 2304


Ignore:
Timestamp:
Jun 18, 2011 10:42:19 AM (9 years ago)
Author:
stefan
Message:

add COIN_CHECK_ISFINITE and COIN_CHECK_ISNAN (copied from CoinUtils?)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/coin.m4

    r2293 r2304  
    22442244fi
    22452245]) # AC_COIN_CHECK_GNU_READLINE
     2246
     2247###########################################################################
     2248#                            COIN_CHECK_ISFINITE                          #
     2249###########################################################################
     2250
     2251# This macro checks for a usable implementation of a function to check
     2252# whether a given floating point number is finite.
     2253# If a function is found, then the macro defines the symbol
     2254# toupper($1)_C_FINITE to the name of this function.
     2255
     2256AC_DEFUN([AC_COIN_CHECK_ISFINITE],[
     2257
     2258AC_LANG_PUSH(C++)
     2259
     2260AC_COIN_CHECK_CXX_CHEADER(math)
     2261AC_COIN_CHECK_CXX_CHEADER(float)
     2262AC_COIN_CHECK_CXX_CHEADER(ieeefp)
     2263
     2264m4_toupper($1)_C_FINITE=
     2265AC_CHECK_DECL([finite],[m4_toupper($1)_C_FINITE=finite],,[
     2266#ifdef HAVE_CMATH
     2267# include <cmath>
     2268#else
     2269# ifdef HAVE_MATH_H
     2270#  include <math.h>
     2271# endif
     2272#endif
     2273#ifdef HAVE_CFLOAT
     2274# include <cfloat>
     2275#else
     2276# ifdef HAVE_FLOAT_H
     2277#  include <float.h>
     2278# endif
     2279#endif
     2280#ifdef HAVE_CIEEEFP
     2281# include <cieeefp>
     2282#else
     2283# ifdef HAVE_IEEEFP_H
     2284#  include <ieeefp.h>
     2285# endif
     2286#endif])
     2287if test -z "$m4_toupper($1)_C_FINITE"; then
     2288  AC_CHECK_DECL([_finite],[m4_toupper($1)_C_FINITE=_finite],,[
     2289#ifdef HAVE_CMATH
     2290# include <cmath>
     2291#else
     2292# ifdef HAVE_MATH_H
     2293#  include <math.h>
     2294# endif
     2295#endif
     2296#ifdef HAVE_CFLOAT
     2297# include <cfloat>
     2298#else
     2299# ifdef HAVE_FLOAT_H
     2300#  include <float.h>
     2301# endif
     2302#endif
     2303#ifdef HAVE_CIEEEFP
     2304# include <cieeefp>
     2305#else
     2306# ifdef HAVE_IEEEFP_H
     2307#  include <ieeefp.h>
     2308# endif
     2309#endif])
     2310  if test -z "$m4_toupper($1)_C_FINITE"; then
     2311    AC_CHECK_DECL([isfinite],[m4_toupper($1)_C_FINITE=isfinite],,[
     2312#ifdef HAVE_CMATH
     2313# include <cmath>
     2314#else
     2315# ifdef HAVE_MATH_H
     2316#  include <math.h>
     2317# endif
     2318#endif
     2319#ifdef HAVE_CFLOAT
     2320# include <cfloat>
     2321#else
     2322# ifdef HAVE_FLOAT_H
     2323#  include <float.h>
     2324# endif
     2325#endif
     2326#ifdef HAVE_CIEEEFP
     2327# include <cieeefp>
     2328#else
     2329# ifdef HAVE_IEEEFP_H
     2330#  include <ieeefp.h>
     2331# endif
     2332#endif])
     2333  fi
     2334fi
     2335if test -z "$m4_toupper($1)_C_FINITE"; then
     2336  AC_MSG_WARN(Cannot find C-function for checking Inf.)
     2337else
     2338  AC_DEFINE_UNQUOTED(m4_toupper($1)_C_FINITE,[$m4_toupper($1)_C_FINITE],
     2339                     [Define to be the name of C-function for Inf check])
     2340fi
     2341
     2342AC_LANG_POP(C++)
     2343])
     2344
     2345###########################################################################
     2346#                              COIN_CHECK_ISNAN                           #
     2347###########################################################################
     2348
     2349# This macro checks for a usable implementation of a function to check
     2350# whether a given floating point number represents NaN.
     2351# If a function is found, then the macro defines the symbol
     2352# toupper($1)_C_ISNAN to the name of this function.
     2353
     2354AC_DEFUN([AC_COIN_CHECK_ISNAN],[
     2355
     2356AC_LANG_PUSH(C++)
     2357
     2358AC_COIN_CHECK_CXX_CHEADER(math)
     2359AC_COIN_CHECK_CXX_CHEADER(float)
     2360AC_COIN_CHECK_CXX_CHEADER(ieeefp)
     2361
     2362m4_toupper($1)_C_ISNAN=
     2363AC_CHECK_DECL([isnan],[m4_toupper($1)_C_ISNAN=isnan],,[
     2364#ifdef HAVE_CMATH
     2365# include <cmath>
     2366#else
     2367# ifdef HAVE_MATH_H
     2368#  include <math.h>
     2369# endif
     2370#endif
     2371#ifdef HAVE_CFLOAT
     2372# include <cfloat>
     2373#else
     2374# ifdef HAVE_FLOAT_H
     2375#  include <float.h>
     2376# endif
     2377#endif
     2378#ifdef HAVE_CIEEEFP
     2379# include <cieeefp>
     2380#else
     2381# ifdef HAVE_IEEEFP_H
     2382#  include <ieeefp.h>
     2383# endif
     2384#endif])
     2385
     2386# It appears that for some systems (e.g., Mac OSX), cmath will provide only
     2387# std::isnan, and bare isnan will be unavailable. Typically we need a parameter
     2388# in the test to allow C++ to do overload resolution.
     2389
     2390if test -z "$m4_toupper($1)_C_ISNAN"; then
     2391  AC_CHECK_DECL([std::isnan(42.42)],[m4_toupper($1)_C_ISNAN=std::isnan],,[
     2392#ifdef HAVE_CMATH
     2393# include <cmath>
     2394#else
     2395# ifdef HAVE_MATH_H
     2396#  include <math.h>
     2397# endif
     2398#endif
     2399#ifdef HAVE_CFLOAT
     2400# include <cfloat>
     2401#else
     2402# ifdef HAVE_FLOAT_H
     2403#  include <float.h>
     2404# endif
     2405#endif
     2406#ifdef HAVE_CIEEEFP
     2407# include <cieeefp>
     2408#else
     2409# ifdef HAVE_IEEEFP_H
     2410#  include <ieeefp.h>
     2411# endif
     2412#endif])
     2413fi
     2414
     2415if test -z "$m4_toupper($1)_C_ISNAN"; then
     2416  AC_CHECK_DECL([_isnan],[m4_toupper($1)_C_ISNAN=_isnan],,[
     2417#ifdef HAVE_CMATH
     2418# include <cmath>
     2419#else
     2420# ifdef HAVE_MATH_H
     2421#  include <math.h>
     2422# endif
     2423#endif
     2424#ifdef HAVE_CFLOAT
     2425# include <cfloat>
     2426#else
     2427# ifdef HAVE_FLOAT_H
     2428#  include <float.h>
     2429# endif
     2430#endif
     2431#ifdef HAVE_CIEEEFP
     2432# include <cieeefp>
     2433#else
     2434# ifdef HAVE_IEEEFP_H
     2435#  include <ieeefp.h>
     2436# endif
     2437#endif])
     2438fi
     2439if test -z "$m4_toupper($1)_C_ISNAN"; then
     2440  AC_CHECK_DECL([isnand],[m4_toupper($1)_C_ISNAN=isnand],,[
     2441#ifdef HAVE_CMATH
     2442# include <cmath>
     2443#else
     2444# ifdef HAVE_MATH_H
     2445#  include <math.h>
     2446# endif
     2447#endif
     2448#ifdef HAVE_CFLOAT
     2449# include <cfloat>
     2450#else
     2451# ifdef HAVE_FLOAT_H
     2452#  include <float.h>
     2453# endif
     2454#endif
     2455#ifdef HAVE_CIEEEFP
     2456# include <cieeefp>
     2457#else
     2458# ifdef HAVE_IEEEFP_H
     2459#  include <ieeefp.h>
     2460# endif
     2461#endif])
     2462fi
     2463if test -z "$m4_toupper($1)_C_ISNAN"; then
     2464  AC_MSG_WARN(Cannot find C-function for checking NaN.)
     2465else
     2466  AC_DEFINE_UNQUOTED(m4_toupper($1)_C_ISNAN,[$m4_toupper($1)_C_ISNAN],
     2467                     [Define to be the name of C-function for NaN check])
     2468fi
     2469
     2470AC_LANG_POP(C++)
     2471])
    22462472
    22472473###########################################################################
Note: See TracChangeset for help on using the changeset viewer.