Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iox-605 Introduce memory namespace #1677

Merged
4 changes: 2 additions & 2 deletions doc/shared-memory-communication.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ 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::rp::RelativePointer` and
the `iox::rp::relocatable_ptr`.
To deal with this, iceoryx utilizes specialized pointer types: the `iox::memory::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
14 changes: 7 additions & 7 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,19 +403,19 @@
}
```

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

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

// after
#include "iceoryx_hoofs/memory/relative_pointer.hpp" /// @todo #605 adapt namespace and directory
#include "iceoryx_hoofs/memory/relative_pointer.hpp"
mossmaurice marked this conversation as resolved.
Show resolved Hide resolved
iox::memory::UntypedRelativePointer myUntypedRelativePointer;
```

20. The `CMakeLists.txt` of apps using iceoryx need to add `iceoryx_platform`
22. The `CMakeLists.txt` of apps using iceoryx need to add `iceoryx_platform`

```cmake
// before
Expand All @@ -441,7 +441,7 @@
include(IceoryxPlatformSettings) // new
```

21. `iceoryx_hoofs/platform` was moved into separate package `iceoryx_platform`. All includes must
23. `iceoryx_hoofs/platform` was moved into separate package `iceoryx_platform`. All includes must
be adjusted.

```cxx
Expand All @@ -452,7 +452,7 @@
#include "iceoryx_platform/some_header.hpp"
```

22. `cxx::unique_ptr` is no longer nullable.
24. `cxx::unique_ptr` is no longer nullable.

```cxx
// before
Expand Down Expand Up @@ -482,7 +482,7 @@
will warn the user with a used after move warning when one accesses a moved object. Accessing
a moved `unique_ptr` is well defined and behaves like dereferencing a `nullptr`.

23. `mutex` must be always stored inside an `cxx::optional` and must use the builder pattern for
25. `mutex` must be always stored inside an `cxx::optional` and must use the builder pattern for
construction

```cpp
Expand All @@ -499,7 +499,7 @@
myMutex->lock();
```

24. Change return type of `cxx::vector::erase` from iterator to bool
26. Change return type of `cxx::vector::erase` from iterator to bool

```cpp
// before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace iox
{
namespace rp
namespace memory
{
/// @brief Smart pointer type that allows objects using it to able to be copied by memcpy
/// without invalidating the pointer.
Expand Down Expand Up @@ -149,7 +149,7 @@ bool operator==(const relocatable_ptr<T>& lhs, const relocatable_ptr<T>& rhs) no
template <typename T>
bool operator!=(const relocatable_ptr<T>& lhs, const relocatable_ptr<T>& rhs) noexcept;

} // namespace rp
} // namespace memory
} // namespace iox

#include "iceoryx_dust/relocatable_pointer/relocatable_ptr.inl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace iox
{
namespace rp
namespace memory
{
template <typename T>
inline relocatable_ptr<T>::relocatable_ptr(T* ptr) noexcept
Expand Down Expand Up @@ -161,7 +161,7 @@ inline bool operator!=(const relocatable_ptr<T>& lhs, const relocatable_ptr<T>&
return !operator==(lhs, rhs);
}

} // namespace rp
} // namespace memory
} // namespace iox

#endif // IOX_DUST_RELOCATABLE_POINTER_RELOCATABLE_PTR_INL
80 changes: 40 additions & 40 deletions iceoryx_dust/test/moduletests/test_relocatable_ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace
{
using namespace ::testing;
using namespace iox::rp;
using namespace iox::memory;

// Needed especially for void implementation tests where we cannot
// construct a corresponding object of type void to point to.
Expand Down Expand Up @@ -134,7 +134,7 @@ class RelocatableType
RelocatableType& operator=(RelocatableType&&) = delete;

int data;
iox::rp::relocatable_ptr<int> rp;
iox::memory::relocatable_ptr<int> rp;
};

