From 33e902a74465110489c6566f5f0c035ad9432de4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 1 Jul 2022 18:30:37 +0200 Subject: compat: drop pre-C++20 macros.hpp header --- compat/check-visible.cpp | 2 +- compat/check-visible.hpp | 2 +- compat/correlation-calibrator.cpp | 2 +- compat/macros.h | 53 +++++++++++++++++++++++++++++++++++++++ compat/macros.hpp | 17 ------------- compat/macros1.h | 53 --------------------------------------- compat/shm.h | 4 ++- 7 files changed, 59 insertions(+), 74 deletions(-) create mode 100644 compat/macros.h delete mode 100644 compat/macros.hpp delete mode 100644 compat/macros1.h (limited to 'compat') diff --git a/compat/check-visible.cpp b/compat/check-visible.cpp index 4da649c7..621d941a 100644 --- a/compat/check-visible.cpp +++ b/compat/check-visible.cpp @@ -10,7 +10,7 @@ static bool visible = true; #if defined _WIN32 #include "timer.hpp" -#include "macros.hpp" +#include "macros.h" static Timer timer; diff --git a/compat/check-visible.hpp b/compat/check-visible.hpp index e24260ab..6669b84d 100644 --- a/compat/check-visible.hpp +++ b/compat/check-visible.hpp @@ -1,7 +1,7 @@ #pragma once #include "export.hpp" -#include "macros1.h" +#include "macros.h" class QWidget; diff --git a/compat/correlation-calibrator.cpp b/compat/correlation-calibrator.cpp index 4f08ecd5..07ef7d3d 100644 --- a/compat/correlation-calibrator.cpp +++ b/compat/correlation-calibrator.cpp @@ -2,7 +2,7 @@ #include "variance.hpp" #include "compat/math.hpp" #include "compat/meta.hpp" -#include "compat/macros1.h" +#include "compat/macros.h" #include #include diff --git a/compat/macros.h b/compat/macros.h new file mode 100644 index 00000000..5325d055 --- /dev/null +++ b/compat/macros.h @@ -0,0 +1,53 @@ +#pragma once + +#if defined _MSC_VER +# define never_inline __declspec(noinline) +#else +# define never_inline __attribute__((noinline)) +#endif + +#if defined _MSC_VER +# define force_inline __forceinline +#else +# define force_inline __attribute__((always_inline)) +#endif + +#if !defined likely +# if defined __GNUC__ +# define likely(x) __builtin_expect(!!(x),1) +# define unlikely(x) __builtin_expect(!!(x),0) +# else +# define likely(x) (x) +# define unlikely(x) (x) +# endif +#endif + +#if defined _MSC_VER +# define function_name __FUNCSIG__ +#else +# define function_name __PRETTY_FUNCTION__ +#endif + +#ifdef _MSC_VER +# define unreachable() do { __assume(0); *(volatile int*)nullptr = 0; } while (0) /* NOLINT(clang-analyzer-core.NullDereference) */ +#else +# define unreachable() do { __builtin_unreachable(); *(volatile int*)nullptr = 0; } while (0) /* NOLINT(clang-analyzer-core.NullDereference) */ +#endif + +#ifdef __cplusplus +# define progn(...) ([&]() -> decltype(auto) { __VA_ARGS__ }()) +# define eval_once2(expr, ctr) eval_once3(expr, ctr) +# define eval_once3(expr, ctr) ([&] { [[maybe_unused]] static const char init_ ## ctr = ((void)(expr), 0); }()) +# define eval_once(expr) eval_once2(expr, __COUNTER__) + +#define OTR_DISABLE_MOVE_COPY(type) \ + type(const type&) = delete; \ + type(type&&) = delete; \ + type& operator=(const type&) = delete; \ + type& operator=(type&&) = delete +#endif + +#ifdef _MSC_VER +# define strncasecmp _strnicmp +# define strcasecmp _stricmp +#endif diff --git a/compat/macros.hpp b/compat/macros.hpp deleted file mode 100644 index b6eea12b..00000000 --- a/compat/macros.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "macros1.h" - -#include -#include - -// before C++20 -namespace cxx20_compat { - template - struct remove_cvref { - using type = std::remove_cv_t>; - }; -} // ns cxx20_compat - -template -using remove_cvref_t = typename cxx20_compat::remove_cvref::type; diff --git a/compat/macros1.h b/compat/macros1.h deleted file mode 100644 index 5325d055..00000000 --- a/compat/macros1.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#if defined _MSC_VER -# define never_inline __declspec(noinline) -#else -# define never_inline __attribute__((noinline)) -#endif - -#if defined _MSC_VER -# define force_inline __forceinline -#else -# define force_inline __attribute__((always_inline)) -#endif - -#if !defined likely -# if defined __GNUC__ -# define likely(x) __builtin_expect(!!(x),1) -# define unlikely(x) __builtin_expect(!!(x),0) -# else -# define likely(x) (x) -# define unlikely(x) (x) -# endif -#endif - -#if defined _MSC_VER -# define function_name __FUNCSIG__ -#else -# define function_name __PRETTY_FUNCTION__ -#endif - -#ifdef _MSC_VER -# define unreachable() do { __assume(0); *(volatile int*)nullptr = 0; } while (0) /* NOLINT(clang-analyzer-core.NullDereference) */ -#else -# define unreachable() do { __builtin_unreachable(); *(volatile int*)nullptr = 0; } while (0) /* NOLINT(clang-analyzer-core.NullDereference) */ -#endif - -#ifdef __cplusplus -# define progn(...) ([&]() -> decltype(auto) { __VA_ARGS__ }()) -# define eval_once2(expr, ctr) eval_once3(expr, ctr) -# define eval_once3(expr, ctr) ([&] { [[maybe_unused]] static const char init_ ## ctr = ((void)(expr), 0); }()) -# define eval_once(expr) eval_once2(expr, __COUNTER__) - -#define OTR_DISABLE_MOVE_COPY(type) \ - type(const type&) = delete; \ - type(type&&) = delete; \ - type& operator=(const type&) = delete; \ - type& operator=(type&&) = delete -#endif - -#ifdef _MSC_VER -# define strncasecmp _strnicmp -# define strcasecmp _stricmp -#endif diff --git a/compat/shm.h b/compat/shm.h index d1363219..5036b335 100644 --- a/compat/shm.h +++ b/compat/shm.h @@ -20,7 +20,7 @@ #endif #include "export.hpp" -#include "macros1.h" +#include "macros.h" class OTR_COMPAT_EXPORT shm_wrapper final { @@ -39,4 +39,6 @@ public: bool unlock(); bool success(); inline void* ptr() { return mem; } + + OTR_DISABLE_MOVE_COPY(shm_wrapper); }; -- cgit v1.2.3