Laszlo's fix to make generate threads idle priority on Linux,
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>
Thu, 8 Jul 2010 16:14:56 +0000 (16:14 +0000)
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>
Thu, 8 Jul 2010 16:14:56 +0000 (16:14 +0000)
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

17 files changed:
headers.h
init.cpp
locale/de/LC_MESSAGES/bitcoin.mo
locale/de/LC_MESSAGES/bitcoin.po
locale/it/LC_MESSAGES/bitcoin.mo
locale/it/LC_MESSAGES/bitcoin.po
locale/nl/LC_MESSAGES/bitcoin.mo
locale/nl/LC_MESSAGES/bitcoin.po
main.cpp
makefile.unix
rpc.cpp
serialize.h
uibase.cpp
uibase.h
uiproject.fbp
util.cpp
util.h

index 73b09ed..b53de82 100644 (file)
--- a/headers.h
+++ b/headers.h
 #include <boost/function.hpp>\r
 #include <boost/filesystem.hpp>\r
 #include <boost/algorithm/string.hpp>\r
+#include <boost/interprocess/sync/interprocess_mutex.hpp>\r
+#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>\r
+#include <boost/date_time/gregorian/gregorian_types.hpp>\r
+#include <boost/date_time/posix_time/posix_time_types.hpp>\r
 \r
 #ifdef __WXMSW__\r
 #include <windows.h>\r
index b97a2d0..4660ccd 100644 (file)
--- a/init.cpp
+++ b/init.cpp
@@ -4,6 +4,8 @@
 \r
 #include "headers.h"\r
 \r
+extern string GetDefaultDataDir(); /// todo: delete this later, just used by debug test\r
+\r
 \r
 \r
 \r
@@ -59,40 +61,6 @@ void Shutdown(void* parg)
 //\r
 \r
 #ifdef __WXMSW__\r
-typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);\r
-\r
-string MyGetSpecialFolderPath(int nFolder, bool fCreate)\r
-{\r
-    char pszPath[MAX_PATH+100] = "";\r
-\r
-    // SHGetSpecialFolderPath is not usually available on NT 4.0\r
-    HMODULE hShell32 = LoadLibraryA("shell32.dll");\r
-    if (hShell32)\r
-    {\r
-        PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath =\r
-            (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA");\r
-        if (pSHGetSpecialFolderPath)\r
-            (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate);\r
-        FreeModule(hShell32);\r
-    }\r
-\r
-    // Backup option\r
-    if (pszPath[0] == '\0')\r
-    {\r
-        if (nFolder == CSIDL_STARTUP)\r
-        {\r
-            strcpy(pszPath, getenv("USERPROFILE"));\r
-            strcat(pszPath, "\\Start Menu\\Programs\\Startup");\r
-        }\r
-        else if (nFolder == CSIDL_APPDATA)\r
-        {\r
-            strcpy(pszPath, getenv("APPDATA"));\r
-        }\r
-    }\r
-\r
-    return pszPath;\r
-}\r
-\r
 string StartupShortcutPath()\r
 {\r
     return MyGetSpecialFolderPath(CSIDL_STARTUP, true) + "\\Bitcoin.lnk";\r
@@ -100,7 +68,7 @@ string StartupShortcutPath()
 \r
 bool GetStartOnSystemStartup()\r
 {\r
-    return wxFileExists(StartupShortcutPath());\r
+    return filesystem::exists(StartupShortcutPath().c_str());\r
 }\r
 \r
 void SetStartOnSystemStartup(bool fAutoStart)\r
@@ -166,7 +134,7 @@ void SetStartOnSystemStartup(bool fAutoStart) { }
 //\r
 \r
 // Define a new application\r
-class CMyApp: public wxApp\r
+class CMyApp : public wxApp\r
 {\r
 public:\r
     wxLocale m_locale;\r
@@ -216,7 +184,10 @@ bool CMyApp::Initialize(int& argc, wxChar** argv)
             #ifdef __WXMSW__\r
             if (str.size() >= 1 && str[0] == '/')\r
                 str[0] = '-';\r
-            str = str.MakeLower();\r
+            char pszLower[MAX_PATH];\r
+            strlcpy(pszLower, str.c_str(), sizeof(pszLower));\r
+            strlwr(pszLower);\r
+            str = pszLower;\r
             #endif\r
             // haven't decided which argument to use for this yet\r
             if (str == "-daemon" || str == "-d" || str == "start")\r
@@ -356,18 +327,14 @@ bool CMyApp::OnInit2()
             "  -daemon         \t  " + _("Run in the background as a daemon and accept commands\n") +\r
             "  -?              \t  " + _("This help message\n");\r
 \r
-\r
-        if (fWindows && fGUI)\r
-        {\r
-            // Tabs make the columns line up in the message box\r
-            wxMessageBox(strUsage, "Bitcoin", wxOK);\r
-        }\r
-        else\r
-        {\r
-            // Remove tabs\r
-            strUsage.Replace("\t", "");\r
-            fprintf(stderr, "%s", ((string)strUsage).c_str());\r
-        }\r
+#if defined(__WXMSW__) && wxUSE_GUI\r
+        // Tabs make the columns line up in the message box\r
+        wxMessageBox(strUsage, "Bitcoin", wxOK);\r
+#else\r
+        // Remove tabs\r
+        strUsage.Replace("\t", "");\r
+        fprintf(stderr, "%s", ((string)strUsage).c_str());\r
+#endif\r
         return false;\r
     }\r
 \r
@@ -387,6 +354,15 @@ bool CMyApp::OnInit2()
     printf("System default language is %d %s\n", m_locale.GetSystemLanguage(), ((string)m_locale.GetSysName()).c_str());\r
     printf("Language file %s (%s)\n", (string("locale/") + (string)m_locale.GetCanonicalName() + "/LC_MESSAGES/bitcoin.mo").c_str(), ((string)m_locale.GetLocale()).c_str());\r
 \r
+        /// debug - for now, just watching if these match\r
+        if (pszSetDataDir[0] == 0)\r
+        {\r
+            if (GetDefaultDataDir() != GetDataDir())\r
+                printf("**** GetDefaultDataDir() %s != %s\n", GetDefaultDataDir().c_str(), GetDataDir().c_str());\r
+            else\r
+                printf("OK GetDefaultDataDir() %s == %s\n", GetDefaultDataDir().c_str(), GetDataDir().c_str());\r
+        }\r
+\r
     if (mapArgs.count("-loadblockindextest"))\r
     {\r
         CTxDB txdb("r");\r
index e6c860e..d53b22f 100644 (file)
Binary files a/locale/de/LC_MESSAGES/bitcoin.mo and b/locale/de/LC_MESSAGES/bitcoin.mo differ
index fa3b8a4..9d1b6b0 100644 (file)
@@ -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"
index b3160d1..dc7b94e 100644 (file)
Binary files a/locale/it/LC_MESSAGES/bitcoin.mo and b/locale/it/LC_MESSAGES/bitcoin.mo differ
index 6d6e10f..7a26707 100644 (file)
@@ -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"
index 79f5c83..380eafe 100644 (file)
Binary files a/locale/nl/LC_MESSAGES/bitcoin.mo and b/locale/nl/LC_MESSAGES/bitcoin.mo differ
index 643dc30..c97d7d6 100644 (file)
@@ -691,6 +691,8 @@ msgstr "versie"
 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"
@@ -700,6 +702,8 @@ msgid ""
 msgstr ""
 "Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
 "\n"
+"Dit is experimentele software.\n"
+"\n"
 "Gedistributeerd onder de MIT/X11 software licentie, see het bijbehorende bestand \n"
 "license.txt of http://www.opensource.org/licenses/mit-license.php.\n"
 "\n"
index 2b08744..803548e 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -1477,7 +1477,10 @@ bool CheckDiskSpace(int64 nAdditionalBytes)
     if (nFreeBytesAvailable < (int64)15000000 + nAdditionalBytes)\r
     {\r
         fShutdown = true;\r
+        printf("***  %s***\n", _("Warning: Disk space is low  "));\r
+#if wxUSE_GUI\r
         ThreadSafeMessageBox(_("Warning: Disk space is low  "), "Bitcoin", wxOK | wxICON_EXCLAMATION);\r
+#endif\r
         CreateThread(Shutdown, NULL);\r
         return false;\r
     }\r
@@ -2713,25 +2716,32 @@ void BitcoinMiner()
             if ((++tmp.block.nNonce & nMask) == 0)\r
             {\r
                 // Meter hashes/sec\r
-                static int64 nHashCounter;\r
-                static int64 nLastTick;\r
-                if (nLastTick == 0)\r
-                    nLastTick = GetTimeMillis();\r
+                static int64 nTimerStart;\r
+                static int nHashCounter;\r
+                if (nTimerStart == 0)\r
+                    nTimerStart = GetTimeMillis();\r
                 else\r
-                    nHashCounter += nMask + 1;\r
-                if (GetTimeMillis() - nLastTick > 4000)\r
+                    nHashCounter++;\r
+                if (GetTimeMillis() - nTimerStart > 4000)\r
                 {\r
-                    double dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nLastTick);\r
-                    nLastTick = GetTimeMillis();\r
-                    nHashCounter = 0;\r
-                    string strStatus = strprintf("    %.0f khash/s", dHashesPerSec/1000.0);\r
-                    UIThreadCall(bind(CalledSetStatusBar, strStatus, 0));\r
-                    static int64 nLogTime;\r
-                    if (GetTime() - nLogTime > 30 * 60)\r
+                    static CCriticalSection cs;\r
+                    CRITICAL_BLOCK(cs)\r
                     {\r
-                        nLogTime = GetTime();\r
-                        printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str());\r
-                        printf("hashmeter %3d CPUs %6.0f khash/s\n", vnThreadsRunning[3], dHashesPerSec/1000.0);\r
+                        if (GetTimeMillis() - nTimerStart > 4000)\r
+                        {\r
+                            double dHashesPerSec = 1000.0 * (nMask+1) * nHashCounter / (GetTimeMillis() - nTimerStart);\r
+                            nTimerStart = GetTimeMillis();\r
+                            nHashCounter = 0;\r
+                            string strStatus = strprintf("    %.0f khash/s", dHashesPerSec/1000.0);\r
+                            UIThreadCall(bind(CalledSetStatusBar, strStatus, 0));\r
+                            static int64 nLogTime;\r
+                            if (GetTime() - nLogTime > 30 * 60)\r
+                            {\r
+                                nLogTime = GetTime();\r
+                                printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str());\r
+                                printf("hashmeter %3d CPUs %6.0f khash/s\n", vnThreadsRunning[3], dHashesPerSec/1000.0);\r
+                            }\r
+                        }\r
                     }\r
                 }\r
 \r
index b42f1d6..f6ca110 100644 (file)
@@ -68,6 +68,6 @@ bitcoind: $(OBJS:obj/%=obj/nogui/%) obj/sha.o
 \r
 \r
 clean:\r
-       -rm obj/*.o\r
-       -rm obj/nogui/*.o\r
-       -rm headers.h.gch\r
+       -rm -f obj/*.o\r
+       -rm -f obj/nogui/*.o\r
+       -rm -f headers.h.gch\r
diff --git a/rpc.cpp b/rpc.cpp
index a9f16e6..4408d36 100644 (file)
--- 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));\r
         if (result.type() != null_type)\r
         {\r
-            if (fWindows && fGUI)\r
-                // Windows GUI apps can't print to command line,\r
-                // so settle for a message box yuck\r
-                MyMessageBox(strResult.c_str(), "Bitcoin", wxOK);\r
-            else\r
-                fprintf(stdout, "%s\n", strResult.c_str());\r
+#if defined(__WXMSW__) && wxUSE_GUI\r
+            // Windows GUI apps can't print to command line,\r
+            // so settle for a message box yuck\r
+            MyMessageBox(strResult.c_str(), "Bitcoin", wxOK);\r
+#else\r
+            fprintf(stdout, "%s\n", strResult.c_str());\r
+#endif\r
         }\r
         return 0;\r
     }\r
     catch (std::exception& e) {\r
-        if (fWindows && fGUI)\r
-            MyMessageBox(strprintf("error: %s\n", e.what()).c_str(), "Bitcoin", wxOK);\r
-        else\r
-            fprintf(stderr, "error: %s\n", e.what());\r
+#if defined(__WXMSW__) && wxUSE_GUI\r
+        MyMessageBox(strprintf("error: %s\n", e.what()).c_str(), "Bitcoin", wxOK);\r
+#else\r
+        fprintf(stderr, "error: %s\n", e.what());\r
+#endif\r
     } catch (...) {\r
         PrintException(NULL, "CommandLineRPC()");\r
     }\r
index 57ac5e3..44eeb23 100644 (file)
@@ -20,7 +20,7 @@ class CDataStream;
 class CAutoFile;\r
 \r
 static const int VERSION = 300;\r
-static const char* pszSubVer = "";\r
+static const char* pszSubVer = ".1";\r
 \r
 \r
 \r
index 7ce4981..4209377 100644 (file)
@@ -554,7 +554,7 @@ CAboutDialogBase::CAboutDialogBase( wxWindow* parent, wxWindowID id, const wxStr
        \r
        bSizer631->Add( 0, 4, 0, wxEXPAND, 5 );\r
        \r
-       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 );\r
+       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 );\r
        m_staticTextMain->Wrap( -1 );\r
        bSizer631->Add( m_staticTextMain, 0, wxALL, 5 );\r
        \r
index 67501cb..10c438c 100644 (file)
--- a/uibase.h
+++ b/uibase.h
@@ -227,7 +227,7 @@ class CAboutDialogBase : public wxDialog
        \r
        public:\r
                wxStaticText* m_staticTextVersion;\r
-               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 );\r
+               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 );\r
                ~CAboutDialogBase();\r
        \r
 };\r
index f5d654e..4753924 100644 (file)
             <property name="minimum_size"></property>\r
             <property name="name">CAboutDialogBase</property>\r
             <property name="pos"></property>\r
-            <property name="size">532,315</property>\r
+            <property name="size">532,329</property>\r
             <property name="style">wxDEFAULT_DIALOG_STYLE</property>\r
             <property name="subclass"></property>\r
             <property name="title">About Bitcoin</property>\r
                                                 <property name="font"></property>\r
                                                 <property name="hidden">0</property>\r
                                                 <property name="id">wxID_ANY</property>\r
-                                                <property name="label">Copyright (c) 2009-2010 Satoshi Nakamoto.&#x0A;&#x0A;Distributed under the MIT/X11 software license, see the accompanying file &#x0A;license.txt or http://www.opensource.org/licenses/mit-license.php.&#x0A;&#x0A;This product includes software developed by the OpenSSL Project for use in the &#x0A;OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by &#x0A;Eric Young (eay@cryptsoft.com).</property>\r
+                                                <property name="label">Copyright (c) 2009-2010 Satoshi Nakamoto.&#x0A;&#x0A;This is experimental software.&#x0A;&#x0A;Distributed under the MIT/X11 software license, see the accompanying file &#x0A;license.txt or http://www.opensource.org/licenses/mit-license.php.&#x0A;&#x0A;This product includes software developed by the OpenSSL Project for use in the &#x0A;OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by &#x0A;Eric Young (eay@cryptsoft.com).</property>\r
                                                 <property name="maximum_size"></property>\r
                                                 <property name="minimum_size"></property>\r
                                                 <property name="name">m_staticTextMain</property>\r
index 62ae3b4..c09419f 100644 (file)
--- a/util.cpp
+++ b/util.cpp
@@ -20,13 +20,13 @@ bool fCommandLine = false;
 \r
 \r
 // Init openssl library multithreading support\r
-static wxMutex** ppmutexOpenSSL;\r
+static boost::interprocess::interprocess_mutex** ppmutexOpenSSL;\r
 void locking_callback(int mode, int i, const char* file, int line)\r
 {\r
     if (mode & CRYPTO_LOCK)\r
-        ppmutexOpenSSL[i]->Lock();\r
+        ppmutexOpenSSL[i]->lock();\r
     else\r
-        ppmutexOpenSSL[i]->Unlock();\r
+        ppmutexOpenSSL[i]->unlock();\r
 }\r
 \r
 // Init\r
@@ -36,9 +36,9 @@ public:
     CInit()\r
     {\r
         // Init openssl library multithreading support\r
-        ppmutexOpenSSL = (wxMutex**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(wxMutex*));\r
+        ppmutexOpenSSL = (boost::interprocess::interprocess_mutex**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(boost::interprocess::interprocess_mutex*));\r
         for (int i = 0; i < CRYPTO_num_locks(); i++)\r
-            ppmutexOpenSSL[i] = new wxMutex();\r
+            ppmutexOpenSSL[i] = new boost::interprocess::interprocess_mutex();\r
         CRYPTO_set_locking_callback(locking_callback);\r
 \r
 #ifdef __WXMSW__\r
@@ -152,7 +152,7 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
         if (fileout)\r
         {\r
             //// Debug print useful for profiling\r
-            //fprintf(fileout, " %"PRI64d" ", wxGetLocalTimeMillis().GetValue());\r
+            //fprintf(fileout, " %"PRI64d" ", GetTimeMillis());\r
             va_list arg_ptr;\r
             va_start(arg_ptr, pszFormat);\r
             ret = vfprintf(fileout, pszFormat, arg_ptr);\r
@@ -521,6 +521,69 @@ void PrintException(std::exception* pex, const char* pszThread)
 \r
 \r
 \r
+#ifdef __WXMSW__\r
+typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);\r
+\r
+string MyGetSpecialFolderPath(int nFolder, bool fCreate)\r
+{\r
+    char pszPath[MAX_PATH+100] = "";\r
+\r
+    // SHGetSpecialFolderPath isn't always available on old Windows versions\r
+    HMODULE hShell32 = LoadLibraryA("shell32.dll");\r
+    if (hShell32)\r
+    {\r
+        PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath =\r
+            (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA");\r
+        if (pSHGetSpecialFolderPath)\r
+            (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate);\r
+        FreeModule(hShell32);\r
+    }\r
+\r
+    // Backup option\r
+    if (pszPath[0] == '\0')\r
+    {\r
+        if (nFolder == CSIDL_STARTUP)\r
+        {\r
+            strcpy(pszPath, getenv("USERPROFILE"));\r
+            strcat(pszPath, "\\Start Menu\\Programs\\Startup");\r
+        }\r
+        else if (nFolder == CSIDL_APPDATA)\r
+        {\r
+            strcpy(pszPath, getenv("APPDATA"));\r
+        }\r
+    }\r
+\r
+    return pszPath;\r
+}\r
+#endif\r
+\r
+string GetDefaultDataDir()\r
+{\r
+    // Windows: C:\Documents and Settings\username\Application Data\Appname\r
+    // Mac: ~/Library/Application Support/Appname\r
+    // Unix: ~/.appname\r
+#ifdef __WXMSW__\r
+    // Windows\r
+    return MyGetSpecialFolderPath(CSIDL_APPDATA, true) + "\\Bitcoin";\r
+#else\r
+    char* pszHome = getenv("HOME");\r
+    if (pszHome == NULL || strlen(pszHome) == 0)\r
+        pszHome = (char*)"/";\r
+    string strHome = pszHome;\r
+    if (strHome[strHome.size()-1] != '/')\r
+        strHome += '/';\r
+#ifdef __WXOSX__\r
+    // Mac\r
+    strHome += "Library/Application Support/";\r
+    _mkdir(strHome.c_str());\r
+    return strHome + "Bitcoin";\r
+#else\r
+    // Unix\r
+    return strHome + ".bitcoin";\r
+#endif\r
+#endif\r
+}\r
+\r
 void GetDataDir(char* pszDir)\r
 {\r
     // pszDir must be at least MAX_PATH length.\r
@@ -538,11 +601,6 @@ void GetDataDir(char* pszDir)
     {\r
         // This can be called during exceptions by printf, so we cache the\r
         // value so we don't have to do memory allocations after that.\r
-        // wxStandardPaths::GetUserDataDir\r
-        //  Return the directory for the user-dependent application data files:\r
-        //  Unix: ~/.appname\r
-        //  Windows: C:\Documents and Settings\username\Application Data\appname\r
-        //  Mac: ~/Library/Application Support/appname\r
         static char pszCachedDir[MAX_PATH];\r
         if (pszCachedDir[0] == 0)\r
         {\r
diff --git a/util.h b/util.h
index 40d46bc..e92204f 100644 (file)
--- a/util.h
+++ b/util.h
@@ -141,6 +141,9 @@ void ParseParameters(int argc, char* argv[]);
 const char* wxGetTranslation(const char* psz);\r
 int GetFilesize(FILE* file);\r
 void GetDataDir(char* pszDirRet);\r
+#ifdef __WXMSW__\r
+string MyGetSpecialFolderPath(int nFolder, bool fCreate);\r
+#endif\r
 string GetDataDir();\r
 void ShrinkDebugFile();\r
 uint64 GetRand(uint64 nMax);\r
@@ -174,13 +177,13 @@ public:
     bool TryEnter() { return TryEnterCriticalSection(&cs); }\r
 #else\r
 protected:\r
-    wxMutex mutex;\r
+    boost::interprocess::interprocess_recursive_mutex mutex;\r
 public:\r
-    explicit CCriticalSection() : mutex(wxMUTEX_RECURSIVE) { }\r
+    explicit CCriticalSection() { }\r
     ~CCriticalSection() { }\r
-    void Enter() { mutex.Lock(); }\r
-    void Leave() { mutex.Unlock(); }\r
-    bool TryEnter() { return mutex.TryLock() == wxMUTEX_NO_ERROR; }\r
+    void Enter() { mutex.lock(); }\r
+    void Leave() { mutex.unlock(); }\r
+    bool TryEnter() { return mutex.try_lock(); }\r
 #endif\r
 public:\r
     const char* pszFile;\r
@@ -324,7 +327,8 @@ inline int64 PerformanceCounter()
 \r
 inline int64 GetTimeMillis()\r
 {\r
-    return wxGetLocalTimeMillis().GetValue();\r
+    return (posix_time::ptime(posix_time::microsec_clock::universal_time()) -\r
+            posix_time::ptime(gregorian::date(1970,1,1))).total_milliseconds();\r
 }\r
 \r
 inline string DateTimeStrFormat(const char* pszFormat, int64 nTime)\r
@@ -513,7 +517,7 @@ inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=fa
     return hthread;\r
 }\r
 \r
-#define THREAD_PRIORITY_LOWEST          PRIO_MIN\r
+#define THREAD_PRIORITY_LOWEST          PRIO_MAX\r
 #define THREAD_PRIORITY_BELOW_NORMAL    2\r
 #define THREAD_PRIORITY_NORMAL          0\r
 #define THREAD_PRIORITY_ABOVE_NORMAL    0\r