From: Arnaud Giersch Date: Tue, 1 Oct 2013 12:02:31 +0000 (+0200) Subject: Centralize declaration for _sg_init_status (renamed to _sg_cfg_init_status). X-Git-Tag: v3_9_90~56^2~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a35265d3c8fa860614bab6b7a438ad0cc2803e79 Centralize declaration for _sg_init_status (renamed to _sg_cfg_init_status). --- diff --git a/src/include/simgrid/sg_config.h b/src/include/simgrid/sg_config.h index 9952bfca13..d0e93c449d 100644 --- a/src/include/simgrid/sg_config.h +++ b/src/include/simgrid/sg_config.h @@ -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); diff --git a/src/mc/mc_global.c b/src/mc/mc_global.c index 242b413fc1..558fca058b 100644 --- a/src/mc/mc_global.c +++ b/src/mc/mc_global.c @@ -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); diff --git a/src/simgrid/sg_config.c b/src/simgrid/sg_config.c index 9ec43f64f7..34e5b43f32 100644 --- a/src/simgrid/sg_config.c +++ b/src/simgrid/sg_config.c @@ -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 */ diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index f1d5ea5a35..ec7334ff20 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -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){ diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 4d48cad5a5..b7540cf748 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -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 tags must be given before any platform elements (such as , , , , etc)."); } }