From 1c467a5847c354647025f9dccd33b524b34f7442 Mon Sep 17 00:00:00 2001 From: Tobias Widlund Date: Sat, 30 Jun 2018 11:39:55 +0200 Subject: [PATCH 1/4] Fix warning re shadowing, implicit conversion and added include --- client/TracyCallstack.cpp | 1 + client/TracyProfiler.cpp | 8 ++++---- client/concurrentqueue.h | 10 +++++----- client/tracy_rpmalloc.cpp | 5 ++--- common/TracyAlloc.hpp | 1 + common/TracySystem.cpp | 8 ++++---- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/client/TracyCallstack.cpp b/client/TracyCallstack.cpp index 26211aec..9857a827 100644 --- a/client/TracyCallstack.cpp +++ b/client/TracyCallstack.cpp @@ -1,4 +1,5 @@ #include "TracyCallstack.hpp" +#include #ifdef TRACY_HAS_CALLSTACK diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index f38e631b..b14289dd 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -775,10 +775,10 @@ void Profiler::CalibrateDelay() auto mindiff = std::numeric_limits::max(); for( int i=0; i 0 && dt < mindiff ) mindiff = dt; + const auto t0_inner = GetTime(); + const auto t1_inner = GetTime(); + const auto dt_inner = t1_inner - t0_inner; + if( dt_inner > 0 && dt_inner < mindiff ) mindiff = dt_inner; } m_resolution = mindiff; diff --git a/client/concurrentqueue.h b/client/concurrentqueue.h index 227c0d3b..76bd734e 100644 --- a/client/concurrentqueue.h +++ b/client/concurrentqueue.h @@ -1713,8 +1713,8 @@ private: /////////////////////////// struct ExplicitProducer : public ProducerBase { - explicit ExplicitProducer(ConcurrentQueue* parent) : - ProducerBase(parent, true), + explicit ExplicitProducer(ConcurrentQueue* _parent) : + ProducerBase(_parent, true), blockIndex(nullptr), pr_blockIndexSlotsUsed(0), pr_blockIndexSize(EXPLICIT_INITIAL_INDEX_SIZE >> 1), @@ -1722,7 +1722,7 @@ private: pr_blockIndexEntries(nullptr), pr_blockIndexRaw(nullptr) { - size_t poolBasedIndexSize = details::ceil_to_pow_2(parent->initialBlockPoolSize) >> 1; + size_t poolBasedIndexSize = details::ceil_to_pow_2(_parent->initialBlockPoolSize) >> 1; if (poolBasedIndexSize > pr_blockIndexSize) { pr_blockIndexSize = poolBasedIndexSize; } @@ -2397,8 +2397,8 @@ private: struct ImplicitProducer : public ProducerBase { - ImplicitProducer(ConcurrentQueue* parent) : - ProducerBase(parent, false), + ImplicitProducer(ConcurrentQueue* _parent) : + ProducerBase(_parent, false), nextBlockIndexCapacity(IMPLICIT_INITIAL_INDEX_SIZE), blockIndex(nullptr) { diff --git a/client/tracy_rpmalloc.cpp b/client/tracy_rpmalloc.cpp index cb9d75be..fdee7748 100644 --- a/client/tracy_rpmalloc.cpp +++ b/client/tracy_rpmalloc.cpp @@ -719,7 +719,8 @@ _memory_unmap_deferred(heap_t* heap, size_t wanted_count) { do { //Verify that we own the master span, otherwise re-defer to owner void* next = span->next_span; - if (!found_span && SPAN_COUNT(span->flags) == wanted_count) { + size_t span_count = SPAN_COUNT(span->flags); + if (!found_span && span_count == wanted_count) { assert(!SPAN_HAS_FLAG(span->flags, SPAN_FLAG_MASTER) || !SPAN_HAS_FLAG(span->flags, SPAN_FLAG_SUBSPAN)); found_span = span; } @@ -1522,9 +1523,7 @@ rpmalloc_initialize_config(const rpmalloc_config_t* config) { if (config) memcpy(&_memory_config, config, sizeof(rpmalloc_config_t)); - int default_mapper = 0; if (!_memory_config.memory_map || !_memory_config.memory_unmap) { - default_mapper = 1; _memory_config.memory_map = _memory_map_os; _memory_config.memory_unmap = _memory_unmap_os; } diff --git a/common/TracyAlloc.hpp b/common/TracyAlloc.hpp index 8e57c8bd..ae19312c 100644 --- a/common/TracyAlloc.hpp +++ b/common/TracyAlloc.hpp @@ -1,5 +1,6 @@ #ifndef __TRACYALLOC_HPP__ #define __TRACYALLOC_HPP__ +#include #ifdef TRACY_ENABLE # include "../client/tracy_rpmalloc.hpp" diff --git a/common/TracySystem.cpp b/common/TracySystem.cpp index 4e6b7ee8..bef0c22e 100644 --- a/common/TracySystem.cpp +++ b/common/TracySystem.cpp @@ -85,10 +85,10 @@ void SetThreadName( std::thread::native_handle_type handle, const char* name ) #ifdef TRACY_COLLECT_THREAD_NAMES { rpmalloc_thread_initialize(); - const auto sz = strlen( name ); - char* buf = (char*)tracy_malloc( sz+1 ); - memcpy( buf, name, sz ); - buf[sz+1] = '\0'; + const auto sz_inner = strlen( name ); + char* buf = (char*)tracy_malloc( sz_inner+1 ); + memcpy( buf, name, sz_inner ); + buf[sz_inner+1] = '\0'; auto data = (ThreadNameData*)tracy_malloc( sizeof( ThreadNameData ) ); # ifdef _WIN32 data->id = GetThreadId( static_cast( handle ) ); From b6cce4ddb6958de436a96ae069ef285758774554 Mon Sep 17 00:00:00 2001 From: Tobias Widlund Date: Sat, 30 Jun 2018 15:36:06 +0200 Subject: [PATCH 2/4] Improve fixes for warnings as per request --- client/TracyCallstack.cpp | 2 +- client/TracyProfiler.cpp | 8 ++++---- common/TracyAlloc.hpp | 1 + common/TracySystem.cpp | 30 ++++++++++++++++-------------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/client/TracyCallstack.cpp b/client/TracyCallstack.cpp index 9857a827..daf5ce02 100644 --- a/client/TracyCallstack.cpp +++ b/client/TracyCallstack.cpp @@ -1,5 +1,5 @@ +#include "stdio.h" #include "TracyCallstack.hpp" -#include #ifdef TRACY_HAS_CALLSTACK diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index b14289dd..be4a769c 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -775,10 +775,10 @@ void Profiler::CalibrateDelay() auto mindiff = std::numeric_limits::max(); for( int i=0; i 0 && dt_inner < mindiff ) mindiff = dt_inner; + const auto t0i = GetTime(); + const auto t1i = GetTime(); + const auto dti = t1i - t0i; + if( dti > 0 && dti < mindiff ) mindiff = dti; } m_resolution = mindiff; diff --git a/common/TracyAlloc.hpp b/common/TracyAlloc.hpp index ae19312c..3fde086e 100644 --- a/common/TracyAlloc.hpp +++ b/common/TracyAlloc.hpp @@ -1,5 +1,6 @@ #ifndef __TRACYALLOC_HPP__ #define __TRACYALLOC_HPP__ + #include #ifdef TRACY_ENABLE diff --git a/common/TracySystem.cpp b/common/TracySystem.cpp index bef0c22e..bfe06266 100644 --- a/common/TracySystem.cpp +++ b/common/TracySystem.cpp @@ -69,26 +69,28 @@ void SetThreadName( std::thread::native_handle_type handle, const char* name ) } # endif #elif defined _GNU_SOURCE && !defined __EMSCRIPTEN__ - const auto sz = strlen( name ); - if( sz <= 15 ) { - pthread_setname_np( handle, name ); - } - else - { - char buf[16]; - memcpy( buf, name, 15 ); - buf[15] = '\0'; - pthread_setname_np( handle, buf ); + const auto sz = strlen( name ); + if( sz <= 15 ) + { + pthread_setname_np( handle, name ); + } + else + { + char buf[16]; + memcpy( buf, name, 15 ); + buf[15] = '\0'; + pthread_setname_np( handle, buf ); + } } #endif #ifdef TRACY_COLLECT_THREAD_NAMES { rpmalloc_thread_initialize(); - const auto sz_inner = strlen( name ); - char* buf = (char*)tracy_malloc( sz_inner+1 ); - memcpy( buf, name, sz_inner ); - buf[sz_inner+1] = '\0'; + const auto sz = strlen( name ); + char* buf = (char*)tracy_malloc( sz+1 ); + memcpy( buf, name, sz ); + buf[sz+1] = '\0'; auto data = (ThreadNameData*)tracy_malloc( sizeof( ThreadNameData ) ); # ifdef _WIN32 data->id = GetThreadId( static_cast( handle ) ); From 273355b665cd0ad643841e4c081bdb004e28b032 Mon Sep 17 00:00:00 2001 From: Tobias Widlund Date: Sat, 30 Jun 2018 16:00:51 +0200 Subject: [PATCH 3/4] Change system include from using "" to <> --- Tracy.hpp | 8 ++++---- client/TracyCallstack.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Tracy.hpp b/Tracy.hpp index a2551d04..1b43dd85 100644 --- a/Tracy.hpp +++ b/Tracy.hpp @@ -40,10 +40,10 @@ #include "client/TracyProfiler.hpp" #include "client/TracyScoped.hpp" -#define ZoneScoped static const tracy::SourceLocation __tracy_source_location { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ); -#define ZoneScopedN( name ) static const tracy::SourceLocation __tracy_source_location { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ); -#define ZoneScopedC( color ) static const tracy::SourceLocation __tracy_source_location { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ); -#define ZoneScopedNC( name, color ) static const tracy::SourceLocation __tracy_source_location { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ); +#define ZoneScoped static const tracy::SourceLocation __tracy_source_location ## __LINE__ { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ## __LINE__ ); +#define ZoneScopedN( name ) static const tracy::SourceLocation __tracy_source_location ## __LINE__ { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ## __LINE__ ); +#define ZoneScopedC( color ) static const tracy::SourceLocation __tracy_source_location ## __LINE__ { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ## __LINE__ ); +#define ZoneScopedNC( name, color ) static const tracy::SourceLocation __tracy_source_location ## __LINE__ { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ## __LINE__ ); #define ZoneText( txt, size ) ___tracy_scoped_zone.Text( txt, size ); #define ZoneName( txt, size ) ___tracy_scoped_zone.Name( txt, size ); diff --git a/client/TracyCallstack.cpp b/client/TracyCallstack.cpp index daf5ce02..94a5afd4 100644 --- a/client/TracyCallstack.cpp +++ b/client/TracyCallstack.cpp @@ -1,4 +1,4 @@ -#include "stdio.h" +#include #include "TracyCallstack.hpp" #ifdef TRACY_HAS_CALLSTACK From f09623b6c9fe06cfc6fcbddc20cf5c0dd577fc36 Mon Sep 17 00:00:00 2001 From: Tobias Widlund Date: Sat, 30 Jun 2018 16:23:16 +0200 Subject: [PATCH 4/4] Revert inappropriate fix --- Tracy.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tracy.hpp b/Tracy.hpp index 1b43dd85..a2551d04 100644 --- a/Tracy.hpp +++ b/Tracy.hpp @@ -40,10 +40,10 @@ #include "client/TracyProfiler.hpp" #include "client/TracyScoped.hpp" -#define ZoneScoped static const tracy::SourceLocation __tracy_source_location ## __LINE__ { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ## __LINE__ ); -#define ZoneScopedN( name ) static const tracy::SourceLocation __tracy_source_location ## __LINE__ { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ## __LINE__ ); -#define ZoneScopedC( color ) static const tracy::SourceLocation __tracy_source_location ## __LINE__ { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ## __LINE__ ); -#define ZoneScopedNC( name, color ) static const tracy::SourceLocation __tracy_source_location ## __LINE__ { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ## __LINE__ ); +#define ZoneScoped static const tracy::SourceLocation __tracy_source_location { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ); +#define ZoneScopedN( name ) static const tracy::SourceLocation __tracy_source_location { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ); +#define ZoneScopedC( color ) static const tracy::SourceLocation __tracy_source_location { nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ); +#define ZoneScopedNC( name, color ) static const tracy::SourceLocation __tracy_source_location { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location ); #define ZoneText( txt, size ) ___tracy_scoped_zone.Text( txt, size ); #define ZoneName( txt, size ) ___tracy_scoped_zone.Name( txt, size );