Browse Source

WIN32 -> _WIN32

metaverse
jl777 7 years ago
parent
commit
9cb1ec9c6e
  1. 2
      src/bitcoind.cpp
  2. 10
      src/compat.h
  3. 14
      src/init.cpp
  4. 2
      src/komodo_pax.h
  5. 2
      src/komodo_structs.h
  6. 10
      src/komodo_utils.h
  7. 4
      src/metrics.cpp
  8. 16
      src/net.cpp
  9. 2
      src/net.h
  10. 18
      src/netbase.cpp
  11. 2
      src/netbase.h
  12. 2
      src/protocol.cpp
  13. 6
      src/random.cpp
  14. 6
      src/support/pagelocker.cpp
  15. 2
      src/test/alert_tests.cpp
  16. 30
      src/util.cpp
  17. 6
      src/util.h
  18. 2
      src/wallet/db.cpp

2
src/bitcoind.cpp

@ -173,7 +173,7 @@ bool AppInit(int argc, char* argv[])
exit(1);
}
#ifndef WIN32
#ifndef _WIN32
fDaemon = GetBoolArg("-daemon", false);
if (fDaemon)
{

10
src/compat.h

@ -10,7 +10,7 @@
#include "config/bitcoin-config.h"
#endif
#ifdef WIN32
#ifdef _WIN32
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
@ -46,7 +46,7 @@
#include <unistd.h>
#endif
#ifdef WIN32
#ifdef _WIN32
#define MSG_DONTWAIT 0
#else
typedef u_int SOCKET;
@ -64,7 +64,7 @@ typedef u_int SOCKET;
#define SOCKET_ERROR -1
#endif
#ifdef WIN32
#ifdef _WIN32
#ifndef S_IRUSR
#define S_IRUSR 0400
#define S_IWUSR 0200
@ -78,7 +78,7 @@ typedef u_int SOCKET;
#define MSG_NOSIGNAL 0
#endif
#ifndef WIN32
#ifndef _WIN32
// PRIO_MAX is not defined on Solaris
#ifndef PRIO_MAX
#define PRIO_MAX 20
@ -94,7 +94,7 @@ size_t strnlen( const char *start, size_t max_len);
#endif // HAVE_DECL_STRNLEN
bool static inline IsSelectableSocket(SOCKET s) {
#ifdef WIN32
#ifdef _WIN32
return true;
#else
return (s < FD_SETSIZE);

14
src/init.cpp

@ -40,7 +40,7 @@
#include <stdint.h>
#include <stdio.h>
#ifndef WIN32
#ifndef _WIN32
#include <signal.h>
#endif
@ -74,7 +74,7 @@ bool fFeeEstimatesInitialized = false;
static CZMQNotificationInterface* pzmqNotificationInterface = NULL;
#endif
#ifdef WIN32
#ifdef _WIN32
// Win32 LevelDB doesn't use file descriptors, and the ones used for
// accessing block files don't count towards the fd_set size limit
// anyway.
@ -236,7 +236,7 @@ void Shutdown()
}
#endif
#ifndef WIN32
#ifndef _WIN32
try {
boost::filesystem::remove(GetPidFile());
} catch (const boost::filesystem::filesystem_error& e) {
@ -334,7 +334,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-maxorphantx=<n>", strprintf(_("Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS));
strUsage += HelpMessageOpt("-par=<n>", strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"),
-(int)boost::thread::hardware_concurrency(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS));
#ifndef WIN32
#ifndef _WIN32
strUsage += HelpMessageOpt("-pid=<file>", strprintf(_("Specify pid file (default: %s)"), "komodod.pid"));
#endif
strUsage += HelpMessageOpt("-prune=<n>", strprintf(_("Reduce storage requirements by pruning (deleting) old blocks. This mode disables wallet support and is incompatible with -txindex. "
@ -716,7 +716,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// Disable confusing "helpful" text message on abort, Ctrl-C
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#endif
#ifdef WIN32
#ifdef _WIN32
// Enable Data Execution Prevention (DEP)
// Minimum supported OS versions: WinXP SP3, WinVista >= SP1, Win Server 2008
// A failure is non-critical and needs no further attention!
@ -733,7 +733,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
if (!SetupNetworking())
return InitError("Error: Initializing networking failed");
#ifndef WIN32
#ifndef _WIN32
if (GetBoolArg("-sysperms", false)) {
#ifdef ENABLE_WALLET
if (!GetBoolArg("-disablewallet", false))
@ -1047,7 +1047,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Komodo is probably already running.") + " %s.", strDataDir, e.what()));
}
#ifndef WIN32
#ifndef _WIN32
CreatePidFile(GetPidFile(), getpid());
#endif
if (GetBoolArg("-shrinkdebugfile", !fDebug))

2
src/komodo_pax.h

@ -233,7 +233,7 @@ int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize)
{
static uint32_t lastcrc;
FILE *fp; char fname[512]; uint32_t crc32,check,timestamp; int32_t i,n=0,retval,fsize,len=0; uint8_t data[8192];
#ifdef WIN32
#ifdef _WIN32
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"komodofeed");
#else
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),(char *)"komodofeed");

