From 58801abf7076bc6bd09c971104f6dbd3ff236fc6 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 14 Jun 2019 15:29:18 +0200 Subject: [PATCH] This void* for Constraint::id_ is a Resource*. --- src/instr/instr_platform.cpp | 3 +-- src/kernel/lmm/maxmin.cpp | 4 ++-- src/kernel/lmm/maxmin.hpp | 8 ++++---- src/surf/cpu_interface.cpp | 2 +- src/surf/network_interface.cpp | 2 +- src/surf/ptask_L07.cpp | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index c3d88b94ec..9ce839a27c 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -247,8 +247,7 @@ static void instr_action_on_state_change(simgrid::kernel::resource::Action const for (int i = 0; i < n; i++) { double value = action.get_variable()->get_value() * action.get_variable()->get_constraint_weight(i); /* Beware of composite actions: ptasks put links and cpus together. Extra pb: we cannot dynamic_cast from void* */ - simgrid::kernel::resource::Resource* resource = - static_cast(action.get_variable()->get_constraint(i)->get_id()); + simgrid::kernel::resource::Resource* resource = action.get_variable()->get_constraint(i)->get_id(); simgrid::kernel::resource::Cpu* cpu = dynamic_cast(resource); if (cpu != nullptr) diff --git a/src/kernel/lmm/maxmin.cpp b/src/kernel/lmm/maxmin.cpp index 628b69c093..06822fd420 100644 --- a/src/kernel/lmm/maxmin.cpp +++ b/src/kernel/lmm/maxmin.cpp @@ -169,7 +169,7 @@ void System::cnst_free(Constraint* cnst) delete cnst; } -Constraint::Constraint(void* id_value, double bound_value) : bound_(bound_value), id_(id_value) +Constraint::Constraint(resource::Resource* id_value, double bound_value) : bound_(bound_value), id_(id_value) { rank_ = next_rank_++; @@ -185,7 +185,7 @@ Constraint::Constraint(void* id_value, double bound_value) : bound_(bound_value) cnst_light_ = nullptr; } -Constraint* System::constraint_new(void* id, double bound_value) +Constraint* System::constraint_new(resource::Resource* id, double bound_value) { Constraint* cnst = new Constraint(id, bound_value); insert_constraint(cnst); diff --git a/src/kernel/lmm/maxmin.hpp b/src/kernel/lmm/maxmin.hpp index abbb741289..a7b72987eb 100644 --- a/src/kernel/lmm/maxmin.hpp +++ b/src/kernel/lmm/maxmin.hpp @@ -179,7 +179,7 @@ public: class XBT_PUBLIC Constraint { public: Constraint() = delete; - Constraint(void* id_value, double bound_value); + Constraint(resource::Resource* id_value, double bound_value); /** @brief Unshare a constraint. */ void unshare() { sharing_policy_ = s4u::Link::SharingPolicy::FATPIPE; } @@ -244,7 +244,7 @@ public: * @brief Get the data associated to a constraint * @return The data associated to the constraint */ - void* get_id() const { return id_; } + resource::Resource* get_id() const { return id_; } /* hookup to system */ boost::intrusive::list_member_hook<> constraint_set_hook_; @@ -278,7 +278,7 @@ private: static int next_rank_; // To give a separate rank_ to each contraint int concurrency_limit_; /* The maximum number of variables that may be enabled at any time (stage variables if * necessary) */ - void* id_; + resource::Resource* id_; }; /** @@ -392,7 +392,7 @@ public: * @param id Data associated to the constraint (e.g.: a network link) * @param bound_value The bound value of the constraint */ - Constraint* constraint_new(void* id, double bound_value); + Constraint* constraint_new(resource::Resource* id, double bound_value); /** * @brief Create a new Linear MaxMin variable diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index caca3f5565..768299562f 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -188,7 +188,7 @@ std::list CpuAction::cpus() const for (int i = 0; i < llen; i++) { /* Beware of composite actions: ptasks put links and cpus together */ // extra pb: we cannot dynamic_cast from void*... - Resource* resource = static_cast(get_variable()->get_constraint(i)->get_id()); + Resource* resource = get_variable()->get_constraint(i)->get_id(); Cpu* cpu = dynamic_cast(resource); if (cpu != nullptr) retlist.push_back(cpu); diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 33d0764303..e7d5ad9a54 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -179,7 +179,7 @@ std::list NetworkAction::links() const for (int i = 0; i < llen; i++) { /* Beware of composite actions: ptasks put links and cpus together */ // extra pb: we cannot dynamic_cast from void*... - Resource* resource = static_cast(get_variable()->get_constraint(i)->get_id()); + Resource* resource = get_variable()->get_constraint(i)->get_id(); LinkImpl* link = dynamic_cast(resource); if (link != nullptr) retlist.push_back(link); diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 17dca147d7..18cba8cae7 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -121,8 +121,8 @@ void HostL07Model::update_actions_state(double /*now*/, double delta) kernel::lmm::Constraint* cnst = action.get_variable()->get_constraint(i); while (cnst != nullptr) { i++; - void* constraint_id = cnst->get_id(); - if (not static_cast(constraint_id)->is_on()) { + kernel::resource::Resource* constraint_id = cnst->get_id(); + if (not constraint_id->is_on()) { XBT_DEBUG("Action (%p) Failed!!", &action); action.finish(kernel::resource::Action::State::FAILED); break; -- 2.20.1