From: Martin Quinson Date: Wed, 9 Nov 2011 17:06:57 +0000 (+0100) Subject: use a sane way to declare postparse callbacks, now that this way exists X-Git-Tag: exp_20120216~384 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/13025e8ea0f4fccfb16bc3214ed42aefa1b8d9d9?hp=31077d64ac51b75cdfecb8aea7baf854ae1032a8 use a sane way to declare postparse callbacks, now that this way exists --- diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index e733d69287..6627be748d 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -49,7 +49,6 @@ typedef struct surf_model_description { const char *name; const char *description; void (*model_init_preparse) (void); - void (*model_init_postparse) (void); } s_surf_model_description_t, *surf_model_description_t; XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table, @@ -635,12 +634,6 @@ XBT_PUBLIC_DATA(xbt_cfg_t) _surf_cfg_set; */ XBT_PUBLIC(void) surf_init(int *argc, char **argv); /* initialize common structures */ -/** \brief create the elements of the models - * - * Must be called after parsing the platform file and before using any elements - */ -XBT_PUBLIC(void) surf_config_models_create_elms(void); - /** \brief Finish simulation initialization * \ingroup SURF_simulation * diff --git a/src/surf/surf.c b/src/surf/surf.c index 786b76cd57..764671ff72 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -149,7 +149,7 @@ s_surf_model_description_t surf_network_model_description[] = { {"Vegas", "Model using lagrange_solve instead of lmm_solve (experts only)", surf_network_model_init_Vegas}, - {NULL, NULL, NULL, NULL} /* this array must be NULL terminated */ + {NULL, NULL, NULL} /* this array must be NULL terminated */ }; s_surf_model_description_t surf_cpu_model_description[] = { @@ -161,18 +161,18 @@ s_surf_model_description_t surf_cpu_model_description[] = { {"CpuTI", "Variation of Cas01 with also trace integration. Should produce the same values, only faster if you use availability traces", surf_cpu_model_init_ti}, - {NULL, NULL, NULL, NULL} /* this array must be NULL terminated */ + {NULL, NULL, NULL} /* this array must be NULL terminated */ }; s_surf_model_description_t surf_workstation_model_description[] = { {"CLM03", "Default workstation model, using LV08 and CM02 as network and CPU", - surf_workstation_model_init_CLM03, create_workstations}, + surf_workstation_model_init_CLM03}, {"compound", "Workstation model allowing you to use other network and CPU models", - surf_workstation_model_init_compound, create_workstations}, + surf_workstation_model_init_compound}, {"ptask_L07", "Workstation model with better parallel task modeling", - surf_workstation_model_init_ptask_L07, NULL}, + surf_workstation_model_init_ptask_L07}, {NULL, NULL, NULL} /* this array must be NULL terminated */ }; diff --git a/src/surf/surf_config.c b/src/surf/surf_config.c index c6797afaa6..23de181fb9 100644 --- a/src/surf/surf_config.c +++ b/src/surf/surf_config.c @@ -525,16 +525,3 @@ void surf_config_models_setup() XBT_DEBUG("Call workstation_model_init"); surf_workstation_model_description[workstation_id].model_init_preparse(); } - -void surf_config_models_create_elms(void) -{ - char *workstation_model_name = - xbt_cfg_get_string(_surf_cfg_set, "workstation/model"); - int workstation_id = - find_model_description(surf_workstation_model_description, - workstation_model_name); - if (surf_workstation_model_description - [workstation_id].model_init_postparse != NULL) - surf_workstation_model_description[workstation_id].model_init_postparse - (); -} diff --git a/src/surf/surfxml_parseplatf.c b/src/surf/surfxml_parseplatf.c index 45db0f379a..9f2e6de3f5 100644 --- a/src/surf/surfxml_parseplatf.c +++ b/src/surf/surfxml_parseplatf.c @@ -193,7 +193,5 @@ void parse_platform_file(const char *file) surf_parse_close(); if (parse_status) xbt_die("Parse error in %s", file); - - surf_config_models_create_elms(); } diff --git a/src/surf/workstation.c b/src/surf/workstation.c index 3f8276f5c4..0a8c3221ae 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -356,6 +356,7 @@ void surf_workstation_model_init_CLM03(void) surf_cpu_model_init_Cas01_im(); surf_network_model_init_LegrandVelho(); xbt_dynar_push(model_list, &surf_workstation_model); + sg_platf_postparse_add_cb(create_workstations); } void surf_workstation_model_init_compound() @@ -365,4 +366,5 @@ void surf_workstation_model_init_compound() xbt_assert(surf_network_model, "No network model defined yet!"); surf_workstation_model_init_internal(); xbt_dynar_push(model_list, &surf_workstation_model); + sg_platf_postparse_add_cb(create_workstations); }