From ed1436de46a7989e6ca45b6053ea1205b6715151 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 10 Nov 2011 17:33:46 +0100 Subject: [PATCH] kill further globals --- src/surf/surf_private.h | 2 +- src/surf/surf_routing.c | 2 +- src/surf/surf_routing_dijkstra.c | 27 ++++++++++++--------------- src/surf/surf_routing_floyd.c | 4 +--- src/surf/surf_routing_full.c | 4 +--- src/surf/surf_routing_generic.c | 10 ++++------ src/surf/surf_routing_none.c | 2 -- src/surf/surf_routing_private.h | 6 +++--- src/surf/surf_routing_rulebased.c | 2 -- 9 files changed, 23 insertions(+), 36 deletions(-) diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index 0da07719ef..8739042843 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -107,7 +107,7 @@ typedef struct s_model_type { const char *name; const char *desc; AS_t (*create) (); - void (*end) (); + void (*end) (AS_t as); } s_routing_model_description_t, *routing_model_description_t; typedef struct s_route { diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 658d80c5e4..fb5f324915 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -374,7 +374,7 @@ void routing_AS_end() (void *) info); if (current_routing->routing->end) - (*(current_routing->routing->end)) (); + (*(current_routing->routing->end)) (current_routing); current_routing = current_routing->routing_father; } } diff --git a/src/surf/surf_routing_dijkstra.c b/src/surf/surf_routing_dijkstra.c index 0c6c78c627..442c965cfc 100644 --- a/src/surf/surf_routing_dijkstra.c +++ b/src/surf/surf_routing_dijkstra.c @@ -8,8 +8,6 @@ /* Global vars */ extern routing_global_t global_routing; -extern AS_t current_routing; -extern routing_model_description_t current_routing_model; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_dijkstra, surf, "Routing part of surf -- dijkstra routing logic"); @@ -462,30 +460,29 @@ AS_t model_dijkstracache_create(void) return model_dijkstra_both_create(1); } -void model_dijkstra_both_end(void) +void model_dijkstra_both_end(AS_t as) { - as_dijkstra_t routing = - (as_dijkstra_t) current_routing; + as_dijkstra_t THIS = (as_dijkstra_t) as; xbt_node_t node = NULL; unsigned int cursor2; xbt_dynar_t nodes = NULL; /* Create the topology graph */ - if(!routing->route_graph) - routing->route_graph = xbt_graph_new_graph(1, NULL); - if(!routing->graph_node_map) - routing->graph_node_map = xbt_dict_new(); + if(!THIS->route_graph) + THIS->route_graph = xbt_graph_new_graph(1, NULL); + if(!THIS->graph_node_map) + THIS->graph_node_map = xbt_dict_new(); - if (routing->cached && !routing->route_cache) - routing->route_cache = xbt_dict_new(); + if (THIS->cached && !THIS->route_cache) + THIS->route_cache = xbt_dict_new(); /* Add the loopback if needed */ - if (current_routing->hierarchy == SURF_ROUTING_BASE) - add_loopback_dijkstra(routing); + if (as->hierarchy == SURF_ROUTING_BASE) + add_loopback_dijkstra(THIS); /* initialize graph indexes in nodes after graph has been built */ - nodes = xbt_graph_get_nodes(routing->route_graph); + nodes = xbt_graph_get_nodes(THIS->route_graph); xbt_dynar_foreach(nodes, cursor2, node) { graph_node_data_t data = xbt_graph_node_get_data(node); @@ -529,6 +526,6 @@ void model_dijkstra_both_parse_route (AS_t asg, const char *src, } route_extended_t e_route = - generic_new_extended_route(current_routing->hierarchy, route, 1); + generic_new_extended_route(asg->hierarchy, route, 1); route_new_dijkstra(as, *src_id, *dst_id, e_route); } diff --git a/src/surf/surf_routing_floyd.c b/src/surf/surf_routing_floyd.c index b441684e23..211cf928ca 100644 --- a/src/surf/surf_routing_floyd.c +++ b/src/surf/surf_routing_floyd.c @@ -8,8 +8,6 @@ /* Global vars */ extern routing_global_t global_routing; -extern AS_t current_routing; -extern routing_model_description_t current_routing_model; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_floyd, surf, "Routing part of surf"); @@ -183,7 +181,7 @@ AS_t model_floyd_create(void) return (AS_t)new_component; } -void model_floyd_end(void) +void model_floyd_end(AS_t current_routing) { as_floyd_t as = diff --git a/src/surf/surf_routing_full.c b/src/surf/surf_routing_full.c index 1b439deb69..15ef1e21b1 100644 --- a/src/surf/surf_routing_full.c +++ b/src/surf/surf_routing_full.c @@ -8,8 +8,6 @@ /* Global vars */ extern routing_global_t global_routing; -extern AS_t current_routing; -extern routing_model_description_t current_routing_model; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf"); @@ -139,7 +137,7 @@ AS_t model_full_create(void) return (AS_t) new_component; } -void model_full_end(void) +void model_full_end(AS_t current_routing) { unsigned int i; route_extended_t e_route; diff --git a/src/surf/surf_routing_generic.c b/src/surf/surf_routing_generic.c index 5b771d5218..e99aa19bf8 100644 --- a/src/surf/surf_routing_generic.c +++ b/src/surf/surf_routing_generic.c @@ -14,8 +14,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing"); -extern AS_t current_routing; - AS_t routmod_generic_create(size_t childsize) { AS_t new_component = xbt_malloc0(childsize); @@ -38,22 +36,22 @@ AS_t routmod_generic_create(size_t childsize) { } -void generic_parse_PU(AS_t rc, const char *name) +void generic_parse_PU(AS_t as, const char *name) { XBT_DEBUG("Load process unit \"%s\"", name); int *id = xbt_new0(int, 1); xbt_dict_t _to_index; - _to_index = current_routing->to_index; + _to_index = as->to_index; *id = xbt_dict_length(_to_index); xbt_dict_set(_to_index, name, id, xbt_free); } -void generic_parse_AS(AS_t rc, const char *name) +void generic_parse_AS(AS_t as, const char *name) { XBT_DEBUG("Load Autonomous system \"%s\"", name); int *id = xbt_new0(int, 1); xbt_dict_t _to_index; - _to_index = current_routing->to_index; + _to_index = as->to_index; *id = xbt_dict_length(_to_index); xbt_dict_set(_to_index, name, id, xbt_free); } diff --git a/src/surf/surf_routing_none.c b/src/surf/surf_routing_none.c index 21ed6cdb54..415f12487c 100644 --- a/src/surf/surf_routing_none.c +++ b/src/surf/surf_routing_none.c @@ -8,8 +8,6 @@ /* Global vars */ extern routing_global_t global_routing; -extern AS_t current_routing; -extern routing_model_description_t current_routing_model; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_none, surf, "Routing part of surf"); diff --git a/src/surf/surf_routing_private.h b/src/surf/surf_routing_private.h index 311dbb76d2..7e7405a747 100644 --- a/src/surf/surf_routing_private.h +++ b/src/surf/surf_routing_private.h @@ -63,7 +63,7 @@ void generic_src_dst_check(AS_t rc, const char *src, /* ************************************************************************** */ /* *************************** FLOYD ROUTING ******************************** */ AS_t model_floyd_create(void); /* create structures for floyd routing model */ -void model_floyd_end(void); /* finalize the creation of floyd routing model */ +void model_floyd_end(AS_t as); /* finalize the creation of floyd routing model */ void model_floyd_parse_route(AS_t rc, const char *src, const char *dst, route_extended_t route); @@ -90,14 +90,14 @@ AS_t model_vivaldi_create(void); /* create structures for vivaldi routing m AS_t model_dijkstra_both_create(int cached); /* create by calling dijkstra or dijkstracache */ AS_t model_dijkstra_create(void); /* create structures for dijkstra routing model */ AS_t model_dijkstracache_create(void); /* create structures for dijkstracache routing model */ -void model_dijkstra_both_end(void); /* finalize the creation of dijkstra routing model */ +void model_dijkstra_both_end(AS_t as); /* finalize the creation of dijkstra routing model */ void model_dijkstra_both_parse_route (AS_t rc, const char *src, const char *dst, route_extended_t route); /* ************************************************************************** */ /* *************************** FULL ROUTING ********************************* */ AS_t model_full_create(void); /* create structures for full routing model */ -void model_full_end(void); /* finalize the creation of full routing model */ +void model_full_end(AS_t as); /* finalize the creation of full routing model */ void model_full_set_route( /* Set the route and ASroute between src and dst */ AS_t rc, const char *src, const char *dst, route_extended_t route); diff --git a/src/surf/surf_routing_rulebased.c b/src/surf/surf_routing_rulebased.c index 2e5a948502..6e7a605bab 100644 --- a/src/surf/surf_routing_rulebased.c +++ b/src/surf/surf_routing_rulebased.c @@ -8,8 +8,6 @@ /* Global vars */ extern routing_global_t global_routing; -extern AS_t current_routing; -extern routing_model_description_t current_routing_model; extern xbt_dynar_t link_list; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_rulebased, surf, "Routing part of surf"); -- 2.20.1