From 9198ee7801b7b7ba8062519cb67121e8dfd21aef Mon Sep 17 00:00:00 2001
From: Hartmut Kaiser <hartmut.kaiser@gmail.com>
Date: Wed, 11 Oct 2023 12:37:21 -0500
Subject: [PATCH] Fixing compilation problems on 32 Linux systems
---
.../concurrency/detail/tagged_ptr_pair.hpp | 32 ++++++++++++++++---
.../detail/tagged_ptr_ptrcompression.hpp | 2 +-
.../src/server/destroy_component.cpp | 5 +--
3 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/libs/core/concurrency/include/hpx/concurrency/detail/tagged_ptr_pair.hpp b/libs/core/concurrency/include/hpx/concurrency/detail/tagged_ptr_pair.hpp
index cc2afb9f940..a9d46b3ba02 100644
--- a/libs/core/concurrency/include/hpx/concurrency/detail/tagged_ptr_pair.hpp
+++ b/libs/core/concurrency/include/hpx/concurrency/detail/tagged_ptr_pair.hpp
@@ -26,7 +26,7 @@ namespace hpx::lockfree {
uint128_type() = default;
- constexpr uint128_type(std::uint64_t l, std::uint64_t r) noexcept
+ constexpr uint128_type(std::size_t l, std::size_t r) noexcept
: left(l)
, right(r)
{
@@ -52,11 +52,30 @@ namespace hpx::lockfree {
}
};
+ namespace detail {
+
+ template <std::size_t Size>
+ struct ptr_mask; // intentionally left unimplemented
+
+ template <>
+ struct ptr_mask<4>
+ {
+ static constexpr std::uint32_t value = 0xffffffff;
+ };
+
+ template <>
+ struct ptr_mask<8>
+ {
+ static constexpr std::uint64_t value = 0xffffffffffff;
+ };
+ } // namespace detail
+
template <typename Left, typename Right>
struct HPX_LOCKFREE_DCAS_ALIGNMENT tagged_ptr_pair
{
using compressed_ptr_pair_t = uint128_type;
- using compressed_ptr_t = std::uint64_t;
+ // compressed_ptr_t must be of the same size as a pointer
+ using compressed_ptr_t = std::size_t;
using tag_t = std::uint16_t;
struct HPX_LOCKFREE_DCAS_ALIGNMENT cast_unit
@@ -82,18 +101,21 @@ namespace hpx::lockfree {
static constexpr std::size_t left_tag_index = 3;
static constexpr std::size_t right_tag_index = 7;
- static constexpr compressed_ptr_t ptr_mask = 0xffffffffffff;
+ static constexpr compressed_ptr_t ptr_mask =
+ detail::ptr_mask<sizeof(compressed_ptr_t)>::value;
static constexpr Left* extract_left_ptr(
compressed_ptr_pair_t i) noexcept
{
- return hpx::bit_cast<Left*>(i.left & ptr_mask);
+ return hpx::bit_cast<Left*>(
+ static_cast<compressed_ptr_t>(i.left & ptr_mask));
}
static constexpr Right* extract_right_ptr(
compressed_ptr_pair_t i) noexcept
{
- return hpx::bit_cast<Right*>(i.right & ptr_mask);
+ return hpx::bit_cast<Right*>(
+ static_cast<compressed_ptr_t>(i.right & ptr_mask));
}
static constexpr tag_t extract_left_tag(
diff --git a/libs/core/concurrency/include/hpx/concurrency/detail/tagged_ptr_ptrcompression.hpp b/libs/core/concurrency/include/hpx/concurrency/detail/tagged_ptr_ptrcompression.hpp
index e40e0164b78..6d245c51e03 100644
--- a/libs/core/concurrency/include/hpx/concurrency/detail/tagged_ptr_ptrcompression.hpp
+++ b/libs/core/concurrency/include/hpx/concurrency/detail/tagged_ptr_ptrcompression.hpp
@@ -55,7 +55,7 @@ namespace hpx::lockfree::detail {
static constexpr T* extract_ptr(compressed_ptr_t i) noexcept
{
- return hpx::bit_cast<T*>(i & ptr_mask);
+ return hpx::bit_cast<T*>(static_cast<std::size_t>(i & ptr_mask));
}
static constexpr tag_t extract_tag(compressed_ptr_t i) noexcept
diff --git a/libs/full/async_colocated/src/server/destroy_component.cpp b/libs/full/async_colocated/src/server/destroy_component.cpp
index 17d08642d58..6a12d463515 100644
--- a/libs/full/async_colocated/src/server/destroy_component.cpp
+++ b/libs/full/async_colocated/src/server/destroy_component.cpp
@@ -33,7 +33,7 @@ namespace hpx::components::server {
agas::is_local_address_cached(gid, addr))
{
// Check if component was migrated, we are not interested in pinning
- // the object as it is supposed to be destroyed anyways that is, no
+ // the object as it is supposed to be destroyed anyway - that is, no
// one else has a handle to it anymore
// The object is local, we can destroy it locally...
@@ -44,7 +44,8 @@ namespace hpx::components::server {
if (naming::refers_to_virtual_memory(gid))
{
// simply delete the memory
- delete[] hpx::bit_cast<std::uint8_t*>(gid.get_lsb());
+ delete[] hpx::bit_cast<std::uint8_t*>(
+ static_cast<std::size_t>(gid.get_lsb()));
return;
}