// Not all tests make sense to be run as typed tests
Expand Down Expand Up @@ -191,7 +191,7 @@ TYPED_TEST(Relocatable_ptr_typed_test, wrappedPointerTypeIsCorrect)
{
::testing::Test::RecordProperty("TEST_ID", "12de29e3-673c-487c-9808-67e5c3e25c73");
using T = typename TestFixture::DataType;
using P = typename iox::rp::relocatable_ptr<T>::ptr_t;
using P = typename iox::memory::relocatable_ptr<T>::ptr_t;
constexpr bool pointerTypeIsCorrect = std::is_same<P, T*>::value;
EXPECT_TRUE(pointerTypeIsCorrect);
}
Expand All @@ -200,16 +200,16 @@ TYPED_TEST(Relocatable_ptr_typed_test, defaulCtorCreatesNullpointer)
{
::testing::Test::RecordProperty("TEST_ID", "6823533f-9594-4f53-9493-d80a73706013");
using T = typename TestFixture::DataType;
iox::rp::relocatable_ptr<T> rp;
iox::memory::relocatable_ptr<T> rp;
EXPECT_EQ(rp.get(), nullptr);
}

TYPED_TEST(Relocatable_ptr_typed_test, copyCtorOfNullptrWorks)
{
::testing::Test::RecordProperty("TEST_ID", "de23e14d-1c06-4005-ba61-45e5aeedaf47");
using T = typename TestFixture::DataType;
iox::rp::relocatable_ptr<T> rp1;
iox::rp::relocatable_ptr<T> rp2(rp1);
iox::memory::relocatable_ptr<T> rp1;
iox::memory::relocatable_ptr<T> rp2(rp1);
EXPECT_EQ(rp1.get(), nullptr);
EXPECT_EQ(rp2.get(), nullptr);
}
Expand All @@ -218,8 +218,8 @@ TYPED_TEST(Relocatable_ptr_typed_test, moveCtorOfNullptrWorks)
{
::testing::Test::RecordProperty("TEST_ID", "f0ecd49e-c165-4e25-985c-5bc44a072f2e");
using T = typename TestFixture::DataType;
iox::rp::relocatable_ptr<T> rp1;
iox::rp::relocatable_ptr<T> rp2(std::move(rp1));
iox::memory::relocatable_ptr<T> rp1;
iox::memory::relocatable_ptr<T> rp2(std::move(rp1));
EXPECT_EQ(rp1.get(), nullptr);
EXPECT_EQ(rp2.get(), nullptr);
}
Expand All @@ -231,8 +231,8 @@ TYPED_TEST(Relocatable_ptr_typed_test, copyAssignmentOfNullptrWorks)
// we cannot construct an actual object if T = void
// and it is not necessary fro most tests, we just need some non-nullptr
T* p = nonNullPtr<T>();
iox::rp::relocatable_ptr<T> rp1;
iox::rp::relocatable_ptr<T> rp2(p);
iox::memory::relocatable_ptr<T> rp1;
iox::memory::relocatable_ptr<T> rp2(p);
rp2 = rp1;
EXPECT_EQ(rp1.get(), nullptr);
EXPECT_EQ(rp2.get(), nullptr);
Expand All @@ -243,8 +243,8 @@ TYPED_TEST(Relocatable_ptr_typed_test, moveAssignmentOfNullptrWorks)
::testing::Test::RecordProperty("TEST_ID", "b15da71c-bb71-4059-a3fb-7d5d8f8020a6");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
iox::rp::relocatable_ptr<T> rp1;
iox::rp::relocatable_ptr<T> rp2(p);
iox::memory::relocatable_ptr<T> rp1;
iox::memory::relocatable_ptr<T> rp2(p);
rp2 = std::move(rp1);
EXPECT_EQ(rp1.get(), nullptr);
EXPECT_EQ(rp2.get(), nullptr);
Expand All @@ -255,7 +255,7 @@ TYPED_TEST(Relocatable_ptr_typed_test, nonNullPointerConstructionWorks)
::testing::Test::RecordProperty("TEST_ID", "6258b81c-97b4-4d5b-9543-ca7e2fc8e6f0");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
iox::rp::relocatable_ptr<T> rp(p);
iox::memory::relocatable_ptr<T> rp(p);
EXPECT_EQ(rp.get(), p);
}

