From e4c05d31778a85014b2a52e2f20753b38dfbf950 Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Thu, 5 Nov 2009 04:41:36 +0000 Subject: unix build merged in, bitmap resources from xpm instead of rc, better addr relay, better selection of addrs by time last seen for faster connect git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@32 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- util.h | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'util.h') diff --git a/util.h b/util.h index 822a049ce7..3bc7c798a5 100644 --- a/util.h +++ b/util.h @@ -55,9 +55,34 @@ inline T& REF(const T& val) } #ifndef __WXMSW__ -#define closesocket(s) close(s) -#define INVALID_SOCKET (SOCKET)(~0) +#define _UI64_MAX UINT64_MAX +#define _I64_MAX INT64_MAX +#define WSAGetLastError() errno +#define WSAEWOULDBLOCK EWOULDBLOCK +#define WSAEMSGSIZE EMSGSIZE +#define WSAEINTR EINTR +#define WSAEINPROGRESS EINPROGRESS +#define WSAEADDRINUSE EADDRINUSE +#define closesocket(s) close(s) +#define INVALID_SOCKET (SOCKET)(~0) +#define SOCKET_ERROR -1 typedef u_int SOCKET; +#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d) +#define strlwr(psz) to_lower(psz) +#define _strlwr(psz) to_lower(psz) +#define _mkdir(psz) filesystem::create_directory(psz) +#define MAX_PATH 1024 +#define Sleep(n) wxMilliSleep(n) +#define Beep(n1,n2) (0) +inline int _beginthread(void(*pfn)(void*), unsigned nStack, void* parg) { thread(bind(pfn, parg)); return 0; } +inline void _endthread() { pthread_exit(NULL); } +inline int GetCurrentThread() { return 0; } +// threads are processes on linux, so setpriority affects just the one thread +inline void SetThreadPriority(int nThread, int nPriority) { setpriority(PRIO_PROCESS, getpid(), nPriority); } +#define THREAD_PRIORITY_LOWEST PRIO_MIN +#define THREAD_PRIORITY_BELOW_NORMAL 2 +#define THREAD_PRIORITY_NORMAL 0 +#define THREAD_PRIORITY_ABOVE_NORMAL 0 #endif @@ -120,7 +145,7 @@ public: protected: wxMutex mutex; public: - explicit CCriticalSection() { } + explicit CCriticalSection() : mutex(wxMUTEX_RECURSIVE) { } ~CCriticalSection() { } void Enter() { mutex.Lock(); } void Leave() { mutex.Unlock(); } @@ -183,7 +208,7 @@ inline int OutputDebugStringF(const char* pszFormat, ...) // print to debug.log char pszFile[MAX_PATH+100]; GetDataDir(pszFile); - strlcat(pszFile, "\\debug.log", sizeof(pszFile)); + strlcat(pszFile, "/debug.log", sizeof(pszFile)); FILE* fileout = fopen(pszFile, "a"); if (fileout) { @@ -354,13 +379,6 @@ inline int64 GetTimeMillis() return wxGetLocalTimeMillis().GetValue(); } -#ifndef __WXMSW__ -inline void Sleep(unsigned int nMilliseconds) -{ - wxMilliSleep(nMilliseconds); -} -#endif - -- cgit v1.2.3