Skip to content

Commit

Permalink
Merge pull request #2335 from elBoberido/iox-2301-32-bit-mvp
Browse files Browse the repository at this point in the history
iox-#2301 32 bit MVP
  • Loading branch information
elBoberido committed Aug 27, 2024
2 parents 5bca9a4 + 72a8dfd commit 9f04853
Show file tree
Hide file tree
Showing 70 changed files with 306 additions and 197 deletions.
2 changes: 2 additions & 0 deletions .github/actions/install-iceoryx-deps-and-clang/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ runs:
- name: Install iceoryx dependencies and clang-tidy
shell: bash
run: |
sudo dpkg --add-architecture i386
sudo wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main"
sudo apt-get update
sudo apt-get install -y libacl1-dev libncurses5-dev
sudo apt-get install -y libacl1-dev:i386 libc6-dev-i386 libc6-dev-i386-cross libstdc++6-i386-cross gcc-multilib g++-multilib
sudo apt-get install -y clang-format-15 clang-tidy-15 clang-tools-15 clang-15 lld
sudo rm /usr/bin/clang
sudo rm /usr/bin/clang++
Expand Down
25 changes: 22 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,24 @@ jobs:
runs-on: ubuntu-20.04
needs: pre-flight-check
steps:
- uses: actions/checkout@v4
- uses: egor-tensin/[email protected]
- name: Checkout
uses: actions/checkout@v4
- name: Install iceoryx dependencies and clang-tidy
uses: ./.github/actions/install-iceoryx-deps-and-clang
- name: Setup GCC
uses: egor-tensin/[email protected]
with:
# gcc 8.3 is compiler used in QNX 7.1
version: 8
platform: x64
- uses: jwlawson/[email protected]
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.16.3' # version used in Ubuntu 20.04 LTS
- run: ./tools/ci/build-test-ubuntu.sh



build-test-windows-msvc:
# prevent stuck jobs consuming runners for 6 hours
timeout-minutes: 60
Expand Down Expand Up @@ -172,6 +179,18 @@ jobs:
- name: Run Thread Sanitizer
run: ./tools/ci/build-test-ubuntu-with-sanitizers.sh clang tsan

build-test-ubuntu-32-bit:
# prevent stuck jobs consuming runners for 6 hours
timeout-minutes: 60
runs-on: ubuntu-latest
needs: pre-flight-check
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install iceoryx dependencies and clang-tidy
uses: ./.github/actions/install-iceoryx-deps-and-clang
- run: ./tools/ci/build-test-ubuntu.sh 32-bit-x86

# Bazel sanity check
build-test-ubuntu-bazel:
# prevent stuck jobs consuming runners for 6 hours
Expand Down
7 changes: 7 additions & 0 deletions doc/website/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ You will need to install the following packages:
sudo apt install gcc g++ cmake libacl1-dev libncurses5-dev pkg-config
```

To build iceoryx as 32-bit library, the following packages need to be installed additionally:

```bash
sudo dpkg --add-architecture i386
sudo apt install libacl1-dev:i386 libc6-dev-i386 libc6-dev-i386-cross libstdc++6-i386-cross gcc-multilib g++-multilib
```

Additionally, there is an optional dependency to the [cpptoml](https://github.com/skystrife/cpptoml) library, which is used to parse the RouDi config file containing mempool configuration.

### QNX
Expand Down
3 changes: 1 addition & 2 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

- The minimal supported GCC compiler is now 8.3
- The required C++ standard is now C++17
- Experimental 32-bit support for all platforms supporting 64-bit atomic operations

**Features:**

Expand Down Expand Up @@ -1467,5 +1468,3 @@
```
64. The non-functional `iox::popo::Node` was removed
65. 32-bit support is disabled by default. For development purposes iceoryx can be build with the `-DIOX_IGNORE_32_BIT_CHECK=ON`
2 changes: 1 addition & 1 deletion iceoryx_binding_c/source/c_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ uint64_t iox_runtime_get_instance_name(char* const name, const uint64_t nameLeng
}