Expand All @@ -264,8 +264,8 @@ TYPED_TEST(Relocatable_ptr_typed_test, copyCtorWorks)
::testing::Test::RecordProperty("TEST_ID", "453b6c32-e5ba-4b15-86af-d7601ee5b97e");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
iox::rp::relocatable_ptr<T> rp1(p);
iox::rp::relocatable_ptr<T> rp2(rp1);
iox::memory::relocatable_ptr<T> rp1(p);
iox::memory::relocatable_ptr<T> rp2(rp1);
EXPECT_EQ(rp1.get(), p);
EXPECT_EQ(rp2.get(), p);
}
Expand All @@ -275,8 +275,8 @@ TYPED_TEST(Relocatable_ptr_typed_test, moveCtorWorks)
::testing::Test::RecordProperty("TEST_ID", "42c3a34d-4dc8-4bf6-bf1e-1fc742570ee2");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
iox::rp::relocatable_ptr<T> rp1(p);
iox::rp::relocatable_ptr<T> rp2(std::move(rp1));
iox::memory::relocatable_ptr<T> rp1(p);
iox::memory::relocatable_ptr<T> rp2(std::move(rp1));
EXPECT_EQ(rp1.get(), nullptr);
EXPECT_EQ(rp2.get(), p);
}
Expand All @@ -286,8 +286,8 @@ TYPED_TEST(Relocatable_ptr_typed_test, copyAssignmentWorks)
::testing::Test::RecordProperty("TEST_ID", "431354d5-400d-49cd-8554-4ee797661cf7");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
iox::rp::relocatable_ptr<T> rp1(p);
iox::rp::relocatable_ptr<T> rp2;
iox::memory::relocatable_ptr<T> rp1(p);
iox::memory::relocatable_ptr<T> rp2;
rp2 = rp1;
EXPECT_EQ(rp1.get(), p);
EXPECT_EQ(rp2.get(), p);
Expand All @@ -298,8 +298,8 @@ TYPED_TEST(Relocatable_ptr_typed_test, moveAssignmentWorks)
::testing::Test::RecordProperty("TEST_ID", "5041782e-2c57-4739-ab21-2d7c1dfc3991");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
iox::rp::relocatable_ptr<T> rp1(p);
iox::rp::relocatable_ptr<T> rp2;
iox::memory::relocatable_ptr<T> rp1(p);
iox::memory::relocatable_ptr<T> rp2;
rp2 = std::move(rp1);
EXPECT_EQ(rp1.get(), nullptr);
EXPECT_EQ(rp2.get(), p);
Expand All @@ -311,7 +311,7 @@ TYPED_TEST(Relocatable_ptr_typed_test, constGetWorks)
::testing::Test::RecordProperty("TEST_ID", "1b478221-d1fb-44aa-905e-7f40d961eaff");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
const iox::rp::relocatable_ptr<T> rp(p);
const iox::memory::relocatable_ptr<T> rp(p);
EXPECT_EQ(rp.get(), p);

constexpr bool isConst = getReturns<decltype(rp), const T*>();
Expand All @@ -323,7 +323,7 @@ TYPED_TEST(Relocatable_ptr_typed_test, conversionToRawPointerWorks)
::testing::Test::RecordProperty("TEST_ID", "d7e46b17-62bc-4b05-a827-b91d2a4b9f23");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
iox::rp::relocatable_ptr<T> rp(p);
iox::memory::relocatable_ptr<T> rp(p);
T* q = rp;
EXPECT_EQ(q, p);

