From 085771e4e7ca692e1e9c75d4df04fdd294f707f1 Mon Sep 17 00:00:00 2001 From: yellowhatter Date: Thu, 26 Dec 2024 16:48:28 +0300 Subject: [PATCH] review fixes --- rmw_zenoh_cpp/src/detail/shm_context.cpp | 8 +++++--- rmw_zenoh_cpp/src/detail/shm_context.hpp | 6 ++++-- rmw_zenoh_cpp/src/detail/zenoh_config.cpp | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/rmw_zenoh_cpp/src/detail/shm_context.cpp b/rmw_zenoh_cpp/src/detail/shm_context.cpp index 865ff69d..51d8187a 100644 --- a/rmw_zenoh_cpp/src/detail/shm_context.cpp +++ b/rmw_zenoh_cpp/src/detail/shm_context.cpp @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY + #include #include "shm_context.hpp" @@ -19,13 +21,13 @@ namespace rmw_zenoh_cpp { ///============================================================================= -#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY ShmContext::ShmContext(size_t alloc_size, size_t msgsize_threshold) : // Create Layout for provider's memory - // Provider's alignment will be 1 byte as we are going to make only 1-byte aligned allocations + // Provider's alignment will be 1 (=2^0) bytes as we are going to make only 1-byte aligned allocations // TODO(yellowhatter): use zenoh_shm_message_size_threshold as base for alignment shm_provider(zenoh::PosixShmProvider(zenoh::MemoryLayout(alloc_size, zenoh::AllocAlignment {0}))), msgsize_threshold(msgsize_threshold) {} -#endif } // namespace rmw_zenoh_cpp + +#endif diff --git a/rmw_zenoh_cpp/src/detail/shm_context.hpp b/rmw_zenoh_cpp/src/detail/shm_context.hpp index 1c44dc58..146d9143 100644 --- a/rmw_zenoh_cpp/src/detail/shm_context.hpp +++ b/rmw_zenoh_cpp/src/detail/shm_context.hpp @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY + #ifndef DETAIL__SHM_CONTEXT_HPP_ #define DETAIL__SHM_CONTEXT_HPP_ @@ -20,7 +22,6 @@ namespace rmw_zenoh_cpp { ///============================================================================= -#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY struct ShmContext { zenoh::PosixShmProvider shm_provider; @@ -28,7 +29,8 @@ struct ShmContext ShmContext(size_t alloc_size, size_t msgsize_threshold); }; -#endif } // namespace rmw_zenoh_cpp #endif // DETAIL__SHM_CONTEXT_HPP_ + +#endif diff --git a/rmw_zenoh_cpp/src/detail/zenoh_config.cpp b/rmw_zenoh_cpp/src/detail/zenoh_config.cpp index dd960529..3d4b725d 100644 --- a/rmw_zenoh_cpp/src/detail/zenoh_config.cpp +++ b/rmw_zenoh_cpp/src/detail/zenoh_config.cpp @@ -49,7 +49,7 @@ static const bool zenoh_shm_enabled_default = true; static const char * zenoh_shm_alloc_size_envar = "ZENOH_SHM_ALLOC_SIZE"; static const size_t zenoh_shm_alloc_size_default = 1 * 1024 * 1024; static const char * zenoh_shm_message_size_threshold_envar = "ZENOH_SHM_MESSAGE_SIZE_THRESHOLD"; -static const size_t zenoh_shm_message_size_threshold_default = 2 * 1024; +static const size_t zenoh_shm_message_size_threshold_default = 1; //2 * 1024; #endif std::optional _get_z_config(