auto instanceName = PoshRuntime::getInstance().getInstanceName();
std::strncpy(name, instanceName.c_str(), nameLength);
std::strncpy(name, instanceName.c_str(), static_cast<size_t>(nameLength));
name[nameLength - 1U] = '\0'; // strncpy doesn't add a null-termination if destination is smaller than source

return instanceName.size();
Expand Down
5 changes: 3 additions & 2 deletions iceoryx_binding_c/source/c_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ iox_sub_t iox_sub_init(iox_sub_storage_t* self,
auto meWithStoragePointer = new SubscriberWithStoragePointer();
meWithStoragePointer->subscriberStorage = self;
auto me = &meWithStoragePointer->subscriber;
assert(reinterpret_cast<uint64_t>(me) - reinterpret_cast<uint64_t>(meWithStoragePointer) == sizeof(void*)
&& "Size mismatch for SubscriberWithStoragePointer!");
auto ptrDiff = reinterpret_cast<size_t>(me) - reinterpret_cast<size_t>(meWithStoragePointer);
IOX_ENFORCE(ptrDiff >= sizeof(void*), "Size mismatch for SubscriberWithStoragePointer!");
IOX_ENFORCE(ptrDiff <= 2 * sizeof(void*), "Size mismatch for SubscriberWithStoragePointer!");

me->m_portData =
PoshRuntime::getInstance().getMiddlewareSubscriber(ServiceDescription{IdString_t(TruncateToCapacity, service),
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_binding_c/test/moduletests/test_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class iox_client_test : public Test
char managementMemory[MANAGEMENT_MEMORY_SIZE];
iox::BumpAllocator mgmtAllocator{managementMemory, MANAGEMENT_MEMORY_SIZE};
static constexpr uint64_t DATA_MEMORY_SIZE = 1024 * 1024;
char dataMemory[DATA_MEMORY_SIZE];
alignas(8) char dataMemory[DATA_MEMORY_SIZE];
iox::BumpAllocator dataAllocator{dataMemory, DATA_MEMORY_SIZE};
iox::mepoo::MemoryManager memoryManager;
iox::mepoo::MePooConfig memoryConfig;
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_binding_c/test/moduletests/test_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class iox_pub_test : public Test
}

static constexpr size_t MEMORY_SIZE = 1024 * 1024;
uint8_t m_memory[MEMORY_SIZE];
alignas(8) uint8_t m_memory[MEMORY_SIZE];
static constexpr uint32_t NUM_CHUNKS_IN_POOL = 20;
static constexpr uint64_t CHUNK_SIZE = 256;

Expand Down
2 changes: 1 addition & 1 deletion iceoryx_binding_c/test/moduletests/test_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class iox_server_test : public Test
char managementMemory[MANAGEMENT_MEMORY_SIZE];
iox::BumpAllocator mgmtAllocator{managementMemory, MANAGEMENT_MEMORY_SIZE};
static constexpr uint64_t DATA_MEMORY_SIZE = 1024 * 1024;
char dataMemory[DATA_MEMORY_SIZE];
alignas(8) char dataMemory[DATA_MEMORY_SIZE];
iox::BumpAllocator dataAllocator{dataMemory, DATA_MEMORY_SIZE};
iox::mepoo::MemoryManager memoryManager;
iox::mepoo::MePooConfig memoryConfig;
Expand Down
17 changes: 15 additions & 2 deletions iceoryx_binding_c/test/moduletests/test_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "iceoryx_posh/internal/popo/ports/subscriber_port_user.hpp"
#include "iceoryx_posh/mepoo/mepoo_config.hpp"
#include "iox/detail/hoofs_error_reporting.hpp"
#include "iox/detail/system_configuration.hpp"

#include "iceoryx_hoofs/testing/fatal_failure.hpp"
#include "iceoryx_posh/roudi_env/minimal_iceoryx_config.hpp"
Expand Down Expand Up @@ -98,8 +99,8 @@ class iox_sub_test : public Test
}

static iox_sub_t m_triggerCallbackLatestArgument;
static constexpr size_t MEMORY_SIZE = 1024 * 1024 * 100;
uint8_t m_memory[MEMORY_SIZE];
static constexpr size_t MEMORY_SIZE = 1024 * 1024;
alignas(8) uint8_t m_memory[MEMORY_SIZE];
static constexpr uint32_t NUM_CHUNKS_IN_POOL = MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY + 2U;
static constexpr uint64_t CHUNK_SIZE = 128U;

Expand Down Expand Up @@ -145,6 +146,12 @@ TEST_F(iox_sub_test, initSubscriberWithNotInitializedSubscriberOptionsTerminates
TEST_F(iox_sub_test, initSubscriberWithDefaultOptionsWorks)
{
::testing::Test::RecordProperty("TEST_ID", "40eaa006-4781-46cd-bde3-40fa7d572f29");

if (iox::detail::isCompiledOn32BitSystem())
{
GTEST_SKIP() << "@todo iox-#2301 This test does not work on 32 bit builds due to the usage of RouDiEnv";
}

RouDiEnv roudiEnv;

iox_runtime_init("hypnotoad");
Expand Down Expand Up @@ -402,6 +409,12 @@ TEST_F(iox_sub_test, hasDataTriggersWaitSetWithCorrectCallback)
TEST_F(iox_sub_test, deinitSubscriberDetachesTriggerFromWaitSet)
{
::testing::Test::RecordProperty("TEST_ID", "93e350fb-5430-43ff-982b-b43c6ae9b890");

if (iox::detail::isCompiledOn32BitSystem())
{
GTEST_SKIP() << "@todo iox-#2301 This test does not work on 32 bit builds due to the usage of RouDiEnv";
}

RouDiEnv roudiEnv;
iox_runtime_init("hypnotoad");

Expand Down
1 change: 0 additions & 1 deletion iceoryx_hoofs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ configure_file(
src = "cmake/iceoryx_hoofs_deployment.hpp.in",
out = "generated/include/iox/iceoryx_hoofs_deployment.hpp",
config = {
"IOX_IGNORE_32_BIT_CHECK_FLAG": "false",
"IOX_MAX_NAMED_PIPE_MESSAGE_SIZE": "4096",
"IOX_MAX_NAMED_PIPE_NUMBER_OF_MESSAGES": "10",
# FIXME: for values see "iceoryx_hoofs/cmake/IceoryxHoofsDeployment.cmake" ... for now some nice defaults
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/cli/source/command_line_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ bool CommandLineParser::doesNotExceedLongOptionDash(const char* option) const no

bool CommandLineParser::doesFitIntoString(const char* value, const uint64_t maxLength) noexcept
{
return (strnlen(value, maxLength + 1) <= maxLength);
return (strnlen(value, static_cast<size_t>(maxLength) + 1) <= maxLength);
}

bool CommandLineParser::doesOptionNameFitIntoString(const char* option) const noexcept
Expand Down
5 changes: 0 additions & 5 deletions iceoryx_hoofs/cmake/IceoryxHoofsDeployment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ configure_option(
DEFAULT_VALUE 10
)

if(IOX_IGNORE_32_BIT_CHECK)
set(IOX_IGNORE_32_BIT_CHECK_FLAG true)
else()
set(IOX_IGNORE_32_BIT_CHECK_FLAG false)
endif()
message(STATUS "[i] IOX_EXPERIMENTAL_POSH_FLAG: ${IOX_EXPERIMENTAL_POSH_FLAG}")

message(STATUS "[i] <<<<<<<<<<<<<< End iceoryx_hoofs configuration: >>>>>>>>>>>>>>")
2 changes: 0 additions & 2 deletions iceoryx_hoofs/cmake/iceoryx_hoofs_deployment.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ constexpr iox::log::LogLevel IOX_MINIMAL_LOG_LEVEL = iox::log::LogLevel::@IOX_MI
constexpr uint64_t IOX_MAX_NAMED_PIPE_MESSAGE_SIZE = static_cast<uint64_t>(@IOX_MAX_NAMED_PIPE_MESSAGE_SIZE@);
constexpr uint32_t IOX_MAX_NAMED_PIPE_NUMBER_OF_MESSAGES = static_cast<uint32_t>(@IOX_MAX_NAMED_PIPE_NUMBER_OF_MESSAGES@);

constexpr bool IOX_IGNORE_32_BIT_CHECK_FLAG = @IOX_IGNORE_32_BIT_CHECK_FLAG@;

} // namespace build
} // namespace iox

Expand Down
8 changes: 4 additions & 4 deletions iceoryx_hoofs/container/include/iox/detail/vector.inl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ inline vector<T, Capacity>& vector<T, Capacity>::operator=(const vector& rhs) no

if constexpr (std::is_trivially_copyable<T>::value)
{
std::memcpy(data(), rhs.data(), rhsSize * sizeof(T));
std::memcpy(data(), rhs.data(), static_cast<size_t>(rhsSize) * sizeof(T));
i = rhsSize;
}
else
Expand Down Expand Up @@ -129,7 +129,7 @@ inline vector<T, Capacity>& vector<T, Capacity>::operator=(vector&& rhs) noexcep

if constexpr (std::is_trivially_copyable<T>::value)
{
std::memcpy(data(), rhs.data(), rhsSize * sizeof(T));
std::memcpy(data(), rhs.data(), static_cast<size_t>(rhsSize) * sizeof(T));
i = rhsSize;
}
else
Expand Down Expand Up @@ -220,7 +220,7 @@ inline bool vector<T, Capacity>::emplace(const uint64_t position, Targs&&... arg
if constexpr (std::is_trivial<T>::value)
{
resize(size() + 1U);
const uint64_t dataLen{sizeBeforeEmplace - position};
const size_t dataLen{static_cast<size_t>(sizeBeforeEmplace) - static_cast<size_t>(position)};
std::memmove(data() + position + 1U, data() + position, dataLen * sizeof(T));
at_unchecked(position) = T{std::forward<Targs>(args)...};
}
Expand Down Expand Up @@ -414,7 +414,7 @@ inline bool vector<T, Capacity>::erase(iterator position) noexcept
at_unchecked(n).~T();
}
uint64_t dataLen{size() - n - 1U};
std::memmove(data() + n, data() + n + 1U, dataLen * sizeof(T));
std::memmove(data() + n, data() + n + 1U, static_cast<size_t>(dataLen) * sizeof(T));
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_hoofs/memory/include/iox/detail/relative_pointer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ inline typename RelativePointer<T>::offset_t RelativePointer<T>::getOffset(const
const auto* const basePtr = getBasePtr(id);
// AXIVION Next Construct AutosarC++19_03-A5.2.4, AutosarC++19_03-M5.2.9 : Cast needed for pointer arithmetic
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
return reinterpret_cast<offset_t>(ptr) - reinterpret_cast<offset_t>(basePtr);
return reinterpret_cast<std::uintptr_t>(ptr) - reinterpret_cast<std::uintptr_t>(basePtr);
}

template <typename T>
Expand All @@ -206,7 +206,7 @@ inline T* RelativePointer<T>::getPtr(const segment_id_t id, const offset_t offse
// AXIVION DISABLE STYLE AutosarC++19_03-M5.2.8 : Cast needed for pointer arithmetic
// AXIVION DISABLE STYLE AutosarC++19_03-M5.2.9 : Cast needed for pointer arithmetic
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast, performance-no-int-to-ptr)
return reinterpret_cast<ptr_t>(offset + reinterpret_cast<offset_t>(basePtr));
return reinterpret_cast<ptr_t>(offset + reinterpret_cast<std::uintptr_t>(basePtr));
// AXIVION ENABLE STYLE AutosarC++19_03-M5.2.9
// AXIVION ENABLE STYLE AutosarC++19_03-M5.2.8
// AXIVION ENABLE STYLE AutosarC++19_03-A5.2.4
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/memory/include/iox/detail/static_storage.inl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ constexpr void* static_storage<Capacity, Align>::allocate(const uint64_t align,

size_t space{Capacity};
m_ptr = m_bytes;
if (std::align(align, size, m_ptr, space) != nullptr)
if (std::align(static_cast<size_t>(align), static_cast<size_t>(size), m_ptr, space) != nullptr)
{
// fits, ptr was potentially modified to reflect alignment
return m_ptr;
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/memory/include/iox/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ T align(const T value, const T alignment) noexcept
/// @param[in] alignment, alignment of the memory
/// @param[in] size, memory size
/// @return void pointer to the aligned memory
void* alignedAlloc(const uint64_t alignment, const uint64_t size) noexcept;
void* alignedAlloc(const size_t alignment, const size_t size) noexcept;

/// @brief frees aligned memory allocated with alignedAlloc
/// @param[in] memory, pointer to the aligned memory
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/memory/include/iox/relative_pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class RelativePointer final
{
public:
using ptr_t = T*;
using offset_t = std::uintptr_t;
using offset_t = std::uint64_t;

/// @brief Default constructs a RelativePointer as a logical nullptr
RelativePointer() noexcept = default;
Expand Down
6 changes: 3 additions & 3 deletions iceoryx_hoofs/memory/source/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@

namespace iox
{
void* alignedAlloc(const uint64_t alignment, const uint64_t size) noexcept
void* alignedAlloc(const size_t alignment, const size_t size) noexcept
{
// -1 == since the max alignment addition is alignment - 1 otherwise the
// memory is already aligned and we have to do nothing
// low-level memory management, no other approach then to use malloc to acquire heap memory
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory,cppcoreguidelines-pro-type-reinterpret-cast,hicpp-no-malloc,cppcoreguidelines-no-malloc)
auto memory = reinterpret_cast<uint64_t>(std::malloc(size + alignment + sizeof(void*) - 1));
auto memory = reinterpret_cast<size_t>(std::malloc(size + alignment + sizeof(void*) - 1));
if (memory == 0)
{
return nullptr;
}
uint64_t alignedMemory = align(memory + sizeof(void*), alignment);
size_t alignedMemory = align(memory + sizeof(void*), alignment);
assert(alignedMemory >= memory + 1);
// low-level memory management, we have to store the actual start of the memory a position before the
// returned aligned address to be able to release the actual memory address again with free when we
Expand Down
8 changes: 6 additions & 2 deletions iceoryx_hoofs/posix/filesystem/source/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ File::read_at(const uint64_t offset, uint8_t* const buffer, const uint64_t buffe
return err(FileReadError::OffsetFailure);
}

auto result = IOX_POSIX_CALL(iox_read)(m_file_descriptor, buffer, buffer_len).failureReturnValue(-1).evaluate();
auto result = IOX_POSIX_CALL(iox_read)(m_file_descriptor, buffer, static_cast<size_t>(buffer_len))
.failureReturnValue(-1)
.evaluate();

if (!result.has_error())
{
Expand Down Expand Up @@ -394,7 +396,9 @@ File::write_at(const uint64_t offset, const uint8_t* const buffer, const uint64_
return err(FileWriteError::OffsetFailure);
}

auto result = IOX_POSIX_CALL(iox_write)(m_file_descriptor, buffer, buffer_len).failureReturnValue(-1).evaluate();
auto result = IOX_POSIX_CALL(iox_write)(m_file_descriptor, buffer, static_cast<size_t>(buffer_len))
.failureReturnValue(-1)
.evaluate();

if (!result.has_error())
{
Expand Down
Loading

0 comments on commit 9f04853

Please sign in to comment.