Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a useless comment added
[simgrid.git] / src / surf / surfxml_parse.c
index 6dfa95e..c8d2f0c 100644 (file)
@@ -23,55 +23,56 @@ void nil_function(void)
   return;
 }
 
-void_f_void_t STag_platform_description_fun = nil_function;
-void_f_void_t ETag_platform_description_fun = nil_function;
-void_f_void_t STag_cpu_fun = nil_function;
-void_f_void_t ETag_cpu_fun = nil_function;
-void_f_void_t STag_network_link_fun = nil_function;
-void_f_void_t ETag_network_link_fun = nil_function;
-void_f_void_t STag_route_fun = nil_function;
-void_f_void_t ETag_route_fun = nil_function;
-void_f_void_t STag_route_element_fun = nil_function;
-void_f_void_t ETag_route_element_fun = nil_function;
-void_f_void_t STag_process_fun = nil_function;
-void_f_void_t ETag_process_fun = nil_function;
-void_f_void_t STag_argument_fun = nil_function;
-void_f_void_t ETag_argument_fun = nil_function;
+void_f_void_t *STag_surfxml_platform_description_fun = nil_function;
+void_f_void_t *ETag_surfxml_platform_description_fun = nil_function;
+void_f_void_t *STag_surfxml_cpu_fun = nil_function;
+void_f_void_t *ETag_surfxml_cpu_fun = nil_function;
+void_f_void_t *STag_surfxml_network_link_fun = nil_function;
+void_f_void_t *ETag_surfxml_network_link_fun = nil_function;
+void_f_void_t *STag_surfxml_route_fun = nil_function;
+void_f_void_t *ETag_surfxml_route_fun = nil_function;
+void_f_void_t *STag_surfxml_route_element_fun = nil_function;
+void_f_void_t *ETag_surfxml_route_element_fun = nil_function;
+void_f_void_t *STag_surfxml_process_fun = nil_function;
+void_f_void_t *ETag_surfxml_process_fun = nil_function;
+void_f_void_t *STag_surfxml_argument_fun = nil_function;
+void_f_void_t *ETag_surfxml_argument_fun = nil_function;
 
 YY_BUFFER_STATE surf_input_buffer;
 FILE *surf_file_to_parse;
 
 void surf_parse_reset_parser(void)
 {
-  STag_platform_description_fun = nil_function;
-  ETag_platform_description_fun = nil_function;
-  STag_cpu_fun = nil_function;
-  ETag_cpu_fun = nil_function;
-  STag_network_link_fun = nil_function;
-  ETag_network_link_fun = nil_function;
-  STag_route_fun = nil_function;
-  ETag_route_fun = nil_function;
-  STag_route_element_fun = nil_function;
-  ETag_route_element_fun = nil_function;
-  STag_process_fun = nil_function;
-  ETag_process_fun = nil_function;
-  STag_argument_fun = nil_function;
-  ETag_argument_fun = nil_function;
+  STag_surfxml_platform_description_fun = nil_function;
+  ETag_surfxml_platform_description_fun = nil_function;
+  STag_surfxml_cpu_fun = nil_function;
+  ETag_surfxml_cpu_fun = nil_function;
+  STag_surfxml_network_link_fun = nil_function;
+  ETag_surfxml_network_link_fun = nil_function;
+  STag_surfxml_route_fun = nil_function;
+  ETag_surfxml_route_fun = nil_function;
+  STag_surfxml_route_element_fun = nil_function;
+  ETag_surfxml_route_element_fun = nil_function;
+  STag_surfxml_process_fun = nil_function;
+  ETag_surfxml_process_fun = nil_function;
+  STag_surfxml_argument_fun = nil_function;
+  ETag_surfxml_argument_fun = nil_function;
 }
 
-void STag_include(void)
+void STag_surfxml_include(void)
 {
   xbt_dynar_push(surf_input_buffer_stack,&surf_input_buffer);
   xbt_dynar_push(surf_file_to_parse_stack,&surf_file_to_parse);
   
-  surf_file_to_parse = surf_fopen(A_include_file,"r");
-  xbt_assert1((surf_file_to_parse), "Unable to open \"%s\"\n",A_include_file);
+  surf_file_to_parse = surf_fopen(A_surfxml_include_file,"r");
+  xbt_assert1((surf_file_to_parse), "Unable to open \"%s\"\n",
+             A_surfxml_include_file);
   surf_input_buffer = surf_parse__create_buffer( surf_file_to_parse, 10);
   surf_parse__switch_to_buffer(surf_input_buffer);
   printf("STAG\n"); fflush(NULL);
 }
 
