From d882773789ea3894de7163f7bb880c5b23072882 Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Thu, 8 Jul 2010 16:14:56 +0000 Subject: [PATCH] Laszlo's fix to make generate threads idle priority on Linux, replaced some wxBase dependencies: wxMutex, wxFileExists, wxStandardPaths, wxGetLocalTimeMillis git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@99 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- headers.h | 4 ++ init.cpp | 74 ++++++++++------------------ locale/de/LC_MESSAGES/bitcoin.mo | Bin 16025 -> 16092 bytes locale/de/LC_MESSAGES/bitcoin.po | 4 ++ locale/it/LC_MESSAGES/bitcoin.mo | Bin 15547 -> 15616 bytes locale/it/LC_MESSAGES/bitcoin.po | 4 ++ locale/nl/LC_MESSAGES/bitcoin.mo | Bin 14859 -> 14923 bytes locale/nl/LC_MESSAGES/bitcoin.po | 4 ++ main.cpp | 42 +++++++++------- makefile.unix | 6 +-- rpc.cpp | 22 +++++---- serialize.h | 2 +- uibase.cpp | 2 +- uibase.h | 2 +- uiproject.fbp | 4 +- util.cpp | 80 ++++++++++++++++++++++++++----- util.h | 18 ++++--- 17 files changed, 167 insertions(+), 101 deletions(-) diff --git a/headers.h b/headers.h index 73b09ed57..b53de8245 100644 --- a/headers.h +++ b/headers.h @@ -59,6 +59,10 @@ #include #include #include +#include +#include +#include +#include #ifdef __WXMSW__ #include diff --git a/init.cpp b/init.cpp index b97a2d0c7..4660ccd3b 100644 --- a/init.cpp +++ b/init.cpp @@ -4,6 +4,8 @@ #include "headers.h" +extern string GetDefaultDataDir(); /// todo: delete this later, just used by debug test + @@ -59,40 +61,6 @@ void Shutdown(void* parg) // #ifdef __WXMSW__ -typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate); - -string MyGetSpecialFolderPath(int nFolder, bool fCreate) -{ - char pszPath[MAX_PATH+100] = ""; - - // SHGetSpecialFolderPath is not usually available on NT 4.0 - HMODULE hShell32 = LoadLibraryA("shell32.dll"); - if (hShell32) - { - PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath = - (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA"); - if (pSHGetSpecialFolderPath) - (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate); - FreeModule(hShell32); - } - - // Backup option - if (pszPath[0] == '\0') - { - if (nFolder == CSIDL_STARTUP) - { - strcpy(pszPath, getenv("USERPROFILE")); - strcat(pszPath, "\\Start Menu\\Programs\\Startup"); - } - else if (nFolder == CSIDL_APPDATA) - { - strcpy(pszPath, getenv("APPDATA")); - } - } - - return pszPath; -} - string StartupShortcutPath() { return MyGetSpecialFolderPath(CSIDL_STARTUP, true) + "\\Bitcoin.lnk"; @@ -100,7 +68,7 @@ string StartupShortcutPath() bool GetStartOnSystemStartup() { - return wxFileExists(StartupShortcutPath()); + return filesystem::exists(StartupShortcutPath().c_str()); } void SetStartOnSystemStartup(bool fAutoStart) @@ -166,7 +134,7 @@ void SetStartOnSystemStartup(bool fAutoStart) { } // // Define a new application -class CMyApp: public wxApp +class CMyApp : public wxApp { public: wxLocale m_locale; @@ -216,7 +184,10 @@ bool CMyApp::Initialize(int& argc, wxChar** argv) #ifdef __WXMSW__ if (str.size() >= 1 && str[0] == '/') str[0] = '-'; - str = str.MakeLower(); + char pszLower[MAX_PATH]; + strlcpy(pszLower, str.c_str(), sizeof(pszLower)); + strlwr(pszLower); + str = pszLower; #endif // haven't decided which argument to use for this yet if (str == "-daemon" || str == "-d" || str == "start") @@ -356,18 +327,14 @@ bool CMyApp::OnInit2() " -daemon \t " + _("Run in the background as a daemon and accept commands\n") + " -? \t " + _("This help message\n"); - - if (fWindows && fGUI) - { - // Tabs make the columns line up in the message box - wxMessageBox(strUsage, "Bitcoin", wxOK); - } - else - { - // Remove tabs - strUsage.Replace("\t", ""); - fprintf(stderr, "%s", ((string)strUsage).c_str()); - } +#if defined(__WXMSW__) && wxUSE_GUI + // Tabs make the columns line up in the message box + wxMessageBox(strUsage, "Bitcoin", wxOK); +#else + // Remove tabs + strUsage.Replace("\t", ""); + fprintf(stderr, "%s", ((string)strUsage).c_str()); +#endif return false; } @@ -387,6 +354,15 @@ bool CMyApp::OnInit2() printf("System default language is %d %s\n", m_locale.GetSystemLanguage(), ((string)m_locale.GetSysName()).c_str()); printf("Language file %s (%s)\n", (string("locale/") + (string)m_locale.GetCanonicalName() + "/LC_MESSAGES/bitcoin.mo").c_str(), ((string)m_locale.GetLocale()).c_str()); + /// debug - for now, just watching if these match + if (pszSetDataDir[0] == 0) + { + if (GetDefaultDataDir() != GetDataDir()) + printf("**** GetDefaultDataDir() %s != %s\n", GetDefaultDataDir().c_str(), GetDataDir().c_str()); + else + printf("OK GetDefaultDataDir() %s == %s\n", GetDefaultDataDir().c_str(), GetDataDir().c_str()); + } + if (mapArgs.count("-loadblockindextest")) { CTxDB txdb("r"); diff --git a/locale/de/LC_MESSAGES/bitcoin.mo b/locale/de/LC_MESSAGES/bitcoin.mo index e6c860eec597e780de408131cc2daa60aa144217..d53b22f7b132668a15441870a5b84999063ad360 100644 GIT binary patch delta 2310 zcmYk+e@xVM9LMqZF@A#t96!{+JEfC5C`FB2NjewGvWTVyb*vV%W3u3I9%Lir><_nU zIa?H4;gra&AloP~*=n)eESGJxm7~>FvvhN_2>)vFxHzCf6HU`iPx;y%o+>LQZb6j*o`UJgIRbG`LkEt{$b3f{T}AyDQv-Wn1>Zb zW~EqzD=~~d?8P)ZT4ZsX;o$@w4f=v8Zo{upfn38CIFGkr@lvx4EXN?OL;ftxf2|n9 z$4KZ0R6rY+o3XTQM+Ni*=3pnXr1dS2n=RvEfQ}tFhRS#mSEJ`vCx9TTB6XOK54!C~ zkz_55s?c6c!d_GWaa@A0;X^ot%KT4MA~!TZ3wlbN2s2R;mLR8Mm3S9!!4N)+nK*=+ z_dY7a3Dkn;Q5Cs>8aIpDZ~=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hv#Vp!Cp(^q#DuW==YT61*iFNbHIA94(`3>VjmM;$NQ(g%HN_s)Rv8) z0=|wK_YbO~2^MYA{jcO9N=FA)V>c3<4WR=17bBSYi2uVe9d(}*sBw!i1DB(Iifdi} zGx$91W>n?_sCh;(2h$j5eY?$r1_oGN5$5A+tU{8q-Kc@*P!oNKD)B|vP9qn_enD+r zl&honXJH(RFc)iZ8rGrSYr=%?|4trMk`$^`T^Pb1jNzv^gqLw8rGCAJ#b^&MH~RxW z<5x-@HTqdvy4^#VVR4HbRFuNHK7jKUethY z)KBY2?)xiPNc#rr{)Z`>#+N(Spyp{r-Htt|YnVdKcX+jR-irJ%yN>5~_!RKbzxjOf o^w2q;T@-k$HyFJa2y}J^VoL*W_g2R~3HF8(75TlJ79WZK4+HJ$&Hw-a diff --git a/locale/de/LC_MESSAGES/bitcoin.po b/locale/de/LC_MESSAGES/bitcoin.po index fa3b8a4c1..9d1b6b08c 100644 --- a/locale/de/LC_MESSAGES/bitcoin.po +++ b/locale/de/LC_MESSAGES/bitcoin.po @@ -692,6 +692,8 @@ msgstr "Version" msgid "" "Copyright (c) 2009-2010 Satoshi Nakamoto.\n" "\n" +"This is experimental software.\n" +"\n" "Distributed under the MIT/X11 software license, see the accompanying file \n" "license.txt or http://www.opensource.org/licenses/mit-license.php.\n" "\n" @@ -701,6 +703,8 @@ msgid "" msgstr "" "Copyright (c) 2009-2010 Satoshi Nakamoto.\n" "\n" +"Dies ist experimentelle Software.\n" +"\n" "Lizensiert unter der MIT/X11 Software-Lizenz. Beachten Sie die beiliegende\n" "Datei license.txt oder http://www.opensource.org/licenses/mit-license.php.\n" "\n" diff --git a/locale/it/LC_MESSAGES/bitcoin.mo b/locale/it/LC_MESSAGES/bitcoin.mo index b3160d13582a1ad63a75cb746f42f09619ee2d0d..dc7b94edfafb3cb0b74c8760a21d544c688c92c5 100644 GIT binary patch delta 2312 zcmYM#drZ}39LMqRA-Nra!&SV19lUXX5|D@#W)9O<6OGNJj%!8kI9+gH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BO*&1o{p%%rQo3yo_CiRC=%^_3&xO0)ynblgo5kU=cPWOWEd9*K9h2PA)uyJ*bQ?V#V4C=lMs13)k7_+Fr{_;O}12jmzE=ENfN0p`m^*{rv70;m-Y{8Sb z8AmWgd4_Qef5CnltPMJ6n>~%)xE)9EJ6ys+(0+H3R=egr;$>Rtn?#bgCR70J7{fiN zR`sANbqbZ~7pVI$B1zewsFoE~c&({HRj3h_Kr5;u+wV*NcQVihyYNj8&%3CN!gI{( zu>w_@ji?QGpn9H0_528`6~|C5_yiT;SyVvZqbfL#I>fh7_f2Am{Vm8z(}iNx=`Tes zyaII=o<%L#irT0HmB}uDoMN0)ZlZ3fyfGS{m_ z8O~?E5S4iw>ho7n0lbb{AmxAlHY)I5q^)+&pI<>`>?FL6qp1C6`>ssT|7tF5<$@x7 z54B+*>cP{fjfYS@J&&9_8%Jf5Tjf=v1Xb#C)E80%>JY9*Rc0fG(M46V8})X*Uq$_E z7<}sAa212hf5Q;oM)mw()C19Z-U4$_EvUz}xC(XuVgGs`s)8p_6}gCdt0u6WGZrCh zzFMryqaIX=2T%`wi9BP&sEYi9uVG{%-}x-K4;9$>A}_Q5 zP_JEVv6nzKszob(+i<}S+jxP;0em#FeF;aiIea5*aTMpT8`Fb8*_Uds;D zSxTc?lR;JZR}AAVR6-LNV}G;9yxzu93sm7MT!G3sjS6G{_23XHlW$QAX8rk1EMy+4 z^X`kI0x3tWy8spNQ>cK}VzKsriGfacJ5IrFR7H+r1pDzD{2U!h-N}Clqs({Ld#-uh zD|uomU(;M~#68%9zhhz2>;b%kO6VSzU`+${SC5`#pq_8Q816Rd_%h4f%)dJQdB(^1QxWu|S6us8CRHQx=fnU2 diff --git a/locale/it/LC_MESSAGES/bitcoin.po b/locale/it/LC_MESSAGES/bitcoin.po index 6d6e10f4c..7a267079f 100644 --- a/locale/it/LC_MESSAGES/bitcoin.po +++ b/locale/it/LC_MESSAGES/bitcoin.po @@ -690,6 +690,8 @@ msgstr "versione" msgid "" "Copyright (c) 2009-2010 Satoshi Nakamoto.\n" "\n" +"This is experimental software.\n" +"\n" "Distributed under the MIT/X11 software license, see the accompanying file \n" "license.txt or http://www.opensource.org/licenses/mit-license.php.\n" "\n" @@ -699,6 +701,8 @@ msgid "" msgstr "" "Copyright (c) 2009-2010 Satoshi Nakamoto.\n" "\n" +"Questo รจ un software sperimentale.\n" +"\n" "Distribuito sotto la licenza software MIT/X11, guarda il file license.txt\n" "incluso oppure su http://www.opensource.org/licenses/mit-license.php.\n" "\n" diff --git a/locale/nl/LC_MESSAGES/bitcoin.mo b/locale/nl/LC_MESSAGES/bitcoin.mo index 79f5c83ac2f5ca56387b0c497ae9656cb83ef69c..380eafe929d9182657d220a3d9d4c580a5a28e6c 100644 GIT binary patch delta 2182 zcmY+_e`wTo9LMqZ_vYzsw;wl8_d_>3r*%6^Gp%ionK^UAMXQBBqhyoLy6x7)oj<@I z-!iTrlw)O-4az`+HNl2wNfGWhVdnwiEm&KPhlaRMP9K_u?sI@DK;^< z8ryL$rttbBBQY1W}$=tXVCe$)$Dd>aSxD{N$g zKf^F(`UWSk1&7(_B>sZqxGv@`G@FB_`c`+F%qkNiAwM{)O>*(y~K(!#QGMap#T#2?;fEt zZua||eN(7FG8n{ts6e0c`-e~!dJT0=PookV!zFkHwN8YSu65?1s|gb{beNW)GHSvF zcn|7q>_lZUfU3YKDx)#~`w7$`yoy>V829FBKn2o@x;1N20d}JTeDsP%?WTQOWq{qLl4 ziU%RQ=6~@Q>X3z)T_ud80$Yir9HMqqW&Wm23atEQ@B3=hVOxMI@e2QW8>(^}a3^-7 zD)OC6L#4isi?HSvGd|YApQ*SXCozjH_{c)W;BnN#U!Ve=K$Y|whB1%HXj%z!BW*eE z#)oki34DvXU2gkgFXB$r1Us-8v#1DPMwM^`+i)DUaO5^KVzx45+pQV(JcSCN52xTB zRHdFkZP8&2;G4*nxOS9=UO0pI;utFPQcjY#qymd@E|%i0s1mRAU5_j1_n<0w998;@ zn2+D1{we+J_rpuQ!#opp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kYUBm6 zHdMyF7{)>8Rh*Uo@_Pp<+2b0Hno<&cjL_BYK^h# 4000) + nHashCounter++; + if (GetTimeMillis() - nTimerStart > 4000) { - double dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nLastTick); - nLastTick = GetTimeMillis(); - nHashCounter = 0; - string strStatus = strprintf(" %.0f khash/s", dHashesPerSec/1000.0); - UIThreadCall(bind(CalledSetStatusBar, strStatus, 0)); - static int64 nLogTime; - if (GetTime() - nLogTime > 30 * 60) + static CCriticalSection cs; + CRITICAL_BLOCK(cs) { - nLogTime = GetTime(); - printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str()); - printf("hashmeter %3d CPUs %6.0f khash/s\n", vnThreadsRunning[3], dHashesPerSec/1000.0); + if (GetTimeMillis() - nTimerStart > 4000) + { + double dHashesPerSec = 1000.0 * (nMask+1) * nHashCounter / (GetTimeMillis() - nTimerStart); + nTimerStart = GetTimeMillis(); + nHashCounter = 0; + string strStatus = strprintf(" %.0f khash/s", dHashesPerSec/1000.0); + UIThreadCall(bind(CalledSetStatusBar, strStatus, 0)); + static int64 nLogTime; + if (GetTime() - nLogTime > 30 * 60) + { + nLogTime = GetTime(); + printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str()); + printf("hashmeter %3d CPUs %6.0f khash/s\n", vnThreadsRunning[3], dHashesPerSec/1000.0); + } + } } } diff --git a/makefile.unix b/makefile.unix index b42f1d66f..f6ca110b7 100644 --- a/makefile.unix +++ b/makefile.unix @@ -68,6 +68,6 @@ bitcoind: $(OBJS:obj/%=obj/nogui/%) obj/sha.o clean: - -rm obj/*.o - -rm obj/nogui/*.o - -rm headers.h.gch + -rm -f obj/*.o + -rm -f obj/nogui/*.o + -rm -f headers.h.gch diff --git a/rpc.cpp b/rpc.cpp index a9f16e635..4408d3634 100644 --- a/rpc.cpp +++ b/rpc.cpp @@ -927,20 +927,22 @@ int CommandLineRPC(int argc, char *argv[]) string strResult = (result.type() == str_type ? result.get_str() : write_string(result, true)); if (result.type() != null_type) { - if (fWindows && fGUI) - // Windows GUI apps can't print to command line, - // so settle for a message box yuck - MyMessageBox(strResult.c_str(), "Bitcoin", wxOK); - else - fprintf(stdout, "%s\n", strResult.c_str()); +#if defined(__WXMSW__) && wxUSE_GUI + // Windows GUI apps can't print to command line, + // so settle for a message box yuck + MyMessageBox(strResult.c_str(), "Bitcoin", wxOK); +#else + fprintf(stdout, "%s\n", strResult.c_str()); +#endif } return 0; } catch (std::exception& e) { - if (fWindows && fGUI) - MyMessageBox(strprintf("error: %s\n", e.what()).c_str(), "Bitcoin", wxOK); - else - fprintf(stderr, "error: %s\n", e.what()); +#if defined(__WXMSW__) && wxUSE_GUI + MyMessageBox(strprintf("error: %s\n", e.what()).c_str(), "Bitcoin", wxOK); +#else + fprintf(stderr, "error: %s\n", e.what()); +#endif } catch (...) { PrintException(NULL, "CommandLineRPC()"); } diff --git a/serialize.h b/serialize.h index 57ac5e34b..44eeb233f 100644 --- a/serialize.h +++ b/serialize.h @@ -20,7 +20,7 @@ class CDataStream; class CAutoFile; static const int VERSION = 300; -static const char* pszSubVer = ""; +static const char* pszSubVer = ".1"; diff --git a/uibase.cpp b/uibase.cpp index 7ce498193..4209377d5 100644 --- a/uibase.cpp +++ b/uibase.cpp @@ -554,7 +554,7 @@ CAboutDialogBase::CAboutDialogBase( wxWindow* parent, wxWindowID id, const wxStr bSizer631->Add( 0, 4, 0, wxEXPAND, 5 ); - m_staticTextMain = new wxStaticText( this, wxID_ANY, _("Copyright (c) 2009-2010 Satoshi Nakamoto.\n\nDistributed under the MIT/X11 software license, see the accompanying file \nlicense.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the \nOpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \nEric Young (eay@cryptsoft.com)."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextMain = new wxStaticText( this, wxID_ANY, _("Copyright (c) 2009-2010 Satoshi Nakamoto.\n\nThis is experimental software.\n\nDistributed under the MIT/X11 software license, see the accompanying file \nlicense.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the \nOpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \nEric Young (eay@cryptsoft.com)."), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextMain->Wrap( -1 ); bSizer631->Add( m_staticTextMain, 0, wxALL, 5 ); diff --git a/uibase.h b/uibase.h index 67501cb95..10c438c82 100644 --- a/uibase.h +++ b/uibase.h @@ -227,7 +227,7 @@ class CAboutDialogBase : public wxDialog public: wxStaticText* m_staticTextVersion; - CAboutDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("About Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 532,315 ), long style = wxDEFAULT_DIALOG_STYLE ); + CAboutDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("About Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 532,329 ), long style = wxDEFAULT_DIALOG_STYLE ); ~CAboutDialogBase(); }; diff --git a/uiproject.fbp b/uiproject.fbp index f5d654e13..4753924d9 100644 --- a/uiproject.fbp +++ b/uiproject.fbp @@ -2866,7 +2866,7 @@ CAboutDialogBase - 532,315 + 532,329 wxDEFAULT_DIALOG_STYLE About Bitcoin @@ -3130,7 +3130,7 @@ 0 wxID_ANY - Copyright (c) 2009-2010 Satoshi Nakamoto. Distributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php. This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by Eric Young (eay@cryptsoft.com). + Copyright (c) 2009-2010 Satoshi Nakamoto. This is experimental software. Distributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php. This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by Eric Young (eay@cryptsoft.com). m_staticTextMain diff --git a/util.cpp b/util.cpp index 62ae3b45d..c09419f97 100644 --- a/util.cpp +++ b/util.cpp @@ -20,13 +20,13 @@ bool fCommandLine = false; // Init openssl library multithreading support -static wxMutex** ppmutexOpenSSL; +static boost::interprocess::interprocess_mutex** ppmutexOpenSSL; void locking_callback(int mode, int i, const char* file, int line) { if (mode & CRYPTO_LOCK) - ppmutexOpenSSL[i]->Lock(); + ppmutexOpenSSL[i]->lock(); else - ppmutexOpenSSL[i]->Unlock(); + ppmutexOpenSSL[i]->unlock(); } // Init @@ -36,9 +36,9 @@ public: CInit() { // Init openssl library multithreading support - ppmutexOpenSSL = (wxMutex**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(wxMutex*)); + ppmutexOpenSSL = (boost::interprocess::interprocess_mutex**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(boost::interprocess::interprocess_mutex*)); for (int i = 0; i < CRYPTO_num_locks(); i++) - ppmutexOpenSSL[i] = new wxMutex(); + ppmutexOpenSSL[i] = new boost::interprocess::interprocess_mutex(); CRYPTO_set_locking_callback(locking_callback); #ifdef __WXMSW__ @@ -152,7 +152,7 @@ inline int OutputDebugStringF(const char* pszFormat, ...) if (fileout) { //// Debug print useful for profiling - //fprintf(fileout, " %"PRI64d" ", wxGetLocalTimeMillis().GetValue()); + //fprintf(fileout, " %"PRI64d" ", GetTimeMillis()); va_list arg_ptr; va_start(arg_ptr, pszFormat); ret = vfprintf(fileout, pszFormat, arg_ptr); @@ -521,6 +521,69 @@ void PrintException(std::exception* pex, const char* pszThread) +#ifdef __WXMSW__ +typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate); + +string MyGetSpecialFolderPath(int nFolder, bool fCreate) +{ + char pszPath[MAX_PATH+100] = ""; + + // SHGetSpecialFolderPath isn't always available on old Windows versions + HMODULE hShell32 = LoadLibraryA("shell32.dll"); + if (hShell32) + { + PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath = + (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA"); + if (pSHGetSpecialFolderPath) + (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate); + FreeModule(hShell32); + } + + // Backup option + if (pszPath[0] == '\0') + { + if (nFolder == CSIDL_STARTUP) + { + strcpy(pszPath, getenv("USERPROFILE")); + strcat(pszPath, "\\Start Menu\\Programs\\Startup"); + } + else if (nFolder == CSIDL_APPDATA) + { + strcpy(pszPath, getenv("APPDATA")); + } + } + + return pszPath; +} +#endif + +string GetDefaultDataDir() +{ + // Windows: C:\Documents and Settings\username\Application Data\Appname + // Mac: ~/Library/Application Support/Appname + // Unix: ~/.appname +#ifdef __WXMSW__ + // Windows + return MyGetSpecialFolderPath(CSIDL_APPDATA, true) + "\\Bitcoin"; +#else + char* pszHome = getenv("HOME"); + if (pszHome == NULL || strlen(pszHome) == 0) + pszHome = (char*)"/"; + string strHome = pszHome; + if (strHome[strHome.size()-1] != '/') + strHome += '/'; +#ifdef __WXOSX__ + // Mac + strHome += "Library/Application Support/"; + _mkdir(strHome.c_str()); + return strHome + "Bitcoin"; +#else + // Unix + return strHome + ".bitcoin"; +#endif +#endif +} + void GetDataDir(char* pszDir) { // pszDir must be at least MAX_PATH length. @@ -538,11 +601,6 @@ void GetDataDir(char* pszDir) { // This can be called during exceptions by printf, so we cache the // value so we don't have to do memory allocations after that. - // wxStandardPaths::GetUserDataDir - // Return the directory for the user-dependent application data files: - // Unix: ~/.appname - // Windows: C:\Documents and Settings\username\Application Data\appname - // Mac: ~/Library/Application Support/appname static char pszCachedDir[MAX_PATH]; if (pszCachedDir[0] == 0) { diff --git a/util.h b/util.h index 40d46bc17..e92204f22 100644 --- a/util.h +++ b/util.h @@ -141,6 +141,9 @@ void ParseParameters(int argc, char* argv[]); const char* wxGetTranslation(const char* psz); int GetFilesize(FILE* file); void GetDataDir(char* pszDirRet); +#ifdef __WXMSW__ +string MyGetSpecialFolderPath(int nFolder, bool fCreate); +#endif string GetDataDir(); void ShrinkDebugFile(); uint64 GetRand(uint64 nMax); @@ -174,13 +177,13 @@ public: bool TryEnter() { return TryEnterCriticalSection(&cs); } #else protected: - wxMutex mutex; + boost::interprocess::interprocess_recursive_mutex mutex; public: - explicit CCriticalSection() : mutex(wxMUTEX_RECURSIVE) { } + explicit CCriticalSection() { } ~CCriticalSection() { } - void Enter() { mutex.Lock(); } - void Leave() { mutex.Unlock(); } - bool TryEnter() { return mutex.TryLock() == wxMUTEX_NO_ERROR; } + void Enter() { mutex.lock(); } + void Leave() { mutex.unlock(); } + bool TryEnter() { return mutex.try_lock(); } #endif public: const char* pszFile; @@ -324,7 +327,8 @@ inline int64 PerformanceCounter() inline int64 GetTimeMillis() { - return wxGetLocalTimeMillis().GetValue(); + return (posix_time::ptime(posix_time::microsec_clock::universal_time()) - + posix_time::ptime(gregorian::date(1970,1,1))).total_milliseconds(); } inline string DateTimeStrFormat(const char* pszFormat, int64 nTime) @@ -513,7 +517,7 @@ inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=fa return hthread; } -#define THREAD_PRIORITY_LOWEST PRIO_MIN +#define THREAD_PRIORITY_LOWEST PRIO_MAX #define THREAD_PRIORITY_BELOW_NORMAL 2 #define THREAD_PRIORITY_NORMAL 0 #define THREAD_PRIORITY_ABOVE_NORMAL 0