Having lround() does not mean llround() is available.

We need to check for both lround() and llround() for at
least Cygwin.
This commit is contained in:
Cary R 2009-12-21 16:31:12 -08:00 committed by Stephen Williams
parent b416176c4d
commit a1e2bfc93c
2 changed files with 10 additions and 6 deletions

View File

@ -174,6 +174,7 @@ AC_CHECK_FUNCS(fopen64)
# systems we may need to use the compiler in C99 mode to get a definition.
# We requested C99 mode earlier with AC_PROG_CC_C99.
AC_SEARCH_LIBS([lround], [m], [AC_DEFINE([HAVE_LROUND], [1])])
AC_SEARCH_LIBS([llround], [m], [AC_DEFINE([HAVE_LLROUND], [1])])
AC_SEARCH_LIBS([nan], [m], [AC_DEFINE([HAVE_NAN], [1])])
AC_SEARCH_LIBS([fmin], [m], [AC_DEFINE([HAVE_FMIN], [1])])
AC_SEARCH_LIBS([fmax], [m], [AC_DEFINE([HAVE_FMAX], [1])])

View File

@ -48,6 +48,7 @@
# undef HAVE_READLINE_HISTORY_H
# undef HAVE_INTTYPES_H
# undef HAVE_LROUND
# undef HAVE_LLROUND
# undef HAVE_NAN
# undef UINT64_T_AND_ULONG_SAME
@ -147,8 +148,13 @@ inline long int lround(double x)
else
return (long)ceil(x-0.5);
}
#endif /* HAVE_LROUND */
#if ((SIZEOF_UNSIGNED_LONG < 8) && (SIZEOF_UNSIGNED_LONG_LONG >= 8))
#if !defined(HAVE_LLROUND)
/*
* We also need an equivalent function with a 64-bit return value.
* We also need an equivalent function with a 64-bit return value if
* it is not available.
*/
inline int64_t i64round(double x)
{
@ -157,16 +163,13 @@ inline int64_t i64round(double x)
else
return (int64_t)ceil(x-0.5);
}
#else /* HAVE_LROUND */
#if ((SIZEOF_UNSIGNED_LONG < 8) && (SIZEOF_UNSIGNED_LONG_LONG >= 8))
#else /* HAVE_LLROUND */
# define i64round llround
#endif /* HAVE_LLROUND */
#else
# define i64round lround
#endif
#endif /* HAVE_LROUND */
#if !defined(HAVE_NAN)
# define nan(x) (NAN)
#endif