Fix build on windows and mac

Replaced all occurrences of #if* __WXMSW__ with WIN32,
and all occurrences of __WXMAC_OSX__ with MAC_OSX, and made
sure those are defined appropriately in the makefile and bitcoin-qt.pro.
This commit is contained in:
Gavin Andresen 2011-10-07 11:02:21 -04:00
parent e9b95e4f6c
commit 6853e627f1
13 changed files with 46 additions and 46 deletions

View File

@ -211,10 +211,10 @@ isEmpty(BOOST_INCLUDE_PATH) {
}
windows:LIBS += -lws2_32 -lgdi32
windows:DEFINES += __WXMSW__
windows:DEFINES += WIN32
windows:RC_FILE = src/qt/res/bitcoin-qt.rc
macx:DEFINES += __WXMAC_OSX__ MSG_NOSIGNAL=0 BOOST_FILESYSTEM_VERSION=3
macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0 BOOST_FILESYSTEM_VERSION=3
macx:ICON = src/qt/res/icons/bitcoin.icns
macx:TARGET = "Bitcoin Qt"

View File

@ -7,7 +7,7 @@
#include <vector>
#include <string>
#include "headers.h"
#ifdef __WXMSW__
#ifdef WIN32
#include <windows.h>
#endif

View File

@ -658,7 +658,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
vector<uint256> vWalletUpgrade;
// Modify defaults
#ifndef __WXMSW__
#ifndef WIN32
// Tray icon sometimes disappears on 9.10 karmic koala 64-bit, leaving no way to access the program
fMinimizeToTray = false;
fMinimizeOnClose = false;

View File

@ -22,7 +22,7 @@
#if (defined(__unix__) || defined(unix)) && !defined(USG)
#include <sys/param.h> // to get BSD define
#endif
#ifdef __WXMAC_OSX__
#ifdef MAC_OSX
#ifndef BSD
#define BSD 1
#endif
@ -51,7 +51,7 @@
#include <boost/foreach.hpp>
#ifdef __WXMSW__
#ifdef WIN32
#include <windows.h>
#include <winsock2.h>
#include <mswsock.h>

View File

