From 07a54f6d32688725e56137a36ede4b6143a17b3a Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Tue, 19 Mar 2024 12:48:50 +0100 Subject: [PATCH] #2063: Update void* to std::byte* in runnable --- src/vt/collective/scatter/scatter.cc | 2 +- src/vt/registry/auto/auto_registry_common.h | 12 ++++++------ src/vt/runnable/make_runnable.h | 2 +- src/vt/runnable/runnable.cc | 8 ++++---- src/vt/runnable/runnable.h | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/vt/collective/scatter/scatter.cc b/src/vt/collective/scatter/scatter.cc index 280d429660..2ebf6eef6d 100644 --- a/src/vt/collective/scatter/scatter.cc +++ b/src/vt/collective/scatter/scatter.cc @@ -118,7 +118,7 @@ void Scatter::scatterIn(ScatterMsg* msg) { }); auto const& active_fn = auto_registry::getScatterAutoHandler(user_handler); - active_fn->dispatch(in_base_ptr, nullptr); + active_fn->dispatch(reinterpret_cast(in_base_ptr), nullptr); } /*static*/ void Scatter::scatterHandler(ScatterMsg* msg) { diff --git a/src/vt/registry/auto/auto_registry_common.h b/src/vt/registry/auto/auto_registry_common.h index c7a3c4cdf3..a7b405f7ef 100644 --- a/src/vt/registry/auto/auto_registry_common.h +++ b/src/vt/registry/auto/auto_registry_common.h @@ -71,7 +71,7 @@ struct SentinelObject {}; struct BaseHandlersDispatcher { virtual ~BaseHandlersDispatcher() = default; - virtual void dispatch(messaging::BaseMsg* msg, void* object) const = 0; + virtual void dispatch(messaging::BaseMsg* msg, std::byte* object) const = 0; }; template @@ -100,11 +100,11 @@ struct HandlersDispatcher final : BaseHandlersDispatcher { detection::is_detected_convertible; public: - void dispatch(messaging::BaseMsg* base_msg, void* object) const override { + void dispatch(messaging::BaseMsg* base_msg, std::byte* object) const override { using T = HandlerT; [[maybe_unused]] auto msg = static_cast(base_msg); - [[maybe_unused]] auto elm = static_cast(object); + [[maybe_unused]] auto elm = reinterpret_cast(object); if constexpr (std::is_same_v) { fp(); @@ -183,7 +183,7 @@ struct MapsDispatcher final : BaseMapsDispatcher { struct BaseScatterDispatcher { virtual ~BaseScatterDispatcher() = default; - virtual void dispatch(void* msg, void* object) const = 0; + virtual void dispatch(std::byte* msg, std::byte* object) const = 0; }; template @@ -191,11 +191,11 @@ struct ScatterDispatcher final : BaseScatterDispatcher { explicit ScatterDispatcher(HandlerT in_fn_ptr) : fp(in_fn_ptr) {} public: - void dispatch(void* msg, void*) const override { + void dispatch(std::byte* msg, std::byte*) const override { using T = HandlerT; if constexpr (std::is_same_v*>) { - fp(static_cast(msg)); + fp(reinterpret_cast(msg)); } else { vtAbort("Invalid function type for scatter handler"); } diff --git a/src/vt/runnable/make_runnable.h b/src/vt/runnable/make_runnable.h index e3b713b83e..382c6eda03 100644 --- a/src/vt/runnable/make_runnable.h +++ b/src/vt/runnable/make_runnable.h @@ -167,7 +167,7 @@ struct RunnableMaker { RunnableMaker&& withObjGroup(ElmT* elm) { set_handler_ = true; if (handler_ != uninitialized_handler) { - impl_->setupHandlerObjGroup(elm, handler_); + impl_->setupHandlerObjGroup(reinterpret_cast(elm), handler_); } return std::move(*this); } diff --git a/src/vt/runnable/runnable.cc b/src/vt/runnable/runnable.cc index ff0ba9fef3..778d8e1fac 100644 --- a/src/vt/runnable/runnable.cc +++ b/src/vt/runnable/runnable.cc @@ -79,7 +79,7 @@ void RunnableNew::setupHandler(HandlerType handler) { } } -void RunnableNew::setupHandlerObjGroup(void* obj, HandlerType handler) { +void RunnableNew::setupHandlerObjGroup(std::byte* obj, HandlerType handler) { f_.func_ = auto_registry::getAutoHandlerObjGroup(handler).get(); obj_ = obj; } @@ -91,14 +91,14 @@ void RunnableNew::setupHandlerElement( f_.func_ = member ? auto_registry::getAutoHandlerCollectionMem(handler).get() : auto_registry::getAutoHandlerCollection(handler).get(); - obj_ = elm; + obj_ = reinterpret_cast(elm); } void RunnableNew::setupHandlerElement( vrt::VirtualContext* elm, HandlerType handler ) { f_.func_ = auto_registry::getAutoHandlerVC(handler).get(); - obj_ = elm; + obj_ = reinterpret_cast(elm); } void RunnableNew::run() { @@ -165,7 +165,7 @@ void RunnableNew::run() { #endif if (is_scatter_) { - f_.func_scat_->dispatch(msg_ == nullptr ? nullptr : msg_.get(), obj_); + f_.func_scat_->dispatch(msg_ == nullptr ? nullptr : reinterpret_cast(msg_.get()), obj_); } else { f_.func_->dispatch(msg_ == nullptr ? nullptr : msg_.get(), obj_); } diff --git a/src/vt/runnable/runnable.h b/src/vt/runnable/runnable.h index 3151a4fe43..a4cc408080 100644 --- a/src/vt/runnable/runnable.h +++ b/src/vt/runnable/runnable.h @@ -202,7 +202,7 @@ struct RunnableNew { * \param[in] elm the object pointer * \param[in] handler the handler ID bits */ - void setupHandlerObjGroup(void* obj, HandlerType handler); + void setupHandlerObjGroup(std::byte* obj, HandlerType handler); /** * \brief Set up a handler to run on an non-collection object @@ -356,7 +356,7 @@ struct RunnableNew { private: detail::Contexts contexts_; /**< The contexts */ MsgSharedPtr msg_ = nullptr; /**< The associated message */ - void* obj_ = nullptr; /**< Object pointer */ + std::byte* obj_ = nullptr; /**< Object pointer */ union { DispatcherType func_; DispatcherScatterType func_scat_;