From db8e8392faa7ad9029ff9bcb325cb34d2519d8c6 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 14 Oct 2017 09:00:39 -0400 Subject: [PATCH] Fix MacOS portability, bug1230. --- Changes | 2 ++ configure.ac | 3 +++ src/V3File.cpp | 2 +- src/config_build.h.in | 7 ++++++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 90f8a11dc..15d26d075 100644 --- a/Changes +++ b/Changes @@ -37,6 +37,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix float-conversion warning, bug1229. [Robert Henry] +**** Fix MacOS portability, bug1230. [Jeff Bush] + * Verilator 3.912 2017-09-23 diff --git a/configure.ac b/configure.ac index 3fd566ec6..c95c5524b 100644 --- a/configure.ac +++ b/configure.ac @@ -222,6 +222,9 @@ _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_NO_UNUSED,-Wno-shadow) AC_SUBST(CFG_CXXFLAGS_NO_UNUSED) # Checks for library functions. +AC_CHECK_MEMBER([struct stat.st_mtim.tv_nsec], + [AC_DEFINE([HAVE_STAT_NSEC],[1],[Define if struct stat has st_mtim.tv_nsec.])], + [], [#include ]) # Checks for system services diff --git a/src/V3File.cpp b/src/V3File.cpp index 8e9791e5b..0c9240e03 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -34,7 +34,7 @@ # define INFILTER_PIPE // Allow pipe filtering. Needs fork() #endif -#ifdef st_mtime // Linux 2.6 +#ifdef HAVE_STAT_NSEC // i.e. Linux 2.6, from configure # define VL_STAT_CTIME_NSEC(stat) ((stat).st_ctim.tv_nsec) // Nanoseconds # define VL_STAT_MTIME_NSEC(stat) ((stat).st_mtim.tv_nsec) // Nanoseconds #else diff --git a/src/config_build.h.in b/src/config_build.h.in index ccfc1e553..49efaad79 100644 --- a/src/config_build.h.in +++ b/src/config_build.h.in @@ -68,8 +68,13 @@ using namespace std; +//********************************************************************** +//**** Configure-discovered library options + +// Define if struct stat has st_mtim.tv_nsec (from configure) +#undef HAVE_STAT_NSEC + //********************************************************************** //**** OS and compiler specifics #include "verilatedos.h" -