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 ++- cv/translation-calibrator.cpp | 2 +- cv/video-widget.cpp | 2 +- dinput/dinput.cpp | 2 +- dinput/keybinding-worker.cpp | 2 +- dinput/win32-joystick.cpp | 2 +- filter-accela/ftnoir_filter_accela.h | 1 - logic/pipeline.cpp | 2 +- opentrack/main-window.cpp | 2 +- options/base-value.hpp | 1 - options/globals.hpp | 2 +- options/group.hpp | 2 +- options/metatype.cpp | 1 - options/slider.hpp | 1 - options/value.hpp | 1 - proto-iokit-foohid/foohidjoystick.cpp | 2 -- proto-iokit-foohid/iokitprotocol.cpp | 2 -- proto-libevdev/ftnoir_protocol_libevdev.h | 1 - proto-vjoystick/vjoystick.h | 1 - qxt-mini/powerset.hpp | 2 -- spline/spline-widget.cpp | 1 - spline/spline.cpp | 6 ++-- tracker-easy/preview.cpp | 2 +- tracker-kinect-face/kinect_face_settings.h | 1 - tracker-kinect-face/kinect_face_tracker.h | 1 - tracker-test/test.h | 1 - tracker-trackhat/trackhat.hpp | 1 - video-ps3eye/module.hpp | 2 +- 34 files changed, 73 insertions(+), 106 deletions(-) create mode 100644 compat/macros.h delete mode 100644 compat/macros.hpp delete mode 100644 compat/macros1.h 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); }; diff --git a/cv/translation-calibrator.cpp b/cv/translation-calibrator.cpp index 8fe9a1b8..6fb3e638 100644 --- a/cv/translation-calibrator.cpp +++ b/cv/translation-calibrator.cpp @@ -8,7 +8,7 @@ #include "translation-calibrator.hpp" #include "compat/euler.hpp" #include "compat/math.hpp" -#include "compat/macros1.h" +#include "compat/macros.h" #include #include diff --git a/cv/video-widget.cpp b/cv/video-widget.cpp index 6d8c0be3..7accd275 100644 --- a/cv/video-widget.cpp +++ b/cv/video-widget.cpp @@ -1,5 +1,5 @@ #include "video-widget.hpp" -#include "compat/macros1.h" +#include "compat/macros.h" #include void cv_video_widget::update_image(const cv::Mat& frame) diff --git a/dinput/dinput.cpp b/dinput/dinput.cpp index 7a0e9cab..b9713b8a 100644 --- a/dinput/dinput.cpp +++ b/dinput/dinput.cpp @@ -1,7 +1,7 @@ #undef NDEBUG #include "dinput.hpp" -#include "compat/macros.hpp" +#include "compat/macros.h" #include #include diff --git a/dinput/keybinding-worker.cpp b/dinput/keybinding-worker.cpp index 02036352..7cd8d663 100644 --- a/dinput/keybinding-worker.cpp +++ b/dinput/keybinding-worker.cpp @@ -9,7 +9,7 @@ #ifdef _WIN32 #include "keybinding-worker.hpp" -#include "compat/macros.hpp" +#include "compat/macros.h" #include "compat/thread-name.hpp" #include diff --git a/dinput/win32-joystick.cpp b/dinput/win32-joystick.cpp index 90350651..cb7a3837 100644 --- a/dinput/win32-joystick.cpp +++ b/dinput/win32-joystick.cpp @@ -1,7 +1,7 @@ #ifdef _WIN32 #include "win32-joystick.hpp" -#include "compat/macros.hpp" +#include "compat/macros.h" #include #include diff --git a/filter-accela/ftnoir_filter_accela.h b/filter-accela/ftnoir_filter_accela.h index ddd3bc03..0d6dca1b 100644 --- a/filter-accela/ftnoir_filter_accela.h +++ b/filter-accela/ftnoir_filter_accela.h @@ -12,7 +12,6 @@ #include "api/plugin-api.hpp" #include "compat/timer.hpp" #include "compat/variance.hpp" -#include "compat/macros.hpp" #include #include diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp index 4bb11424..2f88c8b1 100644 --- a/logic/pipeline.cpp +++ b/logic/pipeline.cpp @@ -15,7 +15,7 @@ #include "compat/sleep.hpp" #include "compat/math.hpp" #include "compat/meta.hpp" -#include "compat/macros.hpp" +#include "compat/macros.h" #include "compat/thread-name.hpp" #include "pipeline.hpp" diff --git a/opentrack/main-window.cpp b/opentrack/main-window.cpp index fadcf1e5..c021eaec 100644 --- a/opentrack/main-window.cpp +++ b/opentrack/main-window.cpp @@ -13,7 +13,7 @@ #include "migration/migration.hpp" #include "compat/check-visible.hpp" #include "compat/sleep.hpp" -#include "compat/macros.hpp" +#include "compat/macros.h" #include "compat/library-path.hpp" #include "compat/math.hpp" #include "compat/sysexits.hpp" diff --git a/options/base-value.hpp b/options/base-value.hpp index 81da0513..7b65d524 100644 --- a/options/base-value.hpp +++ b/options/base-value.hpp @@ -6,7 +6,6 @@ #include "metatype.hpp" #include "export.hpp" -#include "compat/macros.hpp" #include "value-traits.hpp" #include diff --git a/options/globals.hpp b/options/globals.hpp index 7af6533d..af242dc9 100644 --- a/options/globals.hpp +++ b/options/globals.hpp @@ -1,7 +1,7 @@ #pragma once #include "export.hpp" -#include "compat/macros.hpp" +#include "compat/macros.h" #include diff --git a/options/group.hpp b/options/group.hpp index 93299b6e..11bab965 100644 --- a/options/group.hpp +++ b/options/group.hpp @@ -4,7 +4,7 @@ #include "compat/base-path.hpp" #include "compat/library-path.hpp" -#include "compat/macros.hpp" +#include "compat/macros.h" #include "compat/qhash.hpp" #include "export.hpp" diff --git a/options/metatype.cpp b/options/metatype.cpp index 7962b81b..7430c00a 100644 --- a/options/metatype.cpp +++ b/options/metatype.cpp @@ -1,5 +1,4 @@ #include -#include "compat/macros.hpp" namespace options::detail { diff --git a/options/slider.hpp b/options/slider.hpp index 5d21bf0f..1e721ae0 100644 --- a/options/slider.hpp +++ b/options/slider.hpp @@ -8,7 +8,6 @@ #pragma once #include "export.hpp" -#include "compat/macros.hpp" #include diff --git a/options/value.hpp b/options/value.hpp index 4476f8b7..c752d497 100644 --- a/options/value.hpp +++ b/options/value.hpp @@ -14,7 +14,6 @@ #include "slider.hpp" #include "base-value.hpp" #include "value-traits.hpp" -#include "compat/macros.hpp" #include #include diff --git a/proto-iokit-foohid/foohidjoystick.cpp b/proto-iokit-foohid/foohidjoystick.cpp index 898db2f4..b4964bb7 100644 --- a/proto-iokit-foohid/foohidjoystick.cpp +++ b/proto-iokit-foohid/foohidjoystick.cpp @@ -7,8 +7,6 @@ #include "foohidjoystick.h" -#include "compat/macros.hpp" - const char FOOHID_SERVICE_NAME[] = "it_unbit_foohid"; enum class FooHIDMethod { diff --git a/proto-iokit-foohid/iokitprotocol.cpp b/proto-iokit-foohid/iokitprotocol.cpp index 77a1e005..a364fd8a 100644 --- a/proto-iokit-foohid/iokitprotocol.cpp +++ b/proto-iokit-foohid/iokitprotocol.cpp @@ -10,8 +10,6 @@ #include "foohidjoystick.h" #include "iokitprotocoldialog.h" -#include "compat/macros.hpp" - #include IOKitProtocol::IOKitProtocol() diff --git a/proto-libevdev/ftnoir_protocol_libevdev.h b/proto-libevdev/ftnoir_protocol_libevdev.h index 0b0f2612..b81c3baf 100644 --- a/proto-libevdev/ftnoir_protocol_libevdev.h +++ b/proto-libevdev/ftnoir_protocol_libevdev.h @@ -7,7 +7,6 @@ #pragma once #include "ui_ftnoir_libevdev_controls.h" -#include "compat/macros.hpp" #include "api/plugin-api.hpp" #include #include diff --git a/proto-vjoystick/vjoystick.h b/proto-vjoystick/vjoystick.h index 39bc14e3..82ebd3e6 100644 --- a/proto-vjoystick/vjoystick.h +++ b/proto-vjoystick/vjoystick.h @@ -8,7 +8,6 @@ #pragma once #include "ui_vjoystick.h" #include "api/plugin-api.hpp" -#include "compat/macros.hpp" enum status { diff --git a/qxt-mini/powerset.hpp b/qxt-mini/powerset.hpp index d8a8ec9b..901ff0c7 100644 --- a/qxt-mini/powerset.hpp +++ b/qxt-mini/powerset.hpp @@ -1,7 +1,5 @@ #pragma once -#include "compat/macros.hpp" - #include #include #include diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp index d26fb13f..46e2095c 100644 --- a/spline/spline-widget.cpp +++ b/spline/spline-widget.cpp @@ -1,6 +1,5 @@ #include "spline-widget.hpp" #include "compat/math.hpp" -#include "compat/macros.hpp" #include diff --git a/spline/spline.cpp b/spline/spline.cpp index b8f84df5..aae7dd2e 100644 --- a/spline/spline.cpp +++ b/spline/spline.cpp @@ -390,9 +390,9 @@ void spline::set_bundle(bundle b, const QString& axis_name, Axis axis) invalidate_settings_(); S = s; - conn_points = s->points.connect_to(&*ctx, &spline::invalidate_settings(), Qt::DirectConnection); - conn_maxx = s->opts.clamp_x_.connect_to(&*ctx, &spline::invalidate_settings, Qt::DirectConnection); - conn_maxy = s->opts.clamp_y_.connect_to(&*ctx, &spline::invalidate_settings(), Qt::DirectConnection); + conn_points = s->points.connect_to(&*ctx, [this] { invalidate_settings(); }, Qt::DirectConnection); + conn_maxx = s->opts.clamp_x_.connect_to(&*ctx, [this] { invalidate_settings(); }, Qt::DirectConnection); + conn_maxy = s->opts.clamp_y_.connect_to(&*ctx, [this] { invalidate_settings(); }, Qt::DirectConnection); } emit S->recomputed(); diff --git a/tracker-easy/preview.cpp b/tracker-easy/preview.cpp index f8025a64..97c8aeaf 100644 --- a/tracker-easy/preview.cpp +++ b/tracker-easy/preview.cpp @@ -9,7 +9,7 @@ #include "preview.h" #include "compat/math.hpp" -#include "compat/macros1.h" +#include "compat/macros.h" #include #include diff --git a/tracker-kinect-face/kinect_face_settings.h b/tracker-kinect-face/kinect_face_settings.h index 40af1eb7..2c5cc55f 100644 --- a/tracker-kinect-face/kinect_face_settings.h +++ b/tracker-kinect-face/kinect_face_settings.h @@ -8,7 +8,6 @@ #pragma once #include "ui_kinect_face_settings.h" -#include "compat/macros.hpp" #include "api/plugin-api.hpp" class KinectFaceSettings : public ITrackerDialog diff --git a/tracker-kinect-face/kinect_face_tracker.h b/tracker-kinect-face/kinect_face_tracker.h index 8070c519..83b58d71 100644 --- a/tracker-kinect-face/kinect_face_tracker.h +++ b/tracker-kinect-face/kinect_face_tracker.h @@ -12,7 +12,6 @@ #include "api/plugin-api.hpp" #include "compat/timer.hpp" -#include "compat/macros.hpp" #include "video/video-widget.hpp" // Kinect Header files diff --git a/tracker-test/test.h b/tracker-test/test.h index 7f06968e..320145ad 100644 --- a/tracker-test/test.h +++ b/tracker-test/test.h @@ -2,7 +2,6 @@ #include "ui_test.h" #include "api/plugin-api.hpp" #include "compat/timer.hpp" -#include "compat/macros.hpp" #include diff --git a/tracker-trackhat/trackhat.hpp b/tracker-trackhat/trackhat.hpp index 04da69cb..ea00b15e 100644 --- a/tracker-trackhat/trackhat.hpp +++ b/tracker-trackhat/trackhat.hpp @@ -1,7 +1,6 @@ #pragma once #include "../tracker-pt/pt-api.hpp" -#include "compat/macros.hpp" #include "compat/timer.hpp" #include "options/options.hpp" diff --git a/video-ps3eye/module.hpp b/video-ps3eye/module.hpp index 26cfad60..f6934d70 100644 --- a/video-ps3eye/module.hpp +++ b/video-ps3eye/module.hpp @@ -4,7 +4,7 @@ #include "shm-layout.hpp" #include "compat/shm.h" #include "options/options.hpp" -#include "compat/macros1.h" +#include "compat/macros.h" #include "compat/timer.hpp" #include "ui_dialog.h" -- cgit v1.2.3