diff --git a/configure.in b/configure.in index 04c70c207..5def57326 100644 --- a/configure.in +++ b/configure.in @@ -11,6 +11,12 @@ AC_CONFIG_HEADER(tgt-vhdl/vhdl_config.h) AC_CANONICAL_HOST dnl Checks for programs. AC_PROG_CC +# AC_PROG_CC_C99 is only available in autoconf version 2.60 and later. +# If you must use an older version then comment out the following two +# lines, but be warned that there could be issues with finding the +# nan(), etc. functions. It is really best to upgrade to a supported +# version of autoconf. +AC_PREREQ([2.60]) AC_PROG_CC_C99 AC_PROG_CXX AC_PROG_RANLIB @@ -167,6 +173,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/ivlpp/main.c b/ivlpp/main.c index 1b3906c55..9c360fad9 100644 --- a/ivlpp/main.c +++ b/ivlpp/main.c @@ -370,7 +370,7 @@ int main(int argc, char*argv[]) } } - if(dep_path) { + if (dep_path) { depend_file = fopen(dep_path, "a"); if (depend_file == 0) { perror(dep_path); @@ -389,8 +389,8 @@ int main(int argc, char*argv[]) if (yylex()) return -1; destroy_lexor(); - if(depend_file) { - fclose(depend_file); + if (depend_file) { + fclose(depend_file); } if (precomp_out) { @@ -398,6 +398,10 @@ int main(int argc, char*argv[]) fclose(precomp_out); } + if (out_path) { + fclose(out); + } + /* Free the source and include directory lists. */ for (lp = 0; lp < source_cnt; lp += 1) { free(source_list[lp]); 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