mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 14:44:34 +00:00
Wrap std::numeric_limits<T>::max() in parenthesis
The windows.h header file defines the macro max. If the max macro is include it will lead to name collisions with the std::numeric_limits<T>::max() function. One solution is to define NOMINMAX before the inclusion of windows.h. However, that might be a demanding task for a large codebase. Defining the NOMINMAX as global define may also break previous code. Another to solution to the problem is to wrap the numeric_limits function in parenthesis to instruct the compiler to treat it as a function and not a macro. This commit wraps the std::numeric_limits<T>::max() calls in the public interfacing header files, with parenthesis.
This commit is contained in:
parent
84eff4b05d
commit
e1b1fd72dc
@ -21,7 +21,7 @@ public:
|
|||||||
, m_active( false )
|
, m_active( false )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
assert( m_id != std::numeric_limits<uint32_t>::max() );
|
assert( m_id != (std::numeric_limits<uint32_t>::max)() );
|
||||||
|
|
||||||
auto item = Profiler::QueueSerial();
|
auto item = Profiler::QueueSerial();
|
||||||
MemWrite( &item->hdr.type, QueueType::LockAnnounce );
|
MemWrite( &item->hdr.type, QueueType::LockAnnounce );
|
||||||
@ -154,7 +154,7 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void CustomName( const char* name, size_t size )
|
tracy_force_inline void CustomName( const char* name, size_t size )
|
||||||
{
|
{
|
||||||
assert( size < std::numeric_limits<uint16_t>::max() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
auto ptr = (char*)tracy_malloc( size );
|
auto ptr = (char*)tracy_malloc( size );
|
||||||
memcpy( ptr, name, size );
|
memcpy( ptr, name, size );
|
||||||
auto item = Profiler::QueueSerial();
|
auto item = Profiler::QueueSerial();
|
||||||
@ -235,7 +235,7 @@ public:
|
|||||||
, m_active( false )
|
, m_active( false )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
assert( m_id != std::numeric_limits<uint32_t>::max() );
|
assert( m_id != (std::numeric_limits<uint32_t>::max)() );
|
||||||
|
|
||||||
auto item = Profiler::QueueSerial();
|
auto item = Profiler::QueueSerial();
|
||||||
MemWrite( &item->hdr.type, QueueType::LockAnnounce );
|
MemWrite( &item->hdr.type, QueueType::LockAnnounce );
|
||||||
@ -450,7 +450,7 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void CustomName( const char* name, size_t size )
|
tracy_force_inline void CustomName( const char* name, size_t size )
|
||||||
{
|
{
|
||||||
assert( size < std::numeric_limits<uint16_t>::max() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
auto ptr = (char*)tracy_malloc( size );
|
auto ptr = (char*)tracy_malloc( size );
|
||||||
memcpy( ptr, name, size );
|
memcpy( ptr, name, size );
|
||||||
auto item = Profiler::QueueSerial();
|
auto item = Profiler::QueueSerial();
|
||||||
|
@ -289,7 +289,7 @@ public:
|
|||||||
{
|
{
|
||||||
#ifndef TRACY_NO_FRAME_IMAGE
|
#ifndef TRACY_NO_FRAME_IMAGE
|
||||||
auto& profiler = GetProfiler();
|
auto& profiler = GetProfiler();
|
||||||
assert( profiler.m_frameCount.load( std::memory_order_relaxed ) < std::numeric_limits<uint32_t>::max() );
|
assert( profiler.m_frameCount.load( std::memory_order_relaxed ) < (std::numeric_limits<uint32_t>::max)() );
|
||||||
# ifdef TRACY_ON_DEMAND
|
# ifdef TRACY_ON_DEMAND
|
||||||
if( !profiler.IsConnected() ) return;
|
if( !profiler.IsConnected() ) return;
|
||||||
# endif
|
# endif
|
||||||
@ -363,7 +363,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void Message( const char* txt, size_t size, int callstack )
|
static tracy_force_inline void Message( const char* txt, size_t size, int callstack )
|
||||||
{
|
{
|
||||||
assert( size < std::numeric_limits<uint16_t>::max() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
#endif
|
#endif
|
||||||
@ -400,7 +400,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void MessageColor( const char* txt, size_t size, uint32_t color, int callstack )
|
static tracy_force_inline void MessageColor( const char* txt, size_t size, uint32_t color, int callstack )
|
||||||
{
|
{
|
||||||
assert( size < std::numeric_limits<uint16_t>::max() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
#endif
|
#endif
|
||||||
@ -443,7 +443,7 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void MessageAppInfo( const char* txt, size_t size )
|
static tracy_force_inline void MessageAppInfo( const char* txt, size_t size )
|
||||||
{
|
{
|
||||||
assert( size < std::numeric_limits<uint16_t>::max() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
auto ptr = (char*)tracy_malloc( size );
|
auto ptr = (char*)tracy_malloc( size );
|
||||||
memcpy( ptr, txt, size );
|
memcpy( ptr, txt, size );
|
||||||
TracyLfqPrepare( QueueType::MessageAppInfo );
|
TracyLfqPrepare( QueueType::MessageAppInfo );
|
||||||
@ -738,7 +738,7 @@ public:
|
|||||||
static tracy_force_inline uint64_t AllocSourceLocation( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz )
|
static tracy_force_inline uint64_t AllocSourceLocation( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz )
|
||||||
{
|
{
|
||||||
const auto sz32 = uint32_t( 2 + 4 + 4 + functionSz + 1 + sourceSz + 1 + nameSz );
|
const auto sz32 = uint32_t( 2 + 4 + 4 + functionSz + 1 + sourceSz + 1 + nameSz );
|
||||||
assert( sz32 <= std::numeric_limits<uint16_t>::max() );
|
assert( sz32 <= (std::numeric_limits<uint16_t>::max)() );
|
||||||
const auto sz = uint16_t( sz32 );
|
const auto sz = uint16_t( sz32 );
|
||||||
auto ptr = (char*)tracy_malloc( sz );
|
auto ptr = (char*)tracy_malloc( sz );
|
||||||
memcpy( ptr, &sz, 2 );
|
memcpy( ptr, &sz, 2 );
|
||||||
|
@ -108,7 +108,7 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void Text( const char* txt, size_t size )
|
tracy_force_inline void Text( const char* txt, size_t size )
|
||||||
{
|
{
|
||||||
assert( size < std::numeric_limits<uint16_t>::max() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
||||||
@ -123,7 +123,7 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void Name( const char* txt, size_t size )
|
tracy_force_inline void Name( const char* txt, size_t size )
|
||||||
{
|
{
|
||||||
assert( size < std::numeric_limits<uint16_t>::max() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
||||||
|
@ -16,7 +16,7 @@ using lz4sz_t = uint32_t;
|
|||||||
|
|
||||||
enum { TargetFrameSize = 256 * 1024 };
|
enum { TargetFrameSize = 256 * 1024 };
|
||||||
enum { LZ4Size = Lz4CompressBound( TargetFrameSize ) };
|
enum { LZ4Size = Lz4CompressBound( TargetFrameSize ) };
|
||||||
static_assert( LZ4Size <= std::numeric_limits<lz4sz_t>::max(), "LZ4Size greater than lz4sz_t" );
|
static_assert( LZ4Size <= (std::numeric_limits<lz4sz_t>::max)(), "LZ4Size greater than lz4sz_t" );
|
||||||
static_assert( TargetFrameSize * 2 >= 64 * 1024, "Not enough space for LZ4 stream buffer" );
|
static_assert( TargetFrameSize * 2 >= 64 * 1024, "Not enough space for LZ4 stream buffer" );
|
||||||
|
|
||||||
enum { HandshakeShibbolethSize = 8 };
|
enum { HandshakeShibbolethSize = 8 };
|
||||||
|
@ -173,10 +173,10 @@ static tracy_force_inline void SendLuaCallstack( lua_State* L, uint32_t depth )
|
|||||||
{
|
{
|
||||||
const uint32_t line = dbg[i].currentline;
|
const uint32_t line = dbg[i].currentline;
|
||||||
memcpy( dst, &line, 4 ); dst += 4;
|
memcpy( dst, &line, 4 ); dst += 4;
|
||||||
assert( fsz[i] <= std::numeric_limits<uint16_t>::max() );
|
assert( fsz[i] <= (std::numeric_limits<uint16_t>::max)() );
|
||||||
memcpy( dst, fsz+i, 2 ); dst += 2;
|
memcpy( dst, fsz+i, 2 ); dst += 2;
|
||||||
memcpy( dst, func[i], fsz[i] ); dst += fsz[i];
|
memcpy( dst, func[i], fsz[i] ); dst += fsz[i];
|
||||||
assert( ssz[i] <= std::numeric_limits<uint16_t>::max() );
|
assert( ssz[i] <= (std::numeric_limits<uint16_t>::max)() );
|
||||||
memcpy( dst, ssz+i, 2 ); dst += 2;
|
memcpy( dst, ssz+i, 2 ); dst += 2;
|
||||||
memcpy( dst, dbg[i].source, ssz[i] ), dst += ssz[i];
|
memcpy( dst, dbg[i].source, ssz[i] ), dst += ssz[i];
|
||||||
}
|
}
|
||||||
@ -333,7 +333,7 @@ static inline int LuaZoneText( lua_State* L )
|
|||||||
|
|
||||||
auto txt = lua_tostring( L, 1 );
|
auto txt = lua_tostring( L, 1 );
|
||||||
const auto size = strlen( txt );
|
const auto size = strlen( txt );
|
||||||
assert( size < std::numeric_limits<uint16_t>::max() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
|
|
||||||
auto ptr = (char*)tracy_malloc( size );
|
auto ptr = (char*)tracy_malloc( size );
|
||||||
memcpy( ptr, txt, size );
|
memcpy( ptr, txt, size );
|
||||||
@ -358,7 +358,7 @@ static inline int LuaZoneName( lua_State* L )
|
|||||||
|
|
||||||
auto txt = lua_tostring( L, 1 );
|
auto txt = lua_tostring( L, 1 );
|
||||||
const auto size = strlen( txt );
|
const auto size = strlen( txt );
|
||||||
assert( size < std::numeric_limits<uint16_t>::max() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
|
|
||||||
auto ptr = (char*)tracy_malloc( size );
|
auto ptr = (char*)tracy_malloc( size );
|
||||||
memcpy( ptr, txt, size );
|
memcpy( ptr, txt, size );
|
||||||
@ -378,7 +378,7 @@ static inline int LuaMessage( lua_State* L )
|
|||||||
|
|
||||||
auto txt = lua_tostring( L, 1 );
|
auto txt = lua_tostring( L, 1 );
|
||||||
const auto size = strlen( txt );
|
const auto size = strlen( txt );
|
||||||
assert( size < std::numeric_limits<uint16_t>::max() );
|
assert( size < (std::numeric_limits<uint16_t>::max)() );
|
||||||
|
|
||||||
auto ptr = (char*)tracy_malloc( size );
|
auto ptr = (char*)tracy_malloc( size );
|
||||||
memcpy( ptr, txt, size );
|
memcpy( ptr, txt, size );
|
||||||
|
Loading…
Reference in New Issue
Block a user