From: Martin Quinson Date: Mon, 4 Apr 2016 16:59:44 +0000 (+0200) Subject: further rework the config handling. Still much to do X-Git-Tag: v3_13~180^2~8 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/9f646472eb2d52b33a9be7450259564ac890ea99 further rework the config handling. Still much to do --- diff --git a/include/xbt/config.h b/include/xbt/config.h index a1ba9926f6..362fc841a7 100644 --- a/include/xbt/config.h +++ b/include/xbt/config.h @@ -85,20 +85,20 @@ XBT_PUBLIC(void) xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name, va_list pa); XBT_PUBLIC(void) xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options); /* Set the value of the cell \a name in \a cfg with the provided value.*/ -XBT_PUBLIC(void) xbt_cfg_set_int(xbt_cfg_t cfg, const char *name, int val); -XBT_PUBLIC(void) xbt_cfg_set_double(xbt_cfg_t cfg, const char *name, double val); -XBT_PUBLIC(void) xbt_cfg_set_string(xbt_cfg_t cfg, const char *name, const char *val); -XBT_PUBLIC(void) xbt_cfg_set_boolean(xbt_cfg_t cfg, const char *name, const char *val); -XBT_PUBLIC(void*) xbt_cfg_set_as_string(xbt_cfg_t cfg, const char *name, const char *val); +XBT_PUBLIC(void) xbt_cfg_set_int (const char *name, int val); +XBT_PUBLIC(void) xbt_cfg_set_double (const char *name, double val); +XBT_PUBLIC(void) xbt_cfg_set_string (const char *name, const char *val); +XBT_PUBLIC(void) xbt_cfg_set_boolean (const char *name, const char *val); +XBT_PUBLIC(void*) xbt_cfg_set_as_string(const char *name, const char *val); /* Set the default value of the cell \a name in \a cfg with the provided value. If it was already set to something (possibly from the command line), do nothing. */ -XBT_PUBLIC(void) xbt_cfg_setdefault_int(xbt_cfg_t cfg, const char *name, int val); -XBT_PUBLIC(void) xbt_cfg_setdefault_double(xbt_cfg_t cfg, const char *name, double val); -XBT_PUBLIC(void) xbt_cfg_setdefault_string(xbt_cfg_t cfg, const char *name, const char *val); -XBT_PUBLIC(void) xbt_cfg_setdefault_boolean(xbt_cfg_t cfg, const char *name, const char *val); +XBT_PUBLIC(void) xbt_cfg_setdefault_int (const char *name, int val); +XBT_PUBLIC(void) xbt_cfg_setdefault_double (const char *name, double val); +XBT_PUBLIC(void) xbt_cfg_setdefault_string (const char *name, const char *val); +XBT_PUBLIC(void) xbt_cfg_setdefault_boolean(const char *name, const char *val); /** @brief Remove the provided value from the cell #name in #cfg. */ XBT_PUBLIC(void) xbt_cfg_rm_int(xbt_cfg_t cfg, const char *name, int val); @@ -113,7 +113,7 @@ XBT_PUBLIC(void) xbt_cfg_rm_at(xbt_cfg_t cfg, const char *name, int pos); XBT_PUBLIC(void) xbt_cfg_empty(xbt_cfg_t cfg, const char *name); /** @brief Return if configuration is set by default*/ -XBT_PUBLIC(int) xbt_cfg_is_default_value(xbt_cfg_t cfg, const char *name); +XBT_PUBLIC(int) xbt_cfg_is_default_value(const char *name); /* @} */ @@ -187,11 +187,11 @@ XBT_PUBLIC(e_xbt_cfgelm_type_t) xbt_cfg_get_type(xbt_cfg_t cfg, const char *name * @{ */ -XBT_PUBLIC(int) xbt_cfg_get_int(xbt_cfg_t cfg, const char *name); -XBT_PUBLIC(double) xbt_cfg_get_double(xbt_cfg_t cfg, const char *name); -XBT_PUBLIC(char *) xbt_cfg_get_string(xbt_cfg_t cfg, const char *name); -XBT_PUBLIC(int) xbt_cfg_get_boolean(xbt_cfg_t cfg, const char *name); -XBT_PUBLIC(xbt_dynar_t) xbt_cfg_get_dynar(xbt_cfg_t cfg, const char *name); +XBT_PUBLIC(int) xbt_cfg_get_int(const char *name); +XBT_PUBLIC(double) xbt_cfg_get_double(const char *name); +XBT_PUBLIC(char *) xbt_cfg_get_string(const char *name); +XBT_PUBLIC(int) xbt_cfg_get_boolean(const char *name); +XBT_PUBLIC(xbt_dynar_t) xbt_cfg_get_dynar(const char *name); XBT_PUBLIC(int) xbt_cfg_get_int_at(xbt_cfg_t cfg, const char *name, int pos); XBT_PUBLIC(double) xbt_cfg_get_double_at(xbt_cfg_t cfg, const char *name, int pos); diff --git a/src/include/simgrid/sg_config.h b/src/include/simgrid/sg_config.h index 4f305ce87c..6f61086e22 100644 --- a/src/include/simgrid/sg_config.h +++ b/src/include/simgrid/sg_config.h @@ -9,7 +9,7 @@ /** Config Globals */ SG_BEGIN_DECL() -XBT_PUBLIC_DATA(xbt_cfg_t) _sg_cfg_set; +XBT_PUBLIC_DATA(xbt_cfg_t) simgrid_config; XBT_PUBLIC_DATA(int) _sg_cfg_init_status; XBT_PUBLIC_DATA(int) _sg_cfg_exit_asap; XBT_PUBLIC(int) sg_cfg_is_default_value(const char* name); diff --git a/src/instr/instr_TI_trace.cpp b/src/instr/instr_TI_trace.cpp index 84e1e73d5b..3d567cf88a 100644 --- a/src/instr/instr_TI_trace.cpp +++ b/src/instr/instr_TI_trace.cpp @@ -69,7 +69,7 @@ void print_TICreateContainer(paje_event_t event) prefix = xbt_os_time(); } - if (!xbt_cfg_get_boolean(_sg_cfg_set, "tracing/smpi/format/ti_one_file") || temp == NULL) { + if (!xbt_cfg_get_boolean("tracing/smpi/format/ti_one_file") || temp == NULL) { char *folder_name = bprintf("%s_files", TRACE_get_filename()); char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, ((createContainer_t) event->data)->container->name); #ifdef WIN32 @@ -78,8 +78,7 @@ void print_TICreateContainer(paje_event_t event) mkdir(folder_name, S_IRWXU | S_IRWXG | S_IRWXO); #endif temp = fopen(filename, "w"); - if (temp == NULL) - xbt_die("Tracefile %s could not be opened for writing: %s", filename, strerror(errno)); + xbt_assert(temp, "Tracefile %s could not be opened for writing: %s", filename, strerror(errno)); fprintf(tracing_file, "%s\n", filename); xbt_free(folder_name); @@ -91,7 +90,7 @@ void print_TICreateContainer(paje_event_t event) void print_TIDestroyContainer(paje_event_t event) { - if (!xbt_cfg_get_boolean(_sg_cfg_set, "tracing/smpi/format/ti_one_file")|| xbt_dict_length(tracing_files) == 1) { + if (!xbt_cfg_get_boolean("tracing/smpi/format/ti_one_file")|| xbt_dict_length(tracing_files) == 1) { FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, ((destroyContainer_t) event->data)->container->name); fclose(f); } diff --git a/src/instr/instr_config.cpp b/src/instr/instr_config.cpp index f3e0a571aa..7fb9f53aa7 100644 --- a/src/instr/instr_config.cpp +++ b/src/instr/instr_config.cpp @@ -65,26 +65,26 @@ static int trace_active = 0; static void TRACE_getopts(void) { - trace_enabled = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING); - trace_platform = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_PLATFORM); - trace_platform_topology = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_TOPOLOGY); - trace_smpi_enabled = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_SMPI); - trace_smpi_grouped = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_SMPI_GROUP); - trace_smpi_computing = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_SMPI_COMPUTING); - trace_smpi_sleeping = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_SMPI_SLEEPING); - trace_view_internals = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_SMPI_INTERNALS); - trace_categorized = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_CATEGORIZED); - trace_uncategorized = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_UNCATEGORIZED); - trace_msg_process_enabled = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_MSG_PROCESS); - trace_msg_vm_enabled = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_MSG_VM); - trace_buffer = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_BUFFER); - trace_onelink_only = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_ONELINK_ONLY); - trace_disable_destroy = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_DISABLE_DESTROY); - trace_basic = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_BASIC); - trace_display_sizes = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_DISPLAY_SIZES); - trace_disable_link = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_DISABLE_LINK); - trace_disable_power = xbt_cfg_get_boolean(_sg_cfg_set, OPT_TRACING_DISABLE_POWER); - trace_precision = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_PRECISION); + trace_enabled = xbt_cfg_get_boolean(OPT_TRACING); + trace_platform = xbt_cfg_get_boolean(OPT_TRACING_PLATFORM); + trace_platform_topology = xbt_cfg_get_boolean(OPT_TRACING_TOPOLOGY); + trace_smpi_enabled = xbt_cfg_get_boolean(OPT_TRACING_SMPI); + trace_smpi_grouped = xbt_cfg_get_boolean(OPT_TRACING_SMPI_GROUP); + trace_smpi_computing = xbt_cfg_get_boolean(OPT_TRACING_SMPI_COMPUTING); + trace_smpi_sleeping = xbt_cfg_get_boolean(OPT_TRACING_SMPI_SLEEPING); + trace_view_internals = xbt_cfg_get_boolean(OPT_TRACING_SMPI_INTERNALS); + trace_categorized = xbt_cfg_get_boolean(OPT_TRACING_CATEGORIZED); + trace_uncategorized = xbt_cfg_get_boolean(OPT_TRACING_UNCATEGORIZED); + trace_msg_process_enabled = xbt_cfg_get_boolean(OPT_TRACING_MSG_PROCESS); + trace_msg_vm_enabled = xbt_cfg_get_boolean(OPT_TRACING_MSG_VM); + trace_buffer = xbt_cfg_get_boolean(OPT_TRACING_BUFFER); + trace_onelink_only = xbt_cfg_get_boolean(OPT_TRACING_ONELINK_ONLY); + trace_disable_destroy = xbt_cfg_get_boolean(OPT_TRACING_DISABLE_DESTROY); + trace_basic = xbt_cfg_get_boolean(OPT_TRACING_BASIC); + trace_display_sizes = xbt_cfg_get_boolean(OPT_TRACING_DISPLAY_SIZES); + trace_disable_link = xbt_cfg_get_boolean(OPT_TRACING_DISABLE_LINK); + trace_disable_power = xbt_cfg_get_boolean(OPT_TRACING_DISABLE_POWER); + trace_precision = xbt_cfg_get_int(OPT_TRACING_PRECISION); } static xbt_dynar_t TRACE_start_functions = NULL; @@ -322,32 +322,32 @@ int TRACE_display_sizes (void) char *TRACE_get_comment (void) { - return xbt_cfg_get_string(_sg_cfg_set, OPT_TRACING_COMMENT); + return xbt_cfg_get_string(OPT_TRACING_COMMENT); } char *TRACE_get_comment_file (void) { - return xbt_cfg_get_string(_sg_cfg_set, OPT_TRACING_COMMENT_FILE); + return xbt_cfg_get_string(OPT_TRACING_COMMENT_FILE); } int TRACE_precision (void) { - return xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_PRECISION); + return xbt_cfg_get_int(OPT_TRACING_PRECISION); } char *TRACE_get_filename(void) { - return xbt_cfg_get_string(_sg_cfg_set, OPT_TRACING_FILENAME); + return xbt_cfg_get_string(OPT_TRACING_FILENAME); } char *TRACE_get_viva_uncat_conf (void) { - return xbt_cfg_get_string(_sg_cfg_set, OPT_VIVA_UNCAT_CONF); + return xbt_cfg_get_string(OPT_VIVA_UNCAT_CONF); } char *TRACE_get_viva_cat_conf (void) { - return xbt_cfg_get_string(_sg_cfg_set, OPT_VIVA_CAT_CONF); + return xbt_cfg_get_string(OPT_VIVA_CAT_CONF); } void TRACE_global_init(int *argc, char **argv) @@ -364,109 +364,31 @@ void TRACE_global_init(int *argc, char **argv) xbt_cfg_register_boolean(OPT_TRACING_SMPI, "Tracing of the SMPI interface.", "no", NULL); xbt_cfg_register_boolean(OPT_TRACING_SMPI_GROUP, "Group MPI processes by host.", "no", NULL); xbt_cfg_register_boolean(OPT_TRACING_SMPI_COMPUTING, "Generate states for timing out of SMPI parts of the application", "no", NULL); - -/* smpi sleeping */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_SMPI_SLEEPING, - "Generate states for timing out of SMPI parts of the application", xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_SMPI_SLEEPING, "no"); - - /* smpi internals */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_SMPI_INTERNALS, - "View internal messages sent by Collective communications in SMPI", xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_SMPI_INTERNALS, "no"); - - /* tracing categorized resource utilization traces */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_CATEGORIZED, - "Tracing categorized resource utilization of hosts and links.", xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_CATEGORIZED, "no"); - - /* tracing uncategorized resource utilization */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_UNCATEGORIZED, - "Tracing uncategorized resource utilization of hosts and links.", xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_UNCATEGORIZED, "no"); - - /* msg process */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_MSG_PROCESS, "Tracing of MSG process behavior.", - xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_MSG_PROCESS, "no"); - - /* msg process */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_MSG_VM, "Tracing of MSG process behavior.", - xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_MSG_VM, "no"); - - /* disable tracing link */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_DISABLE_LINK, "Do not trace link bandwidth and latency.", - xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_DISABLE_LINK, "no"); - - /* disable tracing link */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_DISABLE_POWER, "Do not trace host power.", xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_DISABLE_POWER, "no"); - - /* tracing buffer */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_BUFFER, "Buffer trace events to put them in temporal order.", - xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_BUFFER, "yes"); - - /* tracing one link only */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_ONELINK_ONLY, "Use only routes with one link to trace platform.", - xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_ONELINK_ONLY, "no"); - - /* disable destroy */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_DISABLE_DESTROY, "Disable platform containers destruction.", - xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_DISABLE_DESTROY, "no"); - - /* basic -- Avoid extended events (impoverished trace file) */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_BASIC, "Avoid extended events (impoverished trace file).", - xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_BASIC, "no"); - - /* display_sizes -- Extended events with message size information */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_DISPLAY_SIZES, - "(smpi only for now) Extended events with message size information", xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_DISPLAY_SIZES, "no"); - - /* format -- Switch the ouput format of Tracing */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_FORMAT, "(smpi only for now) Switch the output format of Tracing", - xbt_cfgelm_string, 1, 1, NULL); - xbt_cfg_setdefault_string(_sg_cfg_set, OPT_TRACING_FORMAT, "Paje"); - - /* format -- Switch the ouput format of Tracing */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_FORMAT_TI_ONEFILE, - "(smpi only for now) For replay format only : output to one file only", - xbt_cfgelm_boolean, 1, 1, NULL); - xbt_cfg_setdefault_boolean(_sg_cfg_set, OPT_TRACING_FORMAT_TI_ONEFILE, "no"); - - /* comment */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_COMMENT, "Comment to be added on the top of the trace file.", - xbt_cfgelm_string, 1, 1, NULL); - xbt_cfg_setdefault_string(_sg_cfg_set, OPT_TRACING_COMMENT, ""); - - /* comment_file */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_COMMENT_FILE, - "The contents of the file are added to the top of the trace file as comment.", - xbt_cfgelm_string, 1, 1, NULL); - xbt_cfg_setdefault_string(_sg_cfg_set, OPT_TRACING_COMMENT_FILE, ""); - - /* trace timestamp precision */ - xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_PRECISION, "Numerical precision used when timestamping events (hence " - "this value is expressed in number of digits after decimal point)", xbt_cfgelm_int, 1, 1, NULL); - xbt_cfg_setdefault_int(_sg_cfg_set, OPT_TRACING_PRECISION, 6); - - /* Viva graph configuration for uncategorized tracing */ - xbt_cfg_register(&_sg_cfg_set, OPT_VIVA_UNCAT_CONF, - "Viva Graph configuration file for uncategorized resource utilization traces.", - xbt_cfgelm_string, 1, 1, NULL); - xbt_cfg_setdefault_string(_sg_cfg_set, OPT_VIVA_UNCAT_CONF, ""); - + xbt_cfg_register_boolean(OPT_TRACING_SMPI_SLEEPING, "Generate states for timing out of SMPI parts of the application", "no", NULL); + xbt_cfg_register_boolean(OPT_TRACING_SMPI_INTERNALS, "View internal messages sent by Collective communications in SMPI", "no", NULL); + xbt_cfg_register_boolean(OPT_TRACING_CATEGORIZED, "Tracing categorized resource utilization of hosts and links.", "no", NULL); + xbt_cfg_register_boolean(OPT_TRACING_UNCATEGORIZED, "Tracing uncategorized resource utilization of hosts and links.", "no", NULL); + + xbt_cfg_register_boolean(OPT_TRACING_MSG_PROCESS, "Tracing of MSG process behavior.", "no", NULL); + xbt_cfg_register_boolean(OPT_TRACING_MSG_VM, "Tracing of MSG process behavior.", "no", NULL); + xbt_cfg_register_boolean(OPT_TRACING_DISABLE_LINK, "Do not trace link bandwidth and latency.", "no", NULL); + xbt_cfg_register_boolean(OPT_TRACING_DISABLE_POWER, "Do not trace host power.", "no", NULL); + xbt_cfg_register_boolean(OPT_TRACING_BUFFER, "Buffer trace events to put them in temporal order.", "yes", NULL); + + xbt_cfg_register_boolean(OPT_TRACING_ONELINK_ONLY, "Use only routes with one link to trace platform.", "no", NULL); + xbt_cfg_register_boolean(OPT_TRACING_DISABLE_DESTROY, "Disable platform containers destruction.", "no", NULL); + xbt_cfg_register_boolean(OPT_TRACING_BASIC, "Avoid extended events (impoverished trace file).", "no", NULL); + xbt_cfg_register_boolean(OPT_TRACING_DISPLAY_SIZES, "(smpi only) Extended events with message size information", "no", NULL); + xbt_cfg_register_string(OPT_TRACING_FORMAT, "(smpi only) Switch the output format of Tracing" ,"Paje", NULL); + xbt_cfg_register_boolean(OPT_TRACING_FORMAT_TI_ONEFILE, "(smpi only) For replay format only : output to one file only", "no", NULL); + xbt_cfg_register_string(OPT_TRACING_COMMENT, "Comment to be added on the top of the trace file.", "", NULL); + xbt_cfg_register_string(OPT_TRACING_COMMENT_FILE, + "The contents of the file are added to the top of the trace file as comment.", "", NULL); + xbt_cfg_register_int(OPT_TRACING_PRECISION, "Numerical precision used when timestamping events " + "(expressed in number of digits after decimal point)", 6, NULL); /* Viva graph configuration for uncategorized tracing */ - xbt_cfg_register(&_sg_cfg_set, OPT_VIVA_CAT_CONF, - "Viva Graph configuration file for categorized resource utilization traces.", - xbt_cfgelm_string, 1, 1, NULL); - xbt_cfg_setdefault_string(_sg_cfg_set, OPT_VIVA_CAT_CONF, ""); + xbt_cfg_register_string(OPT_VIVA_UNCAT_CONF, "Viva Graph configuration file for uncategorized resource utilization traces.", "", NULL); + xbt_cfg_register_string(OPT_VIVA_CAT_CONF, "Viva Graph configuration file for categorized resource utilization traces.", "", NULL); /* instrumentation can be considered configured now */ trace_configured = 1; diff --git a/src/mc/mc_config.cpp b/src/mc/mc_config.cpp index 09f8ec3670..336f0114e5 100644 --- a/src/mc/mc_config.cpp +++ b/src/mc/mc_config.cpp @@ -41,10 +41,9 @@ int _sg_mc_timeout = 0; void _mc_cfg_cb_timeout(const char *name, int pos) { if (_sg_cfg_init_status && !(_sg_do_model_check || MC_record_path)) - 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 bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); + 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 bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - _sg_mc_timeout = xbt_cfg_get_boolean(_sg_cfg_set, name); + _sg_mc_timeout = xbt_cfg_get_boolean(name); } #if HAVE_MC @@ -70,7 +69,7 @@ void _mc_cfg_cb_reduce(const char *name, int pos) xbt_die ("You are specifying a reduction strategy after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - char *val = xbt_cfg_get_string(_sg_cfg_set, name); + char *val = xbt_cfg_get_string(name); if (!strcasecmp(val, "none")) simgrid::mc::reduction_mode = simgrid::mc::ReductionMode::none; else if (!strcasecmp(val, "dpor")) @@ -86,14 +85,14 @@ void _mc_cfg_cb_checkpoint(const char *name, int pos) xbt_die ("You are specifying a checkpointing value after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - _sg_mc_checkpoint = xbt_cfg_get_int(_sg_cfg_set, name); + _sg_mc_checkpoint = xbt_cfg_get_int(name); } void _mc_cfg_cb_sparse_checkpoint(const char *name, int pos) { 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 bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - _sg_mc_sparse_checkpoint = xbt_cfg_get_boolean(_sg_cfg_set, name); + _sg_mc_sparse_checkpoint = xbt_cfg_get_boolean(name); } void _mc_cfg_cb_soft_dirty(const char *name, int pos) { @@ -103,7 +102,7 @@ void _mc_cfg_cb_soft_dirty(const char *name, int pos) { "at config time (through --cfg=model-check:1). " "This won't work, sorry."); - _sg_mc_soft_dirty = xbt_cfg_get_boolean(_sg_cfg_set, name); + _sg_mc_soft_dirty = xbt_cfg_get_boolean(name); } void _mc_cfg_cb_ksm(const char *name, int pos) @@ -111,7 +110,7 @@ void _mc_cfg_cb_ksm(const char *name, int pos) if (_sg_cfg_init_status && !_sg_do_model_check) xbt_die("You are specifying a KSM 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_ksm = xbt_cfg_get_boolean(_sg_cfg_set, name); + _sg_mc_ksm = xbt_cfg_get_boolean(name); } void _mc_cfg_cb_property(const char *name, int pos) @@ -120,7 +119,7 @@ void _mc_cfg_cb_property(const char *name, int pos) xbt_die ("You are specifying a property after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - _sg_mc_property_file = xbt_cfg_get_string(_sg_cfg_set, name); + _sg_mc_property_file = xbt_cfg_get_string(name); } void _mc_cfg_cb_hash(const char *name, int pos) @@ -129,7 +128,7 @@ void _mc_cfg_cb_hash(const char *name, int pos) xbt_die ("You are specifying a value to enable/disable the use of global hash to speedup state comparaison, but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - _sg_mc_hash = xbt_cfg_get_boolean(_sg_cfg_set, name); + _sg_mc_hash = xbt_cfg_get_boolean(name); } void _mc_cfg_cb_snapshot_fds(const char *name, int pos) @@ -138,7 +137,7 @@ void _mc_cfg_cb_snapshot_fds(const char *name, int pos) xbt_die ("You are specifying a value to enable/disable the use of FD snapshotting, but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - _sg_mc_snapshot_fds = xbt_cfg_get_boolean(_sg_cfg_set, name); + _sg_mc_snapshot_fds = xbt_cfg_get_boolean(name); } void _mc_cfg_cb_max_depth(const char *name, int pos) @@ -147,7 +146,7 @@ void _mc_cfg_cb_max_depth(const char *name, int pos) 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 bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - _sg_mc_max_depth = xbt_cfg_get_int(_sg_cfg_set, name); + _sg_mc_max_depth = xbt_cfg_get_int(name); } void _mc_cfg_cb_visited(const char *name, int pos) @@ -156,7 +155,7 @@ void _mc_cfg_cb_visited(const char *name, int pos) 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 bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - _sg_mc_visited = xbt_cfg_get_int(_sg_cfg_set, name); + _sg_mc_visited = xbt_cfg_get_int(name); } void _mc_cfg_cb_dot_output(const char *name, int pos) @@ -165,7 +164,7 @@ void _mc_cfg_cb_dot_output(const char *name, int pos) 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 bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - _sg_mc_dot_output_file = xbt_cfg_get_string(_sg_cfg_set, name); + _sg_mc_dot_output_file = xbt_cfg_get_string(name); } void _mc_cfg_cb_comms_determinism(const char *name, int pos) @@ -174,7 +173,7 @@ void _mc_cfg_cb_comms_determinism(const char *name, int pos) xbt_die ("You are specifying a value to enable/disable the detection of determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - _sg_mc_comms_determinism = xbt_cfg_get_boolean(_sg_cfg_set, name); + _sg_mc_comms_determinism = xbt_cfg_get_boolean(name); } void _mc_cfg_cb_send_determinism(const char *name, int pos) @@ -183,7 +182,7 @@ void _mc_cfg_cb_send_determinism(const char *name, int pos) xbt_die ("You are specifying a value to enable/disable the detection of send-determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - _sg_mc_send_determinism = xbt_cfg_get_boolean(_sg_cfg_set, name); + _sg_mc_send_determinism = xbt_cfg_get_boolean(name); } void _mc_cfg_cb_termination(const char *name, int pos) @@ -192,7 +191,7 @@ void _mc_cfg_cb_termination(const char *name, int pos) xbt_die ("You are specifying a value to enable/disable the detection of non progressive cycles after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); - _sg_mc_termination = xbt_cfg_get_boolean(_sg_cfg_set, name); + _sg_mc_termination = xbt_cfg_get_boolean(name); } #endif diff --git a/src/msg/msg_global.cpp b/src/msg/msg_global.cpp index bc81e86280..adc4fd47f5 100644 --- a/src/msg/msg_global.cpp +++ b/src/msg/msg_global.cpp @@ -23,7 +23,7 @@ static void MSG_exit(void); static void _sg_cfg_cb_msg_debug_multiple_use(const char *name, int pos) { - msg_global->debug_multiple_use = xbt_cfg_get_boolean(_sg_cfg_set, name); + msg_global->debug_multiple_use = xbt_cfg_get_boolean(name); } static void MSG_host_create_(sg_host_t host) @@ -45,10 +45,9 @@ void MSG_init_nocheck(int *argc, char **argv) { msg_global = xbt_new0(s_MSG_Global_t, 1); - xbt_cfg_register(&_sg_cfg_set, "msg/debug_multiple_use", - "Print backtraces of both processes when there is a conflict of multiple use of a task", - xbt_cfgelm_boolean, 1, 1, _sg_cfg_cb_msg_debug_multiple_use); - xbt_cfg_setdefault_boolean(_sg_cfg_set, "msg/debug_multiple_use", "no"); + xbt_cfg_register_boolean("msg/debug_multiple_use", + "Print backtraces of both processes when there is a conflict of multiple use of a task", + "no", _sg_cfg_cb_msg_debug_multiple_use); SIMIX_global_init(argc, argv); @@ -107,7 +106,7 @@ msg_error_t MSG_main(void) */ void MSG_config(const char *key, const char *value){ xbt_assert(msg_global,"ERROR: Please call MSG_init() before using MSG_config()"); - xbt_cfg_set_as_string(_sg_cfg_set, key, value); + xbt_cfg_set_as_string(key, value); } /** \ingroup msg_simulation diff --git a/src/simdag/sd_global.cpp b/src/simdag/sd_global.cpp index fe5e77966d..20476dcd06 100644 --- a/src/simdag/sd_global.cpp +++ b/src/simdag/sd_global.cpp @@ -47,7 +47,7 @@ void SD_init(int *argc, char **argv) surf_init(argc, argv); - xbt_cfg_setdefault_string(_sg_cfg_set, "host/model", "ptask_L07"); + xbt_cfg_setdefault_string("host/model", "ptask_L07"); #if HAVE_JEDULE jedule_sd_init(); @@ -69,7 +69,7 @@ void SD_init(int *argc, char **argv) */ void SD_config(const char *key, const char *value){ xbt_assert(sd_global,"ERROR: Please call SD_init() before using SD_config()"); - xbt_cfg_set_as_string(_sg_cfg_set, key, value); + xbt_cfg_set_as_string(key, value); } /** diff --git a/src/simgrid/sg_config.cpp b/src/simgrid/sg_config.cpp index a95f1b6f13..de7938f623 100644 --- a/src/simgrid/sg_config.cpp +++ b/src/simgrid/sg_config.cpp @@ -54,14 +54,14 @@ static void sg_config_cmd_line(int *argc, char **argv) opt = strchr(argv[i], '='); opt++; - xbt_cfg_set_parse(_sg_cfg_set, opt); + xbt_cfg_set_parse(simgrid_config, opt); XBT_DEBUG("Did apply '%s' as config setting", opt); } else if (!strcmp(argv[i], "--version")) { printf("%s\n", SIMGRID_VERSION_STRING); shall_exit = 1; } else if (!strcmp(argv[i], "--cfg-help") || !strcmp(argv[i], "--help")) { printf("Description of the configuration accepted by this simulator:\n"); - xbt_cfg_help(_sg_cfg_set); + xbt_cfg_help(simgrid_config); printf( "\n" "Each of these configurations can be used by adding\n" @@ -79,7 +79,7 @@ static void sg_config_cmd_line(int *argc, char **argv) shall_exit = 1; } else if (!strcmp(argv[i], "--help-aliases")) { printf("Here is a list of all deprecated option names, with their replacement.\n"); - xbt_cfg_aliases(_sg_cfg_set); + xbt_cfg_aliases(simgrid_config); printf("Please consider using the recent names\n"); shall_exit = 1; } else if (!strcmp(argv[i], "--help-models")) { @@ -115,14 +115,9 @@ static void sg_config_cmd_line(int *argc, char **argv) /* callback of the plugin variable */ static void _sg_cfg_cb__plugin(const char *name, int pos) { - char *val; - - XBT_VERB("PLUGIN"); - xbt_assert(_sg_cfg_init_status < 2, - "Cannot load a plugin after the initialization"); - - val = xbt_cfg_get_string(_sg_cfg_set, name); + xbt_assert(_sg_cfg_init_status < 2, "Cannot load a plugin after the initialization"); + char *val = xbt_cfg_get_string(name); if (!strcmp(val, "help")) { model_help("plugin", surf_plugin_description); sg_cfg_exit_early(); @@ -136,13 +131,9 @@ static void _sg_cfg_cb__plugin(const char *name, int pos) /* callback of the host/model variable */ static void _sg_cfg_cb__host_model(const char *name, int pos) { - char *val; - - xbt_assert(_sg_cfg_init_status < 2, - "Cannot change the model after the initialization"); - - val = xbt_cfg_get_string(_sg_cfg_set, name); + xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization"); + char *val = xbt_cfg_get_string(name); if (!strcmp(val, "help")) { model_help("host", surf_host_model_description); sg_cfg_exit_early(); @@ -155,13 +146,9 @@ static void _sg_cfg_cb__host_model(const char *name, int pos) /* callback of the vm/model variable */ static void _sg_cfg_cb__vm_model(const char *name, int pos) { - char *val; - - xbt_assert(_sg_cfg_init_status < 2, - "Cannot change the model after the initialization"); - - val = xbt_cfg_get_string(_sg_cfg_set, name); + xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization"); + char *val = xbt_cfg_get_string(name); if (!strcmp(val, "help")) { model_help("vm", surf_vm_model_description); sg_cfg_exit_early(); @@ -174,13 +161,9 @@ static void _sg_cfg_cb__vm_model(const char *name, int pos) /* callback of the cpu/model variable */ static void _sg_cfg_cb__cpu_model(const char *name, int pos) { - char *val; - - xbt_assert(_sg_cfg_init_status < 2, - "Cannot change the model after the initialization"); - - val = xbt_cfg_get_string(_sg_cfg_set, name); + xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization"); + char *val = xbt_cfg_get_string(name); if (!strcmp(val, "help")) { model_help("CPU", surf_cpu_model_description); sg_cfg_exit_early(); @@ -198,7 +181,7 @@ static void _sg_cfg_cb__optimization_mode(const char *name, int pos) xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization"); - val = xbt_cfg_get_string(_sg_cfg_set, name); + val = xbt_cfg_get_string(name); if (!strcmp(val, "help")) { model_help("optimization", surf_optimization_mode_description); @@ -217,7 +200,7 @@ static void _sg_cfg_cb__storage_mode(const char *name, int pos) xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization"); - val = xbt_cfg_get_string(_sg_cfg_set, name); + val = xbt_cfg_get_string(name); if (!strcmp(val, "help")) { model_help("storage", surf_storage_model_description); @@ -236,7 +219,7 @@ static void _sg_cfg_cb__network_model(const char *name, int pos) xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization"); - val = xbt_cfg_get_string(_sg_cfg_set, name); + val = xbt_cfg_get_string(name); if (!strcmp(val, "help")) { model_help("network", surf_network_model_description); @@ -250,37 +233,37 @@ static void _sg_cfg_cb__network_model(const char *name, int pos) /* callbacks of the network models values */ static void _sg_cfg_cb__tcp_gamma(const char *name, int pos) { - sg_tcp_gamma = xbt_cfg_get_double(_sg_cfg_set, name); + sg_tcp_gamma = xbt_cfg_get_double(name); } static void _sg_cfg_cb__maxmin_precision(const char* name, int pos) { - sg_maxmin_precision = xbt_cfg_get_double(_sg_cfg_set, name); + sg_maxmin_precision = xbt_cfg_get_double(name); } static void _sg_cfg_cb__surf_precision(const char* name, int pos) { - sg_surf_precision = xbt_cfg_get_double(_sg_cfg_set, name); + sg_surf_precision = xbt_cfg_get_double(name); } static void _sg_cfg_cb__sender_gap(const char* name, int pos) { - sg_sender_gap = xbt_cfg_get_double(_sg_cfg_set, name); + sg_sender_gap = xbt_cfg_get_double(name); } static void _sg_cfg_cb__latency_factor(const char *name, int pos) { - sg_latency_factor = xbt_cfg_get_double(_sg_cfg_set, name); + sg_latency_factor = xbt_cfg_get_double(name); } static void _sg_cfg_cb__bandwidth_factor(const char *name, int pos) { - sg_bandwidth_factor = xbt_cfg_get_double(_sg_cfg_set, name); + sg_bandwidth_factor = xbt_cfg_get_double(name); } static void _sg_cfg_cb__weight_S(const char *name, int pos) { - sg_weight_S_parameter = xbt_cfg_get_double(_sg_cfg_set, name); + sg_weight_S_parameter = xbt_cfg_get_double(name); } #if HAVE_SMPI @@ -294,7 +277,7 @@ static void _sg_cfg_cb__coll(const char *category, xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization"); - val = xbt_cfg_get_string(_sg_cfg_set, name); + val = xbt_cfg_get_string(name); if (!strcmp(val, "help")) { coll_help(category, table); @@ -344,15 +327,15 @@ static void _sg_cfg_cb__coll_barrier(const char *name, int pos){ } static void _sg_cfg_cb__wtime_sleep(const char *name, int pos){ - smpi_wtime_sleep = xbt_cfg_get_double(_sg_cfg_set, name); + smpi_wtime_sleep = xbt_cfg_get_double(name); } static void _sg_cfg_cb__iprobe_sleep(const char *name, int pos){ - smpi_iprobe_sleep = xbt_cfg_get_double(_sg_cfg_set, name); + smpi_iprobe_sleep = xbt_cfg_get_double(name); } static void _sg_cfg_cb__test_sleep(const char *name, int pos){ - smpi_test_sleep = xbt_cfg_get_double(_sg_cfg_set, name); + smpi_test_sleep = xbt_cfg_get_double(name); } @@ -362,7 +345,7 @@ static void _sg_cfg_cb__test_sleep(const char *name, int pos){ /* callback of the inclusion path */ static void _sg_cfg_cb__surf_path(const char *name, int pos) { - char *path = xbt_strdup(xbt_cfg_get_string_at(_sg_cfg_set, name, pos)); + char *path = xbt_strdup(xbt_cfg_get_string_at(simgrid_config, name, pos)); xbt_dynar_push(surf_path, &path); } @@ -375,12 +358,12 @@ extern int _sg_do_model_check_record; #endif static void _sg_cfg_cb_model_check_replay(const char *name, int pos) { - MC_record_path = xbt_cfg_get_string(_sg_cfg_set, name); + MC_record_path = xbt_cfg_get_string(name); } #if HAVE_MC static void _sg_cfg_cb_model_check_record(const char *name, int pos) { - _sg_do_model_check_record = xbt_cfg_get_boolean(_sg_cfg_set, name); + _sg_do_model_check_record = xbt_cfg_get_boolean(name); } #endif @@ -388,46 +371,46 @@ extern int _sg_do_verbose_exit; static void _sg_cfg_cb_verbose_exit(const char *name, int pos) { - _sg_do_verbose_exit = xbt_cfg_get_boolean(_sg_cfg_set, name); + _sg_do_verbose_exit = xbt_cfg_get_boolean(name); } extern int _sg_do_clean_atexit; static void _sg_cfg_cb_clean_atexit(const char *name, int pos) { - _sg_do_clean_atexit = xbt_cfg_get_boolean(_sg_cfg_set, name); + _sg_do_clean_atexit = xbt_cfg_get_boolean(name); } static void _sg_cfg_cb_context_factory(const char *name, int pos) { - smx_context_factory_name = xbt_cfg_get_string(_sg_cfg_set, name); + smx_context_factory_name = xbt_cfg_get_string(name); } static void _sg_cfg_cb_context_stack_size(const char *name, int pos) { smx_context_stack_size_was_set = 1; - smx_context_stack_size = xbt_cfg_get_int(_sg_cfg_set, name) * 1024; + smx_context_stack_size = xbt_cfg_get_int(name) * 1024; } static void _sg_cfg_cb_context_guard_size(const char *name, int pos) { smx_context_guard_size_was_set = 1; - smx_context_guard_size = xbt_cfg_get_int(_sg_cfg_set, name) * xbt_pagesize; + smx_context_guard_size = xbt_cfg_get_int(name) * xbt_pagesize; } static void _sg_cfg_cb_contexts_nthreads(const char *name, int pos) { - SIMIX_context_set_nthreads(xbt_cfg_get_int(_sg_cfg_set, name)); + SIMIX_context_set_nthreads(xbt_cfg_get_int(name)); } static void _sg_cfg_cb_contexts_parallel_threshold(const char *name, int pos) { - SIMIX_context_set_parallel_threshold(xbt_cfg_get_int(_sg_cfg_set, name)); + SIMIX_context_set_parallel_threshold(xbt_cfg_get_int(name)); } static void _sg_cfg_cb_contexts_parallel_mode(const char *name, int pos) { - const char* mode_name = xbt_cfg_get_string(_sg_cfg_set, name); + const char* mode_name = xbt_cfg_get_string(name); if (!strcmp(mode_name, "posix")) { SIMIX_context_set_parallel_mode(XBT_PARMAP_POSIX); } @@ -447,7 +430,7 @@ static void _sg_cfg_cb__surf_network_coordinates(const char *name, int pos) { static int already_set = 0; - int val = xbt_cfg_get_boolean(_sg_cfg_set, name); + int val = xbt_cfg_get_boolean(name); if (val) { if (!already_set) { COORD_HOST_LEVEL = sg_host_extension_create(xbt_dynar_free_voidp); @@ -462,7 +445,7 @@ static void _sg_cfg_cb__surf_network_coordinates(const char *name, static void _sg_cfg_cb__surf_network_crosstraffic(const char *name, int pos) { - sg_network_crosstraffic = xbt_cfg_get_boolean(_sg_cfg_set, name); + sg_network_crosstraffic = xbt_cfg_get_boolean(name); } /* build description line with possible values */ @@ -491,10 +474,8 @@ void sg_config_init(int *argc, char **argv) if (_sg_cfg_init_status == 0) { /* Only create stuff if not already inited */ /* Plugins configuration */ - describe_model(description, surf_plugin_description, - "plugin", "The plugins"); - xbt_cfg_register(&_sg_cfg_set, "plugin", description, - xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__plugin); + describe_model(description, surf_plugin_description, "plugin", "The plugins"); + xbt_cfg_register(&simgrid_config, "plugin", description, xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__plugin); describe_model(description, surf_cpu_model_description, "model", "The model to use for the CPU"); xbt_cfg_register_string("cpu/model", description, "Cas01", &_sg_cfg_cb__cpu_model); @@ -540,7 +521,7 @@ void sg_config_init(int *argc, char **argv) NAN, _sg_cfg_cb__weight_S); /* real default for "network/weight_S" is set in network_*.cpp */ /* Inclusion path */ - xbt_cfg_register(&_sg_cfg_set, "path", "Lookup path for inclusions in platform and deployment XML files", + xbt_cfg_register(&simgrid_config, "path", "Lookup path for inclusions in platform and deployment XML files", xbt_cfgelm_string, 1, 0, _sg_cfg_cb__surf_path); xbt_cfg_register_boolean("cpu/maxmin_selective_update", @@ -550,7 +531,7 @@ void sg_config_init(int *argc, char **argv) "Update the constraint set propagating recursively to others constraints (off by default when optim is set to lazy)", "no", NULL); /* Replay (this part is enabled even if MC it disabled) */ - xbt_cfg_register(&_sg_cfg_set, "model-check/replay", "Enable replay mode with the given path", xbt_cfgelm_string, 0, 1, _sg_cfg_cb_model_check_replay); + xbt_cfg_register(&simgrid_config, "model-check/replay", "Enable replay mode with the given path", xbt_cfgelm_string, 0, 1, _sg_cfg_cb_model_check_replay); #if HAVE_MC /* do model-checking-record */ @@ -682,52 +663,49 @@ void sg_config_init(int *argc, char **argv) xbt_cfg_register_double("smpi/test", "Minimum time to inject inside a call to MPI_Test", 1e-4, _sg_cfg_cb__test_sleep); xbt_cfg_register_double("smpi/wtime", "Minimum time to inject inside a call to MPI_Wtime", 0.0, _sg_cfg_cb__wtime_sleep); - xbt_cfg_register(&_sg_cfg_set, "smpi/coll_selector", - "Which collective selector to use", - xbt_cfgelm_string, 1, 1, NULL); - xbt_cfg_setdefault_string(_sg_cfg_set, "smpi/coll_selector", "default"); + xbt_cfg_register_string("smpi/coll_selector", "Which collective selector to use", "default", NULL); - xbt_cfg_register(&_sg_cfg_set, "smpi/gather", + xbt_cfg_register(&simgrid_config, "smpi/gather", "Which collective to use for gather", xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_gather); - xbt_cfg_register(&_sg_cfg_set, "smpi/allgather", + xbt_cfg_register(&simgrid_config, "smpi/allgather", "Which collective to use for allgather", xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_allgather); - xbt_cfg_register(&_sg_cfg_set, "smpi/barrier", + xbt_cfg_register(&simgrid_config, "smpi/barrier", "Which collective to use for barrier", xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_barrier); - xbt_cfg_register(&_sg_cfg_set, "smpi/reduce_scatter", + xbt_cfg_register(&simgrid_config, "smpi/reduce_scatter", "Which collective to use for reduce_scatter", xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_reduce_scatter); - xbt_cfg_register(&_sg_cfg_set, "smpi/scatter", + xbt_cfg_register(&simgrid_config, "smpi/scatter", "Which collective to use for scatter", xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_scatter); - xbt_cfg_register(&_sg_cfg_set, "smpi/allgatherv", + xbt_cfg_register(&simgrid_config, "smpi/allgatherv", "Which collective to use for allgatherv", xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_allgatherv); - xbt_cfg_register(&_sg_cfg_set, "smpi/allreduce", + xbt_cfg_register(&simgrid_config, "smpi/allreduce", "Which collective to use for allreduce", xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_allreduce); - xbt_cfg_register(&_sg_cfg_set, "smpi/alltoall", + xbt_cfg_register(&simgrid_config, "smpi/alltoall", "Which collective to use for alltoall", xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_alltoall); - xbt_cfg_register(&_sg_cfg_set, "smpi/alltoallv", + xbt_cfg_register(&simgrid_config, "smpi/alltoallv", "Which collective to use for alltoallv", xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_alltoallv); - xbt_cfg_register(&_sg_cfg_set, "smpi/bcast", + xbt_cfg_register(&simgrid_config, "smpi/bcast", "Which collective to use for bcast", xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_bcast); - xbt_cfg_register(&_sg_cfg_set, "smpi/reduce", + xbt_cfg_register(&simgrid_config, "smpi/reduce", "Which collective to use for reduce", xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_reduce); #endif // HAVE_SMPI @@ -743,10 +721,10 @@ void sg_config_init(int *argc, char **argv) xbt_assert((initial_path), "__surf_get_initial_path() failed! Can't resolve current Windows directory"); surf_path = xbt_dynar_new(sizeof(char *), &xbt_free_ref); - xbt_cfg_setdefault_string(_sg_cfg_set, "path", initial_path); + xbt_cfg_setdefault_string("path", initial_path); } - xbt_cfg_check(_sg_cfg_set); + xbt_cfg_check(simgrid_config); _sg_cfg_init_status = 1; sg_config_cmd_line(argc, argv); @@ -762,36 +740,36 @@ void sg_config_finalize(void) if (!_sg_cfg_init_status) return; /* Not initialized yet. Nothing to do */ - xbt_cfg_free(&_sg_cfg_set); + xbt_cfg_free(&simgrid_config); _sg_cfg_init_status = 0; } int sg_cfg_is_default_value(const char *name) { - return xbt_cfg_is_default_value(_sg_cfg_set, name); + return xbt_cfg_is_default_value(name); } int sg_cfg_get_int(const char* name) { - return xbt_cfg_get_int(_sg_cfg_set, name); + return xbt_cfg_get_int(name); } double sg_cfg_get_double(const char* name) { - return xbt_cfg_get_double(_sg_cfg_set, name); + return xbt_cfg_get_double(name); } char* sg_cfg_get_string(const char* name) { - return xbt_cfg_get_string(_sg_cfg_set, name); + return xbt_cfg_get_string(name); } int sg_cfg_get_boolean(const char* name) { - return xbt_cfg_get_boolean(_sg_cfg_set, name); + return xbt_cfg_get_boolean(name); } xbt_dynar_t sg_cfg_get_dynar(const char* name) { - return xbt_cfg_get_dynar(_sg_cfg_set, name); + return xbt_cfg_get_dynar(name); } diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 0469a17199..9c1caf42b7 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -19,7 +19,7 @@ void surf_cpu_model_init_Cas01() xbt_assert(!surf_cpu_model_pm); xbt_assert(!surf_cpu_model_vm); - char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim"); + char *optim = xbt_cfg_get_string("cpu/optim"); if (!strcmp(optim, "TI")) { surf_cpu_model_init_ti(); return; @@ -37,8 +37,8 @@ namespace surf { CpuCas01Model::CpuCas01Model() : simgrid::surf::CpuModel() { - char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim"); - int select = xbt_cfg_get_boolean(_sg_cfg_set, "cpu/maxmin_selective_update"); + char *optim = xbt_cfg_get_string("cpu/optim"); + int select = xbt_cfg_get_boolean("cpu/maxmin_selective_update"); if (!strcmp(optim, "Full")) { updateMechanism_ = UM_FULL; @@ -47,9 +47,7 @@ CpuCas01Model::CpuCas01Model() : simgrid::surf::CpuModel() updateMechanism_ = UM_LAZY; selectiveUpdate_ = 1; xbt_assert((select == 1) - || - (xbt_cfg_is_default_value - (_sg_cfg_set, "cpu/maxmin_selective_update")), + || (xbt_cfg_is_default_value("cpu/maxmin_selective_update")), "Disabling selective update while using the lazy update mechanism is dumb!"); } else { xbt_die("Unsupported optimization (%s) for this model", optim); diff --git a/src/surf/host_clm03.cpp b/src/surf/host_clm03.cpp index c240e0ebfb..42e6792cb6 100644 --- a/src/surf/host_clm03.cpp +++ b/src/surf/host_clm03.cpp @@ -27,7 +27,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_host); void surf_host_model_init_current_default(void) { surf_host_model = new simgrid::surf::HostCLM03Model(); - xbt_cfg_setdefault_boolean(_sg_cfg_set, "network/crosstraffic", "yes"); + xbt_cfg_setdefault_boolean("network/crosstraffic", "yes"); surf_cpu_model_init_Cas01(); surf_network_model_init_LegrandVelho(); diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 839cea3413..cbdf472100 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -43,9 +43,9 @@ void surf_network_model_init_LegrandVelho(void) surf_network_model = new simgrid::surf::NetworkCm02Model(); xbt_dynar_push(all_existing_models, &surf_network_model); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 13.01); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", 0.97); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 20537); + xbt_cfg_setdefault_double("network/latency_factor", 13.01); + xbt_cfg_setdefault_double("network/bandwidth_factor", 0.97); + xbt_cfg_setdefault_double("network/weight_S", 20537); } /***************************************************************************/ @@ -68,9 +68,9 @@ void surf_network_model_init_CM02(void) surf_network_model = new simgrid::surf::NetworkCm02Model(); xbt_dynar_push(all_existing_models, &surf_network_model); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 1.0); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", 1.0); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 0.0); + xbt_cfg_setdefault_double("network/latency_factor", 1.0); + xbt_cfg_setdefault_double("network/bandwidth_factor", 1.0); + xbt_cfg_setdefault_double("network/weight_S", 0.0); } /***************************************************************************/ @@ -94,9 +94,9 @@ void surf_network_model_init_Reno(void) lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi); surf_network_model->f_networkSolve = lagrange_solve; - xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 10.4); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", 0.92); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775); + xbt_cfg_setdefault_double("network/latency_factor", 10.4); + xbt_cfg_setdefault_double("network/bandwidth_factor", 0.92); + xbt_cfg_setdefault_double("network/weight_S", 8775); } @@ -111,9 +111,9 @@ void surf_network_model_init_Reno2(void) lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp, func_reno2_fpi); surf_network_model->f_networkSolve = lagrange_solve; - xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 10.4); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", 0.92); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775); + xbt_cfg_setdefault_double("network/latency_factor", 10.4); + xbt_cfg_setdefault_double("network/bandwidth_factor", 0.92); + xbt_cfg_setdefault_double("network/weight_S", 8775); } void surf_network_model_init_Vegas(void) @@ -127,9 +127,9 @@ void surf_network_model_init_Vegas(void) lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp, func_vegas_fpi); surf_network_model->f_networkSolve = lagrange_solve; - xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 10.4); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", 0.92); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775); + xbt_cfg_setdefault_double("network/latency_factor", 10.4); + xbt_cfg_setdefault_double("network/bandwidth_factor", 0.92); + xbt_cfg_setdefault_double("network/weight_S", 8775); } namespace simgrid { @@ -138,8 +138,8 @@ namespace surf { NetworkCm02Model::NetworkCm02Model() :NetworkModel() { - char *optim = xbt_cfg_get_string(_sg_cfg_set, "network/optim"); - int select = xbt_cfg_get_boolean(_sg_cfg_set, "network/maxmin_selective_update"); + char *optim = xbt_cfg_get_string("network/optim"); + int select = xbt_cfg_get_boolean("network/maxmin_selective_update"); if (!strcmp(optim, "Full")) { updateMechanism_ = UM_FULL; @@ -147,7 +147,7 @@ NetworkCm02Model::NetworkCm02Model() } else if (!strcmp(optim, "Lazy")) { updateMechanism_ = UM_LAZY; selectiveUpdate_ = 1; - xbt_assert((select == 1) || (xbt_cfg_is_default_value(_sg_cfg_set, "network/maxmin_selective_update")), + xbt_assert((select == 1) || (xbt_cfg_is_default_value("network/maxmin_selective_update")), "Disabling selective update while using the lazy update mechanism is dumb!"); } else { xbt_die("Unsupported optimization (%s) for this model", optim); diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index 2fe2e3e2c0..b39302cb2d 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -90,7 +90,7 @@ void surf_network_model_init_IB(void) networkActionStateChangedCallbacks.connect(IB_action_state_changed_callback); Link::onCommunicate.connect(IB_action_init_callback); simgrid::s4u::Host::onCreation.connect(IB_create_host_callback); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775); + xbt_cfg_setdefault_double("network/weight_S", 8775); } diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index cde72ac619..903bdff959 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -219,7 +219,7 @@ namespace simgrid { namespace surf { NetworkNS3Model::NetworkNS3Model() : NetworkModel() { - ns3_initialize(xbt_cfg_get_string(_sg_cfg_set, "ns3/TcpModel")); + ns3_initialize(xbt_cfg_get_string("ns3/TcpModel")); routing_model_create(NULL); simgrid::s4u::Host::onCreation.connect(ns3_add_host); diff --git a/src/surf/network_smpi.cpp b/src/surf/network_smpi.cpp index 228390bd1e..7899183641 100644 --- a/src/surf/network_smpi.cpp +++ b/src/surf/network_smpi.cpp @@ -91,8 +91,8 @@ void surf_network_model_init_SMPI(void) surf_network_model = new simgrid::surf::NetworkSmpiModel(); xbt_dynar_push(all_existing_models, &surf_network_model); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/sender_gap", 10e-6); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775); + xbt_cfg_setdefault_double("network/sender_gap", 10e-6); + xbt_cfg_setdefault_double("network/weight_S", 8775); } namespace simgrid { diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 9fa57c7a29..112e18527a 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -725,22 +725,22 @@ static void surf_config_models_setup() int storage_id = -1; char *storage_model_name = NULL; - host_model_name = xbt_cfg_get_string(_sg_cfg_set, "host/model"); - vm_model_name = xbt_cfg_get_string(_sg_cfg_set, "vm/model"); - network_model_name = xbt_cfg_get_string(_sg_cfg_set, "network/model"); - cpu_model_name = xbt_cfg_get_string(_sg_cfg_set, "cpu/model"); - storage_model_name = xbt_cfg_get_string(_sg_cfg_set, "storage/model"); + host_model_name = xbt_cfg_get_string("host/model"); + vm_model_name = xbt_cfg_get_string("vm/model"); + network_model_name = xbt_cfg_get_string("network/model"); + cpu_model_name = xbt_cfg_get_string("cpu/model"); + storage_model_name = xbt_cfg_get_string("storage/model"); /* Check whether we use a net/cpu model differing from the default ones, in which case * we should switch to the "compound" host model to correctly dispatch stuff to * the right net/cpu models. */ - if ((!xbt_cfg_is_default_value(_sg_cfg_set, "network/model") || - !xbt_cfg_is_default_value(_sg_cfg_set, "cpu/model")) && - xbt_cfg_is_default_value(_sg_cfg_set, "host/model")) { + if ((!xbt_cfg_is_default_value("network/model") || + !xbt_cfg_is_default_value("cpu/model")) && + xbt_cfg_is_default_value("host/model")) { host_model_name = "compound"; - xbt_cfg_set_string(_sg_cfg_set, "host/model", host_model_name); + xbt_cfg_set_string("host/model", host_model_name); } XBT_DEBUG("host model: %s", host_model_name); diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index 056620d6d9..63c8c76335 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -903,8 +903,8 @@ void ETag_surfxml_config(void){ char *cfg; xbt_dict_foreach(current_property_set, cursor, key, elem) { cfg = bprintf("%s:%s",key,elem); - if(xbt_cfg_is_default_value(_sg_cfg_set, key)) - xbt_cfg_set_parse(_sg_cfg_set, cfg); + if(xbt_cfg_is_default_value(key)) + xbt_cfg_set_parse(simgrid_config, cfg); else XBT_INFO("The custom configuration '%s' is already defined by user!",key); free(cfg); diff --git a/src/xbt/config.c b/src/xbt/config.c index b87106d322..a3e59df120 100644 --- a/src/xbt/config.c +++ b/src/xbt/config.c @@ -21,7 +21,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_cfg, xbt, "configuration support"); -xbt_cfg_t _sg_cfg_set = NULL; +xbt_cfg_t simgrid_config = NULL; /* xbt_cfgelm_t: the typedef corresponding to a config variable. @@ -239,31 +239,31 @@ void xbt_cfg_register(xbt_cfg_t * cfg, const char *name, const char *desc, e_xbt } void xbt_cfg_register_double(const char *name, const char *desc, double default_value,xbt_cfg_cb_t cb_set){ - xbt_cfg_register(_sg_cfg_set,name,desc,xbt_cfgelm_double,1,1,cb_set); - xbt_cfg_setdefault_double(_sg_cfg_set, name, default_value); + xbt_cfg_register(simgrid_config,name,desc,xbt_cfgelm_double,1,1,cb_set); + xbt_cfg_setdefault_double(name, default_value); } void xbt_cfg_register_int(const char *name, const char *desc, int default_value,xbt_cfg_cb_t cb_set){ - xbt_cfg_register(_sg_cfg_set,name,desc,xbt_cfgelm_int,1,1,cb_set); - xbt_cfg_setdefault_int(_sg_cfg_set, name, default_value); + xbt_cfg_register(simgrid_config,name,desc,xbt_cfgelm_int,1,1,cb_set); + xbt_cfg_setdefault_int(name, default_value); } void xbt_cfg_register_string(const char *name, const char *desc, const char *default_value, xbt_cfg_cb_t cb_set){ - xbt_cfg_register(_sg_cfg_set,name,desc,xbt_cfgelm_string,1,1,cb_set); - xbt_cfg_setdefault_string(_sg_cfg_set, name, default_value); + xbt_cfg_register(simgrid_config,name,desc,xbt_cfgelm_string,1,1,cb_set); + xbt_cfg_setdefault_string(name, default_value); } void xbt_cfg_register_boolean(const char *name, const char *desc, const char*default_value,xbt_cfg_cb_t cb_set){ - xbt_cfg_register(_sg_cfg_set,name,desc,xbt_cfgelm_boolean,1,1,cb_set); - xbt_cfg_setdefault_boolean(_sg_cfg_set, name, default_value); + xbt_cfg_register(simgrid_config,name,desc,xbt_cfgelm_boolean,1,1,cb_set); + xbt_cfg_setdefault_boolean(name, default_value); } void xbt_cfg_register_alias(const char *newname, const char *oldname) { - if (_sg_cfg_set == NULL) - _sg_cfg_set = xbt_cfg_new(); + if (simgrid_config == NULL) + simgrid_config = xbt_cfg_new(); - xbt_cfgelm_t res = xbt_dict_get_or_null(_sg_cfg_set, oldname); + xbt_cfgelm_t res = xbt_dict_get_or_null(simgrid_config, oldname); xbt_assert(NULL == res, "Refusing to register the option '%s' twice.", oldname); - res = xbt_dict_get_or_null(_sg_cfg_set, newname); + res = xbt_dict_get_or_null(simgrid_config, newname); xbt_assert(res, "Cannot define an alias to the non-existing option '%s'.", newname); res = xbt_new0(s_xbt_cfgelm_t, 1); @@ -276,7 +276,7 @@ void xbt_cfg_register_alias(const char *newname, const char *oldname) res->isdefault = 1; res->content = (xbt_dynar_t)newname; - xbt_dict_set(_sg_cfg_set, oldname, res, NULL); + xbt_dict_set(simgrid_config, oldname, res, NULL); } /** @brief Unregister an element from a config set. @@ -537,19 +537,19 @@ void xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name, va_list pa) switch (type) { case xbt_cfgelm_string: str = va_arg(pa, char *); - xbt_cfg_set_string(cfg, name, str); + xbt_cfg_set_string(name, str); break; case xbt_cfgelm_int: i = va_arg(pa, int); - xbt_cfg_set_int(cfg, name, i); + xbt_cfg_set_int(name, i); break; case xbt_cfgelm_double: d = va_arg(pa, double); - xbt_cfg_set_double(cfg, name, d); + xbt_cfg_set_double(name, d); break; case xbt_cfgelm_boolean: str = va_arg(pa, char *); - xbt_cfg_set_boolean(cfg, name, str); + xbt_cfg_set_boolean(name, str); break; default: xbt_die("Config element variable %s not valid (type=%d)", name, (int)type); @@ -580,24 +580,20 @@ void xbt_cfg_set(xbt_cfg_t cfg, const char *name, ...) * * @todo This is a crude manual parser, it should be a proper lexer. */ -void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) { - char *optionlist_cpy; - char *option, *name, *val; - int len; - - XBT_IN(); +void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) +{ if (!options || !strlen(options)) { /* nothing to do */ return; } - optionlist_cpy = xbt_strdup(options); + char *optionlist_cpy = xbt_strdup(options); XBT_DEBUG("List to parse and set:'%s'", options); - option = optionlist_cpy; + char *option = optionlist_cpy; while (1) { /* breaks in the code */ if (!option) break; - name = option; - len = strlen(name); + char *name = option; + int len = strlen(name); XBT_DEBUG("Still to parse and set: '%s'. len=%d; option-name=%ld", name, len, (long) (option - name)); /* Pass the value */ @@ -626,18 +622,16 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) { if (!strlen(name)) break; - val = strchr(name, ':'); - if (!val) { - /* don't free(optionlist_cpy) here, 'name' points inside it */ - xbt_die("Option '%s' badly formatted. Should be of the form 'name:value'", name); - } + char *val = strchr(name, ':'); + xbt_assert(val, "Option '%s' badly formatted. Should be of the form 'name:value'", name); + /* don't free(optionlist_cpy) if the assert fails, 'name' points inside it */ *(val++) = '\0'; if (strncmp(name, "contexts/", strlen("contexts/")) && strncmp(name, "path", strlen("path"))) XBT_INFO("Configuration change: Set '%s' to '%s'", name, val); TRY { - xbt_cfg_set_as_string(cfg,name,val); + xbt_cfg_set_as_string(name,val); } CATCH_ANONYMOUS { free(optionlist_cpy); RETHROW; @@ -648,14 +642,13 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) { /** @brief Set the value of a variable, using the string representation of that value * - * @param cfg config set to modify * @param key name of the variable to modify * @param value string representation of the value to set * * @return the first char after the parsed value in val */ -void *xbt_cfg_set_as_string(xbt_cfg_t cfg, const char *key, const char *value) { +void *xbt_cfg_set_as_string(const char *key, const char *value) { xbt_ex_t e; char *ret; @@ -665,7 +658,7 @@ void *xbt_cfg_set_as_string(xbt_cfg_t cfg, const char *key, const char *value) { TRY { while (variable == NULL) { - variable = xbt_dict_get((xbt_dict_t) cfg, key); + variable = xbt_dict_get((xbt_dict_t) simgrid_config, key); if (variable->type == xbt_cfgelm_alias) { const char *newname = (const char*)variable->content; XBT_INFO("Note: configuration '%s' is deprecated. Please use '%s' instead.", key, newname); @@ -683,24 +676,24 @@ void *xbt_cfg_set_as_string(xbt_cfg_t cfg, const char *key, const char *value) { switch (variable->type) { case xbt_cfgelm_string: - xbt_cfg_set_string(cfg, key, value); /* throws */ + xbt_cfg_set_string(key, value); /* throws */ break; case xbt_cfgelm_int: i = strtol(value, &ret, 0); if (ret == value) { xbt_die("Value of option %s not valid. Should be an integer", key); } - xbt_cfg_set_int(cfg, key, i); /* throws */ + xbt_cfg_set_int(key, i); /* throws */ break; case xbt_cfgelm_double: d = strtod(value, &ret); if (ret == value) { xbt_die("Value of option %s not valid. Should be a double", key); } - xbt_cfg_set_double(cfg, key, d); /* throws */ + xbt_cfg_set_double(key, d); /* throws */ break; case xbt_cfgelm_boolean: - xbt_cfg_set_boolean(cfg, key, value); /* throws */ + xbt_cfg_set_boolean(key, value); /* throws */ ret = (char *)value + strlen(value); break; default: @@ -715,12 +708,12 @@ void *xbt_cfg_set_as_string(xbt_cfg_t cfg, const char *key, const char *value) { * This is useful to change the default value of a variable while allowing * users to override it with command line arguments */ -void xbt_cfg_setdefault_int(xbt_cfg_t cfg, const char *name, int val) +void xbt_cfg_setdefault_int(const char *name, int val) { - xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_int); + xbt_cfgelm_t variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_int); if (variable->isdefault){ - xbt_cfg_set_int(cfg, name, val); + xbt_cfg_set_int(name, val); variable->isdefault = 1; } else XBT_DEBUG("Do not override configuration variable '%s' with value '%d' because it was already set.", name, val); @@ -731,12 +724,12 @@ void xbt_cfg_setdefault_int(xbt_cfg_t cfg, const char *name, int val) * This is useful to change the default value of a variable while allowing * users to override it with command line arguments */ -void xbt_cfg_setdefault_double(xbt_cfg_t cfg, const char *name, double val) +void xbt_cfg_setdefault_double(const char *name, double val) { - xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_double); + xbt_cfgelm_t variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_double); if (variable->isdefault) { - xbt_cfg_set_double(cfg, name, val); + xbt_cfg_set_double(name, val); variable->isdefault = 1; } else XBT_DEBUG("Do not override configuration variable '%s' with value '%f' because it was already set.", name, val); @@ -747,12 +740,12 @@ void xbt_cfg_setdefault_double(xbt_cfg_t cfg, const char *name, double val) * This is useful to change the default value of a variable while allowing * users to override it with command line arguments */ -void xbt_cfg_setdefault_string(xbt_cfg_t cfg, const char *name, const char *val) +void xbt_cfg_setdefault_string(const char *name, const char *val) { - xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_string); + xbt_cfgelm_t variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_string); if (variable->isdefault){ - xbt_cfg_set_string(cfg, name, val); + xbt_cfg_set_string(name, val); variable->isdefault = 1; } else XBT_DEBUG("Do not override configuration variable '%s' with value '%s' because it was already set.", name, val); @@ -763,12 +756,12 @@ void xbt_cfg_setdefault_string(xbt_cfg_t cfg, const char *name, const char *val) * This is useful to change the default value of a variable while allowing * users to override it with command line arguments */ -void xbt_cfg_setdefault_boolean(xbt_cfg_t cfg, const char *name, const char *val) +void xbt_cfg_setdefault_boolean(const char *name, const char *val) { - xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_boolean); + xbt_cfgelm_t variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_boolean); if (variable->isdefault){ - xbt_cfg_set_boolean(cfg, name, val); + xbt_cfg_set_boolean(name, val); variable->isdefault = 1; } else @@ -781,10 +774,10 @@ void xbt_cfg_setdefault_boolean(xbt_cfg_t cfg, const char *name, const char *val * @param name the name of the variable * @param val the value of the variable */ -void xbt_cfg_set_int(xbt_cfg_t cfg, const char *name, int val) +void xbt_cfg_set_int(const char *name, int val) { XBT_VERB("Configuration setting: %s=%d", name, val); - xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_int); + xbt_cfgelm_t variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_int); if (variable->max == 1) { xbt_dynar_set(variable->content, 0, &val); @@ -807,10 +800,10 @@ void xbt_cfg_set_int(xbt_cfg_t cfg, const char *name, int val) * @param name the name of the variable * @param val the doule to set */ -void xbt_cfg_set_double(xbt_cfg_t cfg, const char *name, double val) +void xbt_cfg_set_double(const char *name, double val) { XBT_VERB("Configuration setting: %s=%f", name, val); - xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_double); + xbt_cfgelm_t variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_double); if (variable->max == 1) { xbt_dynar_set(variable->content, 0, &val); @@ -834,12 +827,12 @@ void xbt_cfg_set_double(xbt_cfg_t cfg, const char *name, double val) * @param val the value to be added * */ -void xbt_cfg_set_string(xbt_cfg_t cfg, const char *name, const char *val) +void xbt_cfg_set_string(const char *name, const char *val) { char *newval = xbt_strdup(val); XBT_VERB("Configuration setting: %s=%s", name, val); - xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_string); + xbt_cfgelm_t variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_string); XBT_DEBUG("Variable: %d to %d %s (=%d) @%p", variable->min, variable->max, xbt_cfgelm_type_name[variable->type], (int)variable->type, variable); @@ -871,12 +864,12 @@ void xbt_cfg_set_string(xbt_cfg_t cfg, const char *name, const char *val) * @param name the name of the variable * @param val the value of the variable */ -void xbt_cfg_set_boolean(xbt_cfg_t cfg, const char *name, const char *val) +void xbt_cfg_set_boolean(const char *name, const char *val) { int i, bval; XBT_VERB("Configuration setting: %s=%s", name, val); - xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_boolean); + xbt_cfgelm_t variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_boolean); for (i = 0; xbt_cfgelm_boolean_values[i].true_val != NULL; i++) { if (strcmp(val, xbt_cfgelm_boolean_values[i].true_val) == 0){ @@ -1055,24 +1048,23 @@ void xbt_cfg_empty(xbt_cfg_t cfg, const char *name) } /* Say if the value is the default value */ -int xbt_cfg_is_default_value(xbt_cfg_t cfg, const char *name) +int xbt_cfg_is_default_value(const char *name) { - xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_any); + xbt_cfgelm_t variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_any); return variable->isdefault; } /*----[ Getting ]---------------------------------------------------------*/ /** @brief Retrieve an integer value of a variable (get a warning if not uniq) * - * @param cfg the config set * @param name the name of the variable * * Returns the first value from the config set under the given name. * If there is more than one value, it will issue a warning. Consider using xbt_cfg_get_dynar() instead. */ -int xbt_cfg_get_int(xbt_cfg_t cfg, const char *name) +int xbt_cfg_get_int(const char *name) { - xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_int); + xbt_cfgelm_t variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_int); if (xbt_dynar_length(variable->content) > 1) { XBT_WARN("You asked for the first value of the config element '%s', but there is %lu values", @@ -1090,9 +1082,9 @@ int xbt_cfg_get_int(xbt_cfg_t cfg, const char *name) * Returns the first value from the config set under the given name. * If there is more than one value, it will issue a warning. Consider using xbt_cfg_get_dynar() instead. */ -double xbt_cfg_get_double(xbt_cfg_t cfg, const char *name) +double xbt_cfg_get_double(const char *name) { - xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_double); + xbt_cfgelm_t variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_double); if (xbt_dynar_length(variable->content) > 1) { XBT_WARN ("You asked for the first value of the config element '%s', but there is %lu values\n", @@ -1113,9 +1105,9 @@ double xbt_cfg_get_double(xbt_cfg_t cfg, const char *name) * * \warning the returned value is the actual content of the config set */ -char *xbt_cfg_get_string(xbt_cfg_t cfg, const char *name) +char *xbt_cfg_get_string(const char *name) { - xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_string); + xbt_cfgelm_t variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_string); if (xbt_dynar_length(variable->content) > 1) { XBT_WARN("You asked for the first value of the config element '%s', but there is %lu values\n", @@ -1135,9 +1127,9 @@ char *xbt_cfg_get_string(xbt_cfg_t cfg, const char *name) * Returns the first value from the config set under the given name. * If there is more than one value, it will issue a warning. Consider using xbt_cfg_get_dynar() instead. */ -int xbt_cfg_get_boolean(xbt_cfg_t cfg, const char *name) +int xbt_cfg_get_boolean(const char *name) { - xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_boolean); + xbt_cfgelm_t variable = xbt_cfgelm_get(simgrid_config, name, xbt_cfgelm_boolean); if (xbt_dynar_length(variable->content) > 1) { XBT_WARN("You asked for the first value of the config element '%s', but there is %lu values", @@ -1156,13 +1148,13 @@ int xbt_cfg_get_boolean(xbt_cfg_t cfg, const char *name) * * \warning the returned value is the actual content of the config set */ -xbt_dynar_t xbt_cfg_get_dynar(xbt_cfg_t cfg, const char *name) +xbt_dynar_t xbt_cfg_get_dynar(const char *name) { xbt_cfgelm_t variable = NULL; xbt_ex_t e; TRY { - variable = xbt_dict_get((xbt_dict_t) cfg, name); + variable = xbt_dict_get((xbt_dict_t) simgrid_config, name); } CATCH(e) { if (e.category == not_found_error) { xbt_ex_free(e); @@ -1273,7 +1265,7 @@ XBT_TEST_UNIT("use", test_config_use, "Data retrieving tests") xbt_cfg_t myset = make_set(); xbt_cfg_set_parse(myset, "peername:toto:42 speed:42"); - ival = xbt_cfg_get_int(myset, "speed"); + ival = xbt_cfg_get_int("speed"); if (ival != 42) xbt_test_fail("Speed value = %d, I expected 42", ival); xbt_cfg_free(&myset); @@ -1288,7 +1280,7 @@ XBT_TEST_UNIT("use", test_config_use, "Data retrieving tests") xbt_cfg_set_parse(myset, "peername:veloce user:foo\nuser:bar\tuser:toto"); xbt_cfg_set_parse(myset, "speed:42"); xbt_cfg_check(myset); - dyn = xbt_cfg_get_dynar(myset, "user"); + dyn = xbt_cfg_get_dynar("user"); if (xbt_dynar_length(dyn) != 3) xbt_test_fail("Dynar length = %lu, I expected 3", xbt_dynar_length(dyn)); diff --git a/teshsuite/surf/surf_usage/surf_usage.cpp b/teshsuite/surf/surf_usage/surf_usage.cpp index 17c8002669..3eeab9668a 100644 --- a/teshsuite/surf/surf_usage/surf_usage.cpp +++ b/teshsuite/surf/surf_usage/surf_usage.cpp @@ -38,8 +38,8 @@ int main(int argc, char **argv) { double now = -1.0; surf_init(&argc, argv); /* Initialize some common structures */ - xbt_cfg_set_parse(_sg_cfg_set, "cpu/model:Cas01"); - xbt_cfg_set_parse(_sg_cfg_set, "network/model:CM02"); + xbt_cfg_set_string("cpu/model","Cas01"); + xbt_cfg_set_string("network/model","CM02"); xbt_assert(argc >1, "Usage : %s platform.txt\n", argv[0]); parse_platform_file(argv[1]); diff --git a/teshsuite/surf/surf_usage2/surf_usage2.cpp b/teshsuite/surf/surf_usage2/surf_usage2.cpp index 0fc3a43d78..490fe3005e 100644 --- a/teshsuite/surf/surf_usage2/surf_usage2.cpp +++ b/teshsuite/surf/surf_usage2/surf_usage2.cpp @@ -24,8 +24,8 @@ int main(int argc, char **argv) surf_init(&argc, argv); /* Initialize some common structures */ - xbt_cfg_set_parse(_sg_cfg_set, "network/model:CM02"); - xbt_cfg_set_parse(_sg_cfg_set, "cpu/model:Cas01"); + xbt_cfg_set_string("network/model","CM02"); + xbt_cfg_set_string("cpu/model","Cas01"); xbt_assert(argc >1, "Usage : %s platform.txt\n", argv[0]); parse_platform_file(argv[1]);