diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..8226365c --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +.DS_Store +.idea +*.log +tmp/ + +# Created by https://www.toptal.com/developers/gitignore/api/c++ +# Edit at https://www.toptal.com/developers/gitignore?templates=c++ + +### C++ ### +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# End of https://www.toptal.com/developers/gitignore/api/c++ + diff --git a/CometSearch/Common.h b/CometSearch/Common.h index 8db19542..8999b892 100644 --- a/CometSearch/Common.h +++ b/CometSearch/Common.h @@ -43,6 +43,11 @@ typedef __int64 comet_fileoffset_t; #include #include #define STRCMP_IGNORE_CASE(a,b) strcasecmp(a,b) +#ifdef __APPLE__ +#define off64_t off_t +#define fseeko64 fseeko +#define ftello64 ftello +#endif typedef off64_t comet_fileoffset_t; #define comet_fseek(handle, offset, whence) fseeko64(handle, offset, whence) #define comet_ftell(handle) ftello64(handle) diff --git a/CometSearch/ThreadPool.h b/CometSearch/ThreadPool.h index 7cdf496b..a8e54572 100644 --- a/CometSearch/ThreadPool.h +++ b/CometSearch/ThreadPool.h @@ -139,8 +139,10 @@ class ThreadPool this->UNLOCK(&this->lock_); //Threading::ThreadSleep(100); // When threads are still busy and no jobs to do wait ... -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__APPLE__) pthread_yield(); +#elif __APPLE__ + sched_yield(); #else std::this_thread::yield(); #endif @@ -179,8 +181,10 @@ class ThreadPool while(data_.size() > 0 && running_count_ >= (int)data_.size()) { this->UNLOCK(&countlock_); -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__APPLE__) pthread_yield(); +#elif __APPLE__ + sched_yield(); #else std::this_thread::yield(); #endif @@ -336,8 +340,10 @@ inline void* threadStart(void* ptr) { tp->UNLOCK(&tp->lock_); -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__APPLE__) pthread_yield(); +#elif __APPLE__ + sched_yield(); #else std::this_thread::yield(); #endif