2
src/komodo_structs.h

@ -16,7 +16,7 @@
#include "uthash.h"
#include "utlist.h"
/*#ifdef WIN32
/*#ifdef _WIN32
#define PACKED
#else
#define PACKED __attribute__((packed))

10
src/komodo_utils.h

@ -1305,7 +1305,7 @@ void komodo_statefname(char *fname,char *symbol,char *str)
}
else
{
#ifdef WIN32
#ifdef _WIN32
strcat(fname,"\\");
#else
strcat(fname,"/");
@ -1315,7 +1315,7 @@ void komodo_statefname(char *fname,char *symbol,char *str)
{
strcat(fname,symbol);
//printf("statefname.(%s) -> (%s)\n",symbol,fname);
#ifdef WIN32
#ifdef _WIN32
strcat(fname,"\\");
#else
strcat(fname,"/");
@ -1347,7 +1347,7 @@ void komodo_configfile(char *symbol,uint16_t port)
password[i*2] = 0;
sprintf(buf,"%s.conf",symbol);
BITCOIND_PORT = port;
#ifdef WIN32
#ifdef _WIN32
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),buf);
#else
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),buf);
@ -1371,7 +1371,7 @@ void komodo_configfile(char *symbol,uint16_t port)
}
}
strcpy(fname,GetDataDir().string().c_str());
#ifdef WIN32
#ifdef _WIN32
while ( fname[strlen(fname)-1] != '\\' )
fname[strlen(fname)-1] = 0;
strcat(fname,"komodo.conf");
@ -1576,7 +1576,7 @@ void komodo_args(char *argv0)
for (iter=0; iter<2; iter++)
{
strcpy(fname,GetDataDir().string().c_str());
#ifdef WIN32
#ifdef _WIN32
while ( fname[strlen(fname)-1] != '\\' )
fname[strlen(fname)-1] = 0;
if ( iter == 0 )

4
src/metrics.cpp

@ -411,7 +411,7 @@ void ThreadShowMetricsScreen()
// Get current window size
if (isTTY) {
#ifdef WIN32
#ifdef _WIN32
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
cols = csbi.srWindow.Right - csbi.srWindow.Left + 1;
@ -421,7 +421,7 @@ void ThreadShowMetricsScreen()
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1 && w.ws_col != 0) {
cols = w.ws_col;
}
#endif
#endif
}
if (isScreen) {

16
src/net.cpp

@ -17,7 +17,7 @@
#include "ui_interface.h"
#include "crypto/common.h"
#ifdef WIN32
#ifdef _WIN32
#include <string.h>
#else
#include <fcntl.h>
@ -42,7 +42,7 @@
// Fix for ancient MinGW versions, that don't have defined these in ws2tcpip.h.
// Todo: Can be removed when our pull-tester is upgraded to a modern MinGW version.
#ifdef WIN32
#ifdef _WIN32
#ifndef PROTECTION_LEVEL_UNRESTRICTED
#define PROTECTION_LEVEL_UNRESTRICTED 10
#endif
@ -930,7 +930,7 @@ static void AcceptConnection(const ListenSocket& hListenSocket) {
// According to the internet TCP_NODELAY is not carried into accepted sockets
// on all platforms. Set it again here just to be sure.
int set = 1;
#ifdef WIN32
#ifdef _WIN32
setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&set, sizeof(int));
#else
setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (void*)&set, sizeof(int));
@ -1727,7 +1727,7 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste
}
#ifndef WIN32
#ifndef _WIN32
#ifdef SO_NOSIGPIPE
// Different way of disabling SIGPIPE on BSD
setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));
@ -1753,13 +1753,13 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste
// and enable it by default or not. Try to enable it, if possible.
if (addrBind.IsIPv6()) {
#ifdef IPV6_V6ONLY
#ifdef WIN32
#ifdef _WIN32
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&nOne, sizeof(int));
#else
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int));
#endif
#endif
#ifdef WIN32
#ifdef _WIN32
int nProtLevel = PROTECTION_LEVEL_UNRESTRICTED;
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_PROTECTION_LEVEL, (const char*)&nProtLevel, sizeof(int));
#endif
@ -1800,7 +1800,7 @@ void static Discover(boost::thread_group& threadGroup)
if (!fDiscover)
return;
#ifdef WIN32
#ifdef _WIN32
// Get local host IP
char pszHostName[256] = "";
if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR)
@ -1945,7 +1945,7 @@ public:
delete pnodeLocalHost;
pnodeLocalHost = NULL;
#ifdef WIN32
#ifdef _WIN32
// Shutdown Windows Sockets
WSACleanup();
#endif

2
src/net.h

@ -22,7 +22,7 @@
#include <deque>
#include <stdint.h>
#ifndef WIN32
#ifndef _WIN32
#include <arpa/inet.h>
#endif

18
src/netbase.cpp

@ -26,7 +26,7 @@
#include <netdb.h>
#endif
#ifndef WIN32
#ifndef _WIN32
#if HAVE_INET_PTON
#include <arpa/inet.h>
#endif
@ -129,7 +129,7 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsign
aiHint.ai_socktype = SOCK_STREAM;
aiHint.ai_protocol = IPPROTO_TCP;
aiHint.ai_family = AF_UNSPEC;
#ifdef WIN32
#ifdef _WIN32
aiHint.ai_flags = fAllowLookup ? 0 : AI_NUMERICHOST;
#else
aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST;
@ -454,7 +454,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
#endif
//Disable Nagle's algorithm
#ifdef WIN32
#ifdef _WIN32
setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&set, sizeof(int));
#else
setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (void*)&set, sizeof(int));
@ -488,7 +488,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
return false;
}
socklen_t nRetSize = sizeof(nRet);
#ifdef WIN32
#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)
@ -505,7 +505,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
return false;
}
}
#ifdef WIN32
#ifdef _WIN32
else if (WSAGetLastError() != WSAEISCONN)
#else
else
@ -1348,7 +1348,7 @@ bool operator<(const CSubNet& a, const CSubNet& b)
return (a.network < b.network || (a.network == b.network && memcmp(a.netmask, b.netmask, 16) < 0));
}
#ifdef WIN32
#ifdef _WIN32
std::string NetworkErrorString(int err)
{
char buf[256];
@ -1386,7 +1386,7 @@ bool CloseSocket(SOCKET& hSocket)
{
if (hSocket == INVALID_SOCKET)
return false;
#ifdef WIN32
#ifdef _WIN32
int ret = closesocket(hSocket);
#else
int ret = close(hSocket);
@ -1398,7 +1398,7 @@ bool CloseSocket(SOCKET& hSocket)
bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking)
{
if (fNonBlocking) {
#ifdef WIN32
#ifdef _WIN32
u_long nOne = 1;
if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) {
#else
@ -1409,7 +1409,7 @@ bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking)
return false;
}
} else {
#ifdef WIN32
#ifdef _WIN32
u_long nZero = 0;
if (ioctlsocket(hSocket, FIONBIO, &nZero) == SOCKET_ERROR) {
#else

2
src/netbase.h

@ -22,7 +22,7 @@ extern bool fNameLookup;
/** -timeout default */
static const int DEFAULT_CONNECT_TIMEOUT = 5000;
#ifdef WIN32
#ifdef _WIN32
// In MSVC, this is defined as a macro, undefine it to prevent a compile and link error
#undef SetPort
#endif

