Browse Source

Use _WIN32 define in kNet.

Lasse Öörni 10 years ago
parent
commit
a47c72aa4b

+ 1 - 1
Source/ThirdParty/kNet/include/kNet.h

@@ -21,7 +21,7 @@
 #include "kNetBuildConfig.h"
 #include "kNetFwd.h"
 
-#ifdef WIN32
+#ifdef _WIN32
 #include "kNet/win32/WS2Include.h"
 #endif
 

+ 2 - 2
Source/ThirdParty/kNet/include/kNet/Atomics.h

@@ -15,7 +15,7 @@
 
 // Modified by Lasse Oorni for Urho3D
 
-#ifdef WIN32
+#ifdef _WIN32
 // Urho3D: windows.h in lowercase to fix MinGW cross-compiling on a case-sensitive system
 #include <windows.h>
 #endif
@@ -28,7 +28,7 @@
 // Returns true if the assignment succeeded.
 // Do NOT call this macro with any side expressions on dst, newVal or cmp.
 
-#ifdef WIN32
+#ifdef _WIN32
 // See http://msdn.microsoft.com/en-us/library/ms683568(VS.85).aspx
 #define CmpXChgPointer(dst, newVal, cmp) (InterlockedCompareExchangePointer((dst), (newVal), (cmp)) == (cmp))
 #else

+ 2 - 2
Source/ThirdParty/kNet/include/kNet/Clock.h

@@ -18,7 +18,7 @@
 
 // Modifed by Lasse Oorni for Urho3D
 
-#ifdef WIN32
+#ifdef _WIN32
 // Urho3D: windows.h in lowercase to fix MinGW cross-compiling on a case-sensitive system
 #include <windows.h>
 #endif
@@ -113,7 +113,7 @@ private:
 	/// Initializes clock tick frequency and marks the application startup time.
 	static void InitClockData();
 
-#ifdef WIN32
+#ifdef _WIN32
 	static LARGE_INTEGER ddwTimerFrequency; ///< Ticks per second.
 	static LARGE_INTEGER ddwTimer;          ///< Temporary storage for Win32 function calls.
 #endif

+ 2 - 2
Source/ThirdParty/kNet/include/kNet/EndPoint.h

