extern bool fRequestShutdown;
extern bool fShutdown;
extern bool fDaemon;
+extern bool fServer;
extern bool fCommandLine;
extern string strMiscWarning;
+extern bool fTestNet;
+extern bool fNoListen;
+extern bool fLogTimestamps;
void RandAddSeed();
void RandAddSeedPerfmon();
return nDefault;
}
+inline bool GetBoolArg(const string& strArg)
+{
+ if (mapArgs.count(strArg))
+ {
+ if (mapArgs[strArg].empty())
+ return true;
+ return (atoi(mapArgs[strArg]) != 0);
+ }
+ return false;
+}
+
+inline string FormatVersion(int nVersion)
+{
+ if (nVersion%100 == 0)
+ return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100);
+ else
+ return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100);
+}
+
pthread_exit((void*)nExitCode);
}
#endif
+
+
+
+
+
+inline bool AffinityBugWorkaround(void(*pfn)(void*))
+{
+#ifdef __WXMSW__
+ // Sometimes after a few hours affinity gets stuck on one processor
+ DWORD dwProcessAffinityMask = -1;
+ DWORD dwSystemAffinityMask = -1;
+ GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinityMask, &dwSystemAffinityMask);
+ DWORD dwPrev1 = SetThreadAffinityMask(GetCurrentThread(), dwProcessAffinityMask);
+ DWORD dwPrev2 = SetThreadAffinityMask(GetCurrentThread(), dwProcessAffinityMask);
+ if (dwPrev2 != dwProcessAffinityMask)
+ {
+ printf("AffinityBugWorkaround() : SetThreadAffinityMask=%d, ProcessAffinityMask=%d, restarting thread\n", dwPrev2, dwProcessAffinityMask);
+ if (!CreateThread(pfn, NULL))
+ printf("Error: CreateThread() failed\n");
+ return true;
+ }
+#endif
+ return false;
+}