2
src/protocol.cpp

@ -8,7 +8,7 @@
#include "util.h"
#include "utilstrencodings.h"
#ifndef WIN32
#ifndef _WIN32
# include <arpa/inet.h>
#endif

6
src/random.cpp

@ -6,7 +6,7 @@
#include "random.h"
#include "support/cleanse.h"
#ifdef WIN32
#ifdef _WIN32
#include "compat.h" // for Windows API
#endif
#include "serialize.h" // for begin_ptr(vec)
@ -15,7 +15,7 @@
#include <limits>
#ifndef WIN32
#ifndef _WIN32
#include <sys/time.h>
#endif
@ -24,7 +24,7 @@
static inline int64_t GetPerformanceCounter()
{
int64_t nCounter = 0;
#ifdef WIN32
#ifdef _WIN32
QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
#else
timeval t;

6
src/support/pagelocker.cpp

@ -8,7 +8,7 @@
#include "config/bitcoin-config.h"
#endif
#ifdef WIN32
#ifdef _WIN32
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
@ -49,7 +49,7 @@ static inline size_t GetSystemPageSize()
bool MemoryPageLocker::Lock(const void* addr, size_t len)
{
#ifdef WIN32
#ifdef _WIN32
return VirtualLock(const_cast<void*>(addr), len) != 0;
#else
return mlock(addr, len) == 0;
@ -58,7 +58,7 @@ bool MemoryPageLocker::Lock(const void* addr, size_t len)
bool MemoryPageLocker::Unlock(const void* addr, size_t len)
{
#ifdef WIN32
#ifdef _WIN32
return VirtualUnlock(const_cast<void*>(addr), len) != 0;
#else
return munlock(addr, len) == 0;

2
src/test/alert_tests.cpp

@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE(AlertNotify)
// Windows built-in echo semantics are different than posixy shells. Quotes and
// whitespace are printed literally.
#ifndef WIN32
#ifndef _WIN32
BOOST_CHECK_EQUAL(r[0], "Alert 1");
BOOST_CHECK_EQUAL(r[1], "Alert 2, cancels 1");
BOOST_CHECK_EQUAL(r[2], "Alert 2, cancels 1");

30
src/util.cpp

@ -23,7 +23,7 @@
#include <pthread_np.h>
#endif
#ifndef WIN32
#ifndef _WIN32
// for posix_fallocate
#ifdef __linux__
@ -335,7 +335,7 @@ void ParseParameters(int argc, const char* const argv[])
strValue = str.substr(is_index+1);
str = str.substr(0, is_index);
}
#ifdef WIN32
#ifdef _WIN32
boost::to_lower(str);
if (boost::algorithm::starts_with(str, "/"))
str = "-" + str.substr(1);
@ -419,7 +419,7 @@ std::string HelpMessageOpt(const std::string &option, const std::string &message
static std::string FormatException(const std::exception* pex, const char* pszThread)
{
#ifdef WIN32
#ifdef _WIN32
char pszModule[MAX_PATH] = "";
GetModuleFileNameA(NULL, pszModule, sizeof(pszModule));
#else
@ -455,7 +455,7 @@ boost::filesystem::path GetDefaultDataDir()
// Windows >= Vista: C:\Users\Username\AppData\Roaming\Zcash
// Mac: ~/Library/Application Support/Zcash
// Unix: ~/.zcash
#ifdef WIN32
#ifdef _WIN32
// Windows
if ( symbol[0] == 0 )
return GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo";
@ -502,7 +502,7 @@ static boost::filesystem::path ZC_GetBaseParamsDir()
// Windows >= Vista: C:\Users\Username\AppData\Roaming\ZcashParams
// Mac: ~/Library/Application Support/ZcashParams
// Unix: ~/.zcash-params
#ifdef WIN32
#ifdef _WIN32
// Windows
return GetSpecialFolderPath(CSIDL_APPDATA) / "ZcashParams";
#else
@ -648,7 +648,7 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
//fprintf(stderr,"from conf file %s RPC %u, used to be %u\n",ASSETCHAINS_SYMBOL,BITCOIND_PORT,BITCOIND_PORT);
}
#ifndef WIN32
#ifndef _WIN32
boost::filesystem::path GetPidFile()
{
boost::filesystem::path pathPidFile(GetArg("-pid", "komodod.pid"));
@ -669,13 +669,13 @@ void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
{
#ifdef WIN32
#ifdef _WIN32
return MoveFileExA(src.string().c_str(), dest.string().c_str(),
MOVEFILE_REPLACE_EXISTING) != 0;
#else
int rc = std::rename(src.string().c_str(), dest.string().c_str());
return (rc == 0);
#endif /* WIN32 */
#endif /* _WIN32 */
}
/**
@ -700,7 +700,7 @@ bool TryCreateDirectory(const boost::filesystem::path& p)
void FileCommit(FILE *fileout)
{
fflush(fileout); // harmless if redundantly called
#ifdef WIN32
#ifdef _WIN32
HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(fileout));
FlushFileBuffers(hFile);
#else
@ -815,7 +815,7 @@ void ShrinkDebugFile()
fclose(file);
}
#ifdef WIN32
#ifdef _WIN32
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate)
{
namespace fs = boost::filesystem;
@ -838,7 +838,7 @@ boost::filesystem::path GetTempPath() {
#else
// TODO: remove when we don't support filesystem v2 anymore
boost::filesystem::path path;
#ifdef WIN32
#ifdef _WIN32
char pszPath[MAX_PATH] = "";
if (GetTempPathA(MAX_PATH, pszPath))
@ -898,7 +898,7 @@ void SetupEnvironment()
bool SetupNetworking()
{
#ifdef WIN32
#ifdef _WIN32
// Initialize Windows Sockets
WSADATA wsadata;
int ret = WSAStartup(MAKEWORD(2,2), &wsadata);
@ -910,15 +910,15 @@ bool SetupNetworking()
void SetThreadPriority(int nPriority)
{
#ifdef WIN32
#ifdef _WIN32
SetThreadPriority(GetCurrentThread(), nPriority);
#else // WIN32
#else // _WIN32
#ifdef PRIO_THREAD
setpriority(PRIO_THREAD, 0, nPriority);
#else // PRIO_THREAD
setpriority(PRIO_PROCESS, 0, nPriority);
#endif // PRIO_THREAD
#endif // WIN32
#endif // _WIN32
}
std::string PrivacyInfo()

6
src/util.h

@ -124,7 +124,7 @@ boost::filesystem::path GetDefaultDataDir();
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
void ClearDatadirCache();
boost::filesystem::path GetConfigFile();
#ifndef WIN32
#ifndef _WIN32
boost::filesystem::path GetPidFile();
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
#endif
@ -133,7 +133,7 @@ public:
missing_zcash_conf() : std::runtime_error("Missing komodo.conf") { }
};
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
#ifdef WIN32
#ifdef _WIN32
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
#endif
boost::filesystem::path GetTempPath();
@ -150,7 +150,7 @@ std::string LicenseInfo();
inline bool IsSwitchChar(char c)
{
#ifdef WIN32
#ifdef _WIN32
return c == '-' || c == '/';
#else
return c == '-';

2
src/wallet/db.cpp

@ -13,7 +13,7 @@
#include <stdint.h>
#ifndef WIN32
#ifndef _WIN32
#include <sys/stat.h>
#endif

Loading…
Cancel
Save