@ -24,7 +24,7 @@ CWallet* pwalletMain;
void ExitTimeout(void* parg)
{
#ifdef __WXMSW__
#ifdef WIN32
Sleep(5000);
ExitProcess(0);
#endif
@ -121,10 +121,10 @@ bool AppInit2(int argc, char* argv[])
// Disable confusing "helpful" text message on abort, ctrl-c
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#endif
#ifndef __WXMSW__
#ifndef WIN32
umask(077);
#endif
#ifndef __WXMSW__
#ifndef WIN32
// Clean shutdown on SIGTERM
struct sigaction sa;
sa.sa_handler = HandleSIGTERM;
@ -192,7 +192,7 @@ bool AppInit2(int argc, char* argv[])
#ifdef GUI
" -server \t\t " + _("Accept command line and JSON-RPC commands\n") +
#endif
#ifndef __WXMSW__
#ifndef WIN32
" -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") +
#endif
" -testnet \t\t " + _("Use the test network\n") +
@ -225,7 +225,7 @@ bool AppInit2(int argc, char* argv[])
fDebug = GetBoolArg("-debug");
fAllowDNS = GetBoolArg("-dns");
#ifndef __WXMSW__
#ifndef WIN32
fDaemon = GetBoolArg("-daemon");
#else
fDaemon = false;
@ -260,7 +260,7 @@ bool AppInit2(int argc, char* argv[])
}
#endif
#ifndef __WXMSW__
#ifndef WIN32
if (fDaemon)
{
// Daemonize

View File

@ -927,7 +927,7 @@ public:
fflush(fileout);
if (!IsInitialBlockDownload() || (nBestHeight+1) % 500 == 0)
{
#ifdef __WXMSW__
#ifdef WIN32
_commit(_fileno(fileout));
#else
fsync(fileno(fileout));

View File

@ -28,7 +28,7 @@ LIBS= -dead_strip \
-lssl \
-lcrypto
DEFS=-DMSG_NOSIGNAL=0 -DUSE_SSL
DEFS=-DMAC_OSX -DMSG_NOSIGNAL=0 -DUSE_SSL
DEBUGFLAGS=-g
# ppc doesn't work because we don't support big-endian

View File

@ -10,7 +10,7 @@
#include "init.h"
#include "strlcpy.h"
#ifdef __WXMSW__
#ifdef WIN32
#include <string.h>
#endif
@ -102,7 +102,7 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout
bool fProxy = (fUseProxy && addrConnect.IsRoutable());
struct sockaddr_in sockaddr = (fProxy ? addrProxy.GetSockAddr() : addrConnect.GetSockAddr());
#ifdef __WXMSW__
#ifdef WIN32
u_long fNonblock = 1;
if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR)
#else
@ -141,7 +141,7 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout
return false;
}
socklen_t nRetSize = sizeof(nRet);
#ifdef __WXMSW__
#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)
@ -158,7 +158,7 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout
return false;
}
}
#ifdef __WXMSW__
#ifdef WIN32
else if (WSAGetLastError() != WSAEISCONN)
#else
else
@ -175,7 +175,7 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout
CNode::ConnectNode immediately turns the socket back to non-blocking
but we'll turn it back to blocking just in case
*/
#ifdef __WXMSW__
#ifdef WIN32
fNonblock = 0;
if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR)
#else
@ -674,7 +674,7 @@ CNode* ConnectNode(CAddress addrConnect, int64 nTimeout)
printf("connected %s\n", addrConnect.ToString().c_str());
// Set to nonblocking
#ifdef __WXMSW__
#ifdef WIN32
u_long nOne = 1;
if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR)
printf("ConnectSocket() : ioctlsocket nonblocking setting failed, error %d\n", WSAGetLastError());
@ -1612,7 +1612,7 @@ bool BindListenPort(string& strError)
int nOne = 1;
addrLocalHost.port = htons(GetListenPort());
#ifdef __WXMSW__
#ifdef WIN32
// Initialize Windows Sockets
WSADATA wsadata;
int ret = WSAStartup(MAKEWORD(2,2), &wsadata);
@ -1638,13 +1638,13 @@ bool BindListenPort(string& strError)
setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));
#endif
#ifndef __WXMSW__
#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 __WXMSW__
#ifdef WIN32
// Set to nonblocking, incoming connections will also inherit this
if (ioctlsocket(hListenSocket, FIONBIO, (u_long*)&nOne) == SOCKET_ERROR)
#else
@ -1691,7 +1691,7 @@ void StartNode(void* parg)
if (pnodeLocalHost == NULL)
pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress("127.0.0.1", 0, false, nLocalServices));
#ifdef __WXMSW__
#ifdef WIN32
// Get local host ip
char pszHostName[1000] = "";
if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR)
@ -1827,7 +1827,7 @@ public:
if (closesocket(hListenSocket) == SOCKET_ERROR)
printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError());
#ifdef __WXMSW__
#ifdef WIN32
// Shutdown Windows Sockets
WSACleanup();
#endif

View File

@ -10,7 +10,7 @@
#include <boost/foreach.hpp>
#include <openssl/rand.h>
#ifndef __WXMSW__
#ifndef WIN32
#include <arpa/inet.h>
#endif

View File

@ -6,7 +6,7 @@
#include "protocol.h"
#include "util.h"
#ifndef __WXMSW__
#ifndef WIN32
# include <arpa/inet.h>
#endif

View File

@ -30,7 +30,7 @@ typedef unsigned long long uint64;
#define for if (false) ; else for
#endif
#ifdef __WXMSW__
#ifdef WIN32
#include <windows.h>
// This is used to attempt to keep keying material out of swap
// Note that VirtualLock does not provide this as a guarantee on Windows,

View File

