From b391d5bb96a9a6c3ea3d1c116543f7a2854ccf22 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 20 Jan 2017 16:24:20 -0500 Subject: [PATCH] Fixed Microprofile on Mingw --- CMakeLists.txt | 2 -- externals/microprofile/microprofile.h | 32 ++++++++++++------------- externals/microprofile/microprofileui.h | 4 ++-- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52a1fd492..d025a8b22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,8 +72,6 @@ if (NOT MSVC) if (MINGW) add_definitions(-DMINGW_HAS_SECURE_API) - # Microprofile causes crashes when launching titles on MinGW - add_definitions(-DMICROPROFILE_ENABLED=0) if (MINGW_STATIC_BUILD) add_definitions(-DQT_STATICPLUGIN) diff --git a/externals/microprofile/microprofile.h b/externals/microprofile/microprofile.h index f45c9ba82..51dc4d6e0 100644 --- a/externals/microprofile/microprofile.h +++ b/externals/microprofile/microprofile.h @@ -197,7 +197,7 @@ inline uint64_t MicroProfileGetCurrentThreadId() #define MP_STRCASECMP strcasecmp #define MP_GETCURRENTTHREADID() MicroProfileGetCurrentThreadId() typedef uint64_t ThreadIdType; -#elif defined(_WIN32) +#elif defined(_MSC_VER) int64_t MicroProfileGetTick(); #define MP_TICK() MicroProfileGetTick() #define MP_BREAK() __debugbreak() @@ -206,7 +206,7 @@ int64_t MicroProfileGetTick(); #define MP_GETCURRENTTHREADID() GetCurrentThreadId() typedef uint32_t ThreadIdType; -#elif !defined(_WIN32) +#elif !defined(_MSC_VER) #include #include inline int64_t MicroProfileTicksPerSecondCpu() @@ -483,7 +483,7 @@ struct MicroProfileScopeGpuHandler #ifndef MICROPROFILE_CONTEXT_SWITCH_TRACE -#if defined(_WIN32) +#if defined(_MSC_VER) #define MICROPROFILE_CONTEXT_SWITCH_TRACE 1 #elif defined(__APPLE__) #define MICROPROFILE_CONTEXT_SWITCH_TRACE 0 //disabled until dtrace script is working. @@ -502,7 +502,7 @@ struct MicroProfileScopeGpuHandler #define MICROPROFILE_MINIZ 0 #endif -#ifdef _WIN32 +#ifdef _MSC_VER #include typedef UINT_PTR MpSocket; #else @@ -510,7 +510,7 @@ typedef int MpSocket; #endif -#ifndef _WIN32 +#ifndef _MSC_VER typedef pthread_t MicroProfileThread; #elif defined(_MSC_VER) typedef HANDLE MicroProfileThread; @@ -878,7 +878,7 @@ inline uint16_t MicroProfileGetGroupIndex(MicroProfileToken t) #ifdef MICROPROFILE_IMPL -#ifdef _WIN32 +#ifdef _MSC_VER #include #define snprintf _snprintf @@ -907,7 +907,7 @@ int64_t MicroProfileGetTick() typedef void* (*MicroProfileThreadFunc)(void*); -#ifndef _WIN32 +#ifndef _MSC_VER typedef pthread_t MicroProfileThread; void MicroProfileThreadStart(MicroProfileThread* pThread, MicroProfileThreadFunc Func) { @@ -955,11 +955,11 @@ inline void MicroProfileThreadJoin(MicroProfileThread* pThread) #if MICROPROFILE_WEBSERVER -#ifdef _WIN32 +#ifdef _MSC_VER #define MP_INVALID_SOCKET(f) (f == INVALID_SOCKET) #endif -#ifndef _WIN32 +#ifndef _MSC_VER #include #include #include @@ -2142,7 +2142,7 @@ void MicroProfilePrintf(MicroProfileWriteCallback CB, void* Handle, const char* char buffer[32*1024]; va_list args; va_start (args, pFmt); -#ifdef _WIN32 +#ifdef _MSC_VER size_t size = vsprintf_s(buffer, pFmt, args); #else 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.. void MicroProfileSetNonBlocking(MpSocket Socket, int NonBlocking) { -#ifdef _WIN32 +#ifdef _MSC_VER u_long nonBlocking = NonBlocking ? 1 : 0; ioctlsocket(Socket, FIONBIO, &nonBlocking); #else @@ -2904,7 +2904,7 @@ void MicroProfileSetNonBlocking(MpSocket Socket, int NonBlocking) void MicroProfileWebServerStart() { -#ifdef _WIN32 +#ifdef _MSC_VER WSADATA wsa; if(WSAStartup(MAKEWORD(2, 2), &wsa)) { @@ -2935,7 +2935,7 @@ void MicroProfileWebServerStart() void MicroProfileWebServerStop() { -#ifdef _WIN32 +#ifdef _MSC_VER closesocket(S.ListenerSocket); WSACleanup(); #else @@ -3047,7 +3047,7 @@ bool MicroProfileWebServerUpdate() } } } -#ifdef _WIN32 +#ifdef _MSC_VER closesocket(Connection); #else close(Connection); @@ -3086,7 +3086,7 @@ void MicroProfileStopContextSwitchTrace() } -#ifdef _WIN32 +#ifdef _MSC_VER #define INITGUID #include #include @@ -3556,7 +3556,7 @@ int MicroProfileGetGpuTickReference(int64_t* pOutCpu, int64_t* pOutGpu) #undef S -#ifdef _WIN32 +#ifdef _MSC_VER #pragma warning(pop) #endif diff --git a/externals/microprofile/microprofileui.h b/externals/microprofile/microprofileui.h index 66a73abc5..b9bc6845b 100644 --- a/externals/microprofile/microprofileui.h +++ b/externals/microprofile/microprofileui.h @@ -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); #ifdef MICROPROFILEUI_IMPL -#ifdef _WIN32 +#ifdef _MSC_VER #define snprintf _snprintf #endif #include @@ -759,7 +759,7 @@ void MicroProfileDebugDumpRange() const char* pBegin = type == MP_LOG_LEAVE ? "END" : (type == MP_LOG_ENTER ? "BEGIN" : "META"); snprintf(buffer, 255, "DUMP 0x%p: %s :: %llx: %s\n", pStart, pBegin, nTick, pTimerName); -#ifdef _WIN32 +#ifdef _MSC_VER OutputDebugString(buffer); #else printf("%s", buffer);