Skip to content

Commit

Permalink
Merge branch 'iceoryx/master' into iox-eclipse-iceoryx#605-cleanup-re…
Browse files Browse the repository at this point in the history
…locatable-ptr

Signed-off-by: Marika Lehmann <[email protected]>
  • Loading branch information
FerdinandSpitzschnueffler committed Mar 22, 2021
2 parents 2fbaaf0 + 5995747 commit fb25816
Show file tree
Hide file tree
Showing 93 changed files with 3,599 additions and 563 deletions.
8 changes: 3 additions & 5 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# codecov yaml
comment:
comment: false
layout: "reach, diff, flags, files"
behavior: default
require_changes: yes
Expand All @@ -13,14 +13,12 @@ coverage:
project:
default:
enabled: yes
target: 70%
target: auto
threshold: 2% # allow coverage to drop maximum by a defined value
patch:
default:
enabled: yes
target: 70%
threshold: 2%
base: auto
target: auto
changes: no

parsers:
Expand Down
24 changes: 13 additions & 11 deletions doc/design/chunk_header.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Chunks are the transport capsules in iceoryx. They store data from a publisher a
| Chunk Header | contains meta information related to the chunk |
| Custom Header | contains custom meta information, e.g. timestamps |
| Payload | the user data |
| Back-Offset | offset stored in front of the payload to calculate back to the chunk header |
| Back-Offset | offset stored in front of the payload to calculate back to the chunk header (for the most simple case it will overlap with the payload offset stored in the Chunk Header) |

## Design

Expand Down Expand Up @@ -62,13 +62,15 @@ For back calculation from the payload pointer to the `ChunkHeader` pointer, the
|------------------>|--------------------->|
| | |
+===================+======================+==================================+
| ChunkHeader ¦ | Payload | Padding |
| ChunkHeader ¦ * | Payload | Padding |
+===================+======================+==================================+
| | |
| payloadOffset | |
|------------------>| |
| chunkSize |
|---------------------------------------------------------------------------->|
*) payloadOffset from ChunkHeader and back-offset are overlapping
```

2. No custom header and alignment exceeds the `ChunkHeader` alignment
Expand Down Expand Up @@ -115,22 +117,22 @@ Depending on the address of the chunk there is the chance that `ChunkHeader` is
payloadOffset = sizeof(ChunkHeader);
```

2. No custom header and payload alignment exceeds the `ChunkHeader` alignment, which means the payload is either adjacent to the `ChunkHeader` or there is a padding with at least the size of `ChunkHeader` in front of the payload and therefore enough space to store the `back-offset`
2. No custom header and payload alignment exceeds the `ChunkHeader` alignment, which means the payload is either adjacent to the `ChunkHeader` or there is a padding with at least the size of `ChunkHeader` alignment in front of the payload and therefore enough space to store the `back-offset`

```
headerEndAddress = addressof(chunkHeader) + sizeof(chunkHeader);
payloadAddress = align(headerEndAddress, payloadAlignment);
payloadOffset = payloadAddress - addressof(chunkHeader);
alignedPayloadAddress = align(headerEndAddress, payloadAlignment);
payloadOffset = alignedPayloadAddress - addressof(chunkHeader);
```

3. Custom header is used

```
headerEndAddress = addressof(chunkHeader) + sizeof(chunkHeader) + sizeof(customHeader);
potentialBackOffsetAddress = align(headerEndAddress, alignof(payloadOffset));
potentialPayloadAddress = potentialBackOffsetAddress + sizeof(payloadOffset);
payloadAddress = align(potentialPayloadAddress, payloadAlignment);
payloadOffset = payloadAddress - addressof(chunkHeader);
anticipatedBackOffsetAddress = align(headerEndAddress, alignof(payloadOffset));
unalignedPayloadAddress = anticipatedBackOffsetAddress + sizeof(payloadOffset);
alignedPayloadAddress = align(unalignedPayloadAddress, payloadAlignment);
payloadOffset = alignedPayloadAddress - addressof(chunkHeader);
```

#### Required Chunk Size Calculation
Expand Down Expand Up @@ -192,8 +194,8 @@ The following formula is used to calculate the required chunk size.
```
headerSize = sizeof(chunkHeader) + sizeof(customHeader)
prePayloadAlignmentOverhang = align(headerSize, alignof(payloadOffset));
maxAlignment = max(alignof(payloadOffset), payloadAlignment);
chunkSize = prePayloadAlignmentOverhang + maxAlignment + payloadSize;
maxPadding = max(sizeof(payloadOffset), payloadAlignment);
chunkSize = prePayloadAlignmentOverhang + maxPadding + payloadSize;
```

#### Accessing Chunk Header Extension
Expand Down
152 changes: 82 additions & 70 deletions doc/website/getting-started/installation.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
# Installation

