diff --git a/doc/design/relocatable_pointer.md b/doc/design/relocatable_pointer.md index 7e9124f698..7c3560456d 100644 --- a/doc/design/relocatable_pointer.md +++ b/doc/design/relocatable_pointer.md @@ -38,7 +38,7 @@ Let a1, b1, c1 and so on be the addresses of segment S, pointer p and object X i c2 in application2. If application 2 maps the memory differently they will be shifted by some common offset d depending on the individual memory mapping: -a2 = a1 + d, b2 = a2 + d, c2 = c1 + d +a2 = a1 + d, b2 = b1 + d, c2 = c1 + d This is why storing a raw pointer to X will not be sufficient, the value c1 of p will not point to X in application 2. However, storing the difference between the location of p and X will work since it is an invariant in both address diff --git a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/chunk_management.hpp b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/chunk_management.hpp index 45cb8fdd37..2cf8c3867d 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/chunk_management.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/chunk_management.hpp @@ -36,12 +36,12 @@ struct alignas(32) ChunkManagement using referenceCounterBase_t = uint64_t; using referenceCounter_t = std::atomic; - ChunkManagement(const cxx::not_null f_chunkHeader, - const cxx::not_null f_mempool, - const cxx::not_null f_chunkManagementPool) - : m_chunkHeader(f_chunkHeader) - , m_mempool(f_mempool) - , m_chunkManagementPool(f_chunkManagementPool) + ChunkManagement(const cxx::not_null chunkHeader, + const cxx::not_null mempool, + const cxx::not_null chunkManagementPool) + : m_chunkHeader(chunkHeader) + , m_mempool(mempool) + , m_chunkManagementPool(chunkManagementPool) { } diff --git a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/mem_pool.hpp b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/mem_pool.hpp index b18021b697..be91ad2945 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/mem_pool.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/mem_pool.hpp @@ -31,11 +31,11 @@ namespace mepoo { struct MemPoolInfo { - MemPoolInfo(uint32_t f_usedChunks, uint32_t f_minFreeChunks, uint32_t f_numChunks, uint32_t f_chunkSize) - : m_usedChunks(f_usedChunks) - , m_minFreeChunks(f_minFreeChunks) - , m_numChunks(f_numChunks) - , m_chunkSize(f_chunkSize) + MemPoolInfo(uint32_t usedChunks, uint32_t minFreeChunks, uint32_t numChunks, uint32_t chunkSize) + : m_usedChunks(usedChunks) + , m_minFreeChunks(minFreeChunks) + , m_numChunks(numChunks) + , m_chunkSize(chunkSize) { } uint32_t m_usedChunks{0}; @@ -50,10 +50,10 @@ class MemPool using freeList_t = concurrent::LoFFLi; static constexpr uint64_t MEMORY_ALIGNMENT = posix::Allocator::MEMORY_ALIGNMENT; - MemPool(const cxx::greater_or_equal f_chunkSize, - const cxx::greater_or_equal f_numberOfChunks, - posix::Allocator* f_managementAllocator, - posix::Allocator* f_payloadAllocator); + MemPool(const cxx::greater_or_equal chunkSize, + const cxx::greater_or_equal numberOfChunks, + posix::Allocator* managementAllocator, + posix::Allocator* payloadAllocator); MemPool(const MemPool&) = delete; MemPool(MemPool&&) = delete; @@ -75,14 +75,14 @@ class MemPool rp::RelativePointer m_rawMemory; - uint32_t m_chunkSize{0u}; + uint32_t m_chunkSize{0U}; /// needs to be 32 bit since loffli supports only 32 bit numbers /// (cas is only 64 bit and we need the other 32 bit for the aba counter) - uint32_t m_numberOfChunks{0u}; + uint32_t m_numberOfChunks{0U}; /// @todo: put this into one struct and in a separate class in concurrent. - std::atomic m_usedChunks{0u}; - std::atomic m_minFree{0u}; + std::atomic m_usedChunks{0U}; + std::atomic m_minFree{0U}; /// @todo: end freeList_t m_freeIndices; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/mepoo_segment.hpp b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/mepoo_segment.hpp index 977dc733b8..f5f5d45902 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/mepoo_segment.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/mepoo_segment.hpp @@ -32,10 +32,10 @@ template -inline MePooSegment::MePooSegment(const MePooConfig& f_mempoolConfig, - posix::Allocator* f_managementAllocator, - const posix::PosixGroup& f_readerGroup, - const posix::PosixGroup& f_writerGroup, +inline MePooSegment::MePooSegment(const MePooConfig& mempoolConfig, + posix::Allocator* managementAllocator, + const posix::PosixGroup& readerGroup, + const posix::PosixGroup& writerGroup, const iox::mepoo::MemoryInfo& memoryInfo) - : m_sharedMemoryObject(std::move(createSharedMemoryObject(f_mempoolConfig, f_writerGroup))) - , m_readerGroup(f_readerGroup) - , m_writerGroup(f_writerGroup) + : m_sharedMemoryObject(std::move(createSharedMemoryObject(mempoolConfig, writerGroup))) + , m_readerGroup(readerGroup) + , m_writerGroup(writerGroup) , m_memoryInfo(memoryInfo) { using namespace posix; - AccessController f_accessController; - if (!(f_readerGroup == f_writerGroup)) + AccessController accessController; + if (!(readerGroup == writerGroup)) { - f_accessController.addPermissionEntry( - AccessController::Category::SPECIFIC_GROUP, AccessController::Permission::READ, f_readerGroup.getName()); + accessController.addPermissionEntry( + AccessController::Category::SPECIFIC_GROUP, AccessController::Permission::READ, readerGroup.getName()); } - f_accessController.addPermissionEntry( - AccessController::Category::SPECIFIC_GROUP, AccessController::Permission::READWRITE, f_writerGroup.getName()); - f_accessController.addPermissionEntry(AccessController::Category::USER, AccessController::Permission::READWRITE); - f_accessController.addPermissionEntry(AccessController::Category::GROUP, AccessController::Permission::READWRITE); - f_accessController.addPermissionEntry(AccessController::Category::OTHERS, AccessController::Permission::NONE); + accessController.addPermissionEntry( + AccessController::Category::SPECIFIC_GROUP, AccessController::Permission::READWRITE, writerGroup.getName()); + accessController.addPermissionEntry(AccessController::Category::USER, AccessController::Permission::READWRITE); + accessController.addPermissionEntry(AccessController::Category::GROUP, AccessController::Permission::READWRITE); + accessController.addPermissionEntry(AccessController::Category::OTHERS, AccessController::Permission::NONE); - if (!f_accessController.writePermissionsToFile(m_sharedMemoryObject.getFileHandle())) + if (!accessController.writePermissionsToFile(m_sharedMemoryObject.getFileHandle())) { errorHandler(Error::kMEPOO__SEGMENT_COULD_NOT_APPLY_POSIX_RIGHTS_TO_SHARED_MEMORY); } - m_memoryManager.configureMemoryManager(f_mempoolConfig, f_managementAllocator, m_sharedMemoryObject.getAllocator()); + m_memoryManager.configureMemoryManager(mempoolConfig, managementAllocator, m_sharedMemoryObject.getAllocator()); m_sharedMemoryObject.finalizeAllocation(); } template -inline SharedMemoryObjectType MePooSegment::createSharedMemoryObject( - const MePooConfig& f_mempoolConfig, const posix::PosixGroup& f_writerGroup) +inline SharedMemoryObjectType +MePooSegment::createSharedMemoryObject(const MePooConfig& mempoolConfig, + const posix::PosixGroup& writerGroup) { // we let the OS decide where to map the shm segments constexpr void* BASE_ADDRESS_HINT{nullptr}; // on qnx the current working directory will be added to the /dev/shmem path if the leading slash is missing - posix::SharedMemory::Name_t shmName = "/" + f_writerGroup.getName(); + posix::SharedMemory::Name_t shmName = "/" + writerGroup.getName(); return std::move( SharedMemoryObjectType::create(shmName, - MemoryManager::requiredChunkMemorySize(f_mempoolConfig), + MemoryManager::requiredChunkMemorySize(mempoolConfig), posix::AccessMode::READ_WRITE, posix::OwnerShip::MINE, BASE_ADDRESS_HINT, static_cast(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) .and_then([this](auto& sharedMemoryObject) { this->setSegmentId(iox::rp::BaseRelativePointer::registerPtr(sharedMemoryObject.getBaseAddress(), - sharedMemoryObject.getSizeInBytes())); + sharedMemoryObject.getSizeInBytes())); LogDebug() << "Roudi registered payload segment " << iox::log::HexFormat(reinterpret_cast(sharedMemoryObject.getBaseAddress())) diff --git a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/shared_chunk.hpp b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/shared_chunk.hpp index aa3796fbcc..0de8fd40ef 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/mepoo/shared_chunk.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/mepoo/shared_chunk.hpp @@ -34,8 +34,8 @@ class SharedChunk { public: SharedChunk() = default; - SharedChunk(ChunkManagement* const f_resource); - SharedChunk(const rp::RelativePointer& f_resource); + SharedChunk(ChunkManagement* const resource); + SharedChunk(const rp::RelativePointer& resource); ~SharedChunk(); SharedChunk(const SharedChunk& rhs); diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_queue_types.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_queue_types.hpp index c16fe24902..bd4aed805e 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_queue_types.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/chunk_queue_types.hpp @@ -26,7 +26,7 @@ namespace popo struct ChunkTuple { ChunkTuple() = default; - explicit ChunkTuple(rp::RelativePointer f_chunk) noexcept; + explicit ChunkTuple(rp::RelativePointer chunk) noexcept; rp::BaseRelativePointer::id_t m_segmentId{rp::BaseRelativePointer::NULL_POINTER_ID}; rp::BaseRelativePointer::offset_t m_chunkOffset{rp::BaseRelativePointer::NULL_POINTER_OFFSET}; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/used_chunk_list.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/used_chunk_list.hpp index 48274e2d33..805b7c2bde 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/used_chunk_list.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/used_chunk_list.hpp @@ -39,7 +39,7 @@ class UsedChunkList } // only from runtime context - bool insert(mepoo::SharedChunk f_chunk) + bool insert(mepoo::SharedChunk chunk) { if (freeSpaceInList()) { @@ -51,7 +51,7 @@ class UsedChunkList m_usedListHead = m_freeListHead; // store chunk mgmt ptr - m_data[m_usedListHead] = f_chunk.release(); + m_data[m_usedListHead] = chunk.release(); // set freeListHead to the next free entry m_freeListHead = nextFree; @@ -67,7 +67,7 @@ class UsedChunkList } // only from runtime context - bool remove(const mepoo::ChunkHeader* f_chunkHeader, mepoo::SharedChunk& f_chunk) + bool remove(const mepoo::ChunkHeader* chunkHeader, mepoo::SharedChunk& chunk) { uint32_t previous = InvalidIndex; @@ -75,10 +75,10 @@ class UsedChunkList for (uint32_t current = m_usedListHead; current != InvalidIndex; current = m_list[current]) { // does the entry match the one we want to remove? - if (m_data[current] != nullptr && m_data[current]->m_chunkHeader == f_chunkHeader) + if (m_data[current] != nullptr && m_data[current]->m_chunkHeader == chunkHeader) { // return the chunk mgmt entry as SharedChunk object - f_chunk = mepoo::SharedChunk(m_data[current]); + chunk = mepoo::SharedChunk(m_data[current]); m_data[current] = nullptr; // remove index from used list diff --git a/iceoryx_posh/source/mepoo/mem_pool.cpp b/iceoryx_posh/source/mepoo/mem_pool.cpp index 0bb991f145..ef39ce6b0d 100644 --- a/iceoryx_posh/source/mepoo/mem_pool.cpp +++ b/iceoryx_posh/source/mepoo/mem_pool.cpp @@ -26,25 +26,25 @@ namespace iox { namespace mepoo { -MemPool::MemPool(const cxx::greater_or_equal f_chunkSize, - const cxx::greater_or_equal f_numberOfChunks, - posix::Allocator* f_managementAllocator, - posix::Allocator* f_payloadAllocator) - : m_chunkSize(f_chunkSize) - , m_numberOfChunks(f_numberOfChunks) - , m_minFree(f_numberOfChunks) +MemPool::MemPool(const cxx::greater_or_equal chunkSize, + const cxx::greater_or_equal numberOfChunks, + posix::Allocator* managementAllocator, + posix::Allocator* payloadAllocator) + : m_chunkSize(chunkSize) + , m_numberOfChunks(numberOfChunks) + , m_minFree(numberOfChunks) { - if (isMultipleOfAlignment(f_chunkSize)) + if (isMultipleOfAlignment(chunkSize)) { m_rawMemory = - static_cast(f_payloadAllocator->allocate(static_cast(m_numberOfChunks) * m_chunkSize)); + static_cast(payloadAllocator->allocate(static_cast(m_numberOfChunks) * m_chunkSize)); auto memoryLoFFLi = - static_cast(f_managementAllocator->allocate(freeList_t::requiredMemorySize(m_numberOfChunks))); + static_cast(managementAllocator->allocate(freeList_t::requiredMemorySize(m_numberOfChunks))); m_freeIndices.init(memoryLoFFLi, m_numberOfChunks); } else { - std::cerr << f_chunkSize << " :: " << f_numberOfChunks << std::endl; + std::cerr << chunkSize << " :: " << numberOfChunks << std::endl; errorHandler( Error::kMEPOO__MEMPOOL_CHUNKSIZE_MUST_BE_LARGER_THAN_SHARED_MEMORY_ALIGNMENT_AND_MULTIPLE_OF_ALIGNMENT); } diff --git a/iceoryx_posh/source/mepoo/shared_chunk.cpp b/iceoryx_posh/source/mepoo/shared_chunk.cpp index f67eb3221f..89df60ea78 100644 --- a/iceoryx_posh/source/mepoo/shared_chunk.cpp +++ b/iceoryx_posh/source/mepoo/shared_chunk.cpp @@ -20,13 +20,13 @@ namespace iox { namespace mepoo { -SharedChunk::SharedChunk(ChunkManagement* const f_resource) - : m_chunkManagement(f_resource) +SharedChunk::SharedChunk(ChunkManagement* const resource) + : m_chunkManagement(resource) { } -SharedChunk::SharedChunk(const rp::RelativePointer& f_resource) - : m_chunkManagement(f_resource) +SharedChunk::SharedChunk(const rp::RelativePointer& resource) + : m_chunkManagement(resource) { } diff --git a/iceoryx_posh/source/popo/building_blocks/chunk_queue_types.cpp b/iceoryx_posh/source/popo/building_blocks/chunk_queue_types.cpp index f13c2622a4..621b9e56fc 100644 --- a/iceoryx_posh/source/popo/building_blocks/chunk_queue_types.cpp +++ b/iceoryx_posh/source/popo/building_blocks/chunk_queue_types.cpp @@ -20,9 +20,9 @@ namespace iox { namespace popo { -ChunkTuple::ChunkTuple(iox::rp::RelativePointer f_chunk) noexcept - : m_segmentId(f_chunk.getId()) - , m_chunkOffset(f_chunk.getOffset()) +ChunkTuple::ChunkTuple(iox::rp::RelativePointer chunk) noexcept + : m_segmentId(chunk.getId()) + , m_chunkOffset(chunk.getOffset()) { } diff --git a/iceoryx_utils/include/iceoryx_utils/internal/concurrent/loffli.hpp b/iceoryx_utils/include/iceoryx_utils/internal/concurrent/loffli.hpp index f1adace1e4..c6d180d7bd 100644 --- a/iceoryx_utils/include/iceoryx_utils/internal/concurrent/loffli.hpp +++ b/iceoryx_utils/include/iceoryx_utils/internal/concurrent/loffli.hpp @@ -59,20 +59,20 @@ class LoFFLi /// }; /// @endcode - uint32_t m_size{0u}; - uint32_t m_invalidIndex{0u}; - std::atomic m_head{{0u, 1u}}; + uint32_t m_size{0U}; + uint32_t m_invalidIndex{0U}; + std::atomic m_head{{0U, 1U}}; iox::rp::RelativePointer m_nextFreeIndex; public: LoFFLi() = default; /// @todo: why init not in ctor - /// @todo: f_size = capacity + /// @todo: size = capacity /// Initializes the lock-free free-list - /// @param [in] f_freeIndicesMemory pointer to a memory with the size calculated by requiredMemorySize() - /// @param [in] f_size is the number of elements of the free-list; must be the same used at requiredMemorySize() - void init(cxx::not_null f_freeIndicesMemory, const uint32_t f_size); + /// @param [in] freeIndicesMemory pointer to a memory with the size calculated by requiredMemorySize() + /// @param [in] size is the number of elements of the free-list; must be the same used at requiredMemorySize() + void init(cxx::not_null freeIndicesMemory, const uint32_t size); /// Pop a value from the free-list /// @param [out] index for an element to use @@ -85,11 +85,11 @@ class LoFFLi bool push(const uint32_t index); /// Calculates the required memory size for a free-list - /// @param [in] f_size is the number of elements of the free-list - /// @return the required memory size for a free-list with f_size elements - static inline constexpr std::size_t requiredMemorySize(const uint32_t f_size) + /// @param [in] size is the number of elements of the free-list + /// @return the required memory size for a free-list with size elements + static inline constexpr std::size_t requiredMemorySize(const uint32_t size) { - return (static_cast(f_size) + 1u) * sizeof(uint32_t); + return (static_cast(size) + 1U) * sizeof(uint32_t); } }; diff --git a/iceoryx_utils/source/concurrent/loffli.cpp b/iceoryx_utils/source/concurrent/loffli.cpp index e86596d808..d6087b7ae1 100644 --- a/iceoryx_utils/source/concurrent/loffli.cpp +++ b/iceoryx_utils/source/concurrent/loffli.cpp @@ -23,13 +23,13 @@ namespace iox { namespace concurrent { -void LoFFLi::init(cxx::not_null f_freeIndicesMemory, const uint32_t f_size) +void LoFFLi::init(cxx::not_null freeIndicesMemory, const uint32_t size) { - cxx::Expects(f_size > 0); - cxx::Expects(f_size <= UINT32_MAX - 2U); + cxx::Expects(size > 0); + cxx::Expects(size <= UINT32_MAX - 2U); - m_nextFreeIndex = f_freeIndicesMemory; - m_size = f_size; + m_nextFreeIndex = freeIndicesMemory; + m_size = size; m_invalidIndex = m_size + 1; if (m_nextFreeIndex != nullptr)