Skip to content

Commit

Permalink
iox-eclipse-iceoryx#33 solved merge conflict with 32 bit branch
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Eltzschig <christian.eltzschig2@de.bosch.com>
  • Loading branch information
elfenpiff committed Feb 5, 2020
2 parents 08b9a07 + 9691c50 commit 1915537
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 103 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ Examples for a "porcelain" API would be e.g.
[Adaptive Autosar Foundation](https://www.autosar.org/fileadmin/Releases_TEMP/Adaptive_Platform_19-03/AdaptiveFoundation.zip)
(see AUTOSAR_EXP_ARAComAPI.pdf) or [ROS](https://www.ros.org).

### Supported Platforms

* Linux
* QNX
* macOS (not yet - currently in progress with high priority)
* Windows 10 (not yet - currently in progress)

### Scope

Who can benefit of using iceoryx? What's in for those folks?
Expand Down
1 change: 1 addition & 0 deletions iceoryx_posh/include/iceoryx_posh/iceoryx_posh_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ constexpr uint32_t MAX_INTERFACE_CAPRO_FIFO_SIZE = MAX_PORT_NUMBER;
constexpr uint32_t MAX_APPLICATION_CAPRO_FIFO_SIZE = 128;

// Memory
constexpr uint64_t SHARED_MEMORY_ALIGNMENT = 32;
constexpr uint32_t MAX_NUMBER_OF_MEMPOOLS = 32;
constexpr uint32_t MAX_SHM_SEGMENTS = 100;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ uint64_t SegmentManager<SegmentType>::requiredManagementMemorySize(const RouDiCo
uint64_t memorySize{0};
for (auto segment : f_config.m_sharedMemorySegments)
{
memorySize += cxx::align(MemoryManager::requiredManagementMemorySize(segment.m_mempoolConfig), 32ul);
memorySize += cxx::align(MemoryManager::requiredManagementMemorySize(segment.m_mempoolConfig), SHARED_MEMORY_ALIGNMENT);
}
return memorySize;
}
Expand All @@ -173,15 +173,15 @@ uint64_t SegmentManager<SegmentType>::requiredChunkMemorySize(const RouDiConfig_
uint64_t memorySize{0};
for (auto segment : f_config.m_sharedMemorySegments)
{
memorySize += cxx::align(MemoryManager::requiredChunkMemorySize(segment.m_mempoolConfig), 32ul);
memorySize += cxx::align(MemoryManager::requiredChunkMemorySize(segment.m_mempoolConfig), SHARED_MEMORY_ALIGNMENT);
}
return memorySize;
}

template <typename SegmentType>
uint64_t SegmentManager<SegmentType>::requiredFullMemorySize(const RouDiConfig_t& f_config)
{
return cxx::align(requiredManagementMemorySize(f_config) + requiredChunkMemorySize(f_config), 32ul);
return cxx::align(requiredManagementMemorySize(f_config) + requiredChunkMemorySize(f_config), SHARED_MEMORY_ALIGNMENT);
}

} // namespace mepoo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ template <typename T>
uint64_t TypedMemPool<T>::requiredManagementMemorySize(const uint64_t f_numberOfChunks)
{
return f_numberOfChunks * sizeof(ChunkManagement)
+ 2 * cxx::align(MemPool::freeList_t::requiredMemorySize(f_numberOfChunks), 32ul);
+ 2 * cxx::align(static_cast<uint64_t>(MemPool::freeList_t::requiredMemorySize(f_numberOfChunks)), SHARED_MEMORY_ALIGNMENT);
}

template <typename T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ inline SharedMemoryCreator<ShmType>::SharedMemoryCreator(const RouDiConfig_t& co
/// @todo these are internal mempool for the introspection, move to a better place
mepoo::MePooConfig mempoolConfig;
mempoolConfig.m_mempoolConfig.push_back(
{static_cast<uint32_t>(cxx::align(sizeof(roudi::MemPoolIntrospectionTopic), 32ul)), 250});
{static_cast<uint32_t>(cxx::align(static_cast<uint64_t>(sizeof(roudi::MemPoolIntrospectionTopic)), SHARED_MEMORY_ALIGNMENT)), 250});
mempoolConfig.m_mempoolConfig.push_back(
{static_cast<uint32_t>(cxx::align(sizeof(roudi::ProcessIntrospectionFieldTopic), 32ul)), 10});
{static_cast<uint32_t>(cxx::align(static_cast<uint64_t>(sizeof(roudi::ProcessIntrospectionFieldTopic)), SHARED_MEMORY_ALIGNMENT)), 10});
mempoolConfig.m_mempoolConfig.push_back(
{static_cast<uint32_t>(cxx::align(sizeof(roudi::PortIntrospectionFieldTopic), 32ul)), 10});
{static_cast<uint32_t>(cxx::align(static_cast<uint64_t>(sizeof(roudi::PortIntrospectionFieldTopic)), SHARED_MEMORY_ALIGNMENT)), 10});
mempoolConfig.m_mempoolConfig.push_back(
{static_cast<uint32_t>(cxx::align(sizeof(roudi::PortThroughputIntrospectionFieldTopic), 32ul)), 10});
{static_cast<uint32_t>(cxx::align(static_cast<uint64_t>(sizeof(roudi::PortThroughputIntrospectionFieldTopic)), SHARED_MEMORY_ALIGNMENT)), 10});
mempoolConfig.optimize();