-void ETag_include(void)
+void ETag_surfxml_include(void)
 {
   printf("ETAG\n"); fflush(NULL);
   surf_parse__delete_buffer(surf_input_buffer);
@@ -80,79 +81,99 @@ void ETag_include(void)
   xbt_dynar_pop(surf_input_buffer_stack,&surf_input_buffer);
 }
 
-void STag_platform_description(void)
+void STag_surfxml_platform_description(void)
 {
-  STag_platform_description_fun();
+  double version=0.0;
+
+  sscanf(A_surfxml_platform_description_version,"%lg",&version);
+
+  xbt_assert0((version>=1.0),"******* BIG FAT WARNING *********\n "
+             "You're using an old 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 "
+             "platform files "
+             "is available in the contrib/platform_generation directory "
+             "of the simgrid repository. Please check also out the "
+             "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).");
+
+  STag_surfxml_platform_description_fun();
 }
 
-void ETag_platform_description(void)
+void ETag_surfxml_platform_description(void)
 {
-  ETag_platform_description_fun();
+  ETag_surfxml_platform_description_fun();
 }
 
-void STag_cpu(void)
+void STag_surfxml_cpu(void)
 {
-  STag_cpu_fun();
+  STag_surfxml_cpu_fun();
 }
 
-void ETag_cpu(void)
+void ETag_surfxml_cpu(void)
 {
-  ETag_cpu_fun();
+  ETag_surfxml_cpu_fun();
 }
 
-void STag_network_link(void)
+void STag_surfxml_network_link(void)
 {
-  STag_network_link_fun();
+  STag_surfxml_network_link_fun();
 }
 
-void ETag_network_link(void)
+void ETag_surfxml_network_link(void)
 {
-  ETag_network_link_fun();
+  ETag_surfxml_network_link_fun();
 }
 
-void STag_route(void)
+void STag_surfxml_route(void)
 {
-  STag_route_fun();
+  STag_surfxml_route_fun();
 }
 
-void ETag_route(void)
+void ETag_surfxml_route(void)
 {
-  ETag_route_fun();
+  ETag_surfxml_route_fun();
 }
 
-void STag_route_element(void)
+void STag_surfxml_route_element(void)
 {
-  STag_route_element_fun();
+  STag_surfxml_route_element_fun();
 }
 
-void ETag_route_element(void)
+void ETag_surfxml_route_element(void)
 {
-  ETag_route_element_fun();
+  ETag_surfxml_route_element_fun();
 }
 
-void STag_process(void)
+void STag_surfxml_process(void)
 {
-  STag_process_fun();
+  STag_surfxml_process_fun();
 }
 
-void ETag_process(void)
+void ETag_surfxml_process(void)
 {
-  ETag_process_fun();
+  ETag_surfxml_process_fun();
 }
 
-void STag_argument(void)
+void STag_surfxml_argument(void)
 {
-  STag_argument_fun();
+  STag_surfxml_argument_fun();
 }
 
-void ETag_argument(void)
+void ETag_surfxml_argument(void)
 {
-  ETag_argument_fun();
+  ETag_surfxml_argument_fun();
 }
 
 void  surf_parse_open(const char *file) {
+  static int warned = 0; /* warn only once */
   if(!file) {
-    WARN0("I hope you know what you're doing... you just gave me a NULL pointer!");
+    if (!warned) {
+      WARN0("Bypassing the XML parser since surf_parse_open received a NULL pointer. If it is not what you want, go fix your code.");
+      warned = 1;
+    }
     return;
   }
   if(!surf_input_buffer_stack) 
@@ -185,7 +206,7 @@ static int _surf_parse(void)
   return surf_parse_lex();
 }
 
-int_f_void_t surf_parse = _surf_parse;
+int_f_void_t *surf_parse = _surf_parse;
 
 void surf_parse_get_double(double *value,const char *string)
 {