Skip to content

Commit 1915537

Browse files
committed
iox-eclipse-iceoryx#33 solved merge conflict with 32 bit branch
Signed-off-by: Christian Eltzschig <[email protected]>
2 parents 08b9a07 + 9691c50 commit 1915537

File tree

13 files changed

+118
-103
lines changed

13 files changed

+118
-103
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ Examples for a "porcelain" API would be e.g.
2626
[Adaptive Autosar Foundation](https://www.autosar.org/fileadmin/Releases_TEMP/Adaptive_Platform_19-03/AdaptiveFoundation.zip)
2727
(see AUTOSAR_EXP_ARAComAPI.pdf) or [ROS](https://www.ros.org).
2828

29+
### Supported Platforms
30+
31+
* Linux
32+
* QNX
33+
* macOS (not yet - currently in progress with high priority)
34+
* Windows 10 (not yet - currently in progress)
35+
2936
### Scope
3037

3138
Who can benefit of using iceoryx? What's in for those folks?

iceoryx_posh/include/iceoryx_posh/iceoryx_posh_types.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ constexpr uint32_t MAX_INTERFACE_CAPRO_FIFO_SIZE = MAX_PORT_NUMBER;
5656
constexpr uint32_t MAX_APPLICATION_CAPRO_FIFO_SIZE = 128;
5757

5858
// Memory
59+
constexpr uint64_t SHARED_MEMORY_ALIGNMENT = 32;
5960
constexpr uint32_t MAX_NUMBER_OF_MEMPOOLS = 32;
6061
constexpr uint32_t MAX_SHM_SEGMENTS = 100;
6162

iceoryx_posh/include/iceoryx_posh/internal/mepoo/segment_manager.inl

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ uint64_t SegmentManager<SegmentType>::requiredManagementMemorySize(const RouDiCo
162162
uint64_t memorySize{0};
163163
for (auto segment : f_config.m_sharedMemorySegments)
164164
{
165-
memorySize += cxx::align(MemoryManager::requiredManagementMemorySize(segment.m_mempoolConfig), 32ul);
165+
memorySize += cxx::align(MemoryManager::requiredManagementMemorySize(segment.m_mempoolConfig), SHARED_MEMORY_ALIGNMENT);
166166
}
167167
return memorySize;
168168
}
@@ -173,15 +173,15 @@ uint64_t SegmentManager<SegmentType>::requiredChunkMemorySize(const RouDiConfig_
173173
uint64_t memorySize{0};
174174
for (auto segment : f_config.m_sharedMemorySegments)
175175
{
176-
memorySize += cxx::align(MemoryManager::requiredChunkMemorySize(segment.m_mempoolConfig), 32ul);
176+
memorySize += cxx::align(MemoryManager::requiredChunkMemorySize(segment.m_mempoolConfig), SHARED_MEMORY_ALIGNMENT);
177177
}
178178
return memorySize;
179179
}
180180

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

187187
} // namespace mepoo

iceoryx_posh/include/iceoryx_posh/internal/mepoo/typed_mem_pool.inl

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ template <typename T>
8282
uint64_t TypedMemPool<T>::requiredManagementMemorySize(const uint64_t f_numberOfChunks)
8383
{
8484
return f_numberOfChunks * sizeof(ChunkManagement)
85-
+ 2 * cxx::align(MemPool::freeList_t::requiredMemorySize(f_numberOfChunks), 32ul);
85+
+ 2 * cxx::align(static_cast<uint64_t>(MemPool::freeList_t::requiredMemorySize(f_numberOfChunks)), SHARED_MEMORY_ALIGNMENT);
8686
}
8787

8888
template <typename T>

iceoryx_posh/include/iceoryx_posh/internal/runtime/shared_memory_creator.inl

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ inline SharedMemoryCreator<ShmType>::SharedMemoryCreator(const RouDiConfig_t& co
4141
/// @todo these are internal mempool for the introspection, move to a better place
4242
mepoo::MePooConfig mempoolConfig;
4343
mempoolConfig.m_mempoolConfig.push_back(
44-
{static_cast<uint32_t>(cxx::align(sizeof(roudi::MemPoolIntrospectionTopic), 32ul)), 250});
44+
{static_cast<uint32_t>(cxx::align(static_cast<uint64_t>(sizeof(roudi::MemPoolIntrospectionTopic)), SHARED_MEMORY_ALIGNMENT)), 250});
4545
mempoolConfig.m_mempoolConfig.push_back(
46-
{static_cast<uint32_t>(cxx::align(sizeof(roudi::ProcessIntrospectionFieldTopic), 32ul)), 10});
46+
{static_cast<uint32_t>(cxx::align(static_cast<uint64_t>(sizeof(roudi::ProcessIntrospectionFieldTopic)), SHARED_MEMORY_ALIGNMENT)), 10});
4747
mempoolConfig.m_mempoolConfig.push_back(
48-
{static_cast<uint32_t>(cxx::align(sizeof(roudi::PortIntrospectionFieldTopic), 32ul)), 10});
48+
{static_cast<uint32_t>(cxx::align(static_cast<uint64_t>(sizeof(roudi::PortIntrospectionFieldTopic)), SHARED_MEMORY_ALIGNMENT)), 10});
4949
mempoolConfig.m_mempoolConfig.push_back(
50-
{static_cast<uint32_t>(cxx::align(sizeof(roudi::PortThroughputIntrospectionFieldTopic), 32ul)), 10});
50+
{static_cast<uint32_t>(cxx::align(static_cast<uint64_t>(sizeof(roudi::PortThroughputIntrospectionFieldTopic)), SHARED_MEMORY_ALIGNMENT)), 10});
5151
mempoolConfig.optimize();
5252

