From b9d8e59bbf727fcc1a073bbf27e5d1703b9490ef Mon Sep 17 00:00:00 2001 From: kwolekr Date: Wed, 13 Feb 2013 22:43:15 -0500 Subject: Add emerge.cpp, initial EmergeThread changes - Neatly placed all emerge related code into a new file, emerge.cpp - Greatly cleaned up the code in EmergeThread::Thread() - Reworked Emerge queue. Now an actual std::queue of v3s16 block positions - Removed the completely unnecessary map of peer ids requesting blocks --- src/jthread/jmutex.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/jthread') diff --git a/src/jthread/jmutex.h b/src/jthread/jmutex.h index 9ce013096..6675162a5 100644 --- a/src/jthread/jmutex.h +++ b/src/jthread/jmutex.h @@ -67,4 +67,54 @@ private: bool initialized; }; +#ifdef _WIN32 + +class Event { + HANDLE hEvent; + +public: + Event() { + hEvent = CreateEvent(NULL, 0, 0, NULL); + } + + ~Event() { + CloseHandle(hEvent); + } + + void wait() { + WaitForSingleObject(hEvent, INFINITE); + } + + void signal() { + SetEvent(hEvent); + } +} + +#else + +#include + +class Event { + sem_t sem; + +public: + Event() { + sem_init(&sem, 0, 0); + } + + ~Event() { + sem_destroy(&sem); + } + + void wait() { + sem_wait(&sem); + } + + void signal() { + sem_post(&sem); + } +}; + +#endif + #endif // JMUTEX_H -- cgit v1.2.3 From 28c50c16cdeda7de39ed15c17094f3de01287d4c Mon Sep 17 00:00:00 2001 From: kwolekr Date: Sat, 23 Feb 2013 12:30:13 -0500 Subject: Fix build on Windows --- src/debug.h | 3 +++ src/jthread/jmutex.h | 5 ++++- src/porting.h | 7 +++++-- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src/jthread') diff --git a/src/debug.h b/src/debug.h index 69a215a42..56952427c 100644 --- a/src/debug.h +++ b/src/debug.h @@ -32,6 +32,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN + #ifndef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 + #endif #include #ifdef _MSC_VER #include diff --git a/src/jthread/jmutex.h b/src/jthread/jmutex.h index 6675162a5..e528aeb4a 100644 --- a/src/jthread/jmutex.h +++ b/src/jthread/jmutex.h @@ -30,6 +30,9 @@ #define JMUTEX_H #if (defined(WIN32) || defined(_WIN32_WCE)) + #ifndef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 + #endif #ifndef _WIN32_WCE #include #endif // _WIN32_WCE @@ -88,7 +91,7 @@ public: void signal() { SetEvent(hEvent); } -} +}; #else diff --git a/src/porting.h b/src/porting.h index 03d2fcbd3..d7d107340 100644 --- a/src/porting.h +++ b/src/porting.h @@ -40,14 +40,17 @@ with this program; if not, write to the Free Software Foundation, Inc., //#define ALIGNOF(type) offsetof (alignment_trick, member) #ifdef _WIN32 + #ifndef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 + #endif #include #define sleep_ms(x) Sleep(x) #else #include #include //for uintptr_t - - #if defined(linux) || defined(__linux) + + #if (defined(linux) || defined(__linux)) && !defined(_GNU_SOURCE) #define _GNU_SOURCE #endif -- cgit v1.2.3