diff --git a/configure.ac b/configure.ac index 943ce8e8ab..f939bea19d 100644 --- a/configure.ac +++ b/configure.ac @@ -440,6 +440,7 @@ fi if test "x$CXXFLAGS_overridden" = "xno"; then AX_CHECK_COMPILE_FLAG([-Wall],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wall"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wextra],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wextra"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wgnu],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wgnu"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wformat],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wvla],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wvla"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wshadow-field],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wshadow-field"],,[[$CXXFLAG_WERROR]]) diff --git a/src/logging/timer.h b/src/logging/timer.h index 24be460000..4f61a66e5e 100644 --- a/src/logging/timer.h +++ b/src/logging/timer.h @@ -93,12 +93,10 @@ private: } // namespace BCLog -#define LOG_TIME_MICROS(end_msg, ...) \ - BCLog::Timer PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, ## __VA_ARGS__) -#define LOG_TIME_MILLIS(end_msg, ...) \ - BCLog::Timer PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, ## __VA_ARGS__) -#define LOG_TIME_SECONDS(end_msg, ...) \ - BCLog::Timer PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, ## __VA_ARGS__) +#define LOG_TIME_MILLIS_WITH_CATEGORY(end_msg, log_category) \ + BCLog::Timer PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, log_category) +#define LOG_TIME_SECONDS(end_msg) \ + BCLog::Timer PASTE2(logging_timer, __COUNTER__)(__func__, end_msg) #endif // BITCOIN_LOGGING_TIMER_H diff --git a/src/prevector.h b/src/prevector.h index 5d4b196d3e..25b69800d2 100644 --- a/src/prevector.h +++ b/src/prevector.h @@ -152,7 +152,7 @@ private: struct { char* indirect; size_type capacity; - }; + } indirect_contents; }; #pragma pack(pop) alignas(char*) direct_or_indirect _union = {}; @@ -163,8 +163,8 @@ private: T* direct_ptr(difference_type pos) { return reinterpret_cast(_union.direct) + pos; } const T* direct_ptr(difference_type pos) const { return reinterpret_cast(_union.direct) + pos; } - T* indirect_ptr(difference_type pos) { return reinterpret_cast(_union.indirect) + pos; } - const T* indirect_ptr(difference_type pos) const { return reinterpret_cast(_union.indirect) + pos; } + T* indirect_ptr(difference_type pos) { return reinterpret_cast(_union.indirect_contents.indirect) + pos; } + const T* indirect_ptr(difference_type pos) const { return reinterpret_cast(_union.indirect_contents.indirect) + pos; } bool is_direct() const { return _size <= N; } void change_capacity(size_type new_capacity) { @@ -182,17 +182,17 @@ private: /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert success. These should instead use an allocator or new/delete so that handlers are called as necessary, but performance would be slightly degraded by doing so. */ - _union.indirect = static_cast(realloc(_union.indirect, ((size_t)sizeof(T)) * new_capacity)); - assert(_union.indirect); - _union.capacity = new_capacity; + _union.indirect_contents.indirect = static_cast(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); + assert(_union.indirect_contents.indirect); + _union.indirect_contents.capacity = new_capacity; } else { char* new_indirect = static_cast(malloc(((size_t)sizeof(T)) * new_capacity)); assert(new_indirect); T* src = direct_ptr(0); T* dst = reinterpret_cast(new_indirect); memcpy(dst, src, size() * sizeof(T)); - _union.indirect = new_indirect; - _union.capacity = new_capacity; + _union.indirect_contents.indirect = new_indirect; + _union.indirect_contents.capacity = new_capacity; _size += N + 1; } } @@ -318,7 +318,7 @@ public: if (is_direct()) { return N; } else { - return _union.capacity; + return _union.indirect_contents.capacity; } } @@ -485,8 +485,8 @@ public: clear(); } if (!is_direct()) { - free(_union.indirect); - _union.indirect = nullptr; + free(_union.indirect_contents.indirect); + _union.indirect_contents.indirect = nullptr; } } @@ -538,7 +538,7 @@ public: if (is_direct()) { return 0; } else { - return ((size_t)(sizeof(T))) * _union.capacity; + return ((size_t)(sizeof(T))) * _union.indirect_contents.capacity; } } diff --git a/src/validation.cpp b/src/validation.cpp index 6508f71a7a..1d4fe13252 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2488,11 +2488,11 @@ bool CChainState::FlushStateToDisk( LOCK(cs_LastBlockFile); if (fPruneMode && (fCheckForPruning || nManualPruneHeight > 0) && !fReindex) { if (nManualPruneHeight > 0) { - LOG_TIME_MILLIS("find files to prune (manual)", BCLog::BENCHMARK); + LOG_TIME_MILLIS_WITH_CATEGORY("find files to prune (manual)", BCLog::BENCHMARK); FindFilesToPruneManual(g_chainman, setFilesToPrune, nManualPruneHeight); } else { - LOG_TIME_MILLIS("find files to prune", BCLog::BENCHMARK); + LOG_TIME_MILLIS_WITH_CATEGORY("find files to prune", BCLog::BENCHMARK); FindFilesToPrune(g_chainman, setFilesToPrune, chainparams.PruneAfterHeight()); fCheckForPruning = false; @@ -2533,7 +2533,7 @@ bool CChainState::FlushStateToDisk( } // First make sure all block and undo data is flushed to disk. { - LOG_TIME_MILLIS("write block and undo data to disk", BCLog::BENCHMARK); + LOG_TIME_MILLIS_WITH_CATEGORY("write block and undo data to disk", BCLog::BENCHMARK); // First make sure all block and undo data is flushed to disk. FlushBlockFile(); @@ -2541,7 +2541,7 @@ bool CChainState::FlushStateToDisk( // Then update all block file information (which may refer to block and undo files). { - LOG_TIME_MILLIS("write block index to disk", BCLog::BENCHMARK); + LOG_TIME_MILLIS_WITH_CATEGORY("write block index to disk", BCLog::BENCHMARK); std::vector > vFiles; vFiles.reserve(setDirtyFileInfo.size()); @@ -2561,7 +2561,7 @@ bool CChainState::FlushStateToDisk( } // Finally remove any pruned files if (fFlushForPrune) { - LOG_TIME_MILLIS("unlink pruned files", BCLog::BENCHMARK); + LOG_TIME_MILLIS_WITH_CATEGORY("unlink pruned files", BCLog::BENCHMARK); UnlinkPrunedFiles(setFilesToPrune); }