5353
uint64_t totalSharedMemorySize = ShmType::getRequiredSharedMemory()

iceoryx_posh/source/mepoo/memory_manager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ uint64_t MemoryManager::requiredManagementMemorySize(const MePooConfig& f_mePooC
124124
for (const auto& mempool : f_mePooConfig.m_mempoolConfig)
125125
{
126126
sumOfAllChunks += mempool.m_chunkCount;
127-
memorySize += cxx::align(MemPool::freeList_t::requiredMemorySize(mempool.m_chunkCount), 32ul);
127+
memorySize += cxx::align(static_cast<uint64_t>(MemPool::freeList_t::requiredMemorySize(mempool.m_chunkCount)), SHARED_MEMORY_ALIGNMENT);
128128
}
129129

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

133133
return memorySize;
134134
}

iceoryx_utils/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ target_include_directories(iceoryx_utils
189189
target_compile_options(iceoryx_utils PUBLIC -std=c++11)
190190
target_compile_options(iceoryx_utils PUBLIC -fPIC)
191191

192+
<<<<<<< HEAD
193+
=======
194+
if(NOT CMAKE_SYSTEM_NAME MATCHES QNX)
195+
target_link_libraries(iceoryx_utils PRIVATE acl atomic rt ${CODE_COVERAGE_LIBS})
196+
endif(NOT CMAKE_SYSTEM_NAME MATCHES QNX)
197+
198+
>>>>>>> iox-#12-compilation-error-in-utils-with-32-bit
192199
set_target_properties(iceoryx_utils
193200
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
194201
)

iceoryx_utils/include/iceoryx_utils/cxx/convert.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <cmath>
2222
#include <cstdlib>
2323
#include <cstring>
24+
#include <limits>
2425
#include <sstream>
2526
#include <string>
2627

iceoryx_utils/include/iceoryx_utils/internal/cxx/convert.inl

+63-38
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,15 @@ inline bool convert::stringIsNumberWithErrorMessage(const char* v, const NumberT
104104
std::cerr << v << " is not ";
105105
switch (type)
106106
{
107-
case NumberType::FLOAT:
108-
{
107+
case NumberType::FLOAT: {
109108
std::cerr << "a float";
110109
break;
111110
}
112-
case NumberType::INTEGER:
113-
{
111+
case NumberType::INTEGER: {
114112
std::cerr << "a signed integer";
115113
break;
116114
}
117-
case NumberType::UNSIGNED_INTEGER:
118-
{
115+
case NumberType::UNSIGNED_INTEGER: {
119116
std::cerr << "an unsigned integer";
120117
break;
121118
}
@@ -184,79 +181,79 @@ inline bool convert::fromString<long double>(const char* v, long double& dest)
184181
}
185182

186183
template <>
187-
inline bool convert::fromString<unsigned int>(const char* v, unsigned int& dest)
184+
inline bool convert::fromString<uint64_t>(const char* v, uint64_t& dest)
188185
{
189186
if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER))
190187
{
191188
return false;
192189
}
193190

194-
auto call = makeSmartC(strtoul, ReturnMode::PRE_DEFINED_ERROR_CODE, {ULONG_MAX}, {}, v, nullptr, 10);
191+
auto call = makeSmartC(strtoull, ReturnMode::PRE_DEFINED_ERROR_CODE, {ULLONG_MAX}, {}, v, nullptr, 10);
195192
if (call.hasErrors())
196193
{
197194
return false;
198195
}
199196

200-
if (call.getReturnValue() > UINT_MAX)
197+
if (call.getReturnValue() > std::numeric_limits<uint64_t>::max())
201198
{
202-
std::cerr << call.getReturnValue() << " too large, unsigned integer overflow" << std::endl;
199+
std::cerr << call.getReturnValue() << " too large, uint64_t overflow" << std::endl;
203200
return false;
204201
}
205202

206-
dest = static_cast<unsigned int>(call.getReturnValue());
203+
dest = static_cast<uint64_t>(call.getReturnValue());
207204
return true;
208205
}
209206

210207
template <>
211-
inline bool convert::fromString<unsigned short>(const char* v, unsigned short& dest)
208+
inline bool convert::fromString<uint32_t>(const char* v, uint32_t& dest)
212209
{
213210
if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER))
214211
{
215212
return false;
216213
}
217214

218-
auto call = makeSmartC(strtoul, ReturnMode::PRE_DEFINED_ERROR_CODE, {ULONG_MAX}, {}, v, nullptr, 10);
215+
auto call = makeSmartC(strtoull, ReturnMode::PRE_DEFINED_ERROR_CODE, {ULLONG_MAX}, {}, v, nullptr, 10);
219216
if (call.hasErrors())
220217
{
221218
return false;
222219
}
223220

224-
if (call.getReturnValue() > USHRT_MAX)
221+
if (call.getReturnValue() > std::numeric_limits<uint32_t>::max())
225222
{
226-
std::cerr << call.getReturnValue() << " too large, unsigned short overflow" << std::endl;
223+
std::cerr << call.getReturnValue() << " too large, uint32_t overflow" << std::endl;
227224
return false;
228225
}
229226

230-
dest = static_cast<unsigned short>(call.getReturnValue());
227+
dest = static_cast<uint32_t>(call.getReturnValue());
231228
return true;
232229
}
233230

234231
template <>
235-
inline bool convert::fromString<short>(const char* v, short& dest)
232+
inline bool convert::fromString<uint16_t>(const char* v, uint16_t& dest)
236233
{
237-
if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER))
234+
if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER))
238235
{
239236
return false;
240237
}
241238

