diff -uNr a/bitcoin/src/bitcoinrpc.cpp b/bitcoin/src/bitcoinrpc.cpp --- a/bitcoin/src/bitcoinrpc.cpp be601828da9d44e686e4fb5341373a1559642121a92080bd9ddb223c7dcb2bac08ba6236653645eb5a458d5fe05de7b4fd14f590975477e952f5d667ae049adc +++ b/bitcoin/src/bitcoinrpc.cpp bc6c82ab1a129e9e74a6bf785df99ac939fef94d72afbee153913fd53cab5d05120047275342cb4d52a98a951184eed47cccd9710e3655c261b68d2f257614a3 @@ -2422,11 +2422,6 @@ #ifdef TEST int main(int argc, char *argv[]) { -#ifdef _MSC_VER - // Turn off microsoft heap dump noise - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); - _CrtSetReportFile(_CRT_WARN, CreateFile("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0)); -#endif setbuf(stdin, NULL); setbuf(stdout, NULL); setbuf(stderr, NULL); diff -uNr a/bitcoin/src/crypter.cpp b/bitcoin/src/crypter.cpp --- a/bitcoin/src/crypter.cpp 64dddc1348603ea005f4f5297ea6d51074fead3dd8d1256c1a4c2a678fef1abcb58d148ebb9eb3716e200e27abf6d07c19d1cf6fcbb4e1b9dcba59fde8eae324 +++ b/bitcoin/src/crypter.cpp 195bde01368dc6b69e0f9d5046b2dd83f1f2345393e88382a3838efac8b6635c5992f2f8599d0ad3913b4a4b8c144cad7c7e714e7c2f96aa15a86ba820b27321 @@ -7,9 +7,6 @@ #include #include #include "headers.h" -#ifdef WIN32 -#include -#endif #include "crypter.h" #include "main.h" diff -uNr a/bitcoin/src/db.cpp b/bitcoin/src/db.cpp --- a/bitcoin/src/db.cpp c5aa0633f19e5ed97f1d80509a84bd8aeeb42ade44eb1b45a1220c429b78c3943a2dfc83da82fa9cdb87dc9563a1278d2033c20b5e2da83252e36407a470df93 +++ b/bitcoin/src/db.cpp 66f81f6da997109f4d34ca654d30e24cb850fa87a6fbe6a045c6cb1a9f6d47d979fb4e25a0bbb35064c1259cda3c7b5ff12f68d9c22c1acf45299dbb4ed72317 @@ -768,11 +768,9 @@ bool fIsEncrypted = false; // Modify defaults -#ifndef WIN32 // Tray icon sometimes disappears on 9.10 karmic koala 64-bit, leaving no way to access the program fMinimizeToTray = false; fMinimizeOnClose = false; -#endif //// todo: shouldn't we catch exceptions and try to recover and continue? CRITICAL_BLOCK(pwallet->cs_wallet) diff -uNr a/bitcoin/src/headers.h b/bitcoin/src/headers.h --- a/bitcoin/src/headers.h 5fa4d450d3f50651eeb12e3de9657c1a8a3968d37f2df15a7c1f7b0ad44fdbd427d8934f0cf81df00f6eac9a456a80adf7cbc2882678ac943c207ede1c2f637a +++ b/bitcoin/src/headers.h b86114b5b74d2b9e737798f78804439c5cdd0ae42440615c57fc85cb0ac7d8b8a454d2ef44048db6af0ca00a938178173eece431b273462dbc299c1501b86600 @@ -3,22 +3,6 @@ // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. -#ifdef _MSC_VER -#pragma warning(disable:4786) -#pragma warning(disable:4804) -#pragma warning(disable:4805) -#pragma warning(disable:4717) -#endif -#ifdef _WIN32_WINNT -#undef _WIN32_WINNT -#endif -#define _WIN32_WINNT 0x0500 -#ifdef _WIN32_IE -#undef _WIN32_IE -#endif -#define _WIN32_IE 0x0400 -#define WIN32_LEAN_AND_MEAN 1 - // Include boost/foreach here as it defines __STDC_LIMIT_MACROS on some systems. #include #ifndef __STDC_LIMIT_MACROS @@ -55,16 +39,6 @@ #include #include -#ifdef WIN32 -#include -#include -#include -#include -#include -#include -#include -#include -#else #include #include #include @@ -77,7 +51,7 @@ #include #include #include -#endif + #ifdef BSD #include #endif diff -uNr a/bitcoin/src/init.cpp b/bitcoin/src/init.cpp --- a/bitcoin/src/init.cpp 44df7fd78d25997fd3e84e4df43ea6511de2aed69dced33a64a14d9c918ca34eea4d5fd1afff711b490991ce90f90cf67052433cdd5fccda08bb974e75f0929d +++ b/bitcoin/src/init.cpp a8b85aa6dba112f0e314bd86f737d2fef1206e4ad81b4c346c053d2bf3e4f36a1f5687dcd1321a0a7f3884db1fb31ffce69603afb78f7c4e1b5ca638840a4404 @@ -25,10 +25,6 @@ void ExitTimeout(void* parg) { -#ifdef WIN32 - Sleep(5000); - ExitProcess(0); -#endif } void Shutdown(void* parg) @@ -113,19 +109,8 @@ bool AppInit2(int argc, char* argv[]) { -#ifdef _MSC_VER - // Turn off microsoft heap dump noise - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); - _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0)); -#endif -#if _MSC_VER >= 1400 - // Disable confusing "helpful" text message on abort, ctrl-c - _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); -#endif -#ifndef WIN32 umask(077); -#endif -#ifndef WIN32 + // Clean shutdown on SIGTERM struct sigaction sa; sa.sa_handler = HandleSIGTERM; @@ -134,7 +119,6 @@ sigaction(SIGTERM, &sa, NULL); sigaction(SIGINT, &sa, NULL); sigaction(SIGHUP, &sa, NULL); -#endif // // Parameters @@ -189,16 +173,11 @@ " -maxreceivebuffer=\t " + _("Maximum per-connection receive buffer, *1000 bytes (default: 10000)\n") + " -maxsendbuffer=\t " + _("Maximum per-connection send buffer, *1000 bytes (default: 10000)\n") + " -paytxfee= \t " + _("Fee per kB to add to transactions you send\n") + -#if !defined(WIN32) " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") + -#endif " -testnet \t\t " + _("Use the test network\n") + " -debug \t\t " + _("Output extra debugging information\n") + " -logtimestamps \t " + _("Prepend debug output with timestamp\n") + " -printtoconsole \t " + _("Send trace/debug info to console instead of debug.log file\n") + -#ifdef WIN32 - " -printtodebugger \t " + _("Send trace/debug info to debugger\n") + -#endif " -rpcuser= \t " + _("Username for JSON-RPC connections\n") + " -rpcpassword=\t " + _("Password for JSON-RPC connections\n") + " -rpcport= \t\t " + _("Listen for JSON-RPC connections on (default: 8332)\n") + @@ -218,12 +197,7 @@ fTestNet = GetBoolArg("-testnet"); fDebug = GetBoolArg("-debug"); - -#if !defined(WIN32) fDaemon = GetBoolArg("-daemon"); -#else - fDaemon = false; -#endif if (fDaemon) fServer = true; @@ -246,7 +220,6 @@ exit(ret); } -#if !defined(WIN32) if (fDaemon) { // Daemonize @@ -266,7 +239,6 @@ if (sid < 0) fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno); } -#endif if (!fDebug && !pszSetDataDir[0]) ShrinkDebugFile(); diff -uNr a/bitcoin/src/main.h b/bitcoin/src/main.h --- a/bitcoin/src/main.h 784c9af0366ee1f7033155638503bc35ff23aaf675e177f3917f0890e14a9d5ceeb80fd833751d674f0d7e41e6fe1d93ea32694872028fec1dc8a83c0ad17944 +++ b/bitcoin/src/main.h 8cfdda6fd46e07e50ab42e4f4652274c324b6020f30a340b6bb9ee3fd620c497473c8480102218d48261646d7adfecff7ff987f8a798997b4d3ebd032066d78d @@ -923,11 +923,7 @@ fflush(fileout); if (!IsInitialBlockDownload() || (nBestHeight+1) % 500 == 0) { -#ifdef WIN32 - _commit(_fileno(fileout)); -#else fsync(fileno(fileout)); -#endif } return true; diff -uNr a/bitcoin/src/makefile.linux-mingw b/bitcoin/src/makefile.linux-mingw --- a/bitcoin/src/makefile.linux-mingw c345f6b5bc7d336782f8c032d9fc7ba0004a64782f1373dc82e3b117dc276a10c0bd0e31b646d8e9bbb4ffb6a9e6878a0d17851af9748b93b0107f3b4285a5a0 +++ b/bitcoin/src/makefile.linux-mingw false @@ -1,95 +0,0 @@ -# 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. - -DEPSDIR:=/usr/i586-mingw32msvc - -INCLUDEPATHS= \ - -I"$(DEPSDIR)/boost_1_47_0" \ - -I"$(DEPSDIR)/db-4.8.30.NC/build_unix" \ - -I"$(DEPSDIR)/openssl-1.0.0e/include" \ - -I"$(DEPSDIR)" - -LIBPATHS= \ - -L"$(DEPSDIR)/boost_1_47_0/stage/lib" \ - -L"$(DEPSDIR)/db-4.8.30.NC/build_unix" \ - -L"$(DEPSDIR)/openssl-1.0.0e" - -LIBS= \ - -l boost_system-mt-s \ - -l boost_filesystem-mt-s \ - -l boost_program_options-mt-s \ - -l boost_thread_win32-mt-s \ - -l db_cxx \ - -l ssl \ - -l crypto - -DEFS=-D_MT -DWIN32 -D_WINDOWS -DNOPCH -DBOOST_THREAD_USE_LIB -DEBUGFLAGS=-g -CFLAGS=-O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) -HEADERS = \ - base58.h \ - bignum.h \ - checkpoints.h \ - crypter.h \ - db.h \ - headers.h \ - init.h \ - irc.h \ - key.h \ - keystore.h \ - main.h \ - net.h \ - noui.h \ - protocol.h \ - bitcoinrpc.h \ - script.h \ - serialize.h \ - strlcpy.h \ - uint256.h \ - util.h \ - wallet.h - - - -LIBS += -l mingwthrd -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi - -OBJS= \ - obj/checkpoints.o \ - obj/crypter.o \ - obj/db.o \ - obj/init.o \ - obj/irc.o \ - obj/keystore.o \ - obj/main.o \ - obj/net.o \ - obj/protocol.o \ - obj/bitcoinrpc.o \ - obj/script.o \ - obj/util.o \ - obj/wallet.o - -all: bitcoind.exe - -obj/nogui/%.o: %.cpp $(HEADERS) - i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $< - -bitcoind.exe: $(OBJS:obj/%=obj/nogui/%) - i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) - - -obj/test/%.o: obj/test/%.cpp $(HEADERS) - i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $< - -test_bitcoin.exe: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) - i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework-mt-s - - -clean: - -rm -f obj/*.o - -rm -f obj/nogui/*.o - -rm -f obj/test/*.o - -rm -f test/*.o - -rm -f headers.h.gch - -rm -f bitcoind.exe - -rm -f test_bitcoin.exe diff -uNr a/bitcoin/src/net.cpp b/bitcoin/src/net.cpp --- a/bitcoin/src/net.cpp 50f2bf26c02d6edbd0aec5a3e5b3ddceaffab27c16d51a4dd972e42e01871d8e34314f525e9394211801c9ea7d1bd8f8266ae214b30a8e645ce207bf5f3bbd92 +++ b/bitcoin/src/net.cpp c67fdd55e9d9d6b4973122b76729d7e83a456a8dc410f1c130cffbfd9f626c47ca7e8006bde912d9e0bd0a4b8457e895270d4a0efd22c4a199cd52ffd95b10dd @@ -10,10 +10,6 @@ #include "init.h" #include "strlcpy.h" -#ifdef WIN32 -#include -#endif - using namespace std; using namespace boost; @@ -94,13 +90,9 @@ bool fProxy = (fUseProxy && addrConnect.IsRoutable()); struct sockaddr_in sockaddr = (fProxy ? addrProxy.GetSockAddr() : addrConnect.GetSockAddr()); -#ifdef WIN32 - u_long fNonblock = 1; - if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR) -#else int fFlags = fcntl(hSocket, F_GETFL, 0); if (fcntl(hSocket, F_SETFL, fFlags | O_NONBLOCK) == -1) -#endif + { closesocket(hSocket); return false; @@ -133,11 +125,7 @@ return false; } socklen_t nRetSize = sizeof(nRet); -#ifdef WIN32 - if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, (char*)(&nRet), &nRetSize) == SOCKET_ERROR) -#else if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR) -#endif { printf("getsockopt() for connection failed: %i\n",WSAGetLastError()); closesocket(hSocket); @@ -150,11 +138,7 @@ return false; } } -#ifdef WIN32 - else if (WSAGetLastError() != WSAEISCONN) -#else else -#endif { printf("connect() failed: %i\n",WSAGetLastError()); closesocket(hSocket); @@ -167,13 +151,8 @@ CNode::ConnectNode immediately turns the socket back to non-blocking but we'll turn it back to blocking just in case */ -#ifdef WIN32 - fNonblock = 0; - if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR) -#else fFlags = fcntl(hSocket, F_GETFL, 0); if (fcntl(hSocket, F_SETFL, fFlags & !O_NONBLOCK) == SOCKET_ERROR) -#endif { closesocket(hSocket); return false; @@ -670,14 +649,8 @@ printf("connected %s\n", addrConnect.ToString().c_str()); // Set to nonblocking -#ifdef WIN32 - u_long nOne = 1; - if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) - printf("ConnectSocket() : ioctlsocket nonblocking setting failed, error %d\n", WSAGetLastError()); -#else if (fcntl(hSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR) printf("ConnectSocket() : fcntl nonblocking setting failed, error %d\n", errno); -#endif // Add node CNode* pnode = new CNode(hSocket, addrConnect, false); @@ -1564,18 +1537,6 @@ int nOne = 1; addrLocalHost.port = htons(GetListenPort()); -#ifdef WIN32 - // Initialize Windows Sockets - WSADATA wsadata; - int ret = WSAStartup(MAKEWORD(2,2), &wsadata); - if (ret != NO_ERROR) - { - strError = strprintf("Error: TCP/IP socket library failed to start (WSAStartup returned error %d)", ret); - printf("%s\n", strError.c_str()); - return false; - } -#endif - // Create socket for listening for incoming connections hListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (hListenSocket == INVALID_SOCKET) @@ -1590,18 +1551,11 @@ setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int)); #endif -#ifndef WIN32 // Allow binding if the port is still in TIME_WAIT state after // the program was closed and restarted. Not an issue on windows. setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int)); -#endif -#ifdef WIN32 - // Set to nonblocking, incoming connections will also inherit this - if (ioctlsocket(hListenSocket, FIONBIO, (u_long*)&nOne) == SOCKET_ERROR) -#else if (fcntl(hListenSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR) -#endif { strError = strprintf("Error: Couldn't set properties on socket for incoming connections (error %d)", WSAGetLastError()); printf("%s\n", strError.c_str()); @@ -1643,21 +1597,6 @@ if (pnodeLocalHost == NULL) pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress("127.0.0.1", 0, false, nLocalServices)); -#ifdef WIN32 - // Get local host ip - char pszHostName[1000] = ""; - if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR) - { - vector vaddr; - if (Lookup(pszHostName, vaddr, nLocalServices, -1, true)) - BOOST_FOREACH (const CAddress &addr, vaddr) - if (addr.GetByte(3) != 127) - { - addrLocalHost = addr; - break; - } - } -#else // Get local host ip struct ifaddrs* myaddrs; if (getifaddrs(&myaddrs) == 0) @@ -1692,7 +1631,7 @@ } freeifaddrs(myaddrs); } -#endif + printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str()); if (fUseProxy || mapArgs.count("-connect") || fNoListen) @@ -1778,10 +1717,6 @@ if (closesocket(hListenSocket) == SOCKET_ERROR) printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError()); -#ifdef WIN32 - // Shutdown Windows Sockets - WSACleanup(); -#endif } } instance_of_cnetcleanup; diff -uNr a/bitcoin/src/net.h b/bitcoin/src/net.h --- a/bitcoin/src/net.h ae473b8d2838555df527e16ac7cae7dfff39bfd68769b1fcabb1f847e29e1245af78799942e790016c376a76e112b9ec16d2d7d5f52736e3cc72e45432706d3b +++ b/bitcoin/src/net.h 08231aa424ae8c84086b5b82ea79a7f22fb3403b4245c6d05a20176c4962ae620a35b9cb2505f4b8e33a8f43d077152406007013e49e97ab1ceed6b158b77a0f @@ -10,10 +10,6 @@ #include #include -#ifndef WIN32 -#include -#endif - #include "protocol.h" class CAddrDB; diff -uNr a/bitcoin/src/protocol.cpp b/bitcoin/src/protocol.cpp --- a/bitcoin/src/protocol.cpp 09c7f4cc1247b2ec45ffdae139fe2574dae0eb4cd40d0e48cfd5de49033ab1f4242e564020e4af5418b12e7a78430c87d58b1d4829c837b9dae47d1c1cd32382 +++ b/bitcoin/src/protocol.cpp 8faeddc8ca1b84e53edee8f3325edd7db8b74e063f4d338ae7e280c02dce96e8156157a6802feab5b7f695981e6f8a42ab5f44b9df3093a4d7c4f30f9b029912 @@ -5,10 +5,8 @@ #include "protocol.h" #include "util.h" +#include -#ifndef WIN32 -# include -#endif // Prototypes from net.h, but that header (currently) stinks, can't #include it without breaking things bool Lookup(const char *pszName, std::vector& vaddr, int nServices, int nMaxSolutions, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false); @@ -165,11 +163,7 @@ ss.reserve(18); ss << FLATDATA(pchReserved) << ip << port; - #if defined(_MSC_VER) && _MSC_VER < 1300 - return std::vector((unsigned char*)&ss.begin()[0], (unsigned char*)&ss.end()[0]); - #else return std::vector(ss.begin(), ss.end()); - #endif } struct sockaddr_in CAddress::GetSockAddr() const diff -uNr a/bitcoin/src/script.h b/bitcoin/src/script.h --- a/bitcoin/src/script.h 72636dbd07e5917231ee2b62473be7a766e0e62e573315cc48e38b524da2885803b024f0613fa52c347ba0ed19455ca9461e980018e66d5ca9b05ce0bc380693 +++ b/bitcoin/src/script.h 796b2ab92a49e29b5873be0d63d732d1b973855de76062492190687c57fdbefc069091df6306a0eee86ad5717c8fa90774ea9b8589cba2d9138b544c37e7177f @@ -384,9 +384,7 @@ CScript() { } CScript(const CScript& b) : std::vector(b.begin(), b.end()) { } CScript(const_iterator pbegin, const_iterator pend) : std::vector(pbegin, pend) { } -#ifndef _MSC_VER CScript(const unsigned char* pbegin, const unsigned char* pend) : std::vector(pbegin, pend) { } -#endif CScript& operator+=(const CScript& b) { diff -uNr a/bitcoin/src/serialize.h b/bitcoin/src/serialize.h --- a/bitcoin/src/serialize.h 0dcf98014abe06b33ab296a747e42e88770a87f8d4e408be4fc1ebe6b02312695cc129d0b58c0886bf8521b6d2c79bf6f2c33e19c03aee8f5357d8db779829ad +++ b/bitcoin/src/serialize.h 762e48eeae1d5086a18fc1f37dfc395ca6a6c393aa71dc177e19c106e69b3e3e3130252ec7d229976d1bcb325a1e6bd1ca5e73de1ebba6c37d71326385a4244c @@ -19,27 +19,9 @@ #include #include -#if defined(_MSC_VER) || defined(__BORLANDC__) -typedef __int64 int64; -typedef unsigned __int64 uint64; -#else typedef long long int64; typedef unsigned long long uint64; -#endif -#if defined(_MSC_VER) && _MSC_VER < 1300 -#define for if (false) ; else for -#endif -#ifdef WIN32 -#include -// This is used to attempt to keep keying material out of swap -// Note that VirtualLock does not provide this as a guarantee on Windows, -// but, in practice, memory that has been VirtualLock'd almost never gets written to -// the pagefile except in rare circumstances where memory is extremely low. -#include -#define mlock(p, n) VirtualLock((p), (n)); -#define munlock(p, n) VirtualUnlock((p), (n)); -#else #include #include /* This comes from limits.h if it's not defined there set a sane default */ @@ -53,7 +35,6 @@ #define munlock(a,b) \ munlock(((void *)(((size_t)(a)) & (~((PAGESIZE)-1)))),\ (((((size_t)(a)) + (b) - 1) | ((PAGESIZE) - 1)) + 1) - (((size_t)(a)) & (~((PAGESIZE) - 1)))) -#endif class CScript; class CDataStream; @@ -902,12 +883,10 @@ Init(nTypeIn, nVersionIn); } -#if !defined(_MSC_VER) || _MSC_VER >= 1300 CDataStream(const char* pbegin, const char* pend, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(pbegin, pend) { Init(nTypeIn, nVersionIn); } -#endif CDataStream(const vector_type& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(vchIn.begin(), vchIn.end()) { @@ -993,7 +972,6 @@ vch.insert(it, first, last); } -#if !defined(_MSC_VER) || _MSC_VER >= 1300 void insert(iterator it, const char* first, const char* last) { if (it == vch.begin() + nReadPos && last - first <= nReadPos) @@ -1005,7 +983,6 @@ else vch.insert(it, first, last); } -#endif iterator erase(iterator it) { diff -uNr a/bitcoin/src/uint256.h b/bitcoin/src/uint256.h --- a/bitcoin/src/uint256.h 3436729b55463ebb34788a47a8856d47ba7ebc27f447c5ff73b8727897d7c468716d8313e9b613e7889a7c3dffa6e577d77149ae8c4c415fb41ce3fc5cc6d852 +++ b/bitcoin/src/uint256.h bff76a65e51957209d7753535337d23927a9a1acc829c5bc5d9f266a1b8c004b555daae74e75b616ca0088f8be0739f082d64edc2387495b3675bebd25658fd3 @@ -11,17 +11,8 @@ #include #include -#if defined(_MSC_VER) || defined(__BORLANDC__) -typedef __int64 int64; -typedef unsigned __int64 uint64; -#else typedef long long int64; typedef unsigned long long uint64; -#endif -#if defined(_MSC_VER) && _MSC_VER < 1300 -#define for if (false) ; else for -#endif - inline int Testuint256AdHoc(std::vector vArg); diff -uNr a/bitcoin/src/util.cpp b/bitcoin/src/util.cpp --- a/bitcoin/src/util.cpp 4b0f7b3a7757336b6e5c349d89170bfc4b4c40a04e0ec3fccf0b155314689c781deb9590ab05daa8af20a123e2f3cad55c5af1244700197a3530d0d4699d32c5 +++ b/bitcoin/src/util.cpp 626e2306c3784911c960136e39bd3eb7c925ca90378faa03fb616a5d7180335889f0807bb39c9ac1907b285c43e730558190e1a1d5717eba4bae6006a9abedfd @@ -64,11 +64,6 @@ ppmutexOpenSSL[i] = new boost::interprocess::interprocess_mutex(); CRYPTO_set_locking_callback(locking_callback); -#ifdef WIN32 - // Seed random number generator with screen scrape and other hardware sources - RAND_screen(); -#endif - // Seed random number generator with performance counter RandAddSeed(); } @@ -108,21 +103,6 @@ return; nLastPerfmon = GetTime(); -#ifdef WIN32 - // Don't need this on Linux, OpenSSL automatically uses /dev/urandom - // Seed with the entire set of perfmon data - unsigned char pdata[250000]; - memset(pdata, 0, sizeof(pdata)); - unsigned long nSize = sizeof(pdata); - long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize); - RegCloseKey(HKEY_PERFORMANCE_DATA); - if (ret == ERROR_SUCCESS) - { - RAND_add(pdata, nSize, nSize/100.0); - memset(pdata, 0, nSize); - printf("%s RandAddSeed() %d bytes\n", DateTimeStrFormat("%x %H:%M", GetTime()).c_str(), nSize); - } -#endif } uint64 GetRand(uint64 nMax) @@ -198,48 +178,6 @@ } } -#ifdef WIN32 - if (fPrintToDebugger) - { - static CCriticalSection cs_OutputDebugStringF; - - // accumulate a line at a time - CRITICAL_BLOCK(cs_OutputDebugStringF) - { - static char pszBuffer[50000]; - static char* pend; - if (pend == NULL) - pend = pszBuffer; - va_list arg_ptr; - va_start(arg_ptr, pszFormat); - int limit = END(pszBuffer) - pend - 2; - int ret = _vsnprintf(pend, limit, pszFormat, arg_ptr); - va_end(arg_ptr); - if (ret < 0 || ret >= limit) - { - pend = END(pszBuffer) - 2; - *pend++ = '\n'; - } - else - pend += ret; - *pend = '\0'; - char* p1 = pszBuffer; - char* p2; - while (p2 = strchr(p1, '\n')) - { - p2++; - char c = *p2; - *p2 = '\0'; - OutputDebugStringA(p1); - *p2 = c; - p1 = p2; - } - if (p1 != pszBuffer) - memmove(pszBuffer, p1, pend - p1 + 1); - pend -= (p1 - pszBuffer); - } - } -#endif return ret; } @@ -457,11 +395,6 @@ pszValue = strchr(psz, '='); *pszValue++ = '\0'; } - #ifdef WIN32 - _strlwr(psz); - if (psz[0] == '/') - psz[0] = '-'; - #endif if (psz[0] != '-') break; mapArgs[psz] = pszValue; @@ -665,13 +598,7 @@ void FormatException(char* pszMessage, std::exception* pex, const char* pszThread) { -#ifdef WIN32 - char pszModule[MAX_PATH]; - pszModule[0] = '\0'; - GetModuleFileNameA(NULL, pszModule, sizeof(pszModule)); -#else const char* pszModule = "bitcoin"; -#endif if (pex) snprintf(pszMessage, 1000, "EXCEPTION: %s \n%s \n%s in %s \n", typeid(*pex).name(), pex->what(), pszModule, pszThread); @@ -717,67 +644,10 @@ strMiscWarning = pszMessage; } - - - - - - - -#ifdef WIN32 -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"); - bool fSuccess = false; - if (pSHGetSpecialFolderPath) - fSuccess = - (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate); - FreeModule(hShell32); - if (fSuccess) - return pszPath; - } - - // Backup option - std::string strPath; - { - const char *pszEnv; - if (nFolder == CSIDL_STARTUP) - { - pszEnv = getenv("USERPROFILE"); - if (pszEnv) - strPath = pszEnv; - strPath += "\\Start Menu\\Programs\\Startup"; - } - else if (nFolder == CSIDL_APPDATA) - { - pszEnv = getenv("APPDATA"); - if (pszEnv) - strPath = pszEnv; - } - } - - return strPath; -} -#endif - string GetDefaultDataDir() { - // Windows: C:\Documents and Settings\username\Application Data\Bitcoin // Mac: ~/Library/Application Support/Bitcoin // Unix: ~/.bitcoin -#ifdef WIN32 - // Windows - return MyGetSpecialFolderPath(CSIDL_APPDATA, true) + "\\Bitcoin"; -#else char* pszHome = getenv("HOME"); if (pszHome == NULL || strlen(pszHome) == 0) pszHome = (char*)"/"; @@ -793,7 +663,6 @@ // Unix return strHome + ".bitcoin"; #endif -#endif } void GetDataDir(char* pszDir) diff -uNr a/bitcoin/src/util.h b/bitcoin/src/util.h --- a/bitcoin/src/util.h 1355ad6ce93816fffc1befd7a68a5fbdf034ae24ae99c64a60269ca9db589363d6531f441cd2393630e3128c2762ddcb8101dd6c305551b70cf24e102e59cfd0 +++ b/bitcoin/src/util.h 1e2275fea3780708aed4d4c7de351b23a9379354df29dda39b8bf2ccc72df95713514b2b7837dc2230d42cf8234744e804bfd608fb4442ff62871257f8d80c12 @@ -7,11 +7,10 @@ #include "uint256.h" -#ifndef WIN32 + #include #include #include -#endif #include #include #include @@ -25,19 +24,10 @@ #include -#if defined(_MSC_VER) || defined(__BORLANDC__) -typedef __int64 int64; -typedef unsigned __int64 uint64; -#else typedef long long int64; typedef unsigned long long uint64; -#endif -#if defined(_MSC_VER) && _MSC_VER < 1300 -#define for if (false) ; else for -#endif -#ifndef _MSC_VER + #define __forceinline inline -#endif #define loop for (;;) #define BEGIN(a) ((char*)&(a)) @@ -53,16 +43,10 @@ #define snprintf my_snprintf #ifndef PRI64d -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MSVCRT__) -#define PRI64d "I64d" -#define PRI64u "I64u" -#define PRI64x "I64x" -#else #define PRI64d "lld" #define PRI64u "llu" #define PRI64x "llx" #endif -#endif // This is needed because the foreach macro can't get over the comma in pair #define PAIRTYPE(t1, t2) std::pair @@ -81,21 +65,6 @@ return u.ptr; } -#ifdef WIN32 -#define MSG_NOSIGNAL 0 -#define MSG_DONTWAIT 0 -#ifndef UINT64_MAX -#define UINT64_MAX _UI64_MAX -#define INT64_MAX _I64_MAX -#define INT64_MIN _I64_MIN -#endif -#ifndef S_IRUSR -#define S_IRUSR 0400 -#define S_IWUSR 0200 -#endif -#define unlink _unlink -typedef int socklen_t; -#else #define WSAGetLastError() errno #define WSAEINVAL EINVAL #define WSAEALREADY EALREADY @@ -119,17 +88,13 @@ So we clamp our sleeps here to 10 years and hope that boost is fixed by 2028.*/ boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(n>315576000000LL?315576000000LL:n)); } -#endif + inline int myclosesocket(SOCKET& hSocket) { if (hSocket == INVALID_SOCKET) return WSAENOTSOCK; -#ifdef WIN32 - int ret = closesocket(hSocket); -#else int ret = close(hSocket); -#endif hSocket = INVALID_SOCKET; return ret; } @@ -140,14 +105,6 @@ } - - - - - - - - extern std::map mapArgs; extern std::map > mapMultiArgs; extern bool fDebug; @@ -193,9 +150,6 @@ std::string GetPidFile(); void CreatePidFile(std::string pidFile, pid_t pid); void ReadConfigFile(std::map& mapSettingsRet, std::map >& mapMultiSettingsRet); -#ifdef WIN32 -std::string MyGetSpecialFolderPath(int nFolder, bool fCreate); -#endif std::string GetDefaultDataDir(); std::string GetDataDir(); void ShrinkDebugFile(); @@ -323,20 +277,12 @@ inline int64 atoi64(const char* psz) { -#ifdef _MSC_VER - return _atoi64(psz); -#else return strtoll(psz, NULL, 10); -#endif } inline int64 atoi64(const std::string& str) { -#ifdef _MSC_VER - return _atoi64(str.c_str()); -#else return strtoll(str.c_str(), NULL, 10); -#endif } inline int atoi(const std::string& str) @@ -411,13 +357,9 @@ inline int64 GetPerformanceCounter() { int64 nCounter = 0; -#ifdef WIN32 - QueryPerformanceCounter((LARGE_INTEGER*)&nCounter); -#else timeval t; gettimeofday(&t, NULL); nCounter = t.tv_sec * 1000000 + t.tv_usec; -#endif return nCounter; } @@ -445,11 +387,7 @@ inline bool IsSwitchChar(char c) { -#ifdef WIN32 - return c == '-' || c == '/'; -#else return c == '-'; -#endif } inline std::string GetArg(const std::string& strArg, const std::string& strDefault) @@ -505,11 +443,6 @@ inline void heapchk() { -#ifdef WIN32 - /// for debugging - //if (_heapchk() != _HEAPOK) - // DebugBreak(); -#endif } // Randomize the stack to help protect against buffer overrun exploits @@ -664,38 +597,6 @@ // 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; - -inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false) -{ - DWORD nUnused = 0; - HANDLE hthread = - CreateThread( - NULL, // default security - 0, // inherit stack size from parent - (LPTHREAD_START_ROUTINE)pfn, // function pointer - parg, // argument - 0, // creation option, start immediately - &nUnused); // thread identifier - if (hthread == NULL) - { - printf("Error: CreateThread() returned %d\n", GetLastError()); - return (pthread_t)0; - } - if (!fWantHandle) - { - CloseHandle(hthread); - return (pthread_t)-1; - } - return hthread; -} - -inline void SetThreadPriority(int nPriority) -{ - SetThreadPriority(GetCurrentThread(), nPriority); -} -#else inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false) { pthread_t hthread = 0; @@ -738,29 +639,11 @@ { pthread_exit((void*)nExitCode); } -#endif - - inline bool AffinityBugWorkaround(void(*pfn)(void*)) { -#ifdef WIN32 - // Sometimes after a few hours affinity gets stuck on one processor - DWORD_PTR dwProcessAffinityMask = -1; - DWORD_PTR dwSystemAffinityMask = -1; - GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinityMask, &dwSystemAffinityMask); - DWORD dwPrev1 = SetThreadAffinityMask(GetCurrentThread(), dwProcessAffinityMask); - DWORD dwPrev2 = SetThreadAffinityMask(GetCurrentThread(), dwProcessAffinityMask); - if (dwPrev2 != dwProcessAffinityMask) - { - printf("AffinityBugWorkaround() : SetThreadAffinityMask=%d, ProcessAffinityMask=%d, restarting thread\n", dwPrev2, dwProcessAffinityMask); - if (!CreateThread(pfn, NULL)) - printf("Error: CreateThread() failed\n"); - return true; - } -#endif return false; }