Skip to content

Commit

Permalink
iox-#1391 Move relative_pointer to correct memory folder
Browse files Browse the repository at this point in the history
  • Loading branch information
FerdinandSpitzschnueffler committed Feb 21, 2023
1 parent 2d37cd4 commit 908ee2a
Show file tree
Hide file tree
Showing 32 changed files with 101 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy-diff-scans.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
./iceoryx_hoofs/source/cxx/*

./iceoryx_hoofs/include/iceoryx_hoofs/internal/memory/*
./iceoryx_hoofs/include/iceoryx_hoofs/memory/*
./iceoryx_hoofs/test/moduletests/test_relative_pointer*
./iceoryx_hoofs/source/memory/*
./iceoryx_hoofs/memory/*
./iceoryx_hoofs/test/moduletests/test_memory*

./iceoryx_hoofs/include/iceoryx_hoofs/internal/concurrent/*
./iceoryx_hoofs/include/iceoryx_hoofs/concurrent/*
Expand Down
2 changes: 1 addition & 1 deletion doc/shared-memory-communication.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Memory chunks are returned to the pool once all attached consumers indicate they

As already discussed, shared memory segments may be mapped to different memory areas in the virtual address space of a
process.
To deal with this, iceoryx utilizes specialized pointer types: the `iox::memory::RelativePointer` and
To deal with this, iceoryx utilizes specialized pointer types: the `iox::RelativePointer` and
the `iox::memory::relocatable_ptr`.

Using these types, the difference in memory mapping is not a factor when it comes to locating a memory chunk.
Expand Down
6 changes: 3 additions & 3 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,16 +501,16 @@
}
```

21. Renamed `BaseRelativePointer` to `UntypedRelativePointer` and moved it from namespace `rp::` to `memory::`
21. Renamed `BaseRelativePointer` to `UntypedRelativePointer` and removed it from namespace `rp::`

```cpp
// before
#include "iceoryx_hoofs/internal/relocatable_pointer/base_relative_pointer.hpp"
iox::rp::BaseRelativePointer myUntypedRelativePointer;

// after
#include "iceoryx_hoofs/memory/relative_pointer.hpp"
iox::memory::UntypedRelativePointer myUntypedRelativePointer;
#include "iox/relative_pointer.hpp"
iox::UntypedRelativePointer myUntypedRelativePointer;
```

22. The `CMakeLists.txt` of apps using iceoryx need to add `iceoryx_platform`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#ifndef IOX_HOOFS_CONCURRENT_LOFFLI_HPP
#define IOX_HOOFS_CONCURRENT_LOFFLI_HPP

#include "iceoryx_hoofs/memory/relative_pointer.hpp"
#include "iox/not_null.hpp"
#include "iox/relative_pointer.hpp"

#include <atomic>
#include <cstdint>
Expand Down Expand Up @@ -71,7 +71,7 @@ class LoFFLi
uint32_t m_size{0U};
Index_t m_invalidIndex{0U};
std::atomic<Node> m_head{{0U, 1U}};
iox::memory::RelativePointer<Index_t> m_nextFreeIndex;
iox::RelativePointer<Index_t> m_nextFreeIndex;

public:
LoFFLi() noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
#ifndef IOX_HOOFS_MEMORY_RELATIVE_POINTER_INL
#define IOX_HOOFS_MEMORY_RELATIVE_POINTER_INL

#include "iceoryx_hoofs/memory/relative_pointer.hpp"
#include "iox/relative_pointer.hpp"

namespace iox
{
namespace memory
{
template <typename T>
// NOLINTJUSTIFICATION NewType size is comparable to an integer, hence pass by value is preferred
// NOLINTNEXTLINE(performance-unnecessary-value-param)
Expand Down Expand Up @@ -295,7 +293,6 @@ inline bool operator!=(const RelativePointer<T> lhs, std::nullptr_t) noexcept
{
return lhs.get() != nullptr;
}
} // namespace memory
} // namespace iox

#endif // IOX_HOOFS_MEMORY_RELATIVE_POINTER_INL
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

namespace iox
{
namespace memory
{
struct segment_id_t : public NewType<uint64_t,
newtype::DefaultConstructable,
newtype::CopyConstructable,
Expand Down Expand Up @@ -262,9 +260,8 @@ bool operator!=(std::nullptr_t, const RelativePointer<T> rhs) noexcept;
template <typename T>
bool operator!=(const RelativePointer<T> lhs, std::nullptr_t rhs) noexcept;

} // namespace memory
} // namespace iox

#include "iceoryx_hoofs/memory/relative_pointer.inl"
#include "iox/detail/relative_pointer.inl"

#endif // IOX_HOOFS_MEMORY_RELATIVE_POINTER_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_hoofs/memory/relative_pointer.hpp"
#include "iox/relative_pointer.hpp"
#include "test.hpp"

#include <cstdint>
Expand All @@ -24,7 +24,7 @@
namespace
{
using namespace ::testing;
using namespace iox::memory;
using namespace iox;

constexpr uint64_t SHARED_MEMORY_SIZE = 4096UL * 32UL;
constexpr uint64_t NUMBER_OF_MEMORY_PARTITIONS = 2U;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#ifndef IOX_POSH_MEPOO_CHUNK_MANAGEMENT_HPP
#define IOX_POSH_MEPOO_CHUNK_MANAGEMENT_HPP

#include "iceoryx_hoofs/memory/relative_pointer.hpp"
#include "iox/not_null.hpp"
#include "iox/relative_pointer.hpp"

#include <atomic>
#include <cstdint>
Expand All @@ -40,11 +40,11 @@ struct ChunkManagement
const not_null<MemPool*> mempool,
const not_null<MemPool*> chunkManagementPool) noexcept;

iox::memory::RelativePointer<base_t> m_chunkHeader;
iox::RelativePointer<base_t> m_chunkHeader;
referenceCounter_t m_referenceCounter{1U};

iox::memory::RelativePointer<MemPool> m_mempool;
iox::memory::RelativePointer<MemPool> m_chunkManagementPool;
iox::RelativePointer<MemPool> m_mempool;
iox::RelativePointer<MemPool> m_chunkManagementPool;
};
} // namespace mepoo
} // namespace iox
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_posh/include/iceoryx_posh/internal/mepoo/mem_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#define IOX_POSH_MEPOO_MEM_POOL_HPP

#include "iceoryx_hoofs/internal/concurrent/loffli.hpp"
#include "iceoryx_hoofs/memory/relative_pointer.hpp"
#include "iceoryx_posh/mepoo/chunk_header.hpp"
#include "iox/algorithm.hpp"
#include "iox/bump_allocator.hpp"
#include "iox/relative_pointer.hpp"

#include <atomic>
#include <cstdint>
Expand Down Expand Up @@ -73,7 +73,7 @@ class MemPool
void adjustMinFree() noexcept;
bool isMultipleOfAlignment(const uint32_t value) const noexcept;

memory::RelativePointer<uint8_t> m_rawMemory;
RelativePointer<uint8_t> m_rawMemory;

uint32_t m_chunkSize{0U};
/// needs to be 32 bit since loffli supports only 32 bit numbers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
#ifndef IOX_POSH_MEPOO_MEPOO_SEGMENT_INL
#define IOX_POSH_MEPOO_MEPOO_SEGMENT_INL

#include "iceoryx_hoofs/memory/relative_pointer.hpp"
#include "iceoryx_posh/error_handling/error_handling.hpp"
#include "iceoryx_posh/internal/log/posh_logging.hpp"
#include "iceoryx_posh/internal/mepoo/mepoo_segment.hpp"
#include "iceoryx_posh/mepoo/memory_info.hpp"
#include "iceoryx_posh/mepoo/mepoo_config.hpp"
#include "iox/relative_pointer.hpp"

namespace iox
{
Expand Down Expand Up @@ -76,8 +76,8 @@ inline SharedMemoryObjectType MePooSegment<SharedMemoryObjectType, MemoryManager
.permissions(SEGMENT_PERMISSIONS)
.create()
.and_then([this](auto& sharedMemoryObject) {
auto maybeSegmentId = iox::memory::UntypedRelativePointer::registerPtr(
sharedMemoryObject.getBaseAddress(), sharedMemoryObject.getSizeInBytes());
auto maybeSegmentId = iox::UntypedRelativePointer::registerPtr(sharedMemoryObject.getBaseAddress(),
sharedMemoryObject.getSizeInBytes());
if (!maybeSegmentId.has_value())
{
errorHandler(PoshError::MEPOO__SEGMENT_INSUFFICIENT_SEGMENT_IDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#ifndef IOX_POSH_MEPOO_SHARED_CHUNK_HPP
#define IOX_POSH_MEPOO_SHARED_CHUNK_HPP

#include "iceoryx_hoofs/memory/relative_pointer.hpp"
#include "iceoryx_posh/internal/mepoo/chunk_management.hpp"
#include "iceoryx_posh/internal/mepoo/mem_pool.hpp"
#include "iceoryx_posh/mepoo/chunk_header.hpp"
#include "iox/relative_pointer.hpp"

namespace iox
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ChunkDistributor<ChunkDistributorDataType>::tryAddQueue(not_null<ChunkQueueData_
const auto alreadyKnownReceiver =
std::find_if(getMembers()->m_queues.begin(),
getMembers()->m_queues.end(),
[&](const memory::RelativePointer<ChunkQueueData_t> queue) { return queue.get() == queueToAdd; });
[&](const RelativePointer<ChunkQueueData_t> queue) { return queue.get() == queueToAdd; });

// check if the queue is not already in the list
if (alreadyKnownReceiver == getMembers()->m_queues.end())
Expand All @@ -63,7 +63,7 @@ ChunkDistributor<ChunkDistributorDataType>::tryAddQueue(not_null<ChunkQueueData_
{
// AXIVION Next Construct AutosarC++19_03-A0.1.2, AutosarC++19_03-M0-3-2 : we checked the capacity, so
// pushing will be fine
getMembers()->m_queues.push_back(memory::RelativePointer<ChunkQueueData_t>(queueToAdd));
getMembers()->m_queues.push_back(RelativePointer<ChunkQueueData_t>(queueToAdd));

const auto currChunkHistorySize = getMembers()->m_history.size();

Expand Down Expand Up @@ -179,8 +179,7 @@ inline uint64_t ChunkDistributor<ChunkDistributorDataType>::deliverToAllStoredQu
// and without this intersection we would deliver to dead queues
typename MemberType_t::LockGuard_t lock(*getMembers());
typename ChunkDistributorDataType::QueueContainer_t queueIntersection(remainingQueues.size());
auto greaterThan = [](memory::RelativePointer<ChunkQueueData_t>& a,
memory::RelativePointer<ChunkQueueData_t>& b) -> bool {
auto greaterThan = [](RelativePointer<ChunkQueueData_t>& a, RelativePointer<ChunkQueueData_t>& b) -> bool {
return reinterpret_cast<uint64_t>(a.get()) > reinterpret_cast<uint64_t>(b.get());
};
std::sort(getMembers()->m_queues.begin(), getMembers()->m_queues.end(), greaterThan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
#define IOX_POSH_POPO_BUILDING_BLOCKS_CHUNK_DISTRIBUTOR_DATA_HPP

#include "iceoryx_hoofs/internal/posix_wrapper/mutex.hpp"
#include "iceoryx_hoofs/memory/relative_pointer.hpp"
#include "iceoryx_posh/error_handling/error_handling.hpp"
#include "iceoryx_posh/internal/log/posh_logging.hpp"
#include "iceoryx_posh/internal/mepoo/shm_safe_unmanaged_chunk.hpp"
#include "iceoryx_posh/internal/popo/building_blocks/chunk_queue_pusher.hpp"
#include "iceoryx_posh/popo/port_queue_policies.hpp"
#include "iox/algorithm.hpp"
#include "iox/relative_pointer.hpp"
#include "iox/vector.hpp"

#include <cstdint>
Expand All @@ -47,8 +47,7 @@ struct ChunkDistributorData : public LockingPolicy

const uint64_t m_historyCapacity;

using QueueContainer_t =
vector<memory::RelativePointer<ChunkQueueData_t>, ChunkDistributorDataProperties_t::MAX_QUEUES>;
using QueueContainer_t = vector<RelativePointer<ChunkQueueData_t>, ChunkDistributorDataProperties_t::MAX_QUEUES>;
QueueContainer_t m_queues;

/// @todo iox-#1710 If we would make the ChunkDistributor lock-free, can we than extend the UsedChunkList to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

#include "iceoryx_hoofs/cxx/variant_queue.hpp"
#include "iceoryx_hoofs/internal/cxx/unique_id.hpp"
#include "iceoryx_hoofs/memory/relative_pointer.hpp"
#include "iceoryx_posh/internal/mepoo/shm_safe_unmanaged_chunk.hpp"
#include "iceoryx_posh/internal/popo/building_blocks/condition_notifier.hpp"
#include "iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp"
#include "iceoryx_posh/popo/port_queue_policies.hpp"
#include "iox/relative_pointer.hpp"

#include <mutex>

Expand All @@ -46,7 +46,7 @@ struct ChunkQueueData : public LockingPolicy
cxx::VariantQueue<mepoo::ShmSafeUnmanagedChunk, MAX_CAPACITY> m_queue;
std::atomic_bool m_queueHasLostChunks{false};

memory::RelativePointer<ConditionVariableData> m_conditionVariableDataPtr;
RelativePointer<ConditionVariableData> m_conditionVariableDataPtr;
optional<uint64_t> m_conditionVariableNotificationIndex;
const QueueFullPolicy m_queueFullPolicy;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct ChunkSenderData : public ChunkDistributorDataType

using ChunkDistributorData_t = ChunkDistributorDataType;

const memory::RelativePointer<mepoo::MemoryManager> m_memoryMgr;
const RelativePointer<mepoo::MemoryManager> m_memoryMgr;
mepoo::MemoryInfo m_memoryInfo;
UsedChunkList<MaxChunksAllocatedSimultaneously> m_chunksInUse;
mepoo::SequenceNumber_t m_sequenceNumber{0U};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#ifndef IOX_POSH_POPO_PORTS_BASE_PORT_DATA_HPP
#define IOX_POSH_POPO_PORTS_BASE_PORT_DATA_HPP

#include "iceoryx_hoofs/memory/relative_pointer.hpp"
#include "iceoryx_posh/capro/service_description.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
#include "iceoryx_posh/internal/capro/capro_message.hpp"
#include "iceoryx_posh/internal/popo/building_blocks/unique_port_id.hpp"
#include "iox/relative_pointer.hpp"

#include <atomic>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class ProcessManager : public ProcessManagerInterface
PortManager& m_portManager;
mepoo::SegmentManager<>* m_segmentManager{nullptr};
mepoo::MemoryManager* m_introspectionMemoryManager{nullptr};
memory::segment_id_underlying_t m_mgmtSegmentId{memory::UntypedRelativePointer::NULL_POINTER_ID};
segment_id_underlying_t m_mgmtSegmentId{UntypedRelativePointer::NULL_POINTER_ID};
ProcessList_t m_processList;
ProcessIntrospectionType* m_processIntrospection{nullptr};
version::CompatibilityCheckLevel m_compatibilityCheckLevel;
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_posh/include/iceoryx_posh/internal/roudi/roudi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include "iceoryx_hoofs/cxx/scope_guard.hpp"
#include "iceoryx_hoofs/internal/concurrent/smart_lock.hpp"
#include "iceoryx_hoofs/memory/relative_pointer.hpp"
#include "iceoryx_hoofs/posix_wrapper/posix_access_rights.hpp"
#include "iceoryx_platform/file.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
Expand All @@ -29,6 +28,7 @@
#include "iceoryx_posh/roudi/memory/roudi_memory_interface.hpp"
#include "iceoryx_posh/roudi/memory/roudi_memory_manager.hpp"
#include "iceoryx_posh/roudi/roudi_app.hpp"
#include "iox/relative_pointer.hpp"

#include <cstdint>
#include <thread>
Expand Down Expand Up @@ -126,7 +126,7 @@ class RouDi

void monitorAndDiscoveryUpdate() noexcept;

cxx::ScopeGuard m_unregisterRelativePtr{[] { memory::UntypedRelativePointer::unregisterAll(); }};
cxx::ScopeGuard m_unregisterRelativePtr{[] { UntypedRelativePointer::unregisterAll(); }};
bool m_killProcessesInDestructor;
std::atomic_bool m_runMonitoringAndDiscoveryThread;
std::atomic_bool m_runHandleRuntimeMessageThread;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef IOX_POSH_RUNTIME_IPC_INTERFACE_BASE_HPP
#define IOX_POSH_RUNTIME_IPC_INTERFACE_BASE_HPP

#include "iceoryx_hoofs/memory/relative_pointer.hpp"
#include "iceoryx_platform/errno.hpp"
#include "iceoryx_platform/fcntl.hpp"
#include "iceoryx_platform/stat.hpp"
Expand All @@ -29,6 +28,7 @@
#include "iceoryx_posh/internal/runtime/ipc_message.hpp"
#include "iox/deadline_timer.hpp"
#include "iox/duration.hpp"
#include "iox/relative_pointer.hpp"

#include "iceoryx_dust/posix_wrapper/message_queue.hpp"
#include "iceoryx_dust/posix_wrapper/named_pipe.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class IpcRuntimeInterface
bool sendRequestToRouDi(const IpcMessage& msg, IpcMessage& answer) noexcept;

/// @brief get the adress offset of the segment manager
/// @return address offset as memory::RelativePointer::offset_t
memory::UntypedRelativePointer::offset_t getSegmentManagerAddressOffset() const noexcept;
/// @return address offset as iox::RelativePointer::offset_t
UntypedRelativePointer::offset_t getSegmentManagerAddressOffset() const noexcept;

/// @brief get the size of the management shared memory object
/// @return size in bytes
Expand All @@ -79,7 +79,7 @@ class IpcRuntimeInterface

private:
RuntimeName_t m_runtimeName;
optional<memory::UntypedRelativePointer::offset_t> m_segmentManagerAddressOffset;
optional<UntypedRelativePointer::offset_t> m_segmentManagerAddressOffset;
optional<IpcInterfaceCreator> m_AppIpcInterface;
IpcInterfaceUser m_RoudiIpcInterface;
uint64_t m_shmTopicSize{0U};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#define IOX_POSH_RUNTIME_SHARED_MEMORY_USER_HPP

#include "iceoryx_hoofs/internal/posix_wrapper/shared_memory_object.hpp"
#include "iceoryx_hoofs/memory/relative_pointer.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
#include "iox/filesystem.hpp"
#include "iox/optional.hpp"
#include "iox/relative_pointer.hpp"
#include "iox/vector.hpp"


Expand All @@ -40,11 +40,11 @@ class SharedMemoryUser
/// address space
SharedMemoryUser(const size_t topicSize,
const uint64_t segmentId,
const memory::UntypedRelativePointer::offset_t segmentManagerAddressOffset) noexcept;
const UntypedRelativePointer::offset_t segmentManagerAddressOffset) noexcept;

private:
void openDataSegments(const uint64_t segmentId,
const memory::UntypedRelativePointer::offset_t segmentManagerAddressOffset) noexcept;
const UntypedRelativePointer::offset_t segmentManagerAddressOffset) noexcept;

private:
optional<posix::SharedMemoryObject> m_shmObject;
Expand Down
Loading

0 comments on commit 908ee2a

Please sign in to comment.