Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1560 Move isCompiledOn32BitSystem to 'system_conf…
Browse files Browse the repository at this point in the history
…iguration.hpp' and remove GCC diagnostic suppressions

Signed-off-by: Simon Hoinkis <[email protected]>
  • Loading branch information
mossmaurice committed Jan 30, 2023
1 parent 604472e commit c9ee555
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 23 deletions.
12 changes: 5 additions & 7 deletions iceoryx_hoofs/include/iceoryx_hoofs/cxx/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,11 @@ struct BestFittingTypeImpl<true, true, false>
template <uint64_t Value>
struct BestFittingType
{
/// ignore the warnings because we need the comparisons to find the best fitting type
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtype-limits"
using Type_t = typename internal::BestFittingTypeImpl<(Value > std::numeric_limits<uint8_t>::max()),
(Value > std::numeric_limits<uint16_t>::max()),
(Value > std::numeric_limits<uint32_t>::max())>::Type_t;
#pragma GCC diagnostic pop
using Type_t =
typename internal::BestFittingTypeImpl<(Value > static_cast<uint64_t>(std::numeric_limits<uint8_t>::max())),
(Value > static_cast<uint64_t>(std::numeric_limits<uint16_t>::max())),
(Value
> static_cast<uint64_t>(std::numeric_limits<uint32_t>::max()))>::Type_t;
};

template <uint64_t Value>
Expand Down
7 changes: 0 additions & 7 deletions iceoryx_hoofs/include/iceoryx_hoofs/cxx/helplets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ static constexpr uint64_t arrayCapacity(T const (&/*notInterested*/)[CapacityVal
{
return CapacityValue;
}

/// @brief Returns info whether called on a 32-bit system
/// @return True if called on 32-bit, false if not 32-bit system
constexpr bool isCompiledOn32BitSystem() noexcept
{
return INTPTR_MAX == INT32_MAX;
}
} // namespace cxx
} // namespace iox

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@

namespace iox
{
namespace posix
namespace internal
{
/// @brief returns the page size of the system
uint64_t pageSize() noexcept;

} // namespace posix
/// @brief Returns info whether called on a 32-bit system
/// @return True if called on 32-bit, false if not 32-bit system
constexpr bool isCompiledOn32BitSystem() noexcept
{
return INTPTR_MAX == INT32_MAX;
}
} // namespace internal
} // namespace iox

#endif // IOX_HOOFS_POSIX_WRAPPER_SYSTEM_CONFIGURATION_HPP
6 changes: 3 additions & 3 deletions iceoryx_hoofs/source/posix_wrapper/system_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

namespace iox
{
namespace posix
namespace internal
{
uint64_t pageSize() noexcept
{
// sysconf fails when one provides an invalid name parameter. _SC_PAGESIZE
// is a valid name parameter therefore it should never fail.
return static_cast<uint64_t>(posixCall(sysconf)(_SC_PAGESIZE)
return static_cast<uint64_t>(posix::posixCall(sysconf)(_SC_PAGESIZE)
.failureReturnValue(-1)
.evaluate()
.or_else([](auto& r) {
Expand All @@ -38,5 +38,5 @@ uint64_t pageSize() noexcept
.value()
.value);
}
} // namespace posix
} // namespace internal
} // namespace iox
2 changes: 2 additions & 0 deletions iceoryx_hoofs/test/moduletests/test_logstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <array>
#include <cstdint>
#include <limits>
#include <sstream>
#include <string>

namespace
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ PosixShmMemoryProvider::~PosixShmMemoryProvider() noexcept
expected<void*, MemoryProviderError> PosixShmMemoryProvider::createMemory(const uint64_t size,
const uint64_t alignment) noexcept
{
if (alignment > posix::pageSize())
if (alignment > internal::pageSize())
{
return error<MemoryProviderError>(MemoryProviderError::MEMORY_ALIGNMENT_EXCEEDS_PAGE_SIZE);
}
Expand Down
3 changes: 2 additions & 1 deletion iceoryx_posh/source/roudi/roudi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "iceoryx_posh/internal/roudi/roudi.hpp"
#include "iceoryx_dust/cxx/convert.hpp"
#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iceoryx_hoofs/internal/posix_wrapper/system_configuration.hpp"
#include "iceoryx_hoofs/posix_wrapper/posix_access_rights.hpp"
#include "iceoryx_hoofs/posix_wrapper/thread.hpp"
#include "iceoryx_posh/internal/log/posh_logging.hpp"
Expand Down Expand Up @@ -49,7 +50,7 @@ RouDi::RouDi(RouDiMemoryInterface& roudiMemoryInterface,
, m_monitoringMode(roudiStartupParameters.m_monitoringMode)
, m_processKillDelay(roudiStartupParameters.m_processKillDelay)
{
if (cxx::isCompiledOn32BitSystem())
if (internal::isCompiledOn32BitSystem())
{
LogWarn() << "Runnning RouDi on 32-bit architectures is not supported! Use at your own risk!";
}
Expand Down
3 changes: 2 additions & 1 deletion iceoryx_posh/source/runtime/posh_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_posh/runtime/posh_runtime.hpp"
#include "iceoryx_hoofs/internal/posix_wrapper/system_configuration.hpp"
#include "iceoryx_posh/internal/log/posh_logging.hpp"
#include "iceoryx_posh/internal/runtime/posh_runtime_impl.hpp"

Expand Down Expand Up @@ -118,7 +119,7 @@ cxx::ScopeGuard PoshRuntime::getLifetimeParticipant() noexcept
PoshRuntime::PoshRuntime(optional<const RuntimeName_t*> name) noexcept
: m_appName(verifyInstanceName(name))
{
if (cxx::isCompiledOn32BitSystem())
if (internal::isCompiledOn32BitSystem())
{
LogWarn() << "Running applications on 32-bit architectures is not supported! Use at your own risk!";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ TEST_F(PosixShmMemoryProvider_Test, CreationFailedWithAlignmentExceedingPageSize
TEST_SHM_NAME, iox::posix::AccessMode::READ_WRITE, iox::posix::OpenMode::PURGE_AND_CREATE);
ASSERT_FALSE(sut.addMemoryBlock(&memoryBlock1).has_error());
uint64_t MEMORY_SIZE{16};
uint64_t MEMORY_ALIGNMENT{iox::posix::pageSize() + 8U};
uint64_t MEMORY_ALIGNMENT{iox::internal::pageSize() + 8U};
EXPECT_CALL(memoryBlock1, size()).WillRepeatedly(Return(MEMORY_SIZE));
EXPECT_CALL(memoryBlock1, alignment()).WillRepeatedly(Return(MEMORY_ALIGNMENT));

Expand Down

0 comments on commit c9ee555

Please sign in to comment.