uint64_t totalSharedMemorySize = ShmType::getRequiredSharedMemory()
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_posh/source/mepoo/memory_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ uint64_t MemoryManager::requiredManagementMemorySize(const MePooConfig& f_mePooC
for (const auto& mempool : f_mePooConfig.m_mempoolConfig)
{
sumOfAllChunks += mempool.m_chunkCount;
memorySize += cxx::align(MemPool::freeList_t::requiredMemorySize(mempool.m_chunkCount), 32ul);
memorySize += cxx::align(static_cast<uint64_t>(MemPool::freeList_t::requiredMemorySize(mempool.m_chunkCount)), SHARED_MEMORY_ALIGNMENT);
}

memorySize += sumOfAllChunks * sizeof(ChunkManagement);
memorySize += cxx::align(MemPool::freeList_t::requiredMemorySize(sumOfAllChunks), 32ul);
memorySize += cxx::align(static_cast<uint64_t>(MemPool::freeList_t::requiredMemorySize(sumOfAllChunks)), SHARED_MEMORY_ALIGNMENT);

return memorySize;
}
Expand Down
7 changes: 7 additions & 0 deletions iceoryx_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ target_include_directories(iceoryx_utils
target_compile_options(iceoryx_utils PUBLIC -std=c++11)
target_compile_options(iceoryx_utils PUBLIC -fPIC)

<<<<<<< HEAD
=======
if(NOT CMAKE_SYSTEM_NAME MATCHES QNX)
target_link_libraries(iceoryx_utils PRIVATE acl atomic rt ${CODE_COVERAGE_LIBS})
endif(NOT CMAKE_SYSTEM_NAME MATCHES QNX)

>>>>>>> iox-#12-compilation-error-in-utils-with-32-bit
set_target_properties(iceoryx_utils
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
Expand Down
1 change: 1 addition & 0 deletions iceoryx_utils/include/iceoryx_utils/cxx/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <limits>
#include <sstream>
#include <string>

Expand Down
101 changes: 63 additions & 38 deletions iceoryx_utils/include/iceoryx_utils/internal/cxx/convert.inl
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,15 @@ inline bool convert::stringIsNumberWithErrorMessage(const char* v, const NumberT
std::cerr << v << " is not ";
switch (type)
{
case NumberType::FLOAT:
{
case NumberType::FLOAT: {
std::cerr << "a float";
break;
}
case NumberType::INTEGER:
{
case NumberType::INTEGER: {
std::cerr << "a signed integer";
break;
}
case NumberType::UNSIGNED_INTEGER:
{
case NumberType::UNSIGNED_INTEGER: {
std::cerr << "an unsigned integer";
break;
}
Expand Down Expand Up @@ -184,79 +181,79 @@ inline bool convert::fromString<long double>(const char* v, long double& dest)
}

template <>
inline bool convert::fromString<unsigned int>(const char* v, unsigned int& dest)
inline bool convert::fromString<uint64_t>(const char* v, uint64_t& dest)
{
if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER))
{
return false;
}

auto call = makeSmartC(strtoul, ReturnMode::PRE_DEFINED_ERROR_CODE, {ULONG_MAX}, {}, v, nullptr, 10);
auto call = makeSmartC(strtoull, ReturnMode::PRE_DEFINED_ERROR_CODE, {ULLONG_MAX}, {}, v, nullptr, 10);
if (call.hasErrors())
{
return false;
}

if (call.getReturnValue() > UINT_MAX)
if (call.getReturnValue() > std::numeric_limits<uint64_t>::max())
{
std::cerr << call.getReturnValue() << " too large, unsigned integer overflow" << std::endl;
std::cerr << call.getReturnValue() << " too large, uint64_t overflow" << std::endl;
return false;
}

dest = static_cast<unsigned int>(call.getReturnValue());
dest = static_cast<uint64_t>(call.getReturnValue());
return true;
}

template <>
inline bool convert::fromString<unsigned short>(const char* v, unsigned short& dest)
inline bool convert::fromString<uint32_t>(const char* v, uint32_t& dest)
{
if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER))
{
return false;
}

auto call = makeSmartC(strtoul, ReturnMode::PRE_DEFINED_ERROR_CODE, {ULONG_MAX}, {}, v, nullptr, 10);
auto call = makeSmartC(strtoull, ReturnMode::PRE_DEFINED_ERROR_CODE, {ULLONG_MAX}, {}, v, nullptr, 10);
if (call.hasErrors())
{
return false;
}

if (call.getReturnValue() > USHRT_MAX)
if (call.getReturnValue() > std::numeric_limits<uint32_t>::max())
{
std::cerr << call.getReturnValue() << " too large, unsigned short overflow" << std::endl;
std::cerr << call.getReturnValue() << " too large, uint32_t overflow" << std::endl;
return false;
}

dest = static_cast<unsigned short>(call.getReturnValue());
dest = static_cast<uint32_t>(call.getReturnValue());
return true;
}

template <>
inline bool convert::fromString<short>(const char* v, short& dest)
inline bool convert::fromString<uint16_t>(const char* v, uint16_t& dest)
{
if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER))
if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER))
{
return false;
}

