X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/504b4d20dd2db9ea1eaa9c4b390b2a412d7c9779..b1b6cb61ca85e53ac6d90a9b2bdc7d031ebaa6b8:/src/surf/surfxml_parse.c diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 7956cd942d..a5f91f6401 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -10,47 +10,85 @@ #include "xbt/dict.h" #include "surf/surfxml_parse_private.h" #include "surf/surf_private.h" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(parse, surf, - "Logging specific to the SURF module"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_parse, surf, + "Logging specific to the SURF parsing module"); #undef CLEANUP #include "surfxml.c" +/* make sure these symbols are defined as strong ones in this file so that the linked can resolve them */ +xbt_dynar_t STag_surfxml_platform_cb_list = NULL; +xbt_dynar_t ETag_surfxml_platform_cb_list = NULL; +xbt_dynar_t STag_surfxml_host_cb_list = NULL; +xbt_dynar_t ETag_surfxml_host_cb_list = NULL; +xbt_dynar_t STag_surfxml_router_cb_list = NULL; +xbt_dynar_t ETag_surfxml_router_cb_list = NULL; +xbt_dynar_t STag_surfxml_link_cb_list = NULL; +xbt_dynar_t ETag_surfxml_link_cb_list = NULL; +xbt_dynar_t STag_surfxml_route_cb_list = NULL; +xbt_dynar_t ETag_surfxml_route_cb_list = NULL; +xbt_dynar_t STag_surfxml_link_c_ctn_cb_list = NULL; +xbt_dynar_t ETag_surfxml_link_c_ctn_cb_list = NULL; +xbt_dynar_t STag_surfxml_process_cb_list = NULL; +xbt_dynar_t ETag_surfxml_process_cb_list = NULL; +xbt_dynar_t STag_surfxml_argument_cb_list = NULL; +xbt_dynar_t ETag_surfxml_argument_cb_list = NULL; +xbt_dynar_t STag_surfxml_prop_cb_list = NULL; +xbt_dynar_t ETag_surfxml_prop_cb_list = NULL; + +xbt_dict_t current_property_set = NULL; + static xbt_dynar_t surf_input_buffer_stack = NULL; static xbt_dynar_t surf_file_to_parse_stack = NULL; -void surfxml_call_cb_functions(xbt_dynar_t); - -void nil_function(void); -void nil_function(void) -{ - return; -} +static inline void surfxml_call_cb_functions(xbt_dynar_t); YY_BUFFER_STATE surf_input_buffer; FILE *surf_file_to_parse; -void surf_parse_reset_parser(void) +void surf_parse_free_callbacks(void) { + xbt_dynar_free(&STag_surfxml_platform_cb_list); + xbt_dynar_free(&ETag_surfxml_platform_cb_list); + xbt_dynar_free(&STag_surfxml_host_cb_list); + xbt_dynar_free(&ETag_surfxml_host_cb_list); + xbt_dynar_free(&STag_surfxml_router_cb_list); + xbt_dynar_free(&ETag_surfxml_router_cb_list); + xbt_dynar_free(&STag_surfxml_link_cb_list); + xbt_dynar_free(&ETag_surfxml_link_cb_list); + xbt_dynar_free(&STag_surfxml_route_cb_list); + xbt_dynar_free(&ETag_surfxml_route_cb_list); + xbt_dynar_free(&STag_surfxml_link_c_ctn_cb_list); + xbt_dynar_free(&ETag_surfxml_link_c_ctn_cb_list); + xbt_dynar_free(&STag_surfxml_process_cb_list); + xbt_dynar_free(&ETag_surfxml_process_cb_list); + xbt_dynar_free(&STag_surfxml_argument_cb_list); + xbt_dynar_free(&ETag_surfxml_argument_cb_list); + xbt_dynar_free(&STag_surfxml_prop_cb_list); + xbt_dynar_free(&ETag_surfxml_prop_cb_list); +} - STag_surfxml_platform_description_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - ETag_surfxml_platform_description_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - STag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - ETag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - STag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - ETag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - STag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - ETag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - STag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - ETag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - STag_surfxml_link_c_ctn_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - ETag_surfxml_link_c_ctn_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - STag_surfxml_process_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - ETag_surfxml_process_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - STag_surfxml_argument_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - ETag_surfxml_argument_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - STag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); - ETag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t),&free); +void surf_parse_reset_parser(void) +{ + surf_parse_free_callbacks(); + STag_surfxml_platform_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + ETag_surfxml_platform_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + STag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + ETag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + STag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + ETag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + STag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + ETag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + STag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + ETag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + STag_surfxml_link_c_ctn_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + ETag_surfxml_link_c_ctn_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + STag_surfxml_process_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + ETag_surfxml_process_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + STag_surfxml_argument_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + ETag_surfxml_argument_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + STag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); + ETag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t),NULL); } @@ -78,14 +116,14 @@ void ETag_surfxml_include(void) xbt_dynar_pop(surf_input_buffer_stack, &surf_input_buffer); } -void STag_surfxml_platform_description(void) +void STag_surfxml_platform(void) { double version = 0.0; - sscanf(A_surfxml_platform_description_version, "%lg", &version); + sscanf(A_surfxml_platform_version, "%lg", &version); xbt_assert0((version >= 1.0), "******* BIG FAT WARNING *********\n " - "You're using an old XML file. " + "You're using an ancient XML file. " "Since SimGrid 3.1, units are Bytes, Flops, and seconds " "instead of MBytes, MFlops and seconds. " "A script (surfxml_update.pl) to help you convert your old " @@ -95,13 +133,19 @@ void STag_surfxml_platform_description(void) "SURF section of the ChangeLog for the 3.1 version. " "Last, do not forget to also update your values for " "the calls to MSG_task_create (if any)."); + xbt_assert0((version >= 2.0), "******* BIG FAT WARNING *********\n " + "You're using an old XML file. " + "A script (surfxml_update.pl) to help you convert your old " + "platform files " + "is available in the contrib/platform_generation directory " + "of the simgrid repository."); - surfxml_call_cb_functions(STag_surfxml_platform_description_cb_list); + surfxml_call_cb_functions(STag_surfxml_platform_cb_list); } -void ETag_surfxml_platform_description(void) +void ETag_surfxml_platform(void) { - surfxml_call_cb_functions(ETag_surfxml_platform_description_cb_list); + surfxml_call_cb_functions(ETag_surfxml_platform_cb_list); } void STag_surfxml_host(void) @@ -266,11 +310,12 @@ void surfxml_add_callback(xbt_dynar_t cb_list, void_f_void_t function) xbt_dynar_push(cb_list, &function); } -void surfxml_call_cb_functions(xbt_dynar_t cb_list) +static inline void surfxml_call_cb_functions(xbt_dynar_t cb_list) { int iterator; - void_f_void_t data; - xbt_dynar_foreach(cb_list, iterator, data){ - (*data)(); + void_f_void_t fun; + xbt_dynar_foreach(cb_list, iterator, fun){ + DEBUG2("call %p %p",fun,*fun); + (*fun)(); } }