From e951e0112946fdcba1a6d9263256f5b2b4c2f9eb Mon Sep 17 00:00:00 2001 From: gertjan Date: Fri, 23 Oct 2009 13:07:03 +0000 Subject: [PATCH] Replaced _MSC_VER with _WIN32 which will work on all windows compilers, not just MS ones git-svn-id: https://ttuki.vtt.fi/svn/p2p-next/TUD/p2tp/trunk@466 e16421f0-f15b-0410-abcd-98678b794739 --- bin.h | 2 +- bin64.h | 2 +- compat/hirestimeofday.cpp | 8 ++++---- compat/hirestimeofday.h | 4 ++-- compat/util.cpp | 4 ++-- datagram.cpp | 12 ++++++------ datagram.h | 4 ++-- hashtree.cpp | 2 +- p2tp.h | 4 ++-- transfer.cpp | 6 +++--- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/bin.h b/bin.h index ed02494..c16d398 100644 --- a/bin.h +++ b/bin.h @@ -9,7 +9,7 @@ #ifndef BIN_H #define BIN_H #include -#ifdef _MSC_VER +#ifdef _WIN32 // To avoid complaints about std::max. Appears to work in VS2008 #undef min #undef max diff --git a/bin64.h b/bin64.h index 16279a9..8ca1d6f 100644 --- a/bin64.h +++ b/bin64.h @@ -1,7 +1,7 @@ #ifndef BIN64_H #define BIN64_H #include -#ifdef _MSC_VER +#ifdef _WIN32 #include "compat/stdint.h" #else #include diff --git a/compat/hirestimeofday.cpp b/compat/hirestimeofday.cpp index d98380f..6a03c00 100644 --- a/compat/hirestimeofday.cpp +++ b/compat/hirestimeofday.cpp @@ -7,7 +7,7 @@ #include #include "compat/hirestimeofday.h" -#ifndef _MSC_VER +#ifndef _WIN32 #include #endif @@ -23,7 +23,7 @@ HiResTimeOfDay* HiResTimeOfDay::Instance() } -#ifdef _MSC_VER +#ifdef _WIN32 #include #include @@ -114,13 +114,13 @@ tint HiResTimeOfDay::getTimeUSec(void) // ARNOTODO: move to p2tp.cpp -#ifdef _MSC_VER +#ifdef _WIN32 static WSADATA _WSAData; #endif void LibraryInit(void) { -#ifdef _MSC_VER +#ifdef _WIN32 // win32 requires you to initialize the Winsock DLL with the desired // specification version WORD wVersionRequested; diff --git a/compat/hirestimeofday.h b/compat/hirestimeofday.h index 623a9f3..186a6a8 100644 --- a/compat/hirestimeofday.h +++ b/compat/hirestimeofday.h @@ -8,7 +8,7 @@ #ifndef HIRESTIMEOFDAY_H #define HIRESTIMEOFDAY_H -#ifdef _MSC_VER +#ifdef _WIN32 #include "compat/stdint.h" #include #else @@ -33,7 +33,7 @@ public: static HiResTimeOfDay* Instance(); private: -#ifdef _MSC_VER +#ifdef _WIN32 tint epochstart; // in usec LARGE_INTEGER epochcounter; LARGE_INTEGER last; diff --git a/compat/util.cpp b/compat/util.cpp index c352c5c..986d9f6 100644 --- a/compat/util.cpp +++ b/compat/util.cpp @@ -6,7 +6,7 @@ #include "util.h" #include -#ifdef _MSC_VER +#ifdef _WIN32 #include #include #endif @@ -16,7 +16,7 @@ namespace p2tp std::string gettmpdir(void) { -#ifdef _MSC_VER +#ifdef _WIN32 DWORD result = ::GetTempPath(0, _T("")); if (result == 0) throw std::runtime_error("Could not get system temp path"); diff --git a/datagram.cpp b/datagram.cpp index c218e66..5edadd7 100644 --- a/datagram.cpp +++ b/datagram.cpp @@ -8,7 +8,7 @@ */ #include -#ifdef _MSC_VER +#ifdef _WIN32 #include typedef int socklen_t; #else @@ -37,7 +37,7 @@ int Datagram::Recv () { length = recvfrom (sock, (char *)buf, MAXDGRAMSZ, 0, (struct sockaddr*)&(addr), &addrlen); if (length<0) -#ifdef _MSC_VER +#ifdef _WIN32 PLOG(ERROR)<<"on recv" << WSAGetLastError() << "\n"; #else PLOG(ERROR)<<"on recv"; @@ -71,7 +71,7 @@ SOCKET Datagram::Wait (int sockcnt, SOCKET* sockets, tint usec) { if (FD_ISSET(sockets[i],&bases)) return sockets[i]; } else if (sel<0) -#ifdef _MSC_VER +#ifdef _WIN32 PLOG(ERROR)<<"select fails" << WSAGetLastError() << "\n"; #else PLOG(ERROR)<<"select fails"; @@ -96,7 +96,7 @@ SOCKET Datagram::Bind (Address addr_) { PLOG(ERROR)<<"socket fails"; return -1; } -#ifdef _MSC_VER +#ifdef _WIN32 u_long enable = 1; ioctlsocket(fd, FIONBIO, &enable); if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (const char *)&sndbuf, sizeof(int)) != 0 ) { @@ -132,7 +132,7 @@ SOCKET Datagram::Bind (Address addr_) { } void Datagram::Close (int sock) { // remove from fd_set -#ifdef _MSC_VER +#ifdef _WIN32 if (closesocket(sock)!=0) #else if (::close(sock)!=0) @@ -143,7 +143,7 @@ void Datagram::Close (int sock) { // remove from fd_set std::string sock2str (struct sockaddr_in addr) { char ipch[32]; -#ifdef _MSC_VER +#ifdef _WIN32 //Vista only: InetNtop(AF_INET,&(addr.sin_addr),ipch,32); // IPv4 only: struct in_addr inaddr; diff --git a/datagram.h b/datagram.h index 3a56152..45099e2 100644 --- a/datagram.h +++ b/datagram.h @@ -9,7 +9,7 @@ #ifndef DATAGRAM_H #define DATAGRAM_H -#ifdef _MSC_VER +#ifdef _WIN32 #include "compat/stdint.h" #include #include "compat/unixio.h" @@ -35,7 +35,7 @@ namespace p2tp { #define MAXDGRAMSZ 1400 -#ifndef _MSC_VER +#ifndef _WIN32 #define INVALID_SOCKET -1 #endif diff --git a/hashtree.cpp b/hashtree.cpp index aa82018..096067a 100644 --- a/hashtree.cpp +++ b/hashtree.cpp @@ -10,7 +10,7 @@ #include "hashtree.h" #include #include -#ifndef _MSC_VER +#ifndef _WIN32 #include #endif #include diff --git a/p2tp.h b/p2tp.h index 5fc296a..6b50663 100644 --- a/p2tp.h +++ b/p2tp.h @@ -49,7 +49,7 @@ Messages #ifndef P2TP_H #define P2TP_H -#ifdef _MSC_VER +#ifdef _WIN32 #include "compat/stdint.h" #else #include @@ -159,7 +159,7 @@ namespace p2tp { PiecePicker* picker_; /** File for keeping the Merkle hash tree. */ int hashfd_; -#ifdef _MSC_VER +#ifdef _WIN32 HANDLE hashmaphandle_; #endif /** Merkle hash tree: root */ diff --git a/transfer.cpp b/transfer.cpp index 1bdcd64..7928303 100644 --- a/transfer.cpp +++ b/transfer.cpp @@ -6,7 +6,7 @@ * Copyright 2009 Delft University of Technology. All rights reserved. * */ -#ifdef _MSC_VER +#ifdef _WIN32 #include "compat/unixio.h" #else #include @@ -112,7 +112,7 @@ void FileTransfer::SetSize (size_t bytes) { // peaks/root must be already set fstat(hashfd_, &hash_file_st); if ( hash_file_st.st_size != expected_size_ ) ftruncate(hashfd_, expected_size_); -#ifdef _MSC_VER +#ifdef _WIN32 HANDLE hashhandle = (HANDLE)_get_osfhandle(hashfd_); hashmaphandle_ = CreateFileMapping(hashhandle, NULL, @@ -291,7 +291,7 @@ void FileTransfer::OfferPeak (bin64_t pos, const Sha1Hash& hash) { FileTransfer::~FileTransfer () { -#ifdef _MSC_VER +#ifdef _WIN32 UnmapViewOfFile(hashes_); CloseHandle(hashmaphandle_); #else -- 2.20.1