From: Martin Quinson Date: Mon, 28 Dec 2015 15:52:36 +0000 (+0100) Subject: Compile src/instr with g++ so that we can use C++ constructs X-Git-Tag: v3_13~1376 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b94fa144e9b0c70d91ea56d7d5e40d6d1341b64a Compile src/instr with g++ so that we can use C++ constructs --- diff --git a/src/instr/instr_TI_trace.c b/src/instr/instr_TI_trace.cpp similarity index 99% rename from src/instr/instr_TI_trace.c rename to src/instr/instr_TI_trace.cpp index 3a1ee51b29..ce579e3c07 100644 --- a/src/instr/instr_TI_trace.c +++ b/src/instr/instr_TI_trace.cpp @@ -100,7 +100,7 @@ void print_TIDestroyContainer(paje_event_t event) { if (!xbt_cfg_get_boolean(_sg_cfg_set, "tracing/smpi/format/ti_one_file")|| xbt_dict_length(tracing_files) == 1) { - FILE* f = xbt_dict_get_or_null(tracing_files, + FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, ((destroyContainer_t) event->data)->container->name); fclose(f); } diff --git a/src/instr/instr_config.c b/src/instr/instr_config.cpp similarity index 100% rename from src/instr/instr_config.c rename to src/instr/instr_config.cpp diff --git a/src/instr/instr_interface.c b/src/instr/instr_interface.cpp similarity index 99% rename from src/instr/instr_interface.c rename to src/instr/instr_interface.cpp index be6cebe312..f4f8c4ee68 100644 --- a/src/instr/instr_interface.c +++ b/src/instr/instr_interface.cpp @@ -95,7 +95,7 @@ void TRACE_category_with_color (const char *category, const char *color) if (!TRACE_needs_platform()) return; //check if category is already created - char *created = xbt_dict_get_or_null(created_categories, category); + char *created = (char*)xbt_dict_get_or_null(created_categories, category); if (created) return; xbt_dict_set (created_categories, category, xbt_strdup("1"), NULL); @@ -163,7 +163,7 @@ void TRACE_declare_mark(const char *mark_type) if (!mark_type) THROWF (tracing_error, 1, "mark_type is NULL"); //check if mark_type is already declared - char *created = xbt_dict_get_or_null(declared_marks, mark_type); + char *created = (char*)xbt_dict_get_or_null(declared_marks, mark_type); if (created) { THROWF (tracing_error, 1, "mark_type with name (%s) is already declared", mark_type); } @@ -306,7 +306,7 @@ static void instr_user_variable(double time, if (!TRACE_needs_platform()) return; //check if variable is already declared - char *created = xbt_dict_get_or_null(filter, variable); + char *created = (char*)xbt_dict_get_or_null(filter, variable); if (what == INSTR_US_DECLARE){ if (created){ //already declared @@ -372,7 +372,7 @@ static void instr_user_srcdst_variable(double time, routing_get_route_and_latency (src_elm, dst_elm, &route,NULL); unsigned int i; - void *link; + surf_cpp_resource_t link; xbt_dynar_foreach (route, i, link) { char *link_name = (char*)surf_resource_name(link); instr_user_variable (time, link_name, variable, father_type, value, what, NULL, user_link_variables); diff --git a/src/instr/instr_paje_containers.c b/src/instr/instr_paje_containers.cpp similarity index 62% rename from src/instr/instr_paje_containers.c rename to src/instr/instr_paje_containers.cpp index 8566b30035..e5d3c3684d 100644 --- a/src/instr/instr_paje_containers.c +++ b/src/instr/instr_paje_containers.cpp @@ -51,92 +51,92 @@ container_t PJ_container_new (const char *name, e_container_types kind, containe char id_str[INSTR_DEFAULT_STR_SIZE]; snprintf (id_str, INSTR_DEFAULT_STR_SIZE, "%lld", container_id++); - container_t new = xbt_new0(s_container_t, 1); - new->name = xbt_strdup (name); // name of the container - new->id = xbt_strdup (id_str); // id (or alias) of the container - new->father = father; + container_t newContainer = xbt_new0(s_container_t, 1); + newContainer->name = xbt_strdup (name); // name of the container + newContainer->id = xbt_strdup (id_str); // id (or alias) of the container + newContainer->father = father; sg_host_t sg_host = sg_host_by_name(name); //Search for network_element_t switch (kind){ case INSTR_HOST: - new->net_elm = sg_host_edge(sg_host); - if(!new->net_elm) xbt_die("Element '%s' not found",name); + newContainer->net_elm = sg_host_edge(sg_host); + if(!newContainer->net_elm) xbt_die("Element '%s' not found",name); break; case INSTR_ROUTER: - new->net_elm = xbt_lib_get_or_null(as_router_lib,name,ROUTING_ASR_LEVEL); - if(!new->net_elm) xbt_die("Element '%s' not found",name); + newContainer->net_elm = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib,name,ROUTING_ASR_LEVEL); + if(!newContainer->net_elm) xbt_die("Element '%s' not found",name); break; case INSTR_AS: - new->net_elm = xbt_lib_get_or_null(as_router_lib,name,ROUTING_ASR_LEVEL); - if(!new->net_elm) xbt_die("Element '%s' not found",name); + newContainer->net_elm = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib,name,ROUTING_ASR_LEVEL); + if(!newContainer->net_elm) xbt_die("Element '%s' not found",name); break; default: - new->net_elm = NULL; + newContainer->net_elm = NULL; break; } // level depends on level of father - if (new->father){ - new->level = new->father->level+1; + if (newContainer->father){ + newContainer->level = newContainer->father->level+1; XBT_DEBUG("new container %s, child of %s", name, father->name); }else{ - new->level = 0; + newContainer->level = 0; } // type definition (method depends on kind of this new container) - new->kind = kind; - if (new->kind == INSTR_AS){ + newContainer->kind = kind; + if (newContainer->kind == INSTR_AS){ //if this container is of an AS, its type name depends on its level char as_typename[INSTR_DEFAULT_STR_SIZE]; - snprintf (as_typename, INSTR_DEFAULT_STR_SIZE, "L%d", new->level); - if (new->father){ - new->type = PJ_type_get_or_null (as_typename, new->father->type); - if (new->type == NULL){ - new->type = PJ_type_container_new (as_typename, new->father->type); + snprintf (as_typename, INSTR_DEFAULT_STR_SIZE, "L%d", newContainer->level); + if (newContainer->father){ + newContainer->type = PJ_type_get_or_null (as_typename, newContainer->father->type); + if (newContainer->type == NULL){ + newContainer->type = PJ_type_container_new (as_typename, newContainer->father->type); } }else{ - new->type = PJ_type_container_new ("0", NULL); + newContainer->type = PJ_type_container_new ("0", NULL); } }else{ //otherwise, the name is its kind - char typename[INSTR_DEFAULT_STR_SIZE]; - switch (new->kind){ - case INSTR_HOST: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "HOST"); break; - case INSTR_LINK: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "LINK"); break; - case INSTR_ROUTER: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "ROUTER"); break; - case INSTR_SMPI: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MPI"); break; - case INSTR_MSG_PROCESS: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_PROCESS"); break; - case INSTR_MSG_VM: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_VM"); break; - case INSTR_MSG_TASK: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_TASK"); break; + char typeNameBuff[INSTR_DEFAULT_STR_SIZE]; + switch (newContainer->kind){ + case INSTR_HOST: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "HOST"); break; + case INSTR_LINK: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "LINK"); break; + case INSTR_ROUTER: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "ROUTER"); break; + case INSTR_SMPI: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "MPI"); break; + case INSTR_MSG_PROCESS: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "MSG_PROCESS"); break; + case INSTR_MSG_VM: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "MSG_VM"); break; + case INSTR_MSG_TASK: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "MSG_TASK"); break; default: THROWF (tracing_error, 0, "new container kind is unknown."); break; } - type_t type = PJ_type_get_or_null (typename, new->father->type); + type_t type = PJ_type_get_or_null (typeNameBuff, newContainer->father->type); if (type == NULL){ - new->type = PJ_type_container_new (typename, new->father->type); + newContainer->type = PJ_type_container_new (typeNameBuff, newContainer->father->type); }else{ - new->type = type; + newContainer->type = type; } } - new->children = xbt_dict_new_homogeneous(NULL); - if (new->father){ - xbt_dict_set(new->father->children, new->name, new, NULL); - new_pajeCreateContainer (new); + newContainer->children = xbt_dict_new_homogeneous(NULL); + if (newContainer->father){ + xbt_dict_set(newContainer->father->children, newContainer->name, newContainer, NULL); + new_pajeCreateContainer (newContainer); } //register all kinds by name - if (xbt_dict_get_or_null(allContainers, new->name) != NULL){ - THROWF(tracing_error, 1, "container %s already present in allContainers data structure", new->name); + if (xbt_dict_get_or_null(allContainers, newContainer->name) != NULL){ + THROWF(tracing_error, 1, "container %s already present in allContainers data structure", newContainer->name); } - xbt_dict_set (allContainers, new->name, new, NULL); - XBT_DEBUG("Add container name '%s'",new->name); + xbt_dict_set (allContainers, newContainer->name, newContainer, NULL); + XBT_DEBUG("Add container name '%s'",newContainer->name); //register NODE types for triva configuration - if (new->kind == INSTR_HOST || new->kind == INSTR_LINK || new->kind == INSTR_ROUTER) { - xbt_dict_set (trivaNodeTypes, new->type->name, xbt_strdup("1"), NULL); + if (newContainer->kind == INSTR_HOST || newContainer->kind == INSTR_LINK || newContainer->kind == INSTR_ROUTER) { + xbt_dict_set (trivaNodeTypes, newContainer->type->name, xbt_strdup("1"), NULL); } - return new; + return newContainer; } container_t PJ_container_get (const char *name) @@ -150,7 +150,7 @@ container_t PJ_container_get (const char *name) container_t PJ_container_get_or_null (const char *name) { - return name ? xbt_dict_get_or_null(allContainers, name) : NULL; + return (container_t)(name ? xbt_dict_get_or_null(allContainers, name) : NULL); } container_t PJ_container_get_root () diff --git a/src/instr/instr_paje_header.c b/src/instr/instr_paje_header.cpp similarity index 100% rename from src/instr/instr_paje_header.c rename to src/instr/instr_paje_header.cpp diff --git a/src/instr/instr_paje_trace.c b/src/instr/instr_paje_trace.cpp similarity index 100% rename from src/instr/instr_paje_trace.c rename to src/instr/instr_paje_trace.cpp diff --git a/src/instr/instr_paje_types.c b/src/instr/instr_paje_types.cpp similarity index 94% rename from src/instr/instr_paje_types.c rename to src/instr/instr_paje_types.cpp index 9d35be56bd..da248047b1 100644 --- a/src/instr/instr_paje_types.c +++ b/src/instr/instr_paje_types.cpp @@ -24,14 +24,14 @@ type_t PJ_type_get_root () return rootType; } -static type_t newType (const char *typename, const char *key, const char *color, e_entity_types kind, type_t father) +static type_t newType (const char *typeNameBuff, const char *key, const char *color, e_entity_types kind, type_t father) { - if (typename == NULL || key == NULL){ + if (typeNameBuff == NULL || key == NULL){ THROWF(tracing_error, 0, "can't create a new type with name or key equal NULL"); } type_t ret = xbt_new0(s_type_t, 1); - ret->name = xbt_strdup (typename); + ret->name = xbt_strdup (typeNameBuff); ret->father = father; ret->kind = kind; ret->children = xbt_dict_new_homogeneous(NULL); @@ -44,7 +44,7 @@ static type_t newType (const char *typename, const char *key, const char *color, if (father != NULL){ xbt_dict_set (father->children, key, ret, NULL); - XBT_DEBUG("new type %s, child of %s", typename, father->name); + XBT_DEBUG("new type %s, child of %s", typeNameBuff, father->name); } return ret; } diff --git a/src/instr/instr_paje_values.c b/src/instr/instr_paje_values.cpp similarity index 100% rename from src/instr/instr_paje_values.c rename to src/instr/instr_paje_values.cpp diff --git a/src/instr/instr_resource_utilization.c b/src/instr/instr_resource_utilization.cpp similarity index 100% rename from src/instr/instr_resource_utilization.c rename to src/instr/instr_resource_utilization.cpp diff --git a/src/instr/instr_trace.c b/src/instr/instr_trace.cpp similarity index 100% rename from src/instr/instr_trace.c rename to src/instr/instr_trace.cpp diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index ae4f8713da..ec4e9d7e0a 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -542,17 +542,17 @@ set(LUA_SRC ) set(TRACING_SRC - src/instr/instr_TI_trace.c - src/instr/instr_config.c - src/instr/instr_interface.c - src/instr/instr_paje_containers.c - src/instr/instr_paje_header.c - src/instr/instr_paje_trace.c - src/instr/instr_paje_types.c - src/instr/instr_paje_values.c + src/instr/instr_TI_trace.cpp + src/instr/instr_config.cpp + src/instr/instr_interface.cpp + src/instr/instr_paje_containers.cpp + src/instr/instr_paje_header.cpp + src/instr/instr_paje_trace.cpp + src/instr/instr_paje_types.cpp + src/instr/instr_paje_values.cpp src/instr/instr_private.h - src/instr/instr_resource_utilization.c - src/instr/instr_trace.c + src/instr/instr_resource_utilization.cpp + src/instr/instr_trace.cpp ) set(JEDULE_SRC