@ -64,7 +64,7 @@ public:
ppmutexOpenSSL[i] = new boost::interprocess::interprocess_mutex();
CRYPTO_set_locking_callback(locking_callback);
#ifdef __WXMSW__
#ifdef WIN32
// Seed random number generator with screen scrape and other hardware sources
RAND_screen();
#endif
@ -108,7 +108,7 @@ void RandAddSeedPerfmon()
return;
nLastPerfmon = GetTime();
#ifdef __WXMSW__
#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];
@ -198,7 +198,7 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
}
}
#ifdef __WXMSW__
#ifdef WIN32
if (fPrintToDebugger)
{
static CCriticalSection cs_OutputDebugStringF;
@ -457,7 +457,7 @@ void ParseParameters(int argc, char* argv[])
pszValue = strchr(psz, '=');
*pszValue++ = '\0';
}
#ifdef __WXMSW__
#ifdef WIN32
_strlwr(psz);
if (psz[0] == '/')
psz[0] = '-';
@ -648,7 +648,7 @@ bool WildcardMatch(const string& str, const string& mask)
void FormatException(char* pszMessage, std::exception* pex, const char* pszThread)
{
#ifdef __WXMSW__
#ifdef WIN32
char pszModule[MAX_PATH];
pszModule[0] = '\0';
GetModuleFileNameA(NULL, pszModule, sizeof(pszModule));
@ -707,7 +707,7 @@ void PrintExceptionContinue(std::exception* pex, const char* pszThread)
#ifdef __WXMSW__
#ifdef WIN32
typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);
string MyGetSpecialFolderPath(int nFolder, bool fCreate)
@ -748,7 +748,7 @@ string GetDefaultDataDir()
// Windows: C:\Documents and Settings\username\Application Data\Bitcoin
// Mac: ~/Library/Application Support/Bitcoin
// Unix: ~/.bitcoin
#ifdef __WXMSW__
#ifdef WIN32
// Windows
return MyGetSpecialFolderPath(CSIDL_APPDATA, true) + "\\Bitcoin";
#else
@ -758,7 +758,7 @@ string GetDefaultDataDir()
string strHome = pszHome;
if (strHome[strHome.size()-1] != '/')
strHome += '/';
#ifdef __WXMAC_OSX__
#ifdef MAC_OSX
// Mac
strHome += "Library/Application Support/";
filesystem::create_directory(strHome.c_str());

View File

@ -7,7 +7,7 @@
#include "uint256.h"
#ifndef __WXMSW__
#ifndef WIN32
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
@ -81,7 +81,7 @@ T* alignup(T* p)
return u.ptr;
}
#ifdef __WXMSW__
#ifdef WIN32
#define MSG_NOSIGNAL 0
#define MSG_DONTWAIT 0
#ifndef UINT64_MAX
@ -123,7 +123,7 @@ inline int myclosesocket(SOCKET& hSocket)
{
if (hSocket == INVALID_SOCKET)
return WSAENOTSOCK;
#ifdef __WXMSW__
#ifdef WIN32
int ret = closesocket(hSocket);
#else
int ret = close(hSocket);
@ -192,7 +192,7 @@ std::string GetConfigFile();
std::string GetPidFile();
void CreatePidFile(std::string pidFile, pid_t pid);
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
#ifdef __WXMSW__
#ifdef WIN32
std::string MyGetSpecialFolderPath(int nFolder, bool fCreate);
#endif
std::string GetDefaultDataDir();
@ -390,7 +390,7 @@ inline void PrintHex(const std::vector<unsigned char>& vch, const char* pszForma
inline int64 GetPerformanceCounter()
{
int64 nCounter = 0;
#ifdef __WXMSW__
#ifdef WIN32
QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
#else
timeval t;
@ -424,7 +424,7 @@ void skipspaces(T& it)
inline bool IsSwitchChar(char c)
{
#ifdef __WXMSW__
#ifdef WIN32
return c == '-' || c == '/';
#else
return c == '-';
@ -467,7 +467,7 @@ inline bool GetBoolArg(const std::string& strArg)
inline void heapchk()
{
#ifdef __WXMSW__
#ifdef WIN32
/// for debugging
//if (_heapchk() != _HEAPOK)
// DebugBreak();
@ -626,7 +626,7 @@ public:
// Note: It turns out we might have been able to use boost::thread
// by using TerminateThread(boost::thread.native_handle(), 0);
#ifdef __WXMSW__
#ifdef WIN32
typedef HANDLE pthread_t;
inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false)
@ -708,7 +708,7 @@ inline void ExitThread(size_t nExitCode)
inline bool AffinityBugWorkaround(void(*pfn)(void*))
{
#ifdef __WXMSW__
#ifdef WIN32
// Sometimes after a few hours affinity gets stuck on one processor
DWORD_PTR dwProcessAffinityMask = -1;
DWORD_PTR dwSystemAffinityMask = -1;