From a81562c6d1a1b73373123d9f24215776613e3746 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 7 Nov 2011 12:14:15 +0100 Subject: [PATCH] Further parser cleanups Simply rename a bunch of symbols to make the module logic clear --- include/simgrid/platf.h | 12 +++++----- src/include/simgrid/platf_interface.h | 8 +++---- src/instr/instr_routing.c | 8 +++---- src/surf/cpu.c | 4 ++-- src/surf/cpu_im.c | 4 ++-- src/surf/cpu_ti.c | 4 ++-- src/surf/network_constant.c | 4 ++-- src/surf/sg_platf.c | 32 +++++++++++++-------------- src/surf/surf_routing.c | 14 ++++++------ src/surf/surfxml_parse.c | 4 ++-- src/surf/surfxml_parseplatf.c | 2 +- src/surf/workstation_ptask_L07.c | 4 ++-- 12 files changed, 50 insertions(+), 50 deletions(-) diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h index 5bade91c42..79aee43c32 100644 --- a/include/simgrid/platf.h +++ b/include/simgrid/platf.h @@ -30,7 +30,7 @@ typedef enum { * used, instead of malloced structures. */ -typedef struct s_surf_parsing_host_arg { +typedef struct { char* V_host_id; //id double V_host_power_peak; //power int V_host_core; //core @@ -39,19 +39,19 @@ typedef struct s_surf_parsing_host_arg { e_surf_resource_state_t V_host_state_initial; //state tmgr_trace_t V_host_state_trace; //state file const char* V_host_coord; -} s_surf_parsing_host_arg_t, *surf_parsing_host_arg_t; +} s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t; -typedef struct s_surf_parsing_router_arg { +typedef struct { const char* V_router_id; const char* V_router_coord; -} s_surf_parsing_router_arg_t, *surf_parsing_router_arg_t; +} s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t; XBT_PUBLIC(void) sg_platf_new_AS_open(const char *id, const char *mode); XBT_PUBLIC(void) sg_platf_new_AS_close(void); -XBT_PUBLIC(void) sg_platf_new_host(surf_parsing_host_arg_t h); -XBT_PUBLIC(void) sg_platf_new_router(surf_parsing_router_arg_t router); +XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host); +XBT_PUBLIC(void) sg_platf_new_router(sg_platf_router_cbarg_t router); #endif /* SG_PLATF_H */ diff --git a/src/include/simgrid/platf_interface.h b/src/include/simgrid/platf_interface.h index bc84e74d96..7e8eb3fb01 100644 --- a/src/include/simgrid/platf_interface.h +++ b/src/include/simgrid/platf_interface.h @@ -17,10 +17,10 @@ void sg_platf_exit(void); /* Managing the parsing callbacks */ -typedef void (*surf_parse_host_fct_t)(surf_parsing_host_arg_t); -typedef void (*surf_parse_router_fct_t)(surf_parsing_router_arg_t); -void surf_parse_host_add_cb(surf_parse_host_fct_t); -void surf_parse_router_add_cb(surf_parse_router_fct_t); +typedef void (*sg_platf_host_cb_t)(sg_platf_host_cbarg_t); +typedef void (*sg_platf_router_cb_t)(sg_platf_router_cbarg_t); +void sg_platf_host_add_cb(sg_platf_host_cb_t); +void sg_platf_router_add_cb(sg_platf_router_cb_t); diff --git a/src/instr/instr_routing.c b/src/instr/instr_routing.c index 183ae07762..8f913c3bbc 100644 --- a/src/instr/instr_routing.c +++ b/src/instr/instr_routing.c @@ -225,7 +225,7 @@ static void instr_routing_parse_start_link () xbt_dynar_free (&links_to_create); } -static void instr_routing_parse_start_host (surf_parsing_host_arg_t host) +static void instr_routing_parse_start_host (sg_platf_host_cbarg_t host) { container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); container_t new = newContainer (host->V_host_id, INSTR_HOST, father); @@ -266,7 +266,7 @@ static void instr_routing_parse_start_host (surf_parsing_host_arg_t host) } } -static void instr_routing_parse_start_router (surf_parsing_router_arg_t router) +static void instr_routing_parse_start_router (sg_platf_router_cbarg_t router) { container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); newContainer (router->V_router_id, INSTR_ROUTER, father); @@ -292,8 +292,8 @@ void instr_routing_define_callbacks () surfxml_add_callback(ETag_surfxml_AS_cb_list, &instr_routing_parse_end_AS); if (!TRACE_needs_platform()) return; surfxml_add_callback(STag_surfxml_link_cb_list, &instr_routing_parse_start_link); - surf_parse_host_add_cb(instr_routing_parse_start_host); - surf_parse_router_add_cb(instr_routing_parse_start_router); + sg_platf_host_add_cb(instr_routing_parse_start_host); + sg_platf_router_add_cb(instr_routing_parse_start_router); surfxml_add_callback(ETag_surfxml_platform_cb_list, &instr_routing_parse_end_platform); } diff --git a/src/surf/cpu.c b/src/surf/cpu.c index 1bbeb9ff1a..fe1b2f2829 100644 --- a/src/surf/cpu.c +++ b/src/surf/cpu.c @@ -71,7 +71,7 @@ static void* cpu_create_resource(const char *name, double power_peak, } -static void parse_cpu_init(surf_parsing_host_arg_t host) +static void parse_cpu_init(sg_platf_host_cbarg_t host) { if(strcmp(host->V_host_coord,"")) xbt_die("Coordinates not implemented yet!"); @@ -124,7 +124,7 @@ static void add_traces_cpu(void) static void cpu_define_callbacks(void) { - surf_parse_host_add_cb(parse_cpu_init); + sg_platf_host_add_cb(parse_cpu_init); surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces_cpu); } diff --git a/src/surf/cpu_im.c b/src/surf/cpu_im.c index 14c9cfb4ca..01630f28b7 100644 --- a/src/surf/cpu_im.c +++ b/src/surf/cpu_im.c @@ -88,7 +88,7 @@ static void* cpu_im_create_resource(const char *name, double power_peak, } -static void parse_cpu_im_init(surf_parsing_host_arg_t host) +static void parse_cpu_im_init(sg_platf_host_cbarg_t host) { cpu_im_create_resource(host->V_host_id, host->V_host_power_peak, @@ -136,7 +136,7 @@ static void cpu_im_add_traces_cpu(void) static void cpu_im_define_callbacks() { - surf_parse_host_add_cb(parse_cpu_im_init); + sg_platf_host_add_cb(parse_cpu_im_init); surfxml_add_callback(ETag_surfxml_platform_cb_list, &cpu_im_add_traces_cpu); } diff --git a/src/surf/cpu_ti.c b/src/surf/cpu_ti.c index fe6e4f446e..206e7dd993 100644 --- a/src/surf/cpu_ti.c +++ b/src/surf/cpu_ti.c @@ -190,7 +190,7 @@ static void* cpu_ti_create_resource(const char *name, double power_peak, } -static void parse_cpu_ti_init(surf_parsing_host_arg_t host) +static void parse_cpu_ti_init(sg_platf_host_cbarg_t host) { cpu_ti_create_resource(host->V_host_id, host->V_host_power_peak, @@ -263,7 +263,7 @@ static void add_traces_cpu_ti(void) static void cpu_ti_define_callbacks() { - surf_parse_host_add_cb(parse_cpu_ti_init); + sg_platf_host_add_cb(parse_cpu_ti_init); surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces_cpu_ti); } diff --git a/src/surf/network_constant.c b/src/surf/network_constant.c index f4251f081d..a94f7acc42 100644 --- a/src/surf/network_constant.c +++ b/src/surf/network_constant.c @@ -21,14 +21,14 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network); static random_data_t random_latency = NULL; static int host_number_int = 0; -static void netcste_count_hosts(surf_parsing_host_arg_t h) +static void netcste_count_hosts(sg_platf_host_cbarg_t h) { host_number_int++; } static void netcste_define_callbacks(void) { - surf_parse_host_add_cb(netcste_count_hosts); + sg_platf_host_add_cb(netcste_count_hosts); } static int netcste_resource_used(void *resource_id) diff --git a/src/surf/sg_platf.c b/src/surf/sg_platf.c index ee11d0b844..219a30a0be 100644 --- a/src/surf/sg_platf.c +++ b/src/surf/sg_platf.c @@ -12,40 +12,40 @@ #include "surf/surf_private.h" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse); -xbt_dynar_t surf_parse_host_cb_list = NULL; // of functions of type: surf_parsing_host_arg_t -> void -xbt_dynar_t surf_parse_router_cb_list = NULL; // of functions of type: surf_parsing_router_arg_t -> void +xbt_dynar_t sg_platf_host_cb_list = NULL; // of sg_platf_host_cb_t +xbt_dynar_t sg_platf_router_cb_list = NULL; // of sg_platf_router_cb_t /** Module management function: creates all internal data structures */ void sg_platf_init(void) { - surf_parse_host_cb_list = xbt_dynar_new(sizeof(surf_parse_host_fct_t), NULL); - surf_parse_router_cb_list = xbt_dynar_new(sizeof(surf_parse_host_fct_t), NULL); + sg_platf_host_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL); + sg_platf_router_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL); } /** Module management function: frees all internal data structures */ void sg_platf_exit(void) { - xbt_dynar_free(&surf_parse_host_cb_list); - xbt_dynar_free(&surf_parse_router_cb_list); + xbt_dynar_free(&sg_platf_host_cb_list); + xbt_dynar_free(&sg_platf_router_cb_list); } -void sg_platf_new_host(surf_parsing_host_arg_t h){ +void sg_platf_new_host(sg_platf_host_cbarg_t h){ unsigned int iterator; - surf_parse_host_fct_t fun; - xbt_dynar_foreach(surf_parse_host_cb_list, iterator, fun) { + sg_platf_host_cb_t fun; + xbt_dynar_foreach(sg_platf_host_cb_list, iterator, fun) { if (fun) (*fun) (h); } } -void sg_platf_new_router(surf_parsing_router_arg_t router) { +void sg_platf_new_router(sg_platf_router_cbarg_t router) { unsigned int iterator; - surf_parse_router_fct_t fun; - xbt_dynar_foreach(surf_parse_router_cb_list, iterator, fun) { + sg_platf_router_cb_t fun; + xbt_dynar_foreach(sg_platf_router_cb_list, iterator, fun) { if (fun) (*fun) (router); } } -void surf_parse_host_add_cb(surf_parse_host_fct_t fct) { - xbt_dynar_push(surf_parse_host_cb_list, &fct); +void sg_platf_host_add_cb(sg_platf_host_cb_t fct) { + xbt_dynar_push(sg_platf_host_cb_list, &fct); } -void surf_parse_router_add_cb(surf_parse_router_fct_t fct) { - xbt_dynar_push(surf_parse_router_cb_list, &fct); +void sg_platf_router_add_cb(sg_platf_router_cb_t fct) { + xbt_dynar_push(sg_platf_router_cb_list, &fct); } diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index ccb2c3ae08..75808fd6f7 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -186,7 +186,7 @@ static void parse_E_host(void) /* * \brief Add a host to the network element list from XML */ -static void parse_S_host_XML(surf_parsing_host_arg_t h) +static void parse_S_host_XML(sg_platf_host_cbarg_t h) { parse_S_host(h->V_host_id, h->V_host_coord); } @@ -207,7 +207,7 @@ static void parse_S_host_lua(const char *host_id, const char *coord) /** * \brief Add a "router" to the network element list */ -static void parse_S_router(surf_parsing_router_arg_t router) +static void parse_S_router(sg_platf_router_cbarg_t router) { network_element_info_t info = NULL; if (current_routing->hierarchy == SURF_ROUTING_NULL) @@ -237,7 +237,7 @@ static void parse_S_router(surf_parsing_router_arg_t router) * brief Add a "router" to the network element list from XML description */ static void parse_S_router_lua(const char* router_id) { - s_surf_parsing_router_arg_t router; + s_sg_platf_router_cbarg_t router; memset(&router,0,sizeof(router)); router.V_router_id = router_id; router.V_router_coord = ""; @@ -960,9 +960,9 @@ void routing_model_create(size_t size_of_links, void *loopback, double_f_cpvoid_ current_routing = NULL; /* parse generic elements */ - surf_parse_host_add_cb(parse_S_host_XML); + sg_platf_host_add_cb(parse_S_host_XML); surfxml_add_callback(ETag_surfxml_host_cb_list, &parse_E_host_XML); - surf_parse_router_add_cb(parse_S_router); + sg_platf_router_add_cb(parse_S_router); surfxml_add_callback(STag_surfxml_route_cb_list, &parse_S_route_new_and_endpoints_XML); @@ -1466,7 +1466,7 @@ void generic_src_dst_check(routing_component_t rc, const char *src, static void parse_create_host_link(int i) { char *host_id, *link_id = NULL; - s_surf_parsing_host_arg_t host; + s_sg_platf_host_cbarg_t host; memset(&host,0,sizeof(host)); host_id = bprintf("%s%d%s", struct_cluster->V_cluster_prefix, i, struct_cluster->V_cluster_suffix); @@ -1567,7 +1567,7 @@ void routing_parse_Scluster(void) static int AX_ptr = 0; char *host_id, *groups, *link_id = NULL; - s_surf_parsing_host_arg_t host; + s_sg_platf_host_cbarg_t host; if( strcmp(struct_cluster->V_cluster_availability_file,"") || strcmp(struct_cluster->V_cluster_state_file,"") ) diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 58d320be70..ffa11fc1a9 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -289,7 +289,7 @@ void STag_surfxml_platform(void) } void STag_surfxml_host(void){ - s_surf_parsing_host_arg_t host; + s_sg_platf_host_cbarg_t host; memset(&host,0,sizeof(host)); host.V_host_id = A_surfxml_host_id; @@ -314,7 +314,7 @@ void ETag_surfxml_host(void){ void STag_surfxml_router(void){ - s_surf_parsing_router_arg_t router; + s_sg_platf_router_cbarg_t router; memset(&router, 0, sizeof(router)); router.V_router_id = xbt_strdup(A_surfxml_router_id); diff --git a/src/surf/surfxml_parseplatf.c b/src/surf/surfxml_parseplatf.c index 312d1001d1..4d6945f158 100644 --- a/src/surf/surfxml_parseplatf.c +++ b/src/surf/surfxml_parseplatf.c @@ -53,7 +53,7 @@ void surfxml_bufferstack_pop(int new) * Pass arguments to parsing callback as structures to save some time (and allow callbacks to ignore some) */ -surf_parsing_router_arg_t struct_router = NULL; +sg_platf_router_cbarg_t struct_router = NULL; surf_parsing_cluster_arg_t struct_cluster = NULL; surf_parsing_peer_arg_t struct_peer = NULL; surf_parsing_link_arg_t struct_lnk = NULL; diff --git a/src/surf/workstation_ptask_L07.c b/src/surf/workstation_ptask_L07.c index 726ecb5db7..ac1c51c768 100644 --- a/src/surf/workstation_ptask_L07.c +++ b/src/surf/workstation_ptask_L07.c @@ -654,7 +654,7 @@ static void* ptask_cpu_create_resource(const char *name, double power_scale, return cpu; } -static void ptask_parse_cpu_init(surf_parsing_host_arg_t host) +static void ptask_parse_cpu_init(sg_platf_host_cbarg_t host) { ptask_cpu_create_resource( host->V_host_id, @@ -802,7 +802,7 @@ static void ptask_add_traces(void) static void ptask_define_callbacks() { /* Adding callback functions */ - surf_parse_host_add_cb(ptask_parse_cpu_init); + sg_platf_host_add_cb(ptask_parse_cpu_init); surfxml_add_callback(ETag_surfxml_link_cb_list, &ptask_parse_link_init); surfxml_add_callback(ETag_surfxml_platform_cb_list, &ptask_add_traces); } -- 2.20.1