Expand All @@ -336,7 +336,7 @@ TYPED_TEST(Relocatable_ptr_typed_test, conversionToConstRawPointerWorks)
::testing::Test::RecordProperty("TEST_ID", "82f40725-67d9-4f80-812a-1fcbdd1cbf60");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
const iox::rp::relocatable_ptr<T> rp(p);
const iox::memory::relocatable_ptr<T> rp(p);
const T* q = rp;
EXPECT_EQ(q, p);

Expand All @@ -349,7 +349,7 @@ TYPED_TEST(Relocatable_ptr_typed_test, arrowOperatorWorks)
::testing::Test::RecordProperty("TEST_ID", "6f3a7428-fd7b-4a98-b3ce-90ac73655ac8");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
iox::rp::relocatable_ptr<T> rp(p);
iox::memory::relocatable_ptr<T> rp(p);
EXPECT_EQ(rp.operator->(), p);

constexpr bool isNotConst = arrowReturns<decltype(rp), T*>();
Expand All @@ -361,7 +361,7 @@ TYPED_TEST(Relocatable_ptr_typed_test, arrowOperatorConstWorks)
::testing::Test::RecordProperty("TEST_ID", "38bf2bb7-6550-4534-b0fe-6ec07632c6d3");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
const iox::rp::relocatable_ptr<T> rp(p);
const iox::memory::relocatable_ptr<T> rp(p);
EXPECT_EQ(rp.operator->(), p);

