Fixed Microprofile on Mingw

This commit is contained in:
Fernando Sahmkow 2017-01-20 16:24:20 -05:00
parent ebe0150635
commit b391d5bb96
3 changed files with 18 additions and 20 deletions

View File

@ -72,8 +72,6 @@ if (NOT MSVC)
if (MINGW) if (MINGW)
add_definitions(-DMINGW_HAS_SECURE_API) add_definitions(-DMINGW_HAS_SECURE_API)
# Microprofile causes crashes when launching titles on MinGW
add_definitions(-DMICROPROFILE_ENABLED=0)
if (MINGW_STATIC_BUILD) if (MINGW_STATIC_BUILD)
add_definitions(-DQT_STATICPLUGIN) add_definitions(-DQT_STATICPLUGIN)

View File

@ -197,7 +197,7 @@ inline uint64_t MicroProfileGetCurrentThreadId()
#define MP_STRCASECMP strcasecmp #define MP_STRCASECMP strcasecmp
#define MP_GETCURRENTTHREADID() MicroProfileGetCurrentThreadId() #define MP_GETCURRENTTHREADID() MicroProfileGetCurrentThreadId()
typedef uint64_t ThreadIdType; typedef uint64_t ThreadIdType;
#elif defined(_WIN32) #elif defined(_MSC_VER)
int64_t MicroProfileGetTick(); int64_t MicroProfileGetTick();
#define MP_TICK() MicroProfileGetTick() #define MP_TICK() MicroProfileGetTick()
#define MP_BREAK() __debugbreak() #define MP_BREAK() __debugbreak()
@ -206,7 +206,7 @@ int64_t MicroProfileGetTick();
#define MP_GETCURRENTTHREADID() GetCurrentThreadId() #define MP_GETCURRENTTHREADID() GetCurrentThreadId()
typedef uint32_t ThreadIdType; typedef uint32_t ThreadIdType;
#elif !defined(_WIN32) #elif !defined(_MSC_VER)
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
inline int64_t MicroProfileTicksPerSecondCpu() inline int64_t MicroProfileTicksPerSecondCpu()
@ -483,7 +483,7 @@ struct MicroProfileScopeGpuHandler
#ifndef MICROPROFILE_CONTEXT_SWITCH_TRACE #ifndef MICROPROFILE_CONTEXT_SWITCH_TRACE
#if defined(_WIN32) #if defined(_MSC_VER)
#define MICROPROFILE_CONTEXT_SWITCH_TRACE 1 #define MICROPROFILE_CONTEXT_SWITCH_TRACE 1
#elif defined(__APPLE__) #elif defined(__APPLE__)
#define MICROPROFILE_CONTEXT_SWITCH_TRACE 0 //disabled until dtrace script is working. #define MICROPROFILE_CONTEXT_SWITCH_TRACE 0 //disabled until dtrace script is working.
@ -502,7 +502,7 @@ struct MicroProfileScopeGpuHandler
#define MICROPROFILE_MINIZ 0 #define MICROPROFILE_MINIZ 0
#endif #endif
#ifdef _WIN32 #ifdef _MSC_VER
#include <basetsd.h> #include <basetsd.h>
typedef UINT_PTR MpSocket; typedef UINT_PTR MpSocket;
#else #else
@ -510,7 +510,7 @@ typedef int MpSocket;
#endif #endif
#ifndef _WIN32 #ifndef _MSC_VER
typedef pthread_t MicroProfileThread; typedef pthread_t MicroProfileThread;
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
typedef HANDLE MicroProfileThread; typedef HANDLE MicroProfileThread;
@ -878,7 +878,7 @@ inline uint16_t MicroProfileGetGroupIndex(MicroProfileToken t)
#ifdef MICROPROFILE_IMPL #ifdef MICROPROFILE_IMPL
#ifdef _WIN32 #ifdef _MSC_VER
#include <windows.h> #include <windows.h>
#define snprintf _snprintf #define snprintf _snprintf
@ -907,7 +907,7 @@ int64_t MicroProfileGetTick()
typedef void* (*MicroProfileThreadFunc)(void*); typedef void* (*MicroProfileThreadFunc)(void*);
#ifndef _WIN32 #ifndef _MSC_VER
typedef pthread_t MicroProfileThread; typedef pthread_t MicroProfileThread;
void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func) void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func)
{ {
@ -955,11 +955,11 @@ inline void MicroProfileThreadJoin(MicroProfileThread* pThread)
#if MICROPROFILE_WEBSERVER #if MICROPROFILE_WEBSERVER
#ifdef _WIN32 #ifdef _MSC_VER
#define MP_INVALID_SOCKET(f) (f == INVALID_SOCKET) #define MP_INVALID_SOCKET(f) (f == INVALID_SOCKET)
#endif #endif
#ifndef _WIN32 #ifndef _MSC_VER
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <fcntl.h> #include <fcntl.h>
@ -2142,7 +2142,7 @@ void MicroProfilePrintf(MicroProfileWriteCallback CB, void* Handle, const char*
char buffer[32*1024]; char buffer[32*1024];
va_list args; va_list args;
va_start (args, pFmt); va_start (args, pFmt);
#ifdef _WIN32 #ifdef _MSC_VER
size_t size = vsprintf_s(buffer, pFmt, args); size_t size = vsprintf_s(buffer, pFmt, args);
#else #else
size_t size = vsnprintf(buffer, sizeof(buffer)-1, pFmt, args); size_t size = vsnprintf(buffer, sizeof(buffer)-1, pFmt, args);
@ -2885,7 +2885,7 @@ void MicroProfileCompressedWriteSocket(void* Handle, size_t nSize, const char* p
#ifndef MicroProfileSetNonBlocking //fcntl doesnt work on a some unix like platforms.. #ifndef MicroProfileSetNonBlocking //fcntl doesnt work on a some unix like platforms..
void MicroProfileSetNonBlocking(MpSocket Socket, int NonBlocking) void MicroProfileSetNonBlocking(MpSocket Socket, int NonBlocking)
{ {
#ifdef _WIN32 #ifdef _MSC_VER
u_long nonBlocking = NonBlocking ? 1 : 0; u_long nonBlocking = NonBlocking ? 1 : 0;
ioctlsocket(Socket, FIONBIO, &nonBlocking); ioctlsocket(Socket, FIONBIO, &nonBlocking);
#else #else
@ -2904,7 +2904,7 @@ void MicroProfileSetNonBlocking(MpSocket Socket, int NonBlocking)
void MicroProfileWebServerStart() void MicroProfileWebServerStart()
{ {
#ifdef _WIN32 #ifdef _MSC_VER
WSADATA wsa; WSADATA wsa;
if(WSAStartup(MAKEWORD(2, 2), &wsa)) if(WSAStartup(MAKEWORD(2, 2), &wsa))
{ {
@ -2935,7 +2935,7 @@ void MicroProfileWebServerStart()
void MicroProfileWebServerStop() void MicroProfileWebServerStop()
{ {
#ifdef _WIN32 #ifdef _MSC_VER
closesocket(S.ListenerSocket); closesocket(S.ListenerSocket);
WSACleanup(); WSACleanup();
#else #else
@ -3047,7 +3047,7 @@ bool MicroProfileWebServerUpdate()
} }
} }
} }
#ifdef _WIN32 #ifdef _MSC_VER
closesocket(Connection); closesocket(Connection);
#else #else
close(Connection); close(Connection);
@ -3086,7 +3086,7 @@ void MicroProfileStopContextSwitchTrace()
} }
#ifdef _WIN32 #ifdef _MSC_VER
#define INITGUID #define INITGUID
#include <evntrace.h> #include <evntrace.h>
#include <evntcons.h> #include <evntcons.h>
@ -3556,7 +3556,7 @@ int MicroProfileGetGpuTickReference(int64_t* pOutCpu, int64_t* pOutGpu)
#undef S #undef S
#ifdef _WIN32 #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#endif #endif

View File

@ -169,7 +169,7 @@ MICROPROFILEUI_API void MicroProfileCustomGroup(const char* pCustomName, uint32_
MICROPROFILEUI_API void MicroProfileCustomGroupAddTimer(const char* pCustomName, const char* pGroup, const char* pTimer); MICROPROFILEUI_API void MicroProfileCustomGroupAddTimer(const char* pCustomName, const char* pGroup, const char* pTimer);
#ifdef MICROPROFILEUI_IMPL #ifdef MICROPROFILEUI_IMPL
#ifdef _WIN32 #ifdef _MSC_VER
#define snprintf _snprintf #define snprintf _snprintf
#endif #endif
#include <stdio.h> #include <stdio.h>
@ -759,7 +759,7 @@ void MicroProfileDebugDumpRange()
const char* pBegin = type == MP_LOG_LEAVE ? "END" : const char* pBegin = type == MP_LOG_LEAVE ? "END" :
(type == MP_LOG_ENTER ? "BEGIN" : "META"); (type == MP_LOG_ENTER ? "BEGIN" : "META");
snprintf(buffer, 255, "DUMP 0x%p: %s :: %llx: %s\n", pStart, pBegin, nTick, pTimerName); snprintf(buffer, 255, "DUMP 0x%p: %s :: %llx: %s\n", pStart, pBegin, nTick, pTimerName);
#ifdef _WIN32 #ifdef _MSC_VER
OutputDebugString(buffer); OutputDebugString(buffer);
#else #else
printf("%s", buffer); printf("%s", buffer);