auto call = makeSmartC(strtol, ReturnMode::PRE_DEFINED_ERROR_CODE, {LONG_MAX, LONG_MIN}, {}, v, nullptr, 10);
auto call = makeSmartC(strtoul, ReturnMode::PRE_DEFINED_ERROR_CODE, {ULONG_MAX}, {}, v, nullptr, 10);
if (call.hasErrors())
{
return false;
}

if (call.getReturnValue() > SHRT_MAX || call.getReturnValue() < SHRT_MIN)
if (call.getReturnValue() > std::numeric_limits<uint16_t>::max())
{
std::cerr << call.getReturnValue() << " too large, short integer overflow" << std::endl;
std::cerr << call.getReturnValue() << " too large, uint16_t overflow" << std::endl;
return false;
}

dest = static_cast<short>(call.getReturnValue());
dest = static_cast<uint16_t>(call.getReturnValue());
return true;
}

template <>
inline bool convert::fromString<unsigned long>(const char* v, unsigned long& dest)
inline bool convert::fromString<uint8_t>(const char* v, uint8_t& dest)
{
if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER))
{
Expand All @@ -269,54 +266,68 @@ inline bool convert::fromString<unsigned long>(const char* v, unsigned long& des
return false;
}

dest = call.getReturnValue();
if (call.getReturnValue() > std::numeric_limits<uint8_t>::max())
{
std::cerr << call.getReturnValue() << " too large, uint8_t overflow" << std::endl;
return false;
}

dest = static_cast<uint8_t>(call.getReturnValue());
return true;
}

template <>
inline bool convert::fromString<unsigned long long>(const char* v, unsigned long long& dest)
inline bool convert::fromString<int64_t>(const char* v, int64_t& dest)
{
if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER))
if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER))
{
return false;
}

auto call = makeSmartC(strtoull, ReturnMode::PRE_DEFINED_ERROR_CODE, {ULLONG_MAX}, {}, v, nullptr, 10);
auto call = makeSmartC(strtoll, ReturnMode::PRE_DEFINED_ERROR_CODE, {LLONG_MAX, LLONG_MIN}, {}, v, nullptr, 10);
if (call.hasErrors())
{
return false;
}

