|
|
|
@ -15,7 +15,7 @@
|
|
|
|
|
#include "Log.h"
|
|
|
|
|
#include "I2PEndian.h"
|
|
|
|
|
|
|
|
|
|
#if not defined (__FreeBSD__)
|
|
|
|
|
#if !defined (__FreeBSD__) && !defined(_MSC_VER)
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -37,6 +37,19 @@
|
|
|
|
|
#include <iphlpapi.h>
|
|
|
|
|
#include <shlobj.h>
|
|
|
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
|
const DWORD MS_VC_EXCEPTION = 0x406D1388;
|
|
|
|
|
#pragma pack(push,8)
|
|
|
|
|
typedef struct tagTHREADNAME_INFO
|
|
|
|
|
{
|
|
|
|
|
DWORD dwType;
|
|
|
|
|
LPCSTR szName;
|
|
|
|
|
DWORD dwThreadID;
|
|
|
|
|
DWORD dwFlags;
|
|
|
|
|
} THREADNAME_INFO;
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
|
|
|
|
|
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
|
|
|
|
|
|
|
|
|
@ -162,7 +175,23 @@ namespace util
|
|
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
|
pthread_setname_np(pthread_self(), "%s", (void *)name);
|
|
|
|
|
#elif !defined(__gnu_hurd__)
|
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
|
THREADNAME_INFO info;
|
|
|
|
|
info.dwType = 0x1000;
|
|
|
|
|
info.szName = name;
|
|
|
|
|
info.dwThreadID = -1;
|
|
|
|
|
info.dwFlags = 0;
|
|
|
|
|
#pragma warning(push)
|
|
|
|
|
#pragma warning(disable: 6320 6322)
|
|
|
|
|
__try {
|
|
|
|
|
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info);
|
|
|
|
|
}
|
|
|
|
|
__except (EXCEPTION_EXECUTE_HANDLER) {
|
|
|
|
|
}
|
|
|
|
|
#pragma warning(pop)
|
|
|
|
|
#else
|
|
|
|
|
pthread_setname_np(pthread_self(), name);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|