From 3e697d0a3c14acfc95f73f509af52d1872a85b0c Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 28 Aug 2017 11:22:18 +0200 Subject: [PATCH] fix clang builds Don't try to have globals linked in the C++ way. Instead, we should kill all those globals (but not today) --- src/instr/instr_config.cpp | 8 ++-- src/instr/instr_interface.cpp | 59 ++++++++++++++--------------- src/instr/instr_paje_containers.cpp | 2 +- src/instr/instr_private.h | 6 +-- src/surf/cpu_interface.cpp | 4 +- 5 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/instr/instr_config.cpp b/src/instr/instr_config.cpp index b0640bbee0..3e229a12c2 100644 --- a/src/instr/instr_config.cpp +++ b/src/instr/instr_config.cpp @@ -138,7 +138,7 @@ int TRACE_end() TRACE_generate_viva_cat_conf(); /* dump trace buffer */ - simgrid::instr::TRACE_last_timestamp_to_dump = surf_get_clock(); + TRACE_last_timestamp_to_dump = surf_get_clock(); TRACE_paje_dump_buffer(1); /* destroy all data structures of tracing (and free) */ @@ -480,9 +480,9 @@ static void output_types (const char *name, xbt_dynar_t types, FILE *file) static void output_categories(const char* name, FILE* file) { - unsigned int i = simgrid::instr::created_categories.size(); + unsigned int i = created_categories.size(); fprintf (file, " values = ("); - for (auto const& cat : simgrid::instr::created_categories) { + for (auto const& cat : created_categories) { --i; fprintf(file, "\"%s%s\"", name, cat.c_str()); if (i > 0) { @@ -560,7 +560,7 @@ static void generate_cat_configuration (const char *output, const char *name, in { if (output && strlen(output) > 0){ //check if we do have categories declared - if (simgrid::instr::created_categories.empty()) { + if (created_categories.empty()) { XBT_INFO("No categories declared, ignoring generation of %s graph configuration", name); return; } diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index fcfea69698..64169c4c3e 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -21,11 +21,11 @@ typedef enum { XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_api, instr, "API"); -std::set simgrid::instr::created_categories; -std::set simgrid::instr::declared_marks; -std::set simgrid::instr::user_host_variables; -std::set simgrid::instr::user_vm_variables; -std::set simgrid::instr::user_link_variables; +std::set created_categories; +std::set declared_marks; +std::set user_host_variables; +std::set user_vm_variables; +std::set user_link_variables; extern std::set trivaNodeTypes; extern std::set trivaEdgeTypes; @@ -86,10 +86,10 @@ void TRACE_category_with_color (const char *category, const char *color) return; //check if category is already created - if (simgrid::instr::created_categories.find(category) != simgrid::instr::created_categories.end()) + if (created_categories.find(category) != created_categories.end()) return; else - simgrid::instr::created_categories.insert(category); + created_categories.insert(category); //define final_color char final_color[INSTR_DEFAULT_STR_SIZE]; @@ -125,7 +125,7 @@ xbt_dynar_t TRACE_get_categories () { if (not TRACE_is_enabled() || not TRACE_categorized()) return nullptr; - return instr_set_to_dynar(&simgrid::instr::created_categories); + return instr_set_to_dynar(&created_categories); } /** \ingroup TRACE_mark @@ -148,13 +148,13 @@ void TRACE_declare_mark(const char *mark_type) THROWF (tracing_error, 1, "mark_type is nullptr"); //check if mark_type is already declared - if (simgrid::instr::declared_marks.find(mark_type) != simgrid::instr::declared_marks.end()) { + if (declared_marks.find(mark_type) != declared_marks.end()) { THROWF (tracing_error, 1, "mark_type with name (%s) is already declared", mark_type); } XBT_DEBUG("MARK,declare %s", mark_type); simgrid::instr::Type::eventNew(mark_type, PJ_type_get_root()); - simgrid::instr::declared_marks.insert(mark_type); + declared_marks.insert(mark_type); } /** \ingroup TRACE_mark @@ -261,7 +261,7 @@ xbt_dynar_t TRACE_get_marks () if (not TRACE_is_enabled()) return nullptr; - return instr_set_to_dynar(&simgrid::instr::declared_marks); + return instr_set_to_dynar(&declared_marks); } static void instr_user_variable(double time, const char* resource, const char* variable, const char* father_type, @@ -316,8 +316,7 @@ static void instr_user_srcdst_variable(double time, const char *src, const char std::vector route; simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(src_elm, dst_elm, &route, nullptr); for (auto const& link : route) - instr_user_variable(time, link->cname(), variable, father_type, value, what, nullptr, - &simgrid::instr::user_link_variables); + instr_user_variable(time, link->cname(), variable, father_type, value, what, nullptr, &user_link_variables); } /** \ingroup TRACE_API @@ -363,7 +362,7 @@ int TRACE_platform_graph_export_graphviz (const char *filename) */ void TRACE_vm_variable_declare (const char *variable) { - instr_user_variable(0, nullptr, variable, "MSG_VM", 0, INSTR_US_DECLARE, nullptr, &simgrid::instr::user_vm_variables); + instr_user_variable(0, nullptr, variable, "MSG_VM", 0, INSTR_US_DECLARE, nullptr, &user_vm_variables); } /** \ingroup TRACE_user_variables @@ -378,7 +377,7 @@ void TRACE_vm_variable_declare (const char *variable) */ void TRACE_vm_variable_declare_with_color (const char *variable, const char *color) { - instr_user_variable(0, nullptr, variable, "MSG_VM", 0, INSTR_US_DECLARE, color, &simgrid::instr::user_vm_variables); + instr_user_variable(0, nullptr, variable, "MSG_VM", 0, INSTR_US_DECLARE, color, &user_vm_variables); } /** \ingroup TRACE_user_variables @@ -440,7 +439,7 @@ void TRACE_vm_variable_sub (const char *vm, const char *variable, double value) */ void TRACE_vm_variable_set_with_time (double time, const char *vm, const char *variable, double value) { - instr_user_variable(time, vm, variable, "MSG_VM", value, INSTR_US_SET, nullptr, &simgrid::instr::user_vm_variables); + instr_user_variable(time, vm, variable, "MSG_VM", value, INSTR_US_SET, nullptr, &user_vm_variables); } /** \ingroup TRACE_user_variables @@ -460,7 +459,7 @@ void TRACE_vm_variable_set_with_time (double time, const char *vm, const char *v */ void TRACE_vm_variable_add_with_time (double time, const char *vm, const char *variable, double value) { - instr_user_variable(time, vm, variable, "MSG_VM", value, INSTR_US_ADD, nullptr, &simgrid::instr::user_vm_variables); + instr_user_variable(time, vm, variable, "MSG_VM", value, INSTR_US_ADD, nullptr, &user_vm_variables); } /** \ingroup TRACE_user_variables @@ -480,7 +479,7 @@ void TRACE_vm_variable_add_with_time (double time, const char *vm, const char *v */ void TRACE_vm_variable_sub_with_time (double time, const char *vm, const char *variable, double value) { - instr_user_variable(time, vm, variable, "MSG_VM", value, INSTR_US_SUB, nullptr, &simgrid::instr::user_vm_variables); + instr_user_variable(time, vm, variable, "MSG_VM", value, INSTR_US_SUB, nullptr, &user_vm_variables); } /* for host variables */ @@ -497,7 +496,7 @@ void TRACE_vm_variable_sub_with_time (double time, const char *vm, const char *v */ void TRACE_host_variable_declare (const char *variable) { - instr_user_variable(0, nullptr, variable, "HOST", 0, INSTR_US_DECLARE, nullptr, &simgrid::instr::user_host_variables); + instr_user_variable(0, nullptr, variable, "HOST", 0, INSTR_US_DECLARE, nullptr, &user_host_variables); } /** \ingroup TRACE_user_variables @@ -512,7 +511,7 @@ void TRACE_host_variable_declare (const char *variable) */ void TRACE_host_variable_declare_with_color (const char *variable, const char *color) { - instr_user_variable(0, nullptr, variable, "HOST", 0, INSTR_US_DECLARE, color, &simgrid::instr::user_host_variables); + instr_user_variable(0, nullptr, variable, "HOST", 0, INSTR_US_DECLARE, color, &user_host_variables); } /** \ingroup TRACE_user_variables @@ -574,7 +573,7 @@ void TRACE_host_variable_sub (const char *host, const char *variable, double val */ void TRACE_host_variable_set_with_time (double time, const char *host, const char *variable, double value) { - instr_user_variable(time, host, variable, "HOST", value, INSTR_US_SET, nullptr, &simgrid::instr::user_host_variables); + instr_user_variable(time, host, variable, "HOST", value, INSTR_US_SET, nullptr, &user_host_variables); } /** \ingroup TRACE_user_variables @@ -594,7 +593,7 @@ void TRACE_host_variable_set_with_time (double time, const char *host, const cha */ void TRACE_host_variable_add_with_time (double time, const char *host, const char *variable, double value) { - instr_user_variable(time, host, variable, "HOST", value, INSTR_US_ADD, nullptr, &simgrid::instr::user_host_variables); + instr_user_variable(time, host, variable, "HOST", value, INSTR_US_ADD, nullptr, &user_host_variables); } /** \ingroup TRACE_user_variables @@ -614,7 +613,7 @@ void TRACE_host_variable_add_with_time (double time, const char *host, const cha */ void TRACE_host_variable_sub_with_time (double time, const char *host, const char *variable, double value) { - instr_user_variable(time, host, variable, "HOST", value, INSTR_US_SUB, nullptr, &simgrid::instr::user_host_variables); + instr_user_variable(time, host, variable, "HOST", value, INSTR_US_SUB, nullptr, &user_host_variables); } /** \ingroup TRACE_user_variables @@ -627,7 +626,7 @@ void TRACE_host_variable_sub_with_time (double time, const char *host, const cha */ xbt_dynar_t TRACE_get_host_variables () { - return instr_set_to_dynar(&simgrid::instr::user_host_variables); + return instr_set_to_dynar(&user_host_variables); } /* for link variables */ @@ -644,7 +643,7 @@ xbt_dynar_t TRACE_get_host_variables () */ void TRACE_link_variable_declare (const char *variable) { - instr_user_variable(0, nullptr, variable, "LINK", 0, INSTR_US_DECLARE, nullptr, &simgrid::instr::user_link_variables); + instr_user_variable(0, nullptr, variable, "LINK", 0, INSTR_US_DECLARE, nullptr, &user_link_variables); } /** \ingroup TRACE_user_variables @@ -659,7 +658,7 @@ void TRACE_link_variable_declare (const char *variable) */ void TRACE_link_variable_declare_with_color (const char *variable, const char *color) { - instr_user_variable(0, nullptr, variable, "LINK", 0, INSTR_US_DECLARE, color, &simgrid::instr::user_link_variables); + instr_user_variable(0, nullptr, variable, "LINK", 0, INSTR_US_DECLARE, color, &user_link_variables); } /** \ingroup TRACE_user_variables @@ -721,7 +720,7 @@ void TRACE_link_variable_sub (const char *link, const char *variable, double val */ void TRACE_link_variable_set_with_time (double time, const char *link, const char *variable, double value) { - instr_user_variable(time, link, variable, "LINK", value, INSTR_US_SET, nullptr, &simgrid::instr::user_link_variables); + instr_user_variable(time, link, variable, "LINK", value, INSTR_US_SET, nullptr, &user_link_variables); } /** \ingroup TRACE_user_variables @@ -741,7 +740,7 @@ void TRACE_link_variable_set_with_time (double time, const char *link, const cha */ void TRACE_link_variable_add_with_time (double time, const char *link, const char *variable, double value) { - instr_user_variable(time, link, variable, "LINK", value, INSTR_US_ADD, nullptr, &simgrid::instr::user_link_variables); + instr_user_variable(time, link, variable, "LINK", value, INSTR_US_ADD, nullptr, &user_link_variables); } /** \ingroup TRACE_user_variables @@ -761,7 +760,7 @@ void TRACE_link_variable_add_with_time (double time, const char *link, const cha */ void TRACE_link_variable_sub_with_time (double time, const char *link, const char *variable, double value) { - instr_user_variable(time, link, variable, "LINK", value, INSTR_US_SUB, nullptr, &simgrid::instr::user_link_variables); + instr_user_variable(time, link, variable, "LINK", value, INSTR_US_SUB, nullptr, &user_link_variables); } /* for link variables, but with src and dst used for get_route */ @@ -898,7 +897,7 @@ void TRACE_link_srcdst_variable_sub_with_time (double time, const char *src, con */ xbt_dynar_t TRACE_get_link_variables () { - return instr_set_to_dynar(&simgrid::instr::user_link_variables); + return instr_set_to_dynar(&user_link_variables); } /** \ingroup TRACE_user_variables diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index 3fd13280c2..3c92073dc6 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -196,7 +196,7 @@ void PJ_container_free (container_t container) //obligation to dump previous events because they might //reference the container that is about to be destroyed - simgrid::instr::TRACE_last_timestamp_to_dump = surf_get_clock(); + TRACE_last_timestamp_to_dump = surf_get_clock(); TRACE_paje_dump_buffer(1); //trace my destruction diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index 01e0e10c78..79335b965a 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -279,6 +279,9 @@ class NewEvent : public PajeEvent { NewEvent(double timestamp, s_container* container, Type* type, Value* val); void print() override; }; +} +} // namespace simgrid::instr +typedef simgrid::instr::s_container* container_t; extern XBT_PRIVATE std::set created_categories; extern XBT_PRIVATE std::set declared_marks; @@ -286,9 +289,6 @@ extern XBT_PRIVATE std::set user_host_variables; extern XBT_PRIVATE std::set user_vm_variables; extern XBT_PRIVATE std::set user_link_variables; extern XBT_PRIVATE double TRACE_last_timestamp_to_dump; -} -} // namespace simgrid::instr -typedef simgrid::instr::s_container* container_t; /* instr_paje_header.c */ XBT_PRIVATE void TRACE_header(int basic, int size); diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 026fcbb3d5..e8282cbba4 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -54,7 +54,7 @@ void CpuModel::updateActionsStateLazy(double now, double /*delta*/) smaller = action->getLastUpdate(); } if (smaller > 0) { - simgrid::instr::TRACE_last_timestamp_to_dump = smaller; + TRACE_last_timestamp_to_dump = smaller; } } } @@ -74,7 +74,7 @@ void CpuModel::updateActionsStateFull(double now, double delta) TRACE_surf_host_set_utilization(cpu->cname(), action->getCategory(), lmm_variable_getvalue(action->getVariable()), now - delta, delta); - simgrid::instr::TRACE_last_timestamp_to_dump = now - delta; + TRACE_last_timestamp_to_dump = now - delta; } action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta); -- 2.20.1