aboutsummaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-10-29 20:10:46 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-10-29 20:10:46 +0000
commite8474beb6f2c5e2654f8ebc671b3dbf5fae78563 (patch)
tree31faa0f74ff1541946f6d0d5d8764be8e2564a66 /util.h
parentdc73b326f97f2ed7ec7b7e8485ebc9eb46e05ddb (diff)
downloadbitcoin-e8474beb6f2c5e2654f8ebc671b3dbf5fae78563.tar.xz
better wallet.dat flush, consolidated QueryPerformanceCounter, PRI64d printf portability
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@20 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'util.h')
-rw-r--r--util.h43
1 files changed, 26 insertions, 17 deletions
diff --git a/util.h b/util.h
index 436281c90a..1c7215d29d 100644
--- a/util.h
+++ b/util.h
@@ -13,7 +13,6 @@ typedef unsigned long long uint64;
#if defined(_MSC_VER) && _MSC_VER < 1300
#define for if (false) ; else for
#endif
-
#ifndef _MSC_VER
#define __forceinline inline
#endif
@@ -25,25 +24,22 @@ typedef unsigned long long uint64;
#define UBEGIN(a) ((unsigned char*)&(a))
#define UEND(a) ((unsigned char*)&((&(a))[1]))
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
-
-#ifdef _WINDOWS
#define printf OutputDebugStringF
-#endif
#ifdef snprintf
#undef snprintf
#endif
#define snprintf my_snprintf
-#ifndef PRId64
+#ifndef PRI64d
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MSVCRT__)
-#define PRId64 "I64d"
-#define PRIu64 "I64u"
-#define PRIx64 "I64x"
+#define PRI64d "I64d"
+#define PRI64u "I64u"
+#define PRI64x "I64x"
#else
-#define PRId64 "lld"
-#define PRIu64 "llu"
-#define PRIx64 "llx"
+#define PRI64d "lld"
+#define PRI64u "llu"
+#define PRI64x "llx"
#endif
#endif
@@ -64,8 +60,6 @@ inline T& REF(const T& val)
-
-
extern bool fDebug;
extern bool fPrintToDebugger;
extern bool fPrintToConsole;
@@ -101,9 +95,7 @@ void AddTimeData(unsigned int ip, int64 nTime);
-
-// Wrapper to automatically initialize critical section
-// Could use wxCriticalSection for portability, but it doesn't support TryEnterCriticalSection
+// Wrapper to automatically initialize critical sections
class CCriticalSection
{
#ifdef __WXMSW__
@@ -191,6 +183,7 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
}
}
+#ifdef __WXMSW__
if (fPrintToDebugger)
{
// accumulate a line at a time
@@ -231,6 +224,7 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
}
}
#endif
+#endif
if (fPrintToConsole)
{
@@ -254,7 +248,7 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
inline string i64tostr(int64 n)
{
- return strprintf("%"PRId64, n);
+ return strprintf("%"PRI64d, n);
}
inline string itostr(int n)
@@ -328,6 +322,20 @@ inline void PrintHex(vector<unsigned char> vch, const char* pszFormat="%s", bool
printf(pszFormat, HexStr(vch, fSpaces).c_str());
}
+inline int64 PerformanceCounter()
+{
+ int64 nCounter = 0;
+ QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
+ return nCounter;
+}
+
+#ifndef __WXMSW__
+inline void Sleep(unsigned int nMilliseconds)
+{
+ wxMilliSleep(nMilliseconds);
+}
+#endif
+
@@ -370,6 +378,7 @@ inline void heapchk()
+
template<typename T1>
inline uint256 Hash(const T1 pbegin, const T1 pend)
{