Process name getter.

This commit is contained in:
Bartosz Taudul 2017-10-03 23:17:16 +02:00
parent b1aa16763b
commit 6485457518

View File

@ -1,9 +1,14 @@
#ifdef _MSC_VER #ifdef _MSC_VER
# include <winsock2.h> # include <winsock2.h>
# include <windows.h>
#else #else
# include <sys/time.h> # include <sys/time.h>
#endif #endif
#ifdef _GNU_SOURCE
# include <errno.h>
#endif
#include <atomic> #include <atomic>
#include <assert.h> #include <assert.h>
#include <chrono> #include <chrono>
@ -24,6 +29,23 @@
namespace tracy namespace tracy
{ {
static const char* GetProcessName()
{
#if defined _MSC_VER || defined __CYGWIN__
static char buf[_MAX_PATH];
GetModuleFileNameA( nullptr, buf, _MAX_PATH );
const char* ptr = buf;
while( *ptr != '\0' ) ptr++;
while( ptr > buf && *ptr != '\\' && *ptr != '/' ) ptr--;
if( ptr > buf ) ptr++;
return ptr;
#elif defined _GNU_SOURCE
return program_invocation_short_name;
#else
return "unknown";
#endif
}
enum { QueuePrealloc = 256 * 1024 }; enum { QueuePrealloc = 256 * 1024 };
moodycamel::ConcurrentQueue<QueueItem> s_queue( QueueItemSize * QueuePrealloc ); moodycamel::ConcurrentQueue<QueueItem> s_queue( QueueItemSize * QueuePrealloc );