From e8dda2c1d40626734f783b8d60e4683963d438a3 Mon Sep 17 00:00:00 2001 From: mutouyun Date: Thu, 24 Jan 2019 23:47:45 +0800 Subject: [PATCH] remove __has_include() --- src/platform/tls_pointer_win.cpp | 6 ------ src/platform/waiter_linux.h | 22 +++++++++++----------- src/platform/waiter_win.h | 6 ------ 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/platform/tls_pointer_win.cpp b/src/platform/tls_pointer_win.cpp index 5d150a0..f8b33fa 100644 --- a/src/platform/tls_pointer_win.cpp +++ b/src/platform/tls_pointer_win.cpp @@ -1,7 +1,3 @@ -#if __has_include() -#include "tls_pointer_linux.cpp" -#else /*!__has_include()*/ - #include "tls_pointer.h" #include // ::Tls... @@ -183,5 +179,3 @@ extern "C" NX_CRTALLOC_(".tls") const IMAGE_TLS_DIRECTORY _tls_used = { #endif/*_MSC_VER, __GNUC__*/ } // namespace ipc - -#endif/*!__has_include()*/ diff --git a/src/platform/waiter_linux.h b/src/platform/waiter_linux.h index 24742bd..f899aae 100644 --- a/src/platform/waiter_linux.h +++ b/src/platform/waiter_linux.h @@ -18,11 +18,11 @@ class waiter { std::atomic counter_ { 0 }; public: - using handle_t = waiter*; + using handle_t = bool; public: constexpr static handle_t invalid() { - return nullptr; + return false; } handle_t open(char const * name) { @@ -63,26 +63,26 @@ public: // release guards guard_mutex.release(); } - return this; + return true; } void close(handle_t h) { if (h == invalid()) return; - if (h->counter_.fetch_sub(1, std::memory_order_acq_rel) == 1) { + if (counter_.fetch_sub(1, std::memory_order_acq_rel) == 1) { ::printf("destroy...\n"); - ::pthread_cond_destroy (&(h->cond_ )); - ::pthread_mutex_destroy(&(h->mutex_)); + ::pthread_cond_destroy(&cond_); + ::pthread_mutex_destroy(&mutex_); ::printf("destroy end...\n"); } } bool wait(handle_t h) { if (h == invalid()) return false; - if (::pthread_mutex_lock(&(h->mutex_)) != 0) { + if (::pthread_mutex_lock(&mutex_) != 0) { return false; } - IPC_UNUSED_ auto guard = unique_ptr(&(h->mutex_), ::pthread_mutex_unlock); - if (::pthread_cond_wait(&(h->cond_), &(h->mutex_)) != 0) { + IPC_UNUSED_ auto guard = unique_ptr(&mutex_, ::pthread_mutex_unlock); + if (::pthread_cond_wait(&cond_, &mutex_) != 0) { return false; } return true; @@ -90,12 +90,12 @@ public: void notify(handle_t h) { if (h == invalid()) return; - ::pthread_cond_signal(&(h->cond_)); + ::pthread_cond_signal(&cond_); } void broadcast(handle_t h) { if (h == invalid()) return; - ::pthread_cond_broadcast(&(h->cond_)); + ::pthread_cond_broadcast(&cond_); } }; diff --git a/src/platform/waiter_win.h b/src/platform/waiter_win.h index 03bb6b8..8807088 100644 --- a/src/platform/waiter_win.h +++ b/src/platform/waiter_win.h @@ -1,9 +1,5 @@ #pragma once -#if __has_include() -#include "waiter_linux.h" -#else /*!__has_include()*/ - #include #include @@ -59,5 +55,3 @@ public: } // namespace detail } // namespace ipc - -#endif/*!__has_include()*/