From: Martin Quinson Date: Mon, 7 Nov 2011 10:41:10 +0000 (+0100) Subject: Make the sg_plat_new_host() function public X-Git-Tag: exp_20120216~463 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/fc1551b7a3cbbcdb9fb48500f70683318c87c47b?hp=f8b73381cb02cdf39dd7829afe40df5f218a27f0 Make the sg_plat_new_host() function public --- diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h index 8014a9b70f..89df78dc4a 100644 --- a/include/simgrid/platf.h +++ b/include/simgrid/platf.h @@ -20,6 +20,16 @@ typedef enum { } e_surf_resource_state_t; +/* + * Platform creation functions. Instead of passing 123 arguments to the creation functions + * (one for each possible XML attribute), we pass structures containing them all. It removes the + * chances of switching arguments by error, and reduce the burden when we add a new attribute: + * old models can just continue to ignore it without having to update their headers. + * + * It shouldn't be too costly at runtime, provided that structures living on the stack are + * used, instead of malloced structures. + */ + typedef struct s_surf_parsing_host_arg { char* V_host_id; //id double V_host_power_peak; //power @@ -35,4 +45,6 @@ typedef struct s_surf_parsing_host_arg { 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); + #endif /* SG_PLATF_H */ diff --git a/src/include/simgrid/platf_interface.h b/src/include/simgrid/platf_interface.h index a78eb2f639..4502cb0f39 100644 --- a/src/include/simgrid/platf_interface.h +++ b/src/include/simgrid/platf_interface.h @@ -20,7 +20,6 @@ void sg_platf_exit(void); typedef void (*surf_parse_host_fct_t)(surf_parsing_host_arg_t); void surf_parse_host_add_cb(surf_parse_host_fct_t); -void surf_parse_host(surf_parsing_host_arg_t h); diff --git a/src/surf/sg_platf.c b/src/surf/sg_platf.c index 89eff09117..f47d406953 100644 --- a/src/surf/sg_platf.c +++ b/src/surf/sg_platf.c @@ -23,7 +23,7 @@ void sg_platf_exit(void) { xbt_dynar_free(&surf_parse_host_cb_list); } -void surf_parse_host(surf_parsing_host_arg_t h){ +void sg_platf_new_host(surf_parsing_host_arg_t h){ unsigned int iterator; surf_parse_host_fct_t fun; xbt_dynar_foreach(surf_parse_host_cb_list, iterator, fun) { diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 634b3c7e38..4a4077e4b2 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -1512,7 +1512,7 @@ static void parse_create_host_link(int i) host.V_host_core = struct_cluster->S_cluster_core; host.V_host_state_initial = SURF_RESOURCE_ON; host.V_host_coord = ""; - surf_parse_host(&host); + sg_platf_new_host(&host); XBT_DEBUG(""); A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED; @@ -1645,7 +1645,7 @@ void routing_parse_Scluster(void) host.V_host_core = struct_cluster->S_cluster_core; host.V_host_state_initial = SURF_RESOURCE_ON; host.V_host_coord = ""; - surf_parse_host(&host); + sg_platf_new_host(&host); XBT_DEBUG(""); A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED; @@ -1725,7 +1725,7 @@ void routing_parse_Scluster(void) host.V_host_core = struct_cluster->S_cluster_core; host.V_host_state_initial = SURF_RESOURCE_ON; host.V_host_coord = ""; - surf_parse_host(&host); + sg_platf_new_host(&host); XBT_DEBUG(""); A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED; diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index e2573452ab..5b4f63c9be 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -309,7 +309,7 @@ void STag_surfxml_host(void){ host.V_host_state_initial = SURF_RESOURCE_OFF; host.V_host_coord = xbt_strdup(A_surfxml_host_coordinates); - surf_parse_host(&host); + sg_platf_new_host(&host); } void ETag_surfxml_host(void){ surfxml_call_cb_functions(ETag_surfxml_host_cb_list);