aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/util.h b/src/util.h
index f0b2f4a71c..178923727a 100644
--- a/src/util.h
+++ b/src/util.h
@@ -7,7 +7,7 @@
#include "uint256.h"
-#ifndef __WXMSW__
+#ifndef WIN32
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
@@ -81,7 +81,7 @@ T* alignup(T* p)
return u.ptr;
}
-#ifdef __WXMSW__
+#ifdef WIN32
#define MSG_NOSIGNAL 0
#define MSG_DONTWAIT 0
#ifndef UINT64_MAX
@@ -123,7 +123,7 @@ inline int myclosesocket(SOCKET& hSocket)
{
if (hSocket == INVALID_SOCKET)
return WSAENOTSOCK;
-#ifdef __WXMSW__
+#ifdef WIN32
int ret = closesocket(hSocket);
#else
int ret = close(hSocket);
@@ -192,7 +192,7 @@ std::string GetConfigFile();
std::string GetPidFile();
void CreatePidFile(std::string pidFile, pid_t pid);
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
-#ifdef __WXMSW__
+#ifdef WIN32
std::string MyGetSpecialFolderPath(int nFolder, bool fCreate);
#endif
std::string GetDefaultDataDir();
@@ -390,7 +390,7 @@ inline void PrintHex(const std::vector<unsigned char>& vch, const char* pszForma
inline int64 GetPerformanceCounter()
{
int64 nCounter = 0;
-#ifdef __WXMSW__
+#ifdef WIN32
QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
#else
timeval t;
@@ -424,7 +424,7 @@ void skipspaces(T& it)
inline bool IsSwitchChar(char c)
{
-#ifdef __WXMSW__
+#ifdef WIN32
return c == '-' || c == '/';
#else
return c == '-';
@@ -467,7 +467,7 @@ inline bool GetBoolArg(const std::string& strArg)
inline void heapchk()
{
-#ifdef __WXMSW__
+#ifdef WIN32
/// for debugging
//if (_heapchk() != _HEAPOK)
// DebugBreak();
@@ -626,7 +626,7 @@ public:
// Note: It turns out we might have been able to use boost::thread
// by using TerminateThread(boost::thread.native_handle(), 0);
-#ifdef __WXMSW__
+#ifdef WIN32
typedef HANDLE pthread_t;
inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false)
@@ -708,10 +708,10 @@ inline void ExitThread(size_t nExitCode)
inline bool AffinityBugWorkaround(void(*pfn)(void*))
{
-#ifdef __WXMSW__
+#ifdef WIN32
// Sometimes after a few hours affinity gets stuck on one processor
- DWORD dwProcessAffinityMask = -1;
- DWORD dwSystemAffinityMask = -1;
+ DWORD_PTR dwProcessAffinityMask = -1;
+ DWORD_PTR dwSystemAffinityMask = -1;
GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinityMask, &dwSystemAffinityMask);
DWORD dwPrev1 = SetThreadAffinityMask(GetCurrentThread(), dwProcessAffinityMask);
DWORD dwPrev2 = SetThreadAffinityMask(GetCurrentThread(), dwProcessAffinityMask);
@@ -726,4 +726,10 @@ inline bool AffinityBugWorkaround(void(*pfn)(void*))
return false;
}
+inline uint32_t ByteReverse(uint32_t value)
+{
+ value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8);
+ return (value<<16) | (value>>16);
+}
+
#endif