mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Move TRACY_UWP define to own header
This commit is contained in:
parent
7169f5f30a
commit
a0a56eaf9e
@ -6,9 +6,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined _WIN32
|
#if defined _WIN32
|
||||||
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
|
# include "../common/TracyUwp.hpp"
|
||||||
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
# ifndef TRACY_UWP
|
||||||
# else
|
|
||||||
# define TRACY_HAS_CALLSTACK 1
|
# define TRACY_HAS_CALLSTACK 1
|
||||||
# endif
|
# endif
|
||||||
#elif defined __ANDROID__
|
#elif defined __ANDROID__
|
||||||
|
|||||||
@ -9,11 +9,7 @@
|
|||||||
# include <tlhelp32.h>
|
# include <tlhelp32.h>
|
||||||
# include <inttypes.h>
|
# include <inttypes.h>
|
||||||
# include <intrin.h>
|
# include <intrin.h>
|
||||||
|
# include "../common/TracyUwp.hpp"
|
||||||
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
|
|
||||||
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
|
||||||
# define TRACY_ON_UWP
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
# include <sys/time.h>
|
# include <sys/time.h>
|
||||||
# include <sys/param.h>
|
# include <sys/param.h>
|
||||||
@ -319,7 +315,7 @@ static void InitFailure( const char* msg )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
# if !defined TRACY_ON_UWP
|
# ifndef TRACY_UWP
|
||||||
MessageBoxA( nullptr, msg, "Tracy Profiler initialization failure", MB_ICONSTOP );
|
MessageBoxA( nullptr, msg, "Tracy Profiler initialization failure", MB_ICONSTOP );
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
@ -447,11 +443,12 @@ static const char* GetHostInfo()
|
|||||||
static char buf[1024];
|
static char buf[1024];
|
||||||
auto ptr = buf;
|
auto ptr = buf;
|
||||||
#if defined _WIN32
|
#if defined _WIN32
|
||||||
# if defined TRACY_ON_UWP
|
# ifdef TRACY_UWP
|
||||||
ptr += sprintf(ptr, "OS: Windows 10\n");
|
auto GetVersion = &::GetVersionEx;
|
||||||
# else
|
# else
|
||||||
t_RtlGetVersion RtlGetVersion = (t_RtlGetVersion)GetProcAddress( GetModuleHandleA( "ntdll.dll" ), "RtlGetVersion" );
|
auto GetVersion = (t_RtlGetVersion)GetProcAddress( GetModuleHandleA( "ntdll.dll" ), "RtlGetVersion" );
|
||||||
if( !RtlGetVersion )
|
# endif
|
||||||
|
if( !GetVersion )
|
||||||
{
|
{
|
||||||
# ifdef __MINGW32__
|
# ifdef __MINGW32__
|
||||||
ptr += sprintf( ptr, "OS: Windows (MingW)\n" );
|
ptr += sprintf( ptr, "OS: Windows (MingW)\n" );
|
||||||
@ -462,7 +459,7 @@ static const char* GetHostInfo()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
RTL_OSVERSIONINFOW ver = { sizeof( RTL_OSVERSIONINFOW ) };
|
RTL_OSVERSIONINFOW ver = { sizeof( RTL_OSVERSIONINFOW ) };
|
||||||
RtlGetVersion( &ver );
|
GetVersion( &ver );
|
||||||
|
|
||||||
# ifdef __MINGW32__
|
# ifdef __MINGW32__
|
||||||
ptr += sprintf( ptr, "OS: Windows %i.%i.%i (MingW)\n", (int)ver.dwMajorVersion, (int)ver.dwMinorVersion, (int)ver.dwBuildNumber );
|
ptr += sprintf( ptr, "OS: Windows %i.%i.%i (MingW)\n", (int)ver.dwMajorVersion, (int)ver.dwMinorVersion, (int)ver.dwBuildNumber );
|
||||||
@ -470,7 +467,6 @@ static const char* GetHostInfo()
|
|||||||
ptr += sprintf( ptr, "OS: Windows %i.%i.%i\n", ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber );
|
ptr += sprintf( ptr, "OS: Windows %i.%i.%i\n", ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber );
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
#elif defined __linux__
|
#elif defined __linux__
|
||||||
struct utsname utsName;
|
struct utsname utsName;
|
||||||
uname( &utsName );
|
uname( &utsName );
|
||||||
@ -519,15 +515,15 @@ static const char* GetHostInfo()
|
|||||||
char hostname[512];
|
char hostname[512];
|
||||||
gethostname( hostname, 512 );
|
gethostname( hostname, 512 );
|
||||||
|
|
||||||
# if defined TRACY_ON_UWP
|
# ifdef TRACY_UWP
|
||||||
ptr += sprintf(ptr, "Hostname: %s\n", hostname);
|
const char* user = "";
|
||||||
# else
|
# else
|
||||||
DWORD userSz = UNLEN+1;
|
DWORD userSz = UNLEN+1;
|
||||||
char user[UNLEN+1];
|
char user[UNLEN+1];
|
||||||
GetUserNameA( user, &userSz );
|
GetUserNameA( user, &userSz );
|
||||||
|
# endif
|
||||||
|
|
||||||
ptr += sprintf( ptr, "User: %s@%s\n", user, hostname );
|
ptr += sprintf( ptr, "User: %s@%s\n", user, hostname );
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
char hostname[_POSIX_HOST_NAME_MAX]{};
|
char hostname[_POSIX_HOST_NAME_MAX]{};
|
||||||
char user[_POSIX_LOGIN_NAME_MAX]{};
|
char user[_POSIX_LOGIN_NAME_MAX]{};
|
||||||
@ -722,7 +718,7 @@ static BroadcastMessage& GetBroadcastMessage( const char* procname, size_t pnsz,
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined _WIN32 && !defined TRACY_ON_UWP
|
#if defined _WIN32 && !defined TRACY_UWP
|
||||||
static DWORD s_profilerThreadId = 0;
|
static DWORD s_profilerThreadId = 0;
|
||||||
static char s_crashText[1024];
|
static char s_crashText[1024];
|
||||||
|
|
||||||
@ -1397,7 +1393,7 @@ void Profiler::SpawnWorkerThreads()
|
|||||||
new(s_symbolThread) Thread( LaunchSymbolWorker, this );
|
new(s_symbolThread) Thread( LaunchSymbolWorker, this );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined _WIN32 && !defined TRACY_ON_UWP
|
#if defined _WIN32 && !defined TRACY_UWP
|
||||||
s_profilerThreadId = GetThreadId( s_thread->Handle() );
|
s_profilerThreadId = GetThreadId( s_thread->Handle() );
|
||||||
m_exceptionHandler = AddVectoredExceptionHandler( 1, CrashFilter );
|
m_exceptionHandler = AddVectoredExceptionHandler( 1, CrashFilter );
|
||||||
#endif
|
#endif
|
||||||
@ -1431,7 +1427,7 @@ Profiler::~Profiler()
|
|||||||
{
|
{
|
||||||
m_shutdown.store( true, std::memory_order_relaxed );
|
m_shutdown.store( true, std::memory_order_relaxed );
|
||||||
|
|
||||||
#if defined _WIN32 && !defined TRACY_ON_UWP
|
#if defined _WIN32 && !defined TRACY_UWP
|
||||||
if( m_crashHandlerInstalled ) RemoveVectoredExceptionHandler( m_exceptionHandler );
|
if( m_crashHandlerInstalled ) RemoveVectoredExceptionHandler( m_exceptionHandler );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -3549,7 +3545,7 @@ void Profiler::ReportTopology()
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if defined _WIN32
|
#if defined _WIN32
|
||||||
# if defined TRACY_ON_UWP
|
# ifdef TRACY_UWP
|
||||||
t_GetLogicalProcessorInformationEx _GetLogicalProcessorInformationEx = &::GetLogicalProcessorInformationEx;
|
t_GetLogicalProcessorInformationEx _GetLogicalProcessorInformationEx = &::GetLogicalProcessorInformationEx;
|
||||||
# else
|
# else
|
||||||
t_GetLogicalProcessorInformationEx _GetLogicalProcessorInformationEx = (t_GetLogicalProcessorInformationEx)GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "GetLogicalProcessorInformationEx" );
|
t_GetLogicalProcessorInformationEx _GetLogicalProcessorInformationEx = (t_GetLogicalProcessorInformationEx)GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "GetLogicalProcessorInformationEx" );
|
||||||
|
|||||||
@ -2,9 +2,8 @@
|
|||||||
#define __TRACYSYSTRACE_HPP__
|
#define __TRACYSYSTRACE_HPP__
|
||||||
|
|
||||||
#if !defined TRACY_NO_SYSTEM_TRACING && ( defined _WIN32 || defined __linux__ )
|
#if !defined TRACY_NO_SYSTEM_TRACING && ( defined _WIN32 || defined __linux__ )
|
||||||
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
|
# include "../common/TracyUwp.hpp"
|
||||||
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
# ifndef TRACY_UWP
|
||||||
# else
|
|
||||||
# define TRACY_HAS_SYSTEM_TRACING
|
# define TRACY_HAS_SYSTEM_TRACING
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -10,11 +10,7 @@
|
|||||||
# endif
|
# endif
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <malloc.h>
|
# include <malloc.h>
|
||||||
|
# include "TracyUwp.hpp"
|
||||||
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
|
|
||||||
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
|
||||||
# define TRACY_ON_UWP
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
@ -132,7 +128,7 @@ void ThreadNameMsvcMagic( const THREADNAME_INFO& info )
|
|||||||
TRACY_API void SetThreadName( const char* name )
|
TRACY_API void SetThreadName( const char* name )
|
||||||
{
|
{
|
||||||
#if defined _WIN32
|
#if defined _WIN32
|
||||||
# if defined TRACY_ON_UWP
|
# ifdef TRACY_UWP
|
||||||
static auto _SetThreadDescription = &::SetThreadDescription;
|
static auto _SetThreadDescription = &::SetThreadDescription;
|
||||||
# else
|
# else
|
||||||
static auto _SetThreadDescription = (t_SetThreadDescription)GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "SetThreadDescription" );
|
static auto _SetThreadDescription = (t_SetThreadDescription)GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "SetThreadDescription" );
|
||||||
@ -200,7 +196,7 @@ TRACY_API const char* GetThreadName( uint32_t id )
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# if defined _WIN32
|
# if defined _WIN32
|
||||||
# if defined TRACY_ON_UWP
|
# ifdef TRACY_UWP
|
||||||
static auto _GetThreadDescription = &::GetThreadDescription;
|
static auto _GetThreadDescription = &::GetThreadDescription;
|
||||||
# else
|
# else
|
||||||
static auto _GetThreadDescription = (t_GetThreadDescription)GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "GetThreadDescription" );
|
static auto _GetThreadDescription = (t_GetThreadDescription)GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "GetThreadDescription" );
|
||||||
|
|||||||
11
common/TracyUwp.hpp
Normal file
11
common/TracyUwp.hpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef __TRACYUWP_HPP__
|
||||||
|
#define __TRACYUWP_HPP__
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# include <winapifamily.h>
|
||||||
|
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||||
|
# define TRACY_UWP
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
x
Reference in New Issue
Block a user