242-
auto call = makeSmartC(strtol, ReturnMode::PRE_DEFINED_ERROR_CODE, {LONG_MAX, LONG_MIN}, {}, v, nullptr, 10);
239+
auto call = makeSmartC(strtoul, ReturnMode::PRE_DEFINED_ERROR_CODE, {ULONG_MAX}, {}, v, nullptr, 10);
243240
if (call.hasErrors())
244241
{
245242
return false;
246243
}
247244

248-
if (call.getReturnValue() > SHRT_MAX || call.getReturnValue() < SHRT_MIN)
245+
if (call.getReturnValue() > std::numeric_limits<uint16_t>::max())
249246
{
250-
std::cerr << call.getReturnValue() << " too large, short integer overflow" << std::endl;
247+
std::cerr << call.getReturnValue() << " too large, uint16_t overflow" << std::endl;
251248
return false;
252249
}
253250

254-
dest = static_cast<short>(call.getReturnValue());
251+
dest = static_cast<uint16_t>(call.getReturnValue());
255252
return true;
256253
}
257254

258255
template <>
259-
inline bool convert::fromString<unsigned long>(const char* v, unsigned long& dest)
256+
inline bool convert::fromString<uint8_t>(const char* v, uint8_t& dest)
260257
{
261258
if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER))
262259
{
@@ -269,54 +266,68 @@ inline bool convert::fromString<unsigned long>(const char* v, unsigned long& des
269266
return false;
270267
}
271268

272-
dest = call.getReturnValue();
269+
if (call.getReturnValue() > std::numeric_limits<uint8_t>::max())
270+
{
271+
std::cerr << call.getReturnValue() << " too large, uint8_t overflow" << std::endl;
272+
return false;
273+
}
274+
275+
dest = static_cast<uint8_t>(call.getReturnValue());
273276
return true;
274277
}
275278

276279
template <>
277-
inline bool convert::fromString<unsigned long long>(const char* v, unsigned long long& dest)
280+
inline bool convert::fromString<int64_t>(const char* v, int64_t& dest)
278281
{
279-
if (!stringIsNumberWithErrorMessage(v, NumberType::UNSIGNED_INTEGER))
282+
if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER))
280283
{
281284
return false;
282285
}
283286

284-
auto call = makeSmartC(strtoull, ReturnMode::PRE_DEFINED_ERROR_CODE, {ULLONG_MAX}, {}, v, nullptr, 10);
287+
auto call = makeSmartC(strtoll, ReturnMode::PRE_DEFINED_ERROR_CODE, {LLONG_MAX, LLONG_MIN}, {}, v, nullptr, 10);
285288
if (call.hasErrors())
286289
{
287290
return false;
288291
}
289292