dest = call.getReturnValue();
if (call.getReturnValue() > std::numeric_limits<int64_t>::max()
|| call.getReturnValue() < std::numeric_limits<int64_t>::min())
{
std::cerr << call.getReturnValue() << " is out of range, int64_t overflow" << std::endl;
return false;
}

dest = static_cast<int64_t>(call.getReturnValue());
return true;
}

template <>
inline bool convert::fromString<int>(const char* v, int& dest)
inline bool convert::fromString<int32_t>(const char* v, int32_t& dest)
{
if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER))
{
return false;
}

auto call = makeSmartC(strtol, ReturnMode::PRE_DEFINED_ERROR_CODE, {LONG_MAX, LONG_MIN}, {}, v, nullptr, 10);
auto call = makeSmartC(strtoll, ReturnMode::PRE_DEFINED_ERROR_CODE, {LLONG_MAX, LLONG_MIN}, {}, v, nullptr, 10);
if (call.hasErrors())
{
return false;
}

if (call.getReturnValue() < INT_MIN || call.getReturnValue() > INT_MAX)
if (call.getReturnValue() > std::numeric_limits<int32_t>::max()
|| call.getReturnValue() < std::numeric_limits<int32_t>::min())
{
std::cerr << call.getReturnValue() << " too large, integer overflow!" << std::endl;
std::cerr << call.getReturnValue() << " is out of range, int32_t overflow" << std::endl;
return false;
}

dest = static_cast<int>(call.getReturnValue());
dest = static_cast<int32_t>(call.getReturnValue());
return true;
}

template <>
inline bool convert::fromString<long>(const char* v, long& dest)
inline bool convert::fromString<int16_t>(const char* v, int16_t& dest)
{
if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER))
{
Expand All @@ -329,25 +340,39 @@ inline bool convert::fromString<long>(const char* v, long& dest)
return false;
}

dest = call.getReturnValue();
if (call.getReturnValue() > std::numeric_limits<int16_t>::max()
|| call.getReturnValue() < std::numeric_limits<int16_t>::min())
{
std::cerr << call.getReturnValue() << " is out of range, int16_t overflow" << std::endl;
return false;
}

dest = static_cast<int16_t>(call.getReturnValue());
return true;
}

template <>
inline bool convert::fromString<long long>(const char* v, long long& dest)
inline bool convert::fromString<int8_t>(const char* v, int8_t& dest)
{
if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER))
{
return false;
}

auto call = makeSmartC(strtoll, ReturnMode::PRE_DEFINED_ERROR_CODE, {LLONG_MAX, LLONG_MIN}, {}, v, nullptr, 10);
auto call = makeSmartC(strtol, ReturnMode::PRE_DEFINED_ERROR_CODE, {LONG_MAX, LONG_MIN}, {}, v, nullptr, 10);
if (call.hasErrors())
{
return false;
}

dest = call.getReturnValue();
if (call.getReturnValue() > std::numeric_limits<int8_t>::max()
|| call.getReturnValue() < std::numeric_limits<int8_t>::min())
{
std::cerr << call.getReturnValue() << " is out of range, int8_t overflow" << std::endl;
return false;
}

dest = static_cast<int8_t>(call.getReturnValue());
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void* Allocator::allocate(const uint64_t f_size, const uint64_t f_alignment)
}

uintptr_t l_currentAddress = reinterpret_cast<uintptr_t>(m_startAddress) + m_currentPosition;
uintptr_t l_alignedPosition = cxx::align(l_currentAddress, f_alignment);
uintptr_t l_alignedPosition = cxx::align(l_currentAddress, static_cast<uintptr_t>(f_alignment));
l_alignedPosition -= reinterpret_cast<uintptr_t>(m_startAddress);

byte_t* l_returnValue = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_utils/source/units/duration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct timespec Duration::timespec(const TimeSpecReference& reference) const
switch (reference)
{
case TimeSpecReference::None:
return {this->seconds<long>(), this->nanoSeconds<long>() - this->seconds<long>() * 1000000000};
return {this->seconds<int>(), static_cast<int>(this->nanoSeconds<int64_t>() - this->seconds<int64_t>() * 1000000000)};
default:
{
struct timespec referenceTime;
Expand Down
Loading

0 comments on commit 1915537

Please sign in to comment.