diff --git a/configure.in b/configure.in index 04c70c207..4d14fcac3 100644 --- a/configure.in +++ b/configure.in @@ -167,6 +167,31 @@ 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])]) +# Check to see if an unsigned long and uint64_t are the same from +# a compiler perspective. We can not just check that they are the +# same size since unsigned long and unsigned long long are not the +# same from an overloading perspective even though they could be +# the same size on some 64 bit machines. The result from this test +# is only used if inttypes.h is available, so if the test fails for +# that reason we don't care. +AC_LANG(C++) +AC_MSG_CHECKING(if uint64_t and unsigned long are identical) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "inttypes.h" +static bool check(unsigned long val) +{ + return val != 0; +} +static bool check(uint64_t val) +{ + return val != 0; +}]], [[unsigned long ulval = 1; +bool result = check(ulval); +uint64_t uival = 1; +result &= check(uival); +return !result;]])], + [AC_MSG_RESULT(no)], + [AC_DEFINE([UINT64_T_AND_ULONG_SAME], [1]) AC_MSG_RESULT(yes)]) + # Linker option used when compiling the target AX_LD_RDYNAMIC diff --git a/vvp/config.h.in b/vvp/config.h.in index 71691a402..50b4c5450 100644 --- a/vvp/config.h.in +++ b/vvp/config.h.in @@ -49,6 +49,7 @@ # undef HAVE_INTTYPES_H # undef HAVE_LROUND # undef HAVE_NAN +# undef UINT64_T_AND_ULONG_SAME /* * Define this if you want to compile vvp with memory freeing and @@ -89,7 +90,7 @@ typedef uint64_t vvp_time64_t; # define TIME_FMT_U PRIu64 # define TIME_FMT_X PRIx64 -# if SIZEOF_UNSIGNED_LONG == 8 +# if UINT64_T_AND_ULONG_SAME # define UL_AND_TIME64_SAME # endif