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)
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)

View File

@ -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 <unistd.h>
#include <time.h>
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 <basetsd.h>
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 <windows.h>
#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 <sys/socket.h>
#include <netinet/in.h>
#include <fcntl.h>
@ -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 <evntrace.h>
#include <evntcons.h>
@ -3556,7 +3556,7 @@ int MicroProfileGetGpuTickReference(int64_t* pOutCpu, int64_t* pOutGpu)
#undef S
#ifdef _WIN32
#ifdef _MSC_VER
#pragma warning(pop)
#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);
#ifdef MICROPROFILEUI_IMPL
#ifdef _WIN32
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
#include <stdio.h>
@ -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);