diff --git a/src/ipc.cpp b/src/ipc.cpp index bb58e6a..1828dd7 100644 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -43,7 +43,7 @@ struct msg_t<0, AlignSize> { template struct msg_t { - msg_t<0, AlignSize> head_ {}; + msg_t<0, AlignSize> head_ { 0, 0, 0, false }; std::aligned_storage_t data_ {}; msg_t() = default; diff --git a/src/platform/detail.h b/src/platform/detail.h index 5d89962..4f6e723 100644 --- a/src/platform/detail.h +++ b/src/platform/detail.h @@ -17,10 +17,21 @@ #ifdef IPC_UNUSED_ # error "IPC_UNUSED_ has been defined." #endif +#ifdef IPC_FALLTHROUGH_ +# error "IPC_FALLTHROUGH_ has been defined." +#endif +#ifdef IPC_STBIND_ +# error "IPC_STBIND_ has been defined." +#endif #if __cplusplus >= 201703L -# define IPC_UNUSED_ [[maybe_unused]] + +#define IPC_UNUSED_ [[maybe_unused]] +#define IPC_FALLTHROUGH_ [[fallthrough]] +#define IPC_STBIND_(A, B, ...) auto [A, B] = __VA_ARGS__ + #else /*__cplusplus < 201703L*/ + #if defined(_MSC_VER) # define IPC_UNUSED_ __pragma(warning(suppress: 4100 4101 4189)) #elif defined(__GNUC__) @@ -28,19 +39,14 @@ #else # define IPC_UNUSED_ #endif -#endif/*__cplusplus < 201703L*/ -#ifdef IPC_STBIND_ -# error "IPC_STBIND_ has been defined." -#endif +#define IPC_FALLTHROUGH_ + +#define IPC_STBIND_(A, B, ...) \ + auto tp___ = __VA_ARGS__ \ + auto A = std::get<0>(tp___); \ + auto B = std::get<1>(tp___) -#if __cplusplus >= 201703L -# define IPC_STBIND_(A, B, ...) auto [A, B] = __VA_ARGS__ -#else /*__cplusplus < 201703L*/ -# define IPC_STBIND_(A, B, ...) \ - auto tp___ = __VA_ARGS__ \ - auto A = std::get<0>(tp); \ - auto B = std::get<1>(tp) #endif/*__cplusplus < 201703L*/ #if __cplusplus >= 201703L diff --git a/src/prod_cons.h b/src/prod_cons.h index 2f44e98..016f465 100644 --- a/src/prod_cons.h +++ b/src/prod_cons.h @@ -6,7 +6,7 @@ #include #include "def.h" - +#include "platform/detail.h" #include "circ/elem_def.h" namespace ipc { @@ -363,7 +363,7 @@ struct prod_cons_impl> { return true; case 1: el->f_ct_.store(cur + N - 1, std::memory_order_release); - [[fallthrough]]; + IPC_FALLTHROUGH_; default: if (el->rc_.compare_exchange_weak( cur_rc, cur_rc + rc_incr - 1, std::memory_order_release)) {