XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_cfg, xbt, "configuration support");
-XBT_EXPORT_NO_IMPORT(xbt_cfg_t) simgrid_config = NULL;
+XBT_EXPORT_NO_IMPORT(xbt_cfg_t) simgrid_config = nullptr;
namespace simgrid {
namespace config {
name,
variable->getDescription().c_str(),
variable->getTypeName(), variable, this);
- xbt_dict_set(this->options, name, variable, NULL);
+ xbt_dict_set(this->options, name, variable, nullptr);
variable->update();
return variable;
}
Config::Config() :
options(xbt_dict_new_homogeneous(xbt_cfgelm_free)),
- aliases(xbt_dict_new_homogeneous(NULL))
+ aliases(xbt_dict_new_homogeneous(nullptr))
{}
Config::~Config()
xbt_assert(this->getDictElement(aliasname) == nullptr, "Alias '%s' already.", aliasname);
xbt_dictelm_t element = this->getDictElement(realname);
xbt_assert(element, "Cannot define an alias to the non-existing option '%s'.", realname);
- xbt_dict_set(this->aliases, aliasname, element, NULL);
+ xbt_dict_set(this->aliases, aliasname, element, nullptr);
}
/** @brief Dump a config set for debuging purpose
void Config::dump(const char *name, const char *indent)
{
xbt_dict_t dict = this->options;
- xbt_dict_cursor_t cursor = NULL;
- simgrid::config::ConfigurationElement* variable = NULL;
- char *key = NULL;
+ xbt_dict_cursor_t cursor = nullptr;
+ simgrid::config::ConfigurationElement* variable = nullptr;
+ char *key = nullptr;
if (name)
printf("%s>> Dumping of the config set '%s':\n", indent, name);
unsigned int dynar_cursor;
xbt_dictelm_t dictel;
char *name;
- xbt_dynar_t names = xbt_dynar_new(sizeof(char *), NULL);
+ xbt_dynar_t names = xbt_dynar_new(sizeof(char *), nullptr);
xbt_dict_foreach(this->aliases, dict_cursor, name, dictel)
xbt_dynar_push(names, &name);
unsigned int dynar_cursor;
simgrid::config::ConfigurationElement* variable;
char *name;
- xbt_dynar_t names = xbt_dynar_new(sizeof(char *), NULL);
+ xbt_dynar_t names = xbt_dynar_new(sizeof(char *), nullptr);
xbt_dict_foreach(this->options, dict_cursor, name, variable)
xbt_dynar_push(names, &name);
XBT_PUBLIC(void) declareFlag(const char* name, const char* description,
T value, std::function<void(const T&)> callback)
{
- if (simgrid_config == NULL)
+ if (simgrid_config == nullptr)
simgrid_config = xbt_cfg_new();
simgrid_config->registerOption<T>(
name, description, std::move(value), std::move(callback));
void xbt_cfg_register_double(const char *name, double default_value,
xbt_cfg_cb_t cb_set, const char *desc)
{
- if (simgrid_config == NULL)
+ if (simgrid_config == nullptr)
simgrid_config = xbt_cfg_new();
simgrid_config->registerOption<double>(name, desc, default_value, cb_set);
}
void xbt_cfg_register_int(const char *name, int default_value,xbt_cfg_cb_t cb_set, const char *desc)
{
- if (simgrid_config == NULL)
+ if (simgrid_config == nullptr)
simgrid_config = xbt_cfg_new();
simgrid_config->registerOption<int>(name, desc, default_value, cb_set);
}
void xbt_cfg_register_string(const char *name, const char *default_value, xbt_cfg_cb_t cb_set, const char *desc)
{
- if (simgrid_config == NULL)
+ if (simgrid_config == nullptr)
simgrid_config = xbt_cfg_new();
simgrid_config->registerOption<std::string>(name, desc,
default_value ? default_value : "", cb_set);
void xbt_cfg_register_boolean(const char *name, const char*default_value,xbt_cfg_cb_t cb_set, const char *desc)
{
- if (simgrid_config == NULL)
+ if (simgrid_config == nullptr)
simgrid_config = xbt_cfg_new();
simgrid_config->registerOption<bool>(name, desc, simgrid::config::parseBool(default_value), cb_set);
}
void xbt_cfg_register_alias(const char *realname, const char *aliasname)
{
- if (simgrid_config == NULL)
+ if (simgrid_config == nullptr)
simgrid_config = xbt_cfg_new();
simgrid_config->alias(realname, aliasname);
}
}
if (option - name == len) {
XBT_DEBUG("Boundary=EOL");
- option = NULL; /* don't do next iteration */
+ option = nullptr; /* don't do next iteration */
} else {
XBT_DEBUG("Boundary on '%c'. len=%d;option-name=%ld", *option, len, (long) (option - name));
/* Pass the following blank chars */
option++;
}
if (option - name == len - 1)
- option = NULL; /* don't do next iteration */
+ option = nullptr; /* don't do next iteration */
}
XBT_DEBUG("parse now:'%s'; parse later:'%s'", name, option);
*
* Returns the first value from the config set under the given name.
* If there is more than one value, it will issue a warning.
- * Returns NULL if there is no value.
+ * Returns nullptr if there is no value.
*
* \warning the returned value is the actual content of the config set
*/
static void make_set()
{
- simgrid_config = NULL;
+ simgrid_config = nullptr;
xbt_log_threshold_set(&_XBT_LOGV(xbt_cfg), xbt_log_priority_critical);
- xbt_cfg_register_int("speed", 0, NULL, "");
- xbt_cfg_register_string("peername", "", NULL, "");
- xbt_cfg_register_string("user", "", NULL, "");
+ xbt_cfg_register_int("speed", 0, nullptr, "");
+ xbt_cfg_register_string("peername", "", nullptr, "");
+ xbt_cfg_register_string("user", "", nullptr, "");
} /* end_of_make_set */
XBT_TEST_UNIT("memuse", test_config_memuse, "Alloc and free a config set")
/* to be returned. */
char* path = bprintf("/proc/%i/maps", (int) pid);
FILE *fp = std::fopen(path, "r");
- if(fp == NULL)
+ if(fp == nullptr)
std::perror("fopen failed");
xbt_assert(fp, "Cannot open %s to investigate the memory map of the process.", path);
free(path);
- setbuf(fp, NULL);
+ setbuf(fp, nullptr);
std::vector<VmMap> ret;
/* Read one line at the time, parse it and add it to the memory map to be returned */
ssize_t read; /* Number of bytes readed */
- char* line = NULL;
+ char* line = nullptr;
std::size_t n = 0; /* Amount of bytes to read by xbt_getline */
while ((read = xbt_getline(&line, &n, fp)) != -1) {
lfields[0] = strtok(line, " ");
int i;
- for (i = 1; i < 6 && lfields[i - 1] != NULL; i++) {
- lfields[i] = std::strtok(NULL, " ");
+ for (i = 1; i < 6 && lfields[i - 1] != nullptr; i++) {
+ lfields[i] = std::strtok(nullptr, " ");
}
/* Check to see if we got the expected amount of columns */
/* Ok we are good enough to try to get the info we need */
/* First get the start and the end address of the map */
char *tok = std::strtok(lfields[0], "-");
- if (tok == NULL)
+ if (tok == nullptr)
xbt_abort();
VmMap memreg;
if (*endptr != '\0')
xbt_abort();
- tok = std::strtok(NULL, "-");
- if (tok == NULL)
+ tok = std::strtok(nullptr, "-");
+ if (tok == nullptr)
xbt_abort();
memreg.end_addr = std::strtoull(tok, &endptr, 16);
/* Get the device major:minor bytes */
tok = std::strtok(lfields[3], ":");
- if (tok == NULL)
+ if (tok == nullptr)
xbt_abort();
memreg.dev_major = (char) strtoul(tok, &endptr, 16);
if (*endptr != '\0')
xbt_abort();
- tok = std::strtok(NULL, ":");
- if (tok == NULL)
+ tok = std::strtok(nullptr, ":");
+ if (tok == nullptr)
xbt_abort();
memreg.dev_minor = (char) std::strtoul(tok, &endptr, 16);
/* Create the pool of worker threads */
xbt_parmap_thread_data_t data;
- parmap->workers[0] = NULL;
+ parmap->workers[0] = nullptr;
#if HAVE_PTHREAD_SETAFFINITY
int core_bind = 0;
#endif
data = xbt_new0(s_xbt_parmap_thread_data_t, 1);
data->parmap = parmap;
data->worker_id = i;
- parmap->workers[i] = xbt_os_thread_create(NULL, xbt_parmap_worker_main, data, NULL);
+ parmap->workers[i] = xbt_os_thread_create(nullptr, xbt_parmap_worker_main, data, nullptr);
#if HAVE_PTHREAD_SETAFFINITY
xbt_os_thread_bind(parmap->workers[i], core_bind);
if (core_bind != xbt_os_get_numcores())
unsigned int i;
for (i = 1; i < parmap->num_workers; i++)
- xbt_os_thread_join(parmap->workers[i], NULL);
+ xbt_os_thread_join(parmap->workers[i], nullptr);
xbt_os_cond_destroy(parmap->ready_cond);
xbt_os_mutex_destroy(parmap->ready_mutex);
*
* Worker threads call this function to get more work.
*
- * \return the next task to process, or NULL if there is no more work
+ * \return the next task to process, or nullptr if there is no more work
*/
void* xbt_parmap_next(xbt_parmap_t parmap)
{
if (index < xbt_dynar_length(parmap->data)) {
return xbt_dynar_get_as(parmap->data, index, void*);
}
- return NULL;
+ return nullptr;
}
static void xbt_parmap_work(xbt_parmap_t parmap)
xbt_parmap_thread_data_t data = (xbt_parmap_thread_data_t) arg;
xbt_parmap_t parmap = data->parmap;
unsigned round = 0;
- smx_context_t context = SIMIX_context_new(std::function<void()>(), NULL, NULL);
+ smx_context_t context = SIMIX_context_new(std::function<void()>(), nullptr, nullptr);
SIMIX_context_set_current(context);
XBT_DEBUG("New worker thread created");
} else {
delete context;
xbt_free(data);
- return NULL;
+ return nullptr;
}
}
}
static void futex_wait(unsigned *uaddr, unsigned val)
{
XBT_VERB("Waiting on futex %p", uaddr);
- syscall(SYS_futex, uaddr, FUTEX_WAIT_PRIVATE, val, NULL, NULL, 0);
+ syscall(SYS_futex, uaddr, FUTEX_WAIT_PRIVATE, val, nullptr, nullptr, 0);
}
static void futex_wake(unsigned *uaddr, unsigned val)
{
XBT_VERB("Waking futex %p", uaddr);
- syscall(SYS_futex, uaddr, FUTEX_WAKE_PRIVATE, val, NULL, NULL, 0);
+ syscall(SYS_futex, uaddr, FUTEX_WAKE_PRIVATE, val, nullptr, nullptr, 0);
}
#endif