// 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
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))
}
#endif
-
-
+#ifndef THROW_WITH_STACKTRACE
+#define THROW_WITH_STACKTRACE(exception) \
+{ \
+ LogStackTrace(); \
+ throw (exception); \
+}
+void LogStackTrace();
+#endif
{
printf("LOCKCONTENTION: %s\n", pszName);
printf("Locker: %s:%d\n", pszFile, nLine);
- }
#endif
lock.lock();
+#ifdef DEBUG_LOCKCONTENTION
+ }
+#endif
}
}
return pszTime;
}
+static const std::string strTimestampFormat = "%Y-%m-%d %H:%M:%S UTC";
+inline std::string DateTimeStrFormat(int64 nTime)
+{
+ return DateTimeStrFormat(strTimestampFormat.c_str(), nTime);
+}
+
template<typename T>
void skipspaces(T& it)
{
// 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 =
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;
}