iceoryx_utils and iceoryx_posh are deployed as independent cmake packages. Posh is using some functions from utils and is depending on it. You are able to build posh and utils and integrate in into existing cmake projects.
_iceoryx_utils_ and _iceoryx_posh_ are deployed as independent CMake packages. _iceoryx_posh_ is using some functions from _iceoryx_utils_ and is depending on it.

## Prerequisites

### Dependencies

- 64-bit hardware (e.g. x86_64 or aarch64; 32-bit hardware might work, but is not supported)
- [cmake](https://cmake.org), 3.5 or later
- One of the following compilers:
- [gcc](https://gcc.gnu.org), 7.4 or later (5.4 currently supported too)
- [clang](https://clang.llvm.org), 9.0 or later
- [msvc](https://visualstudio.microsoft.com/de/), part of Visual Studio 2019 or later
- [libacl](http://download.savannah.gnu.org/releases/acl/), 2.2 or later. Only for Linux & QNX.
- optional, [ncurses](https://invisible-island.net/ncurses/), 6.2 or later. Required by introspection tool.
- 64-bit hardware (e.g. x86_64 or aarch64; 32-bit hardware might work, but is not supported)
- [CMake](https://cmake.org), 3.5 or later
- One of the following compilers:
- [GCC](https://gcc.gnu.org), 7.4 or later (5.4 currently supported too)
- [Clang](https://clang.llvm.org), 9.0 or later
- [MSVC](https://visualstudio.microsoft.com/de/), part of Visual Studio 2019 or later
- [libacl](http://download.savannah.gnu.org/releases/acl/), 2.2 or later. Only for Linux & QNX.
- optional, [ncurses](https://invisible-island.net/ncurses/), 6.2 or later. Required by introspection tool.

#### Optional, Cyclone DDS Gateway
If you would like to use our Cyclone DDS Gateway you have to install [Cyclone DDS](https://github.com/eclipse-cyclonedds/cyclonedds) first.<br>

If you would like to use our Cyclone DDS Gateway you have to install [Cyclone DDS](https://github.com/eclipse-cyclonedds/cyclonedds) first.
Furthermore you have to install:

- [Apache Maven](http://maven.apache.org/download.cgi), 3.5 or later
- [OpenJDK](http://jdk.java.net/11/), 11.0 or later. Alternatively, Java JDK version 8 or later
- [Apache Maven](http://maven.apache.org/download.cgi), 3.5 or later
- [OpenJDK](http://jdk.java.net/11/), 11.0 or later. Alternatively, Java JDK version 8 or later

**Hint:** If you are behind a corporate firewall you may have to adjust the proxy
settings of maven in `/etc/maven/settings.xml`. See: [Maven Proxy Configuration](https://maven.apache.org/settings.html#proxies)
!!! hint
If you are behind a corporate firewall you may have to adjust the proxy
settings of maven in `/etc/maven/settings.xml`. See: [Maven Proxy Configuration](https://maven.apache.org/settings.html#proxies)

### Mac OS

Before installing iceoryx you need to install XCode and git. Optionally, ncurses library is required for
Before installing iceoryx you need to install XCode and git. Optionally, ncurses library is required for
the introspection client. To install ncurses locally into your build folder follow these steps
```

```bash
cd iceoryx
ICEORYX_DIR=$PWD
mkdir -p build
Expand All @@ -47,7 +50,8 @@ make install
Although we strive to be fully POSIX-compliant, we recommend using Ubuntu 18.04 and at least GCC 7.5.0 for development.

You will need to install the following packages:
```

```bash
sudo apt install gcc g++ cmake libacl1-dev libncurses5-dev pkg-config
```

Expand All @@ -58,56 +62,65 @@ Additionally, there is an optional dependency to the MIT licensed [cpptoml](http
QNX SDP 7.0 and 7.1 are supported (shipping with gcc 5.4 and gcc 8.3 respectively).

Easiest way to build iceoryx on QNX is using the build script and providing a toolchain file.<br>
Example:
```
./tools/iceoryx_build_test.sh -t /home/user/toolchains/qnx/qcc_x86_64_toolchain.cmake
```
We provide generic QNX SDP 7.0 toolchain files for ARM_64 and X86_64 in `./tools/toolchains/qnx` ([Direct Link](https://github.com/eclipse-iceoryx/iceoryx/tree/master/tools/toolchains/qnx)).

ARM_64: `./tools/iceoryx_build_test.sh -t /home/user/toolchains/qnx/qnx_sdp70_aarch64le.cmake`<br>
X86_64: `./tools/iceoryx_build_test.sh -t /home/user/toolchains/qnx/qnx_sdp70_x86_64.cmake`

!!! attention
Please make sure the directory `/var/lock` is created by your QNX image

## Build with CMake

**NOTE:** Requires CMake version 3.5 or higher. Building from CMake is the preferred way, for more complex actions like a coverage scan
is a script available (see chapter below).
!!! note
Requires CMake version 3.5 or higher. Building from CMake is the preferred way, for more complex actions like a coverage scan
is a script available (see chapter below).

The `CMakeLists.txt` from `iceoryx_meta` can be used to easily develop iceoryx with an IDE.

1. Clone the repository
```bash
git clone https://github.com/eclipse-iceoryx/iceoryx.git
```

2. Generate the necessary build files
```bash
cd iceoryx
cmake -Bbuild -Hiceoryx_meta #tip: to build all iceoryx components add -DBUILD_ALL to the cmake command
# when you have installed external dependencies like ncurses you have to add them
# to your prefix path
cmake -Bbuild -Hiceoryx_meta -DCMAKE_PREFIX_PATH=$(PWD)/build/dependencies/
```

3. Compile the source code
```bash
cmake --build build
```
Tip: You can fasten up the build by appending `-j 4` where 4 stands for the number of parallel build processes.
You can choose more or less depending on your available CPU cores on your machine.

4. Install to system
Mac:
```bash
cmake --build build --target install
```
Linux:
```bash
sudo cmake --build build --target install
```
Tip: The installation directory is usually left at its default, which is /usr/local
**NOTE:** Iceoryx is build in Release mode with `-O3` optimization by default. If you want to have debug symbols please
set `CMAKE_BUILD_TYPE=Debug`.
1. Clone the repository

git clone https://github.com/eclipse-iceoryx/iceoryx.git

2. Generate the necessary build files

cd iceoryx
cmake -Bbuild -Hiceoryx_meta
# when you have installed external dependencies like ncurses you have to add them
# to your prefix path
cmake -Bbuild -Hiceoryx_meta -DCMAKE_PREFIX_PATH=$(PWD)/build/dependencies/

!!! tip
To build all iceoryx components add `-DBUILD_ALL` to the CMake command

3. Compile the source code

cmake --build build

!!! tip
You can fasten up the build by appending `-j 4` where 4 stands for the number of parallel build processes.
You can choose more or less depending on your available CPU cores on your machine.

4. Install to system

Mac:

cmake --build build --target install

Linux:

sudo cmake --build build --target install

!!! tip
The installation directory is usually left at its default, which is `/usr/local`

!!! note
iceoryx is build in Release mode with `-O3` optimization by default. If you want to have debug symbols please
set `CMAKE_BUILD_TYPE=Debug`.

### Build options

Please take a look at the cmake file [build_options.cmake](../../../iceoryx_meta/build_options.cmake) to get an overview of the available build options for enabling additional features.
Please take a look at the CMake file [build_options.cmake](../../../iceoryx_meta/build_options.cmake) to get an overview of the available build options for enabling additional features.

### Available CMake switches you can customize for the iceoryx_posh build

Expand All @@ -129,27 +142,26 @@ As an alternative we provide our build-test script which we use to integrate ice
The intention of the script is to more than just building with iceoryx. This is for doing a code coverage scan or for using the adress-sanitizer.
The script currently only works for Linux and QNX, it is planned to offer a multi-platform solution.

1. Clone the repository
```
git clone https://github.com/eclipse-iceoryx/iceoryx.git
```
1. Clone the repository

git clone https://github.com/eclipse-iceoryx/iceoryx.git

1. Build everything

2. Build everything
```
cd iceoryx
./tools/iceoryx_build_test.sh build-all
```
cd iceoryx
./tools/iceoryx_build_test.sh build-all

You can use the help for getting an overview over the available options:
```
./tools/iceoryx_build_test.sh help
```

```bash
./tools/iceoryx_build_test.sh help
```

## Build with colcon

Alternatively, iceoryx can be built with [colcon](https://colcon.readthedocs.io/en/released/user/installation.html) to provide a smooth integration for ROS2 developers.

```
```bash
mkdir -p iceoryx_ws/src
cd $_
git clone https://github.com/eclipse-iceoryx/iceoryx.git
Expand Down
7 changes: 3 additions & 4 deletions iceoryx_binding_c/source/c_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ void iox_pub_deinit(iox_pub_t const self)

iox_AllocationResult iox_pub_loan_chunk(iox_pub_t const self, void** const chunk, const uint32_t payloadSize)
{
auto result = PublisherPortUser(self->m_portData).tryAllocateChunk(payloadSize).and_then([&](ChunkHeader* h) {
*chunk = h->payload();
});
auto result = PublisherPortUser(self->m_portData)
.tryAllocateChunk(payloadSize, CHUNK_DEFAULT_PAYLOAD_ALIGNMENT)
.and_then([&chunk](ChunkHeader* h) { *chunk = h->payload(); });
if (result.has_error())
{
return cpp2c::AllocationResult(result.get_error());
Expand Down Expand Up @@ -155,4 +155,3 @@ iox_service_description_t iox_pub_get_service_description(iox_pub_t const self)
{
return TranslateServiceDescription(PublisherPortUser(self->m_portData).getCaProServiceDescription());
}

23 changes: 14 additions & 9 deletions iceoryx_binding_c/test/moduletests/test_event_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ class iox_event_info_test : public Test
m_lastEventCallbackArgument = arg;
}

iox::mepoo::SharedChunk getChunkFromMemoryManager()
{
constexpr uint32_t PAYLOAD_SIZE{100U};
return m_memoryManager.getChunk(PAYLOAD_SIZE,
iox::CHUNK_DEFAULT_PAYLOAD_ALIGNMENT,
iox::CHUNK_NO_CUSTOM_HEADER_SIZE,
iox::CHUNK_NO_CUSTOM_HEADER_ALIGNMENT);
}


static UserTrigger* m_lastEventCallbackArgument;
ConditionVariableData m_condVar{"myApp"};
Expand Down Expand Up @@ -108,7 +117,7 @@ TEST_F(iox_event_info_test, eventInfoHasCorrectId)

auto eventInfoVector = m_waitSet.wait();

ASSERT_THAT(eventInfoVector.size(), Eq(1));
ASSERT_THAT(eventInfoVector.size(), Eq(1U));
EXPECT_EQ(iox_event_info_get_event_id(eventInfoVector[0]), ARBITRARY_EVENT_ID);
}

Expand All @@ -125,10 +134,9 @@ TEST_F(iox_event_info_test, eventOriginIsUserTriggerPointerWhenItsOriginatingFro

TEST_F(iox_event_info_test, eventOriginIsNotUserTriggerPointerWhenItsNotOriginatingFromThem)
{
constexpr uint64_t CHUNK_SIZE = 100U;
iox_ws_attach_subscriber_event(&m_waitSet, m_subscriberHandle, SubscriberEvent_HAS_DATA, 587U, NULL);
this->Subscribe(&m_portPtr);
m_chunkPusher.push(m_memoryManager.getChunk(CHUNK_SIZE));
m_chunkPusher.push(getChunkFromMemoryManager());

auto eventInfoVector = m_waitSet.wait();

Expand All @@ -137,10 +145,9 @@ TEST_F(iox_event_info_test, eventOriginIsNotUserTriggerPointerWhenItsNotOriginat

TEST_F(iox_event_info_test, eventOriginIsSubscriberPointerWhenItsOriginatingFromThem)
{
constexpr uint64_t CHUNK_SIZE = 100U;
iox_ws_attach_subscriber_event(&m_waitSet, m_subscriberHandle, SubscriberEvent_HAS_DATA, 587U, NULL);
this->Subscribe(&m_portPtr);
m_chunkPusher.push(m_memoryManager.getChunk(CHUNK_SIZE));
m_chunkPusher.push(getChunkFromMemoryManager());

auto eventInfoVector = m_waitSet.wait();

Expand Down Expand Up @@ -172,10 +179,9 @@ TEST_F(iox_event_info_test, getOriginReturnsPointerToUserTriggerWhenOriginatingF

TEST_F(iox_event_info_test, getOriginReturnsNullptrUserTriggerWhenNotOriginatingFromThem)
{
constexpr uint64_t CHUNK_SIZE = 100U;
iox_ws_attach_subscriber_event(&m_waitSet, m_subscriberHandle, SubscriberEvent_HAS_DATA, 587U, NULL);
this->Subscribe(&m_portPtr);
m_chunkPusher.push(m_memoryManager.getChunk(CHUNK_SIZE));
m_chunkPusher.push(getChunkFromMemoryManager());

auto eventInfoVector = m_waitSet.wait();

Expand All @@ -185,10 +191,9 @@ TEST_F(iox_event_info_test, getOriginReturnsNullptrUserTriggerWhenNotOriginating

TEST_F(iox_event_info_test, getOriginReturnsPointerToSubscriberWhenOriginatingFromThem)
{
constexpr uint64_t CHUNK_SIZE = 100U;
iox_ws_attach_subscriber_event(&m_waitSet, m_subscriberHandle, SubscriberEvent_HAS_DATA, 587U, NULL);
this->Subscribe(&m_portPtr);
m_chunkPusher.push(m_memoryManager.getChunk(CHUNK_SIZE));
m_chunkPusher.push(getChunkFromMemoryManager());

auto eventInfoVector = m_waitSet.wait();

Expand Down
Loading

0 comments on commit fb25816

Please sign in to comment.