From 807a66f0a27be0f13491cf0cf3653945f129bc6f Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 7 Oct 2009 18:58:27 -0700 Subject: [PATCH] Add a configure check to see if uint64_t and unsigned long are identical. This is needed to get vvp to compile under MacOS 10.6 and possibly other 64 bit systems that define uint64_t as unsigned long long vs unsigned long (both are 64 bits). (cherry picked from commit 39f243b18e4b25594835d7e5b63130ed52f78b59) --- configure.in | 25 +++++++++++++++++++++++++ vvp/config.h.in | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) 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