Merged in rokups/tracy/mingw-fixes (pull request #39)

Fix multiple build errors when compiling with MinGW.
This commit is contained in:
Rokas K. (rku) 2019-08-04 13:36:42 +00:00 committed by Bartosz Taudul
commit 37b03559f0
6 changed files with 26 additions and 2 deletions

View File

@ -35,6 +35,19 @@ CallstackEntry cb_data[MaxCbTrace];
extern "C" { t_RtlWalkFrameChain RtlWalkFrameChain = 0; } extern "C" { t_RtlWalkFrameChain RtlWalkFrameChain = 0; }
#if defined __MINGW32__ && API_VERSION_NUMBER < 12
extern "C" {
// Actual required API_VERSION_NUMBER is unknown because it is undocumented. These functions are not present in at least v11.
DWORD IMAGEAPI SymAddrIncludeInlineTrace(HANDLE hProcess, DWORD64 Address);
BOOL IMAGEAPI SymQueryInlineTrace(HANDLE hProcess, DWORD64 StartAddress, DWORD StartContext, DWORD64 StartRetAddress,
DWORD64 CurAddress, LPDWORD CurContext, LPDWORD CurFrameIndex);
BOOL IMAGEAPI SymFromInlineContext(HANDLE hProcess, DWORD64 Address, ULONG InlineContext, PDWORD64 Displacement,
PSYMBOL_INFO Symbol);
BOOL IMAGEAPI SymGetLineFromInlineContext(HANDLE hProcess, DWORD64 qwAddr, ULONG InlineContext,
DWORD64 qwModuleBaseAddress, PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line64);
};
#endif
void InitCallstack() void InitCallstack()
{ {
#ifdef UNICODE #ifdef UNICODE

View File

@ -235,7 +235,7 @@ static int64_t SetupHwTimer()
#elif defined TRACY_HW_TIMER && ( defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64 ) #elif defined TRACY_HW_TIMER && ( defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64 )
static inline void CpuId( uint32_t* regs, uint32_t leaf ) static inline void CpuId( uint32_t* regs, uint32_t leaf )
{ {
#if defined _MSC_VER || defined __CYGWIN__ #if defined _WIN32 || defined __CYGWIN__
__cpuidex( (int*)regs, leaf, 0 ); __cpuidex( (int*)regs, leaf, 0 );
#else #else
__get_cpuid( leaf, regs, regs+1, regs+2, regs+3 ); __get_cpuid( leaf, regs, regs+1, regs+2, regs+3 );

View File

@ -436,7 +436,11 @@ IpAddress::~IpAddress()
void IpAddress::Set( const struct sockaddr& addr ) void IpAddress::Set( const struct sockaddr& addr )
{ {
#if __MINGW32__
auto ai = (struct sockaddr_in*)&addr;
#else
auto ai = (const struct sockaddr_in*)&addr; auto ai = (const struct sockaddr_in*)&addr;
#endif
inet_ntop( AF_INET, &ai->sin_addr, m_text, 17 ); inet_ntop( AF_INET, &ai->sin_addr, m_text, 17 );
m_number = ai->sin_addr.s_addr; m_number = ai->sin_addr.s_addr;
} }

View File

@ -1,4 +1,4 @@
#ifdef _MSC_VER #ifdef _WIN32
# include <ws2tcpip.h> # include <ws2tcpip.h>
#else #else
# include <arpa/inet.h> # include <arpa/inet.h>

View File

@ -1,12 +1,16 @@
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning( disable: 4244 ) // conversion from don't care to whatever, possible loss of data # pragma warning( disable: 4244 ) // conversion from don't care to whatever, possible loss of data
#endif #endif
#ifdef __MINGW32__
# define __STDC_FORMAT_MACROS
#endif
#include <assert.h> #include <assert.h>
#include <inttypes.h> #include <inttypes.h>
#include <math.h> #include <math.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> // llabs()
#include <string.h> #include <string.h>
#include "TracyPrint.hpp" #include "TracyPrint.hpp"

View File

@ -1,3 +1,6 @@
#ifdef __MINGW32__
# define __STDC_FORMAT_MACROS
#endif
#include <assert.h> #include <assert.h>
#include <inttypes.h> #include <inttypes.h>
#include <string> #include <string>