Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge commit '045db1657e870c721be490b411868f4181a12ced' into surf++
[simgrid.git] / src / simgrid / sg_config.c
index 34e5b43..e2a11b9 100644 (file)
@@ -35,6 +35,12 @@ xbt_cfg_t _sg_cfg_set = NULL;
  */
 int _sg_cfg_init_status = 0;
 
+/* instruct the upper layer (simix or simdag) to exit as soon as possible
+ */
+int _sg_cfg_exit_asap = 0;
+
+#define sg_cfg_exit_early() do { _sg_cfg_exit_asap = 1; return; } while (0)
+
 /* Parse the command line, looking for options */
 static void sg_config_cmd_line(int *argc, char **argv)
 {
@@ -96,10 +102,8 @@ static void sg_config_cmd_line(int *argc, char **argv)
     argv[j] = NULL;
     *argc = j;
   }
-  if (shall_exit) {
-    _sg_cfg_init_status = 1;        // get everything cleanly cleaned on exit
-    exit(0);
-  }
+  if (shall_exit)
+    sg_cfg_exit_early();
 }
 
 /* callback of the workstation/model variable */
@@ -114,7 +118,7 @@ static void _sg_cfg_cb__workstation_model(const char *name, int pos)
 
   if (!strcmp(val, "help")) {
     model_help("workstation", surf_workstation_model_description);
-    exit(0);
+    sg_cfg_exit_early();
   }
 
   /* Make sure that the model exists */
@@ -133,7 +137,7 @@ static void _sg_cfg_cb__cpu_model(const char *name, int pos)
 
   if (!strcmp(val, "help")) {
     model_help("CPU", surf_cpu_model_description);
-    exit(0);
+    sg_cfg_exit_early();
   }
 
   /* New Module missing */
@@ -152,7 +156,7 @@ static void _sg_cfg_cb__optimization_mode(const char *name, int pos)
 
   if (!strcmp(val, "help")) {
     model_help("optimization", surf_optimization_mode_description);
-    exit(0);
+    sg_cfg_exit_early();
   }
 
   /* New Module missing */
@@ -171,7 +175,7 @@ static void _sg_cfg_cb__storage_mode(const char *name, int pos)
 
   if (!strcmp(val, "help")) {
     model_help("storage", surf_storage_model_description);
-    exit(0);
+    sg_cfg_exit_early();
   }
 
   /* New Module missing */
@@ -190,7 +194,7 @@ static void _sg_cfg_cb__network_model(const char *name, int pos)
 
   if (!strcmp(val, "help")) {
     model_help("network", surf_network_model_description);
-    exit(0);
+    sg_cfg_exit_early();
   }
 
   /* New Module missing */
@@ -243,7 +247,7 @@ static void _sg_cfg_cb__coll(const char *category,
 
   if (!strcmp(val, "help")) {
     coll_help(category, table);
-    exit(0);
+    sg_cfg_exit_early();
   }
 
   /* New Module missing */
@@ -401,7 +405,8 @@ static void _sg_cfg_cb__gtnets_jitter_seed(const char *name, int pos)
 /* create the config set, register what should be and parse the command line*/
 void sg_config_init(int *argc, char **argv)
 {
-  char *description = xbt_malloc(1024), *p = description;
+  char *description = xbt_malloc(1024);
+  char *p;
   int i;
 
   /* Create the configuration support */
@@ -442,22 +447,6 @@ void sg_config_init(int *argc, char **argv)
                      xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__storage_mode, NULL);
     xbt_cfg_setdefault_string(_sg_cfg_set, "storage/model", "default");
 
-    /* ********************************************************************* */
-    /* TUTORIAL: New model                                                   */
-    sprintf(description,
-            "The model to use for the New model. Possible values: ");
-    p = description;
-    while (*(++p) != '\0');
-    for (i = 0; surf_new_model_description[i].name; i++)
-      p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
-                   surf_new_model_description[i].name);
-    sprintf(p,
-            ".\n       (use 'help' as a value to see the long description of each model)");
-    xbt_cfg_register(&_sg_cfg_set, "new_model/model", description,
-                     xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__storage_mode, NULL);
-    xbt_cfg_setdefault_string(_sg_cfg_set, "new_model/model", "default");
-    /* ********************************************************************* */
-
     sprintf(description,
             "The model to use for the network. Possible values: ");
     p = description;
@@ -885,15 +874,6 @@ void surf_config_models_setup()
   storage_id = find_model_description(surf_storage_model_description, storage_model_name);
   surf_storage_model_description[storage_id].model_init_preparse();
 
-  /* ********************************************************************* */
-  /* TUTORIAL: New model                                                   */
-  int new_model_id = -1;
-  char *new_model_name = NULL;
-  new_model_name = xbt_cfg_get_string(_sg_cfg_set, "new_model/model");
-  XBT_DEBUG("Call new model_init");
-  new_model_id = find_model_description(surf_new_model_description, new_model_name);
-  surf_new_model_description[new_model_id].model_init_preparse();
-  /* ********************************************************************* */
 }
 
 int sg_cfg_get_int(const char* name)