X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Futil.h;h=8c009385a83c9a401abf6b912a4409a20d3fa414;hb=58561410692c520d91def67c36aadf8edd992272;hp=15ccf82f9aaa7f1bfddc64e7b8fdd1bf70f78626;hpb=f0f1b3775e5e0c7939c1131f831ce0334348ac72;p=novacoin.git diff --git a/src/util.h b/src/util.h index 15ccf82..8c00938 100644 --- a/src/util.h +++ b/src/util.h @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers +// Copyright (c) 2012 The PPCoin developers // Distributed under the MIT/X11 software license, see the accompanying -// file license.txt or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_UTIL_H #define BITCOIN_UTIL_H @@ -36,8 +37,8 @@ typedef int pid_t; /* define for windows compatiblity */ typedef long long int64; typedef unsigned long long uint64; -static const int64 COIN = 100000000; -static const int64 CENT = 1000000; +static const int64 COIN = 1000000; +static const int64 CENT = 10000; #define loop for (;;) #define BEGIN(a) ((char*)&(a)) @@ -103,8 +104,14 @@ inline void Sleep(int64 n) } #endif - - +#ifndef THROW_WITH_STACKTRACE +#define THROW_WITH_STACKTRACE(exception) \ +{ \ + LogStackTrace(); \ + throw (exception); \ +} +void LogStackTrace(); +#endif @@ -168,6 +175,7 @@ bool SetStartOnSystemStartup(bool fAutoStart); void ShrinkDebugFile(); int GetRandInt(int nMax); uint64 GetRand(uint64 nMax); +uint256 GetRandHash(); int64 GetTime(); void SetMockTime(int64 nMockTimeIn); int64 GetAdjustedTime(); @@ -217,9 +225,11 @@ public: { printf("LOCKCONTENTION: %s\n", pszName); printf("Locker: %s:%d\n", pszFile, nLine); - } #endif lock.lock(); +#ifdef DEBUG_LOCKCONTENTION + } +#endif } } @@ -440,6 +450,12 @@ inline std::string DateTimeStrFormat(const char* pszFormat, int64 nTime) return pszTime; } +static const std::string strTimestampFormat = "%F %H:%M:%S"; +inline std::string DateTimeStrFormat(int64 nTime) +{ + return DateTimeStrFormat(strTimestampFormat.c_str(), nTime); +} + template void skipspaces(T& it) { @@ -658,9 +674,9 @@ public: // Note: It turns out we might have been able to use boost::thread // by using TerminateThread(boost::thread.native_handle(), 0); #ifdef WIN32 -typedef HANDLE pthread_t; +typedef HANDLE bitcoin_pthread_t; -inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false) +inline bitcoin_pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false) { DWORD nUnused = 0; HANDLE hthread = @@ -674,12 +690,12 @@ inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=fa if (hthread == NULL) { printf("Error: CreateThread() returned %d\n", GetLastError()); - return (pthread_t)0; + return (bitcoin_pthread_t)0; } if (!fWantHandle) { CloseHandle(hthread); - return (pthread_t)-1; + return (bitcoin_pthread_t)-1; } return hthread; }