constexpr bool isConst = arrowReturns<decltype(rp), const T*>();
Expand All @@ -373,8 +373,8 @@ TYPED_TEST(Relocatable_ptr_typed_test, nullptrIsEqualToNullptr)
{
::testing::Test::RecordProperty("TEST_ID", "45d24a0b-5a46-4a10-bbb8-7f8b7647a992");
using T = typename TestFixture::DataType;
iox::rp::relocatable_ptr<T> rp1;
iox::rp::relocatable_ptr<T> rp2;
iox::memory::relocatable_ptr<T> rp1;
iox::memory::relocatable_ptr<T> rp2;

EXPECT_TRUE(rp1 == rp2);
EXPECT_TRUE(rp2 == rp1);
Expand All @@ -392,8 +392,8 @@ TYPED_TEST(Relocatable_ptr_typed_test, nullptrIsNotEqualToNonNullptr)
::testing::Test::RecordProperty("TEST_ID", "a3fd804d-9e53-4fef-9b34-bb43bd778c02");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
iox::rp::relocatable_ptr<T> rp1(p);
iox::rp::relocatable_ptr<T> rp2;
iox::memory::relocatable_ptr<T> rp1(p);
iox::memory::relocatable_ptr<T> rp2;

EXPECT_FALSE(rp1 == rp2);
EXPECT_FALSE(rp2 == rp1);
Expand All @@ -411,8 +411,8 @@ TYPED_TEST(Relocatable_ptr_typed_test, equalNonNullptrComparisonWorks)
::testing::Test::RecordProperty("TEST_ID", "c3ed8892-db76-4d62-8c04-51819696c7dc");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
iox::rp::relocatable_ptr<T> rp1(p);
iox::rp::relocatable_ptr<T> rp2(p);
iox::memory::relocatable_ptr<T> rp1(p);
iox::memory::relocatable_ptr<T> rp2(p);

EXPECT_TRUE(rp1 == rp2);
EXPECT_TRUE(rp2 == rp1);
Expand All @@ -431,8 +431,8 @@ TYPED_TEST(Relocatable_ptr_typed_test, nonEqualNonNullptrComparisonWorks)
using T = typename TestFixture::DataType;
T* p1 = nonNullPtr<T>();
T* p2 = otherNonNullPtr<T>();
iox::rp::relocatable_ptr<T> rp1(p1);
iox::rp::relocatable_ptr<T> rp2(p2);
iox::memory::relocatable_ptr<T> rp1(p1);
iox::memory::relocatable_ptr<T> rp2(p2);

EXPECT_FALSE(rp1 == rp2);
EXPECT_FALSE(rp2 == rp1);
Expand All @@ -450,7 +450,7 @@ TYPED_TEST(Relocatable_ptr_typed_test, negativeNullPointerCheckWithIfWorks)
::testing::Test::RecordProperty("TEST_ID", "77225288-be1d-4105-b2fb-7f5f452cad89");
using T = typename TestFixture::DataType;
T* p = nonNullPtr<T>();
iox::rp::relocatable_ptr<T> rp(p);
iox::memory::relocatable_ptr<T> rp(p);

if (rp)
{
Expand All @@ -466,7 +466,7 @@ TYPED_TEST(Relocatable_ptr_typed_test, positiveNullPointerCheckWithIfWorks)
{
::testing::Test::RecordProperty("TEST_ID", "4a57801b-3f52-4027-a2f1-474274e83515");
using T = typename TestFixture::DataType;
iox::rp::relocatable_ptr<T> rp;
iox::memory::relocatable_ptr<T> rp;

if (rp)
{
Expand All @@ -479,7 +479,7 @@ TEST_F(Relocatable_ptr_test, dereferencingWorks)
::testing::Test::RecordProperty("TEST_ID", "ea67f218-6ff8-4a82-a81e-52ae988546dc");
constexpr int VALUE = 666;
int x = VALUE;
iox::rp::relocatable_ptr<int> rp(&x);
iox::memory::relocatable_ptr<int> rp(&x);
EXPECT_EQ(*rp, VALUE);

constexpr bool isNotConst = dereferencingReturns<decltype(rp), int&>();
Expand All @@ -491,7 +491,7 @@ TEST_F(Relocatable_ptr_test, dereferencingConstWorks)
::testing::Test::RecordProperty("TEST_ID", "64a7e44e-b9eb-428a-bd50-3bd9e14400bc");
constexpr int VALUE = 314;
int x = VALUE;
const iox::rp::relocatable_ptr<int> rp(&x);
const iox::memory::relocatable_ptr<int> rp(&x);
EXPECT_EQ(*rp, VALUE);

constexpr bool isConst = dereferencingReturns<decltype(rp), const int&>();
Expand All @@ -503,7 +503,7 @@ TEST_F(Relocatable_ptr_test, dereferencingComplexTypeWorks)
::testing::Test::RecordProperty("TEST_ID", "e4a2bda1-c3f2-424e-b6dd-a4da6703b699");
constexpr int VALUE = 69;
Data x(VALUE);
iox::rp::relocatable_ptr<Data> rp(&x);
iox::memory::relocatable_ptr<Data> rp(&x);
EXPECT_EQ((*rp).value, x.value);
EXPECT_EQ(rp->value, x.value);
}
Expand All @@ -513,7 +513,7 @@ TEST_F(Relocatable_ptr_test, dereferencingConstComplexTypeWorks)
::testing::Test::RecordProperty("TEST_ID", "b60f0fd5-ff9b-40a5-ad0d-d13965eff578");
constexpr int VALUE = 69;
Data x(VALUE);
const iox::rp::relocatable_ptr<Data> rp(&x);
const iox::memory::relocatable_ptr<Data> rp(&x);
EXPECT_EQ((*rp).value, x.value);
EXPECT_EQ(rp->value, x.value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define IOX_HOOFS_CONCURRENT_LOFFLI_HPP

#include "iceoryx_hoofs/cxx/helplets.hpp"
#include "iceoryx_hoofs/internal/relocatable_pointer/relative_pointer.hpp"
#include "iceoryx_hoofs/internal/memory/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::rp::RelativePointer<Index_t> m_nextFreeIndex;
iox::memory::RelativePointer<Index_t> m_nextFreeIndex;

public:
LoFFLi() noexcept = default;
Expand Down
Loading