290-
dest = call.getReturnValue();
293+
if (call.getReturnValue() > std::numeric_limits<int64_t>::max()
294+
|| call.getReturnValue() < std::numeric_limits<int64_t>::min())
295+
{
296+
std::cerr << call.getReturnValue() << " is out of range, int64_t overflow" << std::endl;
297+
return false;
298+
}
299+
300+
dest = static_cast<int64_t>(call.getReturnValue());
291301
return true;
292302
}
293303

294304
template <>
295-
inline bool convert::fromString<int>(const char* v, int& dest)
305+
inline bool convert::fromString<int32_t>(const char* v, int32_t& dest)
296306
{
297307
if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER))
298308
{
299309
return false;
300310
}
301311

302-
auto call = makeSmartC(strtol, ReturnMode::PRE_DEFINED_ERROR_CODE, {LONG_MAX, LONG_MIN}, {}, v, nullptr, 10);
312+
auto call = makeSmartC(strtoll, ReturnMode::PRE_DEFINED_ERROR_CODE, {LLONG_MAX, LLONG_MIN}, {}, v, nullptr, 10);
303313
if (call.hasErrors())
304314
{
305315
return false;
306316
}
307317

308-
if (call.getReturnValue() < INT_MIN || call.getReturnValue() > INT_MAX)
318+
if (call.getReturnValue() > std::numeric_limits<int32_t>::max()
319+
|| call.getReturnValue() < std::numeric_limits<int32_t>::min())
309320
{
310-
std::cerr << call.getReturnValue() << " too large, integer overflow!" << std::endl;
321+
std::cerr << call.getReturnValue() << " is out of range, int32_t overflow" << std::endl;
311322
return false;
312323
}
313324

314-
dest = static_cast<int>(call.getReturnValue());
325+
dest = static_cast<int32_t>(call.getReturnValue());
315326
return true;
316327
}
317328

318329
template <>
319-
inline bool convert::fromString<long>(const char* v, long& dest)
330+
inline bool convert::fromString<int16_t>(const char* v, int16_t& dest)
320331
{
321332
if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER))
322333
{
@@ -329,25 +340,39 @@ inline bool convert::fromString<long>(const char* v, long& dest)
329340
return false;
330341
}
331342

332-
dest = call.getReturnValue();
343+
if (call.getReturnValue() > std::numeric_limits<int16_t>::max()
344+
|| call.getReturnValue() < std::numeric_limits<int16_t>::min())
345+
{
346+
std::cerr << call.getReturnValue() << " is out of range, int16_t overflow" << std::endl;
347+
return false;
348+
}
349+
350+
dest = static_cast<int16_t>(call.getReturnValue());
333351
return true;
334352
}
335353

336354
template <>
337-
inline bool convert::fromString<long long>(const char* v, long long& dest)
355+
inline bool convert::fromString<int8_t>(const char* v, int8_t& dest)
338356
{
339357
if (!stringIsNumberWithErrorMessage(v, NumberType::INTEGER))
340358
{
341359
return false;
342360
}
343361

344-
auto call = makeSmartC(strtoll, ReturnMode::PRE_DEFINED_ERROR_CODE, {LLONG_MAX, LLONG_MIN}, {}, v, nullptr, 10);
362+
auto call = makeSmartC(strtol, ReturnMode::PRE_DEFINED_ERROR_CODE, {LONG_MAX, LONG_MIN}, {}, v, nullptr, 10);
345363
if (call.hasErrors())
346364
{
347365
return false;
348366
}
349367

350-
dest = call.getReturnValue();
368+
if (call.getReturnValue() > std::numeric_limits<int8_t>::max()
369+
|| call.getReturnValue() < std::numeric_limits<int8_t>::min())
370+
{
371+
std::cerr << call.getReturnValue() << " is out of range, int8_t overflow" << std::endl;
372+
return false;
373+
}
374+
375+
dest = static_cast<int8_t>(call.getReturnValue());
351376
return true;
352377
}
353378

iceoryx_utils/source/posix_wrapper/shared_memory_object/allocator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void* Allocator::allocate(const uint64_t f_size, const uint64_t f_alignment)
4343
}
4444

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

4949
byte_t* l_returnValue = nullptr;

iceoryx_utils/source/units/duration.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct timespec Duration::timespec(const TimeSpecReference& reference) const
2424
switch (reference)
2525
{
2626
case TimeSpecReference::None:
27-
return {this->seconds<long>(), this->nanoSeconds<long>() - this->seconds<long>() * 1000000000};
27+
return {this->seconds<int>(), static_cast<int>(this->nanoSeconds<int64_t>() - this->seconds<int64_t>() * 1000000000)};
2828
default:
2929
{
3030
struct timespec referenceTime;

0 commit comments

Comments
 (0)