@@ -69,7 +69,7 @@ struct EndPoint
 	static EndPoint FromSockAddrIn(const sockaddr_in &addr)
 	{
 		EndPoint endPoint;
-#ifdef WIN32
+#ifdef _WIN32
 		endPoint.ip[0] = addr.sin_addr.S_un.S_un_b.s_b1;
 		endPoint.ip[1] = addr.sin_addr.S_un.S_un_b.s_b2;
 		endPoint.ip[2] = addr.sin_addr.S_un.S_un_b.s_b3;
@@ -94,7 +94,7 @@ struct EndPoint
 		memset(&address, 0, sizeof(address));
 		address.sin_family = AF_INET;
 		address.sin_port = htons(port);
-#ifdef WIN32
+#ifdef _WIN32
 		address.sin_addr.S_un.S_un_b.s_b1 = ip[0];
 		address.sin_addr.S_un.S_un_b.s_b2 = ip[1];
 		address.sin_addr.S_un.S_un_b.s_b3 = ip[2];

+ 2 - 2
Source/ThirdParty/kNet/include/kNet/Event.h

@@ -16,7 +16,7 @@
 /** @file Event.h
 	@brief The class \ref kNet::Event Event. Provides a mechanism for inter-thread signalling. */
 
-#ifdef WIN32
+#ifdef _WIN32
 #include "win32/WS2Include.h"
 #endif
 
@@ -92,7 +92,7 @@ public:
 private:
 	EventWaitType type;
 
-#ifdef WIN32
+#ifdef _WIN32
 public:
 	WSAEVENT wsaEvent;
 

+ 1 - 1
Source/ThirdParty/kNet/include/kNet/EventArray.h

@@ -60,7 +60,7 @@ private:
 	static const int maxEvents = 64; ///< WSAWaitForMultipleEvents has a built-in limit of 64 items, hence this value.
 	int numAdded;
 
-#ifdef WIN32
+#ifdef _WIN32
 	WSAEVENT events[maxEvents]; 
 
 #elif defined(KNET_UNIX) || defined(ANDROID)

+ 8 - 8
Source/ThirdParty/kNet/include/kNet/Lockable.h

@@ -21,7 +21,7 @@
 #ifdef KNET_USE_BOOST
 #include <boost/thread/recursive_mutex.hpp>
 #include <boost/thread/thread.hpp>
-#elif defined(WIN32)
+#elif defined(_WIN32)
 // Urho3D: windows.h in lowercase to fix MinGW cross-compiling on a case-sensitive system
 #include <windows.h>
 #else
@@ -154,7 +154,7 @@ public:
 	Lockable()
 	{
 #ifndef KNET_USE_BOOST
-#ifdef WIN32
+#ifdef _WIN32
 		InitializeCriticalSection(&lockObject);
 #else
 		pthread_mutexattr_t attr;
@@ -176,7 +176,7 @@ public:
 	:value(value_)
 	{
 #ifndef KNET_USE_BOOST
-#ifdef WIN32
+#ifdef _WIN32
 		InitializeCriticalSection(&lockObject);
 #else
 		pthread_mutexattr_t attr;
@@ -190,7 +190,7 @@ public:
 	~Lockable()
 	{
 #ifndef KNET_USE_BOOST
-#ifdef WIN32
+#ifdef _WIN32
 		DeleteCriticalSection(&lockObject);
 #else
 		pthread_mutex_destroy(&mutex);
@@ -213,7 +213,7 @@ public:
 	{
 #ifdef KNET_USE_BOOST
 		boostMutex.lock();
-#elif defined(WIN32)
+#elif defined(_WIN32)
 		EnterCriticalSection(&lockObject);
 #else
 		pthread_mutex_lock(&mutex);
@@ -225,7 +225,7 @@ public:
 	{
 #ifdef KNET_USE_BOOST
 		boostMutex.lock();
-#elif defined(WIN32)
+#elif defined(_WIN32)
 		EnterCriticalSection(&lockObject);
 #else
 		pthread_mutex_lock(&mutex);
@@ -237,7 +237,7 @@ public:
 	{
 #ifdef KNET_USE_BOOST
 		boostMutex.unlock();
-#elif defined(WIN32)
+#elif defined(_WIN32)
 		LeaveCriticalSection(&lockObject);
 #else
 		pthread_mutex_unlock(&mutex);
@@ -274,7 +274,7 @@ public:
 
 #ifdef KNET_USE_BOOST
 	mutable boost::recursive_mutex boostMutex;
-#elif defined(WIN32)
+#elif defined(_WIN32)
 	mutable CRITICAL_SECTION lockObject;
 #else
 	mutable pthread_mutex_t mutex;

+ 1 - 1
Source/ThirdParty/kNet/include/kNet/Network.h

@@ -175,7 +175,7 @@ private:
 	void Init();
 	void DeInit();
 
-#ifdef WIN32
+#ifdef _WIN32
 	WSADATA wsaData;
 #endif
 };

+ 1 - 1
Source/ThirdParty/kNet/include/kNet/NetworkWorkerThread.h

@@ -56,7 +56,7 @@ private:
 	void MainLoop();
 };
 
-#ifdef WIN32
+#ifdef _WIN32
 DWORD WINAPI NetworkWorkerThreadMain(LPVOID lpParameter);
 #endif
 

+ 6 - 6
Source/ThirdParty/kNet/include/kNet/Socket.h

@@ -16,7 +16,7 @@
 /** @file Socket.h
 	@brief The Socket class. */
 
-#ifdef WIN32
+#ifdef _WIN32
 
 #include "kNetBuildConfig.h"
 #include "win32/WS2Include.h"
@@ -92,7 +92,7 @@ std::string SocketTypeToString(SocketType type);
 
 typedef int OverlappedTransferTag;
 
-#ifdef WIN32
+#ifdef _WIN32
 typedef WSABUF kNetBuffer;
 #else
 struct kNetBuffer
@@ -109,7 +109,7 @@ struct kNetBuffer
 struct OverlappedTransferBuffer
 {
 	kNetBuffer buffer;
-#ifdef WIN32
+#ifdef _WIN32
 	WSAOVERLAPPED overlapped;
 #endif
 
@@ -205,7 +205,7 @@ public:
 	/// This frees the given buffer, do not dereference it after calling this function.
 	void AbortSend(OverlappedTransferBuffer *send);
 
-#ifdef WIN32
+#ifdef _WIN32
 	/// Returns the number of sends in the send queue.
 	int NumOverlappedSendsInProgress() const { return queuedSendBuffers.Size(); }
 	/// Returns the maximum number of sends that can be queued up simultaneously.
@@ -234,7 +234,7 @@ public:
 	OverlappedTransferBuffer *BeginReceive();
 	/// Finishes a read operation on the socket. Frees the given buffer to be re-queued for a future socket read operation.
 	void EndReceive(OverlappedTransferBuffer *buffer);
-#ifdef WIN32
+#ifdef _WIN32
 	/// Returns the number of receive buffers that have been queued for the socket.
 	int NumOverlappedReceivesInProgress() const { return queuedReceiveBuffers.Size(); }
 	/// Returns the maximum number of receive buffers that can be queued for the socket.
@@ -336,7 +336,7 @@ private:
 	/// Tracks whether the socket is open for receiving data (doesn't mean that there necessarily exists new data to be read).
 	bool readOpen;
 
-#ifdef WIN32
+#ifdef _WIN32
 	WaitFreeQueue<OverlappedTransferBuffer*> queuedReceiveBuffers;
 	WaitFreeQueue<OverlappedTransferBuffer*> queuedSendBuffers;
 

+ 3 - 3
Source/ThirdParty/kNet/include/kNet/Thread.h

@@ -27,7 +27,7 @@
 // Urho3D: include Event.h first to make sure WS2Include.h is included before windows.h / winsock.h
 #include "Event.h"
 
-#ifdef WIN32
+#ifdef _WIN32
 // Urho3D: windows.h in lowercase to fix MinGW cross-compiling on a case-sensitive system
 #include <windows.h>
 #else
@@ -50,7 +50,7 @@ namespace kNet
 
 #if defined(KNET_USE_BOOST) && defined(KNET_ENABLE_WINXP_SUPPORT)
 typedef boost::thread::id ThreadId;
-#elif defined(WIN32)
+#elif defined(_WIN32)
 typedef DWORD ThreadId; // Don't use boost::thread::id on Windows even if KNET_USE_BOOST is #defined, since it has issues identifying threads across dll boundaries.
 #elif defined(KNET_USE_BOOST)
 typedef boost::thread::id ThreadId;
@@ -202,7 +202,7 @@ private:
 
 #ifdef KNET_USE_BOOST
 	boost::thread thread;
-#elif defined(WIN32)
+#elif defined(_WIN32)
 	HANDLE threadHandle;
 	ThreadId threadId;
 

+ 14 - 14
Source/ThirdParty/kNet/src/Clock.cpp

@@ -27,7 +27,7 @@
 #include <sys/time.h>
 #endif
 
-#ifdef WIN32
+#ifdef _WIN32
 #define NOMINMAX
 #include <windows.h>
 #endif
@@ -42,7 +42,7 @@
 namespace kNet
 {
 
-#ifdef WIN32
+#ifdef _WIN32
 LARGE_INTEGER Clock::ddwTimerFrequency;
 #endif
 
@@ -55,7 +55,7 @@ void Clock::InitClockData()
 	if (appStartTime == 0)
 		appStartTime = Tick();
 
-#ifdef WIN32
+#ifdef _WIN32
 	if (!QueryPerformanceFrequency(&ddwTimerFrequency))
 	{
 		KNET_LOG(LogError, "The system doesn't support high-resolution timers!");
@@ -88,7 +88,7 @@ void Clock::Sleep(int milliseconds)
 {
 #ifdef WIN8RT
 #pragma WARNING(Clock::Sleep has not been implemented!)
-#elif defined(WIN32)
+#elif defined(_WIN32)
 	::Sleep(milliseconds);
 #elif !defined(__native_client__) && !defined(__EMSCRIPTEN__) && !defined(__APPLE__)
 	// http://linux.die.net/man/2/nanosleep
@@ -105,7 +105,7 @@ void Clock::Sleep(int milliseconds)
 
 int Clock::Year()
 {
-#ifdef WIN32
+#ifdef _WIN32
 	SYSTEMTIME s;
 	GetSystemTime(&s);
 	return s.wYear;
@@ -117,7 +117,7 @@ int Clock::Year()
 
 int Clock::Month()
 {
-#ifdef WIN32
+#ifdef _WIN32
 	SYSTEMTIME s;
 	GetSystemTime(&s);
 	return s.wMonth;
@@ -129,7 +129,7 @@ int Clock::Month()
 
 int Clock::Day()
 {
-#ifdef WIN32
+#ifdef _WIN32
 	SYSTEMTIME s;
 	GetSystemTime(&s);
 	return s.wDay;
@@ -141,7 +141,7 @@ int Clock::Day()
 
 int Clock::Hour()
 {
-#ifdef WIN32
+#ifdef _WIN32
 	SYSTEMTIME s;
 	GetSystemTime(&s);
 	return s.wHour;
@@ -153,7 +153,7 @@ int Clock::Hour()
 
 int Clock::Min()
 {
-#ifdef WIN32
+#ifdef _WIN32
 	SYSTEMTIME s;
 	GetSystemTime(&s);
 	return s.wMinute;
@@ -165,7 +165,7 @@ int Clock::Min()
 
 int Clock::Sec()
 {
-#ifdef WIN32
+#ifdef _WIN32
 	SYSTEMTIME s;
 	GetSystemTime(&s);
 	return s.wSecond;
@@ -177,7 +177,7 @@ int Clock::Sec()
 
 unsigned long Clock::SystemTime()
 {
-#ifdef WIN32
+#ifdef _WIN32
 #if WINVER >= 0x0600 && !defined(KNET_ENABLE_WINXP_SUPPORT)
 	return (unsigned long)GetTickCount64();
 #else
@@ -209,7 +209,7 @@ tick_t Clock::Tick()
 	// scale it to microseconds (1e-6) and return as a tick.
 	return (tick_t)(((double)emscripten_get_now()) * 1e3);
 //	return (tick_t)clock();
-#elif defined(WIN32)
+#elif defined(_WIN32)
 	LARGE_INTEGER ddwTimer;
 	QueryPerformanceCounter(&ddwTimer);
 	return ddwTimer.QuadPart;
@@ -228,7 +228,7 @@ tick_t Clock::Tick()
 
 unsigned long Clock::TickU32()
 {
-#ifdef WIN32
+#ifdef _WIN32
 	LARGE_INTEGER ddwTimer;
 	QueryPerformanceCounter(&ddwTimer);
 	return ddwTimer.LowPart;
@@ -244,7 +244,7 @@ tick_t Clock::TicksPerSec()
 #elif defined(__EMSCRIPTEN__)
 	return 1000000ULL; // 1e6 == microseconds.
 //	return CLOCKS_PER_SEC;
-#elif defined(WIN32)
+#elif defined(_WIN32)
 	return ddwTimerFrequency.QuadPart;
 #elif defined(_POSIX_MONOTONIC_CLOCK)
 	return 1000 * 1000 * 1000;

+ 2 - 2
Source/ThirdParty/kNet/src/MessageConnection.cpp

@@ -1247,13 +1247,13 @@ void MessageConnection::DumpStatus() const
 		MsgsInPerSec(), MsgsOutPerSec(), 
 		FormatBytes(BytesInPerSec()).c_str(), FormatBytes(BytesOutPerSec()).c_str(),
 		(int)eventMsgsOutAvailable.Test(), 
-#ifdef WIN32
+#ifdef _WIN32
 		socket ? socket->NumOverlappedReceivesInProgress() : -1,
 #else
 		-1,
 #endif
 		(socket && socket->GetOverlappedReceiveEvent().Test()) ? "true" : "false",
-#ifdef WIN32
+#ifdef _WIN32
 		socket ? socket->NumOverlappedSendsInProgress() : -1,
 #else
 		-1,

+ 9 - 9
Source/ThirdParty/kNet/src/Network.cpp

@@ -49,7 +49,7 @@ const int cMaxUDPSendSize = 1400;
 
 std::string Network::GetErrorString(int error)
 {
-#ifdef WIN32
+#ifdef _WIN32
 	void *lpMsgBuf = 0;
 
 	HRESULT hresult = HRESULT_FROM_WIN32(error);
@@ -70,7 +70,7 @@ std::string Network::GetErrorString(int error)
 
 int Network::GetLastError()
 {
-#ifdef WIN32
+#ifdef _WIN32
 	return WSAGetLastError();
 #else
 	return errno;
@@ -105,7 +105,7 @@ std::string FormatBytes(double numBytes)
 
 Network::Network()
 {
-#ifdef WIN32
+#ifdef _WIN32
 	memset(&wsaData, 0, sizeof(wsaData));
 #endif
 	Init();
@@ -163,7 +163,7 @@ void Network::PrintAddrInfo(const addrinfo *ptr)
 	case AF_INET6:
 		KNET_LOG(LogInfo, "AF_INET6 (IPv6)\n");
 		break;
-#ifdef WIN32
+#ifdef _WIN32
 	case AF_NETBIOS:
 		KNET_LOG(LogInfo, "AF_NETBIOS (NetBIOS)\n");
 		break;
@@ -267,7 +267,7 @@ void Network::PrintHostNameInfo(const char *hostname, const char *port)
 
 void Network::Init()
 {
-#ifdef WIN32
+#ifdef _WIN32
 	// Initialize Winsock
 	int result = WSAStartup(MAKEWORD(2,2), &wsaData);
 	if (result != 0)
@@ -528,7 +528,7 @@ void Network::DeInit()
 	}
 
 	// Deinitialize network subsystem.
-#ifdef WIN32
+#ifdef _WIN32
 	WSACleanup();
 #endif
 
@@ -575,7 +575,7 @@ Socket *Network::OpenListenSocket(unsigned short port, SocketTransportLayer tran
 		// Allow other sockets to be bound to this address after this. 
 		// (Possibly unsecure, only enable for development purposes - to avoid having to wait for the server listen socket 
 		//  to time out if the server crashes.)
-#ifdef WIN32
+#ifdef _WIN32
 		BOOL val = TRUE;
 		ret = setsockopt(listenSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val));
 #else
@@ -649,7 +649,7 @@ Socket *Network::ConnectSocket(const char *address, unsigned short port, SocketT
 		return 0;
 	}
 
-#ifdef WIN32
+#ifdef _WIN32
 	SOCKET connectSocket = WSASocket(result->ai_family, result->ai_socktype, result->ai_protocol,
 		NULL, 0, WSA_FLAG_OVERLAPPED);
 #else
@@ -664,7 +664,7 @@ Socket *Network::ConnectSocket(const char *address, unsigned short port, SocketT
 	}
 
 	// Connect to server.
-#ifdef WIN32
+#ifdef _WIN32
 	ret = WSAConnect(connectSocket, result->ai_addr, (int)result->ai_addrlen, 0, 0, 0, 0);
 #else
 	ret = connect(connectSocket, result->ai_addr, (int)result->ai_addrlen);

+ 24 - 24
Source/ThirdParty/kNet/src/Socket.cpp

@@ -42,7 +42,7 @@ using namespace std;
 #include <unistd.h>
 #endif
 
-#ifdef WIN32
+#ifdef _WIN32
 const int numConcurrentReceiveBuffers = 4;
 const int numConcurrentSendBuffers = 4;
 #endif
@@ -100,7 +100,7 @@ type(InvalidSocketType),
 maxSendSize(0),
 writeOpen(false),
 readOpen(false)
-#ifdef WIN32
+#ifdef _WIN32
 ,queuedReceiveBuffers(numConcurrentReceiveBuffers)
 ,queuedSendBuffers(numConcurrentSendBuffers)
 #endif
@@ -114,7 +114,7 @@ Socket::~Socket()
 	// We cannot Close() the socket here, since the same underlying BSD SOCKET handle can be shared
 	// between multiple Socket objects. We rely instead to non-RAII behavior and manually remembering to 
 	// Close().
-#ifdef WIN32
+#ifdef _WIN32
 	FreeOverlappedTransferBuffers();
 #endif
 }
@@ -126,7 +126,7 @@ Socket::Socket(SOCKET connection, const EndPoint &localEndPoint_, const char *lo
 remoteEndPoint(remoteEndPoint_), remoteHostName(remoteHostName_), 
 transport(transport_), type(type_), maxSendSize(maxSendSize_),
 writeOpen(true), readOpen(true)
-#ifdef WIN32
+#ifdef _WIN32
 ,queuedReceiveBuffers(numConcurrentReceiveBuffers)
 ,queuedSendBuffers(numConcurrentSendBuffers)
 #endif
@@ -137,7 +137,7 @@ writeOpen(true), readOpen(true)
 }
 
 Socket::Socket(const Socket &rhs)
-#ifdef WIN32
+#ifdef _WIN32
 :queuedReceiveBuffers(numConcurrentReceiveBuffers)
 ,queuedSendBuffers(numConcurrentSendBuffers)
 #endif
@@ -147,7 +147,7 @@ Socket::Socket(const Socket &rhs)
 
 Socket &Socket::operator=(const Socket &rhs)
 {
-#ifdef WIN32
+#ifdef _WIN32
 	// We would be losing data if Socket is copied from old to new when data is present in the receive buffers,
 	// since the receive buffers are not moved or copied to the new Socket.
 	assert(queuedReceiveBuffers.Size() == 0);
@@ -184,7 +184,7 @@ OverlappedTransferBuffer *AllocateOverlappedTransferBuffer(int bytes)
 	buffer->buffer.len = bytes;
 	buffer->bytesContains = 0;
     buffer->bytesAllocated = bytes;
-#ifdef WIN32
+#ifdef _WIN32
 	buffer->overlapped.hEvent = WSACreateEvent();
 	if (buffer->overlapped.hEvent == WSA_INVALID_EVENT)
 	{
@@ -203,7 +203,7 @@ void DeleteOverlappedTransferBuffer(OverlappedTransferBuffer *buffer)
 	if (!buffer)
 		return;
 	delete[] buffer->buffer.buf;
-#ifdef WIN32
+#ifdef _WIN32
 	BOOL success = WSACloseEvent(buffer->overlapped.hEvent);
 	if (success == FALSE)
 		KNET_LOG(LogError, "Socket.cpp:DeleteOverlappedTransferBuffer: WSACloseEvent failed!");
@@ -251,7 +251,7 @@ int Socket::ReceiveBufferSize() const
 	return bytes;
 }
 
-#ifdef WIN32
+#ifdef _WIN32
 void Socket::EnqueueNewReceiveBuffer(OverlappedTransferBuffer *buffer)
 {
 	if (!readOpen || queuedReceiveBuffers.CapacityLeft() == 0 || IsUDPSlaveSocket())
@@ -433,7 +433,7 @@ bool Socket::IsOverlappedReceiveReady() const
 	if (IsUDPSlaveSocket()) // UDP slave sockets are never read directly. For these sockets, act as if they're never ready for reads.
 		return false;
 
-#ifdef WIN32
+#ifdef _WIN32
 	if (queuedReceiveBuffers.Size() == 0)
 		return false;
 	return Event((*queuedReceiveBuffers.Front())->overlapped.hEvent, EventWaitRead).Test();
@@ -452,7 +452,7 @@ Event Socket::GetOverlappedReceiveEvent()
 	if (IsUDPSlaveSocket()) // UDP slave sockets are never read directly. For these sockets, return a null event that never fires.
 		return Event();
 
-#ifdef WIN32
+#ifdef _WIN32
 	if (readOpen)
 	{
 		/// Prime the receive buffers to the full capacity if they weren't so yet.
@@ -478,7 +478,7 @@ Event Socket::GetOverlappedSendEvent()
 	if (!writeOpen)
 		return Event();
 
-#ifdef WIN32
+#ifdef _WIN32
 	if (queuedSendBuffers.Size() == 0)
 		return Event();
 
@@ -497,13 +497,13 @@ OverlappedTransferBuffer *Socket::BeginReceive()
 	// The slave sockets don't receive data directly, but the server socket is used instead to receive data for them.
 	if (IsUDPSlaveSocket())
 	{
-#ifdef WIN32
+#ifdef _WIN32
 		assert(queuedReceiveBuffers.Size() == 0); // We shouldn't ever have queued a single receive buffer for this Socket.
 #endif
 		return 0; // If we happen to come here, act as if the socket never received any data.
 	}
 
-#ifdef WIN32
+#ifdef _WIN32
 	if (readOpen)
 	{
 		// Insert new empty receive buffers to the Overlapped Transfer receive queue until we have a full capacity queue primed.
@@ -595,7 +595,7 @@ OverlappedTransferBuffer *Socket::BeginReceive()
 
 void Socket::EndReceive(OverlappedTransferBuffer *buffer)
 {
-#ifdef WIN32
+#ifdef _WIN32
 	if (readOpen)
 	{
 		EnqueueNewReceiveBuffer(buffer);
@@ -662,12 +662,12 @@ void Socket::Close()
 	readOpen = false;
 	writeOpen = false;
 
-#ifdef WIN32
+#ifdef _WIN32
 	FreeOverlappedTransferBuffers();
 #endif
 }
 
-#ifdef WIN32
+#ifdef _WIN32
 void Socket::FreeOverlappedTransferBuffers()
 {
 	KNET_LOG(LogVerbose, "Socket::FreeOverlappedTransferBuffers(), this: %p.", this);
@@ -685,7 +685,7 @@ void Socket::SetBlocking(bool isBlocking)
 	if (connectSocket == INVALID_SOCKET)
 		return;
 
-#ifdef WIN32
+#ifdef _WIN32
 	u_long nonBlocking = (isBlocking == false) ? 1 : 0;
 	if (ioctlsocket(connectSocket, FIONBIO, &nonBlocking))
 		KNET_LOG(LogError, "Socket::SetBlocking: ioctlsocket failed with error %s!", Network::GetLastErrorString().c_str());
@@ -778,7 +778,7 @@ bool Socket::Send(const char *data, size_t numBytes)
 
 bool Socket::WaitForSendReady(int msecs)
 {
-#ifdef WIN32
+#ifdef _WIN32
 	fd_set writeSet;
 	FD_ZERO(&writeSet);
 	FD_SET(connectSocket, &writeSet);
@@ -796,7 +796,7 @@ bool Socket::IsOverlappedSendReady()
 	if (!writeOpen)
 		return false;
 
-#ifdef WIN32
+#ifdef _WIN32
 	if (queuedSendBuffers.CapacityLeft() > 0)
 		return true;
 
@@ -819,7 +819,7 @@ OverlappedTransferBuffer *Socket::BeginSend(int maxBytesToSend)
 
 	// See if the oldest one of the previously submitted transfers has now finished,
 	// and reuse that buffer without allocating a new one, if so.
-#ifdef WIN32
+#ifdef _WIN32
 	if (queuedSendBuffers.Size() > 0)
 	{
 		OverlappedTransferBuffer *sentData = *queuedSendBuffers.Front();
@@ -873,7 +873,7 @@ bool Socket::EndSend(OverlappedTransferBuffer *sendBuffer)
 	// number of bytes the user had filled into the buffer.
 	sendBuffer->buffer.len = sendBuffer->bytesContains;
 
-#ifdef WIN32
+#ifdef _WIN32
 	// Clear the event flag so that the completion of WSASend can trigger this and signal us.
 	WSAResetEvent(sendBuffer->overlapped.hEvent);
 
@@ -925,7 +925,7 @@ void Socket::AbortSend(OverlappedTransferBuffer *send)
 		return;
 	}
 
-#ifdef WIN32
+#ifdef _WIN32
 	// Set the event flag so as to signal that this buffer is completed immediately.
 	if (WSASetEvent(send->overlapped.hEvent) != TRUE)
 	{
@@ -979,7 +979,7 @@ void Socket::SetNaglesAlgorithmEnabled(bool enabled)
 		return;
 	}
 
-#ifdef WIN32
+#ifdef _WIN32
 	BOOL nagleEnabled = enabled ? TRUE : FALSE;
 	int ret = setsockopt(connectSocket, IPPROTO_TCP, TCP_NODELAY, (const char *)&nagleEnabled, sizeof(nagleEnabled));
 #else

+ 1 - 1
Source/ThirdParty/kNet/src/Thread.cpp

@@ -89,7 +89,7 @@ void Thread::CheckHold()
 }
 
 // This code adapted from http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx "How to: Set a Thread Name in Native Code":
-#ifdef WIN32
+#ifdef _WIN32
 const DWORD MS_VC_EXCEPTION=0x406D1388;
 
 #pragma pack(push,8)

+ 3 - 3
Source/ThirdParty/kNet/src/boost/BoostThread.cpp

@@ -93,7 +93,7 @@ void Thread::Sleep(int msecs)
 
 ThreadId Thread::Id()
 {
-#if defined(WIN32) && !defined(KNET_ENABLE_WINXP_SUPPORT)
+#if defined(_WIN32) && !defined(KNET_ENABLE_WINXP_SUPPORT)
 	HANDLE threadHandle = (HANDLE)thread.native_handle();
 	if (threadHandle == NULL)
 		return NullThreadId();
@@ -108,7 +108,7 @@ ThreadId Thread::Id()
 
 ThreadId Thread::CurrentThreadId()
 {
-#if defined(WIN32) && !defined(KNET_ENABLE_WINXP_SUPPORT)
+#if defined(_WIN32) && !defined(KNET_ENABLE_WINXP_SUPPORT)
 	// On Windows, don't rely on Boost, since it is known to improperly read thread ids at least on Boost 1.40.0.
 	return GetCurrentThreadId();
 #else
@@ -118,7 +118,7 @@ ThreadId Thread::CurrentThreadId()
 
 ThreadId Thread::NullThreadId()
 {
-#if defined(WIN32) && !defined(KNET_ENABLE_WINXP_SUPPORT)
+#if defined(_WIN32) && !defined(KNET_ENABLE_WINXP_SUPPORT)
 	return 0;
 #else
 	return boost::thread::id();

+ 2 - 2
Source/ThirdParty/kNet/src/win32/W32Event.cpp

@@ -14,7 +14,7 @@
 
 /** @file W32Event.cpp
 	@brief */
-#ifdef WIN32
+#ifdef _WIN32
 
 #include <cassert>
 
@@ -103,4 +103,4 @@ bool Event::IsValid() const
 
 } // ~kNet
 
-#endif // ~WIN32
+#endif // ~_WIN32