From a1e2bfc93c723d21db57decdc7d1c7e5722e29af Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 21 Dec 2009 16:31:12 -0800 Subject: [PATCH] Having lround() does not mean llround() is available. We need to check for both lround() and llround() for at least Cygwin. --- configure.in | 1 + vvp/config.h.in | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/configure.in b/configure.in index 971f2925c..4497f033c 100644 --- a/configure.in +++ b/configure.in @@ -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])]) diff --git a/vvp/config.h.in b/vvp/config.h.in index 2a6885b41..53b2f7675 100644 --- a/vvp/config.h.in +++ b/vvp/config.h.in @@ -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