From 3d47a8b38633b798113e988744fda19c1d54f439 Mon Sep 17 00:00:00 2001 From: Yauheni Akhotnikau Date: Tue, 19 Mar 2024 08:03:14 +0300 Subject: [PATCH] Another attempt to fix #80. --- dev/so_5/detect_os.hpp | 62 +++++++++++++++++++++++++++++++++++++ dev/so_5/stats/messages.hpp | 38 ++++++++++++++--------- 2 files changed, 86 insertions(+), 14 deletions(-) create mode 100644 dev/so_5/detect_os.hpp diff --git a/dev/so_5/detect_os.hpp b/dev/so_5/detect_os.hpp new file mode 100644 index 00000000..db60027d --- /dev/null +++ b/dev/so_5/detect_os.hpp @@ -0,0 +1,62 @@ +/* + * SObjectizer-5 + */ + +/*! + * \file + * \brief Helper macros for detection of compiler/platform. + * + * \since v.5.8.2 + */ + +#pragma once + +/*! + * \def SO_5_OS_WIN32 + * \brief A marker for Win32 platform. + * + * \note This marker is also defined for Win64 platform. + */ + +/*! + * \def SO_5_OS_WIN64 + * \brief A marker for Win64 platform. + */ + +/*! + * \def SO_5_OS_WINDOWS + * \brief A marker for Windows platform. + * + * Defined if SO_5_OS_WIN32 or SO_5_OS_WIN64 are defined. + */ + +/*! + * \def SO_5_OS_UNIX + * \brief A marker for Unix platforms, but not macOS/iOS. + */ + +/*! + * \def SO_5_OS_APPLE + * \brief A marker for macOS/iOS. + */ + +#if defined( _WIN64 ) + #define SO_5_OS_WIN64 +#endif + +#if defined( _WIN32 ) + #define SO_5_OS_WIN32 +#endif + +#if defined( SO_5_OS_WIN32 ) || defined( SO_5_OS_WIN64 ) + #define SO_5_OS_WINDOWS +#endif + +#if defined(unix) || defined(__unix__) || defined(__unix) + #define SO_5_OS_UNIX +#endif + +#if defined(__APPLE__) + #define SO_5_OS_APPLE +#endif + diff --git a/dev/so_5/stats/messages.hpp b/dev/so_5/stats/messages.hpp index 01df697e..260e9b9f 100644 --- a/dev/so_5/stats/messages.hpp +++ b/dev/so_5/stats/messages.hpp @@ -4,10 +4,10 @@ /*! * \file - * \since - * v.5.5.4 * * \brief Messages with monitoring information. + * + * \since v.5.5.4 */ #pragma once @@ -16,6 +16,8 @@ #include +#include + #include #include @@ -33,19 +35,28 @@ namespace stats namespace messages { +/* + * Implementation note: this type has to be marked as SO_5_TYPE for + * clang on FreeBSD/macOS. But SO_5_TYPE shouldn't be used on Windows. + */ +#if defined(SO_5_OS_WINDOWS) + #define SO_5_EXPORT_IMPORT_FOR_QUANTITY_MSG /* empty */ +#else + #define SO_5_EXPORT_IMPORT_FOR_QUANTITY_MSG SO_5_TYPE +#endif + /*! - * \since - * v.5.5.4 - * * \brief A message with value of some quantity. * * This message can be used for monitoring things like queue sizes, * count of delayed messages, count of cooperations and so on. * * \tparam T type for representing quantity. + * + * \since v.5.5.4 */ template< typename T > -struct quantity : public message_t +struct SO_5_EXPORT_IMPORT_FOR_QUANTITY_MSG quantity : public message_t { //! Prefix of data_source name. prefix_t m_prefix; @@ -66,33 +77,32 @@ struct quantity : public message_t {} }; +#undef SO_5_EXPORT_IMPORT_FOR_QUANTITY_MSG + /*! * \brief Notification about start of new stats distribution. * - * \since - * v.5.5.18 - * * \note This message is empty now but it is not declared as a signal. * It is for a possibility of expansion of the message in the future. + * + * \since v.5.5.18 */ struct SO_5_TYPE distribution_started : public message_t {}; /*! * \brief Notification about finish of stats distribution. * - * \since - * v.5.5.18 - * * \note This message is empty now but it is not declared as a signal. * It is for a possibility of expansion of the message in the future. + * + * \since v.5.5.18 */ struct SO_5_TYPE distribution_finished : public message_t {}; /*! * \brief Information about one work thread activity. * - * \since - * v.5.5.18 + * \since v.5.5.18 */ struct SO_5_TYPE work_thread_activity : public message_t {