Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Centralize declaration for _sg_init_status (renamed to _sg_cfg_init_status).
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 1 Oct 2013 12:02:31 +0000 (14:02 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 1 Oct 2013 14:03:36 +0000 (16:03 +0200)
src/include/simgrid/sg_config.h
src/mc/mc_global.c
src/simgrid/sg_config.c
src/surf/surf_routing.c
src/surf/surfxml_parse.c

index 9952bfc..d0e93c4 100644 (file)
@@ -1,9 +1,16 @@
+/* Copyright (c) 2012-2013. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
 #include "xbt/config.h"
 
 /*******************************************/
 /*** Config Globals **************************/
 /*******************************************/
 XBT_PUBLIC_DATA(xbt_cfg_t) _sg_cfg_set;
+XBT_PUBLIC_DATA(int) _sg_cfg_init_status;
 XBT_PUBLIC(int) sg_cfg_get_int(const char* name);
 XBT_PUBLIC(double) sg_cfg_get_double(const char* name);
 XBT_PUBLIC(char*) sg_cfg_get_string(const char* name);
index 242b413..558fca0 100644 (file)
@@ -35,9 +35,8 @@ char *_sg_mc_dot_output_file = NULL;
 
 int user_max_depth_reached = 0;
 
-extern int _sg_init_status;
 void _mc_cfg_cb_reduce(const char *name, int pos) {
-  if (_sg_init_status && !_sg_do_model_check) {
+  if (_sg_cfg_init_status && !_sg_do_model_check) {
     xbt_die("You are specifying a reduction strategy after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
   }
   char *val= xbt_cfg_get_string(_sg_cfg_set, name);
@@ -51,41 +50,41 @@ void _mc_cfg_cb_reduce(const char *name, int pos) {
 }
 
 void _mc_cfg_cb_checkpoint(const char *name, int pos) {
-  if (_sg_init_status && !_sg_do_model_check) {
+  if (_sg_cfg_init_status && !_sg_do_model_check) {
     xbt_die("You are specifying a checkpointing value after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
   }
   _sg_mc_checkpoint = xbt_cfg_get_int(_sg_cfg_set, name);
 }
 void _mc_cfg_cb_property(const char *name, int pos) {
-  if (_sg_init_status && !_sg_do_model_check) {
+  if (_sg_cfg_init_status && !_sg_do_model_check) {
     xbt_die("You are specifying a property after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
   }
   _sg_mc_property_file= xbt_cfg_get_string(_sg_cfg_set, name);
 }
 
 void _mc_cfg_cb_timeout(const char *name, int pos) {
-  if (_sg_init_status && !_sg_do_model_check) {
+  if (_sg_cfg_init_status && !_sg_do_model_check) {
     xbt_die("You are specifying a value to enable/disable timeout for wait requests after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
   }
   _sg_mc_timeout= xbt_cfg_get_boolean(_sg_cfg_set, name);
 }
 
 void _mc_cfg_cb_max_depth(const char *name, int pos) {
-  if (_sg_init_status && !_sg_do_model_check) {
+  if (_sg_cfg_init_status && !_sg_do_model_check) {
     xbt_die("You are specifying a max depth value after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
   }
   _sg_mc_max_depth= xbt_cfg_get_int(_sg_cfg_set, name);
 }
 
 void _mc_cfg_cb_visited(const char *name, int pos) {
-  if (_sg_init_status && !_sg_do_model_check) {
+  if (_sg_cfg_init_status && !_sg_do_model_check) {
     xbt_die("You are specifying a number of stored visited states after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
   }
   _sg_mc_visited= xbt_cfg_get_int(_sg_cfg_set, name);
 }
 
 void _mc_cfg_cb_dot_output(const char *name, int pos) {
-  if (_sg_init_status && !_sg_do_model_check) {
+  if (_sg_cfg_init_status && !_sg_do_model_check) {
     xbt_die("You are specifying a file name for a dot output of graph state after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
   }
   _sg_mc_dot_output_file= xbt_cfg_get_string(_sg_cfg_set, name);
index 9ec43f6..34e5b43 100644 (file)
@@ -27,10 +27,13 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config, surf,
 
 xbt_cfg_t _sg_cfg_set = NULL;
 
-int _sg_init_status = 0;      /* 0: beginning of time (config cannot be changed yet);
-                                  1: initialized: cfg_set created (config can now be changed);
-                                  2: configured: command line parsed and config part of platform file was integrated also, platform construction ongoing or done.
-                                     (Config cannot be changed anymore!) */
+/* 0: beginning of time (config cannot be changed yet);
+ * 1: initialized: cfg_set created (config can now be changed);
+ * 2: configured: command line parsed and config part of platform file was
+ *    integrated also, platform construction ongoing or done.
+ *    (Config cannot be changed anymore!)
+ */
+int _sg_cfg_init_status = 0;
 
 /* Parse the command line, looking for options */
 static void sg_config_cmd_line(int *argc, char **argv)
@@ -94,7 +97,7 @@ static void sg_config_cmd_line(int *argc, char **argv)
     *argc = j;
   }
   if (shall_exit) {
-    _sg_init_status = 1;        // get everything cleanly cleaned on exit
+    _sg_cfg_init_status = 1;        // get everything cleanly cleaned on exit
     exit(0);
   }
 }
@@ -104,7 +107,7 @@ static void _sg_cfg_cb__workstation_model(const char *name, int pos)
 {
   char *val;
 
-  xbt_assert(_sg_init_status < 2,
+  xbt_assert(_sg_cfg_init_status < 2,
               "Cannot change the model after the initialization");
 
   val = xbt_cfg_get_string(_sg_cfg_set, name);
@@ -123,7 +126,7 @@ static void _sg_cfg_cb__cpu_model(const char *name, int pos)
 {
   char *val;
 
-  xbt_assert(_sg_init_status < 2,
+  xbt_assert(_sg_cfg_init_status < 2,
               "Cannot change the model after the initialization");
 
   val = xbt_cfg_get_string(_sg_cfg_set, name);
@@ -142,7 +145,7 @@ static void _sg_cfg_cb__optimization_mode(const char *name, int pos)
 {
   char *val;
 
-  xbt_assert(_sg_init_status < 2,
+  xbt_assert(_sg_cfg_init_status < 2,
               "Cannot change the model after the initialization");
 
   val = xbt_cfg_get_string(_sg_cfg_set, name);
@@ -161,7 +164,7 @@ static void _sg_cfg_cb__storage_mode(const char *name, int pos)
 {
   char *val;
 
-  xbt_assert(_sg_init_status < 2,
+  xbt_assert(_sg_cfg_init_status < 2,
               "Cannot change the model after the initialization");
 
   val = xbt_cfg_get_string(_sg_cfg_set, name);
@@ -180,7 +183,7 @@ static void _sg_cfg_cb__network_model(const char *name, int pos)
 {
   char *val;
 
-  xbt_assert(_sg_init_status < 2,
+  xbt_assert(_sg_cfg_init_status < 2,
               "Cannot change the model after the initialization");
 
   val = xbt_cfg_get_string(_sg_cfg_set, name);
@@ -233,7 +236,7 @@ static void _sg_cfg_cb__coll(const char *category,
 {
   char *val;
 
-  xbt_assert(_sg_init_status < 2,
+  xbt_assert(_sg_cfg_init_status < 2,
               "Cannot change the model after the initialization");
 
   val = xbt_cfg_get_string(_sg_cfg_set, name);
@@ -402,7 +405,7 @@ void sg_config_init(int *argc, char **argv)
   int i;
 
   /* Create the configuration support */
-  if (_sg_init_status == 0) { /* Only create stuff if not already inited */
+  if (_sg_cfg_init_status == 0) { /* Only create stuff if not already inited */
     sprintf(description,
             "The model to use for the CPU. Possible values: ");
     p = description;
@@ -554,7 +557,7 @@ void sg_config_init(int *argc, char **argv)
                      "If value=on, one checkpoint is saved for each step => faster verification, but huge memory consumption; higher values are good compromises between speed and memory consumption.",
                      xbt_cfgelm_int, 0, 1, _mc_cfg_cb_checkpoint, NULL);
     xbt_cfg_setdefault_int(_sg_cfg_set, "model-check/checkpoint", 0);
-    
+
     /* do liveness model-checking */
     xbt_cfg_register(&_sg_cfg_set, "model-check/property",
                      "Specify the name of the file containing the property. It must be the result of the ltl2ba program.",
@@ -800,7 +803,7 @@ void sg_config_init(int *argc, char **argv)
       xbt_cfg_setdefault_string(_sg_cfg_set, "path", initial_path);
     }
 
-    _sg_init_status = 1;
+    _sg_cfg_init_status = 1;
 
     sg_config_cmd_line(argc, argv);
 
@@ -815,11 +818,11 @@ void sg_config_init(int *argc, char **argv)
 
 void sg_config_finalize(void)
 {
-  if (!_sg_init_status)
+  if (!_sg_cfg_init_status)
     return;                     /* Not initialized yet. Nothing to do */
 
   xbt_cfg_free(&_sg_cfg_set);
-  _sg_init_status = 0;
+  _sg_cfg_init_status = 0;
 }
 
 /* Pick the right models for CPU, net and workstation, and call their model_init_preparse */
index f1d5ea5..ec7334f 100644 (file)
@@ -5,6 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/platf_interface.h"    // platform creation API internal interface
+#include "simgrid/sg_config.h"
 
 #include "surf_routing_private.h"
 #include "surf/surf_routing.h"
@@ -319,8 +320,6 @@ static void routing_parse_trace_connect(sg_platf_trace_connect_cbarg_t trace_con
   }
 }
 
-extern int _sg_init_status; /* yay, this is an horrible hack */
-
 /**
  * \brief Make a new routing component to the platform
  *
@@ -344,7 +343,9 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
              (as_router_lib, AS->id, ROUTING_ASR_LEVEL),
              "The AS \"%s\" already exists", AS->id);
 
-  _sg_init_status = 2; /* horrible hack: direct access to the global controlling the level of configuration to prevent any further config */
+  _sg_cfg_init_status = 2; /* horrible hack: direct access to the global
+                            * controlling the level of configuration to prevent
+                            * any further config */
 
   /* search the routing model */
   switch(AS->routing){
index 4d48cad..b7540cf 100644 (file)
@@ -858,13 +858,11 @@ void ETag_surfxml_AS(void){
   sg_platf_new_AS_end();
 }
 
-extern int _sg_init_status; /* FIXME: find a proper way to export this at some point */
-
 void STag_surfxml_config(void){
   AS_TAG = 0;
   xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
   XBT_DEBUG("START configuration name = %s",A_surfxml_config_id);
-  if (_sg_init_status == 2) {
+  if (_sg_cfg_init_status == 2) {
     surf_parse_error("All <config> tags must be given before any platform elements (such as <AS>, <host>, <cluster>, <link>, etc).");
   }
 }