From b345190b57970d86765b43d83e815a2bcc74ba2a Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 18 Apr 2018 15:27:13 +0200 Subject: [PATCH] Use xbt_cfg_is_default_value() to check if values were set. --- src/simgrid/sg_config.cpp | 16 ++++------------ src/simix/smx_context.cpp | 3 +++ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/simgrid/sg_config.cpp b/src/simgrid/sg_config.cpp index 3dd70411b5..5f56a50aa7 100644 --- a/src/simgrid/sg_config.cpp +++ b/src/simgrid/sg_config.cpp @@ -357,12 +357,8 @@ void sg_config_init(int *argc, char **argv) extern bool _sg_do_verbose_exit; simgrid::config::bindFlag(_sg_do_verbose_exit, "verbose-exit", "Activate the \"do nothing\" mode in Ctrl-C"); - simgrid::config::declareFlag("contexts/stack-size", "Stack size of contexts in KiB", 8 * 1024, [](int value) { - smx_context_stack_size_was_set = 1; - smx_context_stack_size = value * 1024; - }); - /* (FIXME: this is unpleasant) Reset this static variable that was altered when setting the default value. */ - smx_context_stack_size_was_set = 0; + simgrid::config::declareFlag("contexts/stack-size", "Stack size of contexts in KiB", 8 * 1024, + [](int value) { smx_context_stack_size = value * 1024; }); simgrid::config::alias("contexts/stack-size", {"contexts/stack_size"}); /* guard size for contexts stacks in memory pages */ @@ -372,12 +368,8 @@ void sg_config_init(int *argc, char **argv) int default_guard_size = 1; #endif simgrid::config::declareFlag("contexts/guard-size", "Guard size for contexts stacks in memory pages", - default_guard_size, [](int value) { - smx_context_guard_size_was_set = 1; - smx_context_guard_size = value * xbt_pagesize; - }); - /* No, it was not set yet (the above setdefault() changed this to 1). */ - smx_context_guard_size_was_set = 0; + default_guard_size, + [](int value) { smx_context_guard_size = value * xbt_pagesize; }); simgrid::config::alias("contexts/guard-size", {"contexts/guard_size"}); simgrid::config::declareFlag("contexts/nthreads", "Number of parallel threads used to execute user contexts", 1, &SIMIX_context_set_nthreads); diff --git a/src/simix/smx_context.cpp b/src/simix/smx_context.cpp index 6944ddf9d1..2cc924bc80 100644 --- a/src/simix/smx_context.cpp +++ b/src/simix/smx_context.cpp @@ -97,6 +97,9 @@ void SIMIX_context_mod_init() { xbt_assert(simix_global->context_factory == nullptr); + smx_context_stack_size_was_set = not xbt_cfg_is_default_value("contexts/stack-size"); + smx_context_guard_size_was_set = not xbt_cfg_is_default_value("contexts/guard-size"); + #if HAVE_THREAD_CONTEXTS && not HAVE_THREAD_LOCAL_STORAGE /* the __thread storage class is not available on this platform: * use getspecific/setspecific instead to store the current context in each thread */ -- 2.20.1