From: Frederic Suter Date: Tue, 21 Nov 2017 17:14:59 +0000 (+0100) Subject: Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid X-Git-Tag: v3.18~272^2~3 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/eacb762be40b0552304e3ff0f6dfec4fe9be930b?hp=fbaf01d1d370378f59e8916cfcd42f7d1b6f7536 Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid --- diff --git a/src/bindings/java/org/simgrid/msg/Msg.java b/src/bindings/java/org/simgrid/msg/Msg.java index 0cc18d0248..c58b213e37 100644 --- a/src/bindings/java/org/simgrid/msg/Msg.java +++ b/src/bindings/java/org/simgrid/msg/Msg.java @@ -58,7 +58,6 @@ public final class Msg { /** Example launcher. You can use it or provide your own launcher, as you wish * @param args - * @throws MsgException */ public static void main(String[]args) { /* initialize the MSG simulation. Must be done before anything else (even logging). */ diff --git a/src/bindings/java/org/simgrid/msg/Process.java b/src/bindings/java/org/simgrid/msg/Process.java index 055939e8d3..e4c7900eba 100644 --- a/src/bindings/java/org/simgrid/msg/Process.java +++ b/src/bindings/java/org/simgrid/msg/Process.java @@ -280,7 +280,6 @@ public abstract class Process implements Runnable { /** * This method actually creates and run the process. * It is a noop if the process is already launched. - * @throws HostNotFoundException */ public final void start() { if (bind == 0) diff --git a/src/simix/smx_deployment.cpp b/src/simix/smx_deployment.cpp index f380ffe0c9..18bf778ded 100644 --- a/src/simix/smx_deployment.cpp +++ b/src/simix/smx_deployment.cpp @@ -123,17 +123,13 @@ void SIMIX_process_set_function(const char* process_host, const char* process_fu if (not host) THROWF(arg_error, 0, "Host '%s' unknown", process_host); process.host = process_host; - - process.argc = 1 + xbt_dynar_length(arguments); - process.argv = static_cast(xbt_new(const char*, process.argc + 1)); - process.argv[0] = xbt_strdup(process_function); + process.args.push_back(process_function); /* add arguments */ unsigned int i; char *arg; xbt_dynar_foreach(arguments, i, arg) { - process.argv[i + 1] = xbt_strdup(arg); + process.args.push_back(arg); } - process.argv[process.argc] = nullptr; // Check we know how to handle this function name: simgrid::simix::ActorCodeFactory& parse_code = SIMIX_get_actor_code_factory(process_function); diff --git a/src/smpi/internals/smpi_shared.cpp b/src/smpi/internals/smpi_shared.cpp index 8ed34e8c6e..ce65e1bcf0 100644 --- a/src/smpi/internals/smpi_shared.cpp +++ b/src/smpi/internals/smpi_shared.cpp @@ -271,9 +271,9 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int "stop_offset (%zu) should be lower than its successor start offset (%zu)", stop_offset, shared_block_offsets[2*i_block+2]); size_t start_block_offset = ALIGN_UP(start_offset, smpi_shared_malloc_blocksize); size_t stop_block_offset = ALIGN_DOWN(stop_offset, smpi_shared_malloc_blocksize); - for (unsigned block_id=0, i = start_block_offset / smpi_shared_malloc_blocksize; i < stop_block_offset / smpi_shared_malloc_blocksize; block_id++, i++) { - XBT_DEBUG("\t\tglobal shared allocation, mmap block offset %u", block_id); - void* pos = (void*)((unsigned long)mem + i * smpi_shared_malloc_blocksize); + for (size_t offset = start_block_offset; offset < stop_block_offset; offset += smpi_shared_malloc_blocksize) { + XBT_DEBUG("\t\tglobal shared allocation, mmap block offset %zx", offset); + void* pos = (void*)((unsigned long)mem + offset); void* res = mmap(pos, smpi_shared_malloc_blocksize, PROT_READ | PROT_WRITE, mmap_flag, huge_fd, 0); xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the " diff --git a/src/surf/StorageImpl.cpp b/src/surf/StorageImpl.cpp index 51d1368a93..cc888ddd19 100644 --- a/src/surf/StorageImpl.cpp +++ b/src/surf/StorageImpl.cpp @@ -68,7 +68,7 @@ StorageImpl::StorageImpl(Model* model, std::string name, lmm_system_t maxminSyst , attach_(attach) { content_ = parseContent(content_name); - turnOn(); + StorageImpl::turnOn(); XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size); constraintRead_ = lmm_constraint_new(maxminSystem, this, bread); constraintWrite_ = lmm_constraint_new(maxminSystem, this, bwrite); diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index bd5b18af45..c7b6abcc47 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -150,7 +150,7 @@ NetworkCm02Model::NetworkCm02Model() } maxminSystem_ = lmm_system_new(selectiveUpdate_); - loopback_ = createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE); + loopback_ = NetworkCm02Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE); if (getUpdateMechanism() == UM_LAZY) { modifiedSet_ = new ActionLmmList(); diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index c62664e6e0..bc65a38011 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -65,7 +65,7 @@ NetworkL07Model::NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys) , hostModel_(hmodel) { maxminSystem_ = sys; - loopback_ = createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE); + loopback_ = NetworkL07Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE); } NetworkL07Model::~NetworkL07Model() diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index b22b8b89a7..81a15d0189 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -440,14 +440,14 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process) double kill_time = process->kill_time; int auto_restart = process->on_failure == SURF_ACTOR_ON_FAILURE_DIE ? 0 : 1; - std::vector args(process->argv, process->argv + process->argc); - std::function code = factory(std::move(args)); + std::string process_name = process->args[0]; + std::function code = factory(std::move(process->args)); std::shared_ptr> properties(process->properties); smx_process_arg_t arg = nullptr; arg = new simgrid::simix::ProcessArg(); - arg->name = std::string(process->argv[0]); + arg->name = process_name; arg->code = code; arg->data = nullptr; arg->host = host; @@ -459,7 +459,7 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process) if (start_time > SIMIX_get_clock()) { arg = new simgrid::simix::ProcessArg(); - arg->name = std::string(process->argv[0]); + arg->name = process_name; arg->code = std::move(code); arg->data = nullptr; arg->host = host; diff --git a/src/surf/xml/platf_private.hpp b/src/surf/xml/platf_private.hpp index 82def2f21a..13b3012cff 100644 --- a/src/surf/xml/platf_private.hpp +++ b/src/surf/xml/platf_private.hpp @@ -174,8 +174,7 @@ public: }; struct s_sg_platf_process_cbarg_t { - const char** argv = nullptr; - int argc = 0; + std::vector args; std::map* properties = nullptr; const char* host = nullptr; const char* function = nullptr; diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index 67f14a4432..3d6ead11d1 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -877,8 +877,7 @@ void ETag_surfxml_config() current_property_set = nullptr; } -static int argc; -static char **argv; +static std::vector arguments; void STag_surfxml_process() { @@ -889,9 +888,7 @@ void STag_surfxml_process() void STag_surfxml_actor() { ZONE_TAG = 0; - argc = 1; - argv = xbt_new(char *, 1); - argv[0] = xbt_strdup(A_surfxml_actor_function); + arguments.assign(1, A_surfxml_actor_function); xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)"); } @@ -912,8 +909,7 @@ void ETag_surfxml_actor() actor.properties = current_property_set; current_property_set = nullptr; - actor.argc = argc; - actor.argv = (const char **)argv; + actor.args.swap(arguments); actor.host = A_surfxml_actor_host; actor.function = A_surfxml_actor_function; actor.start_time = surf_parse_get_double(A_surfxml_actor_start___time); @@ -933,17 +929,10 @@ void ETag_surfxml_actor() } sg_platf_new_process(&actor); - - for (int i = 0; i != argc; ++i) - xbt_free(argv[i]); - xbt_free(argv); - argv = nullptr; } void STag_surfxml_argument(){ - argc++; - argv = (char**)xbt_realloc(argv, (argc) * sizeof(char **)); - argv[(argc) - 1] = xbt_strdup(A_surfxml_argument_value); + arguments.push_back(A_surfxml_argument_value); } void STag_surfxml_model___prop(){ diff --git a/src/xbt/dynar.cpp b/src/xbt/dynar.cpp index 63bbc4450c..c6a637c834 100644 --- a/src/xbt/dynar.cpp +++ b/src/xbt/dynar.cpp @@ -119,7 +119,7 @@ extern "C" void xbt_dynar_free_data(xbt_dynar_t dynar) { xbt_dynar_reset(dynar); if (dynar) - free(dynar->data); + xbt_free(dynar->data); } /** @brief Destructor of the structure not touching to the content @@ -133,8 +133,8 @@ extern "C" void xbt_dynar_free_container(xbt_dynar_t* dynar) { if (dynar && *dynar) { xbt_dynar_t d = *dynar; - free(d->data); - free(d); + xbt_free(d->data); + xbt_free(d); *dynar = nullptr; } } @@ -627,7 +627,7 @@ extern "C" void* xbt_dynar_to_array(xbt_dynar_t dynar) xbt_dynar_shrink(dynar, 1); memset(xbt_dynar_push_ptr(dynar), 0, dynar->elmsize); res = dynar->data; - free(dynar); + xbt_free(dynar); return res; } @@ -1025,7 +1025,7 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings") snprintf(buf,1023, "%d", cpt); xbt_dynar_shift(d, &s2); xbt_test_assert(not strcmp(buf, s2), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s2); - free(s2); + xbt_free(s2); } xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */ @@ -1048,7 +1048,7 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings") snprintf(buf,1023, "%d", cpt); xbt_dynar_pop(d, &s2); xbt_test_assert(not strcmp(buf, s2), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s2); - free(s2); + xbt_free(s2); } /* 4. Free the resources */ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */ @@ -1073,21 +1073,21 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings") xbt_dynar_shift(d, &s2); xbt_test_assert(not strcmp(buf, s2), "The retrieved value is not the same than the injected one at the begining (%s!=%s)", buf, s2); - free(s2); + xbt_free(s2); } for (int cpt = (NB_ELEM / 5) - 1; cpt >= 0; cpt--) { snprintf(buf,1023, "%d", cpt); xbt_dynar_shift(d, &s2); xbt_test_assert(not strcmp(buf, s2), "The retrieved value is not the same than the injected one in the middle (%s!=%s)", buf, s2); - free(s2); + xbt_free(s2); } for (int cpt = NB_ELEM / 2; cpt < NB_ELEM; cpt++) { snprintf(buf,1023, "%d", cpt); xbt_dynar_shift(d, &s2); xbt_test_assert(not strcmp(buf, s2), "The retrieved value is not the same than the injected one at the end (%s!=%s)", buf, s2); - free(s2); + xbt_free(s2); } xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */ @@ -1104,7 +1104,7 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings") snprintf(buf,1023, "%d", cpt); xbt_dynar_remove_at(d, 2 * (NB_ELEM / 5), &s2); xbt_test_assert(not strcmp(buf, s2), "Remove a bad value. Got %s, expected %s", s2, buf); - free(s2); + xbt_free(s2); } xbt_dynar_free(&d); /* end_of_doxygen */ } diff --git a/src/xbt/ex.cpp b/src/xbt/ex.cpp index e6dfd96341..c4395699b9 100644 --- a/src/xbt/ex.cpp +++ b/src/xbt/ex.cpp @@ -65,7 +65,7 @@ xbt_ex::~xbt_ex() = default; void _xbt_throw(char* message, xbt_errcat_t errcat, int value, const char* file, int line, const char* func) { xbt_ex e(simgrid::xbt::ThrowPoint(file, line, func), message); - free(message); + xbt_free(message); e.category = errcat; e.value = value; throw e; diff --git a/src/xbt/xbt_main.cpp b/src/xbt/xbt_main.cpp index 92a311b0c2..810cd26376 100644 --- a/src/xbt/xbt_main.cpp +++ b/src/xbt/xbt_main.cpp @@ -124,8 +124,8 @@ void xbt_init(int *argc, char **argv) { simgrid::xbt::installExceptionHandler(); - if (xbt_initialized) { - xbt_initialized++; + xbt_initialized++; + if (xbt_initialized > 1) { XBT_DEBUG("XBT has been initialized %d times.", xbt_initialized); return; } @@ -139,16 +139,16 @@ void xbt_init(int *argc, char **argv) } /* these two functions belong to xbt/sysdep.h, which have no corresponding .c file */ -/** @brief like free, but you can be sure that it is a function */ +/** @brief like xbt_free, but you can be sure that it is a function */ void xbt_free_f(void *p) { - free(p); + xbt_free(p); } /** @brief should be given a pointer to pointer, and frees the second one */ void xbt_free_ref(void *d) { - free(*(void **) d); + xbt_free(*(void**)d); } /** @brief Kill the program in silence */ diff --git a/src/xbt/xbt_str.cpp b/src/xbt/xbt_str.cpp index 9a1a893d77..06f1860fac 100644 --- a/src/xbt/xbt_str.cpp +++ b/src/xbt/xbt_str.cpp @@ -188,7 +188,7 @@ xbt_dynar_t xbt_str_split_quoted(const char *s) char *q=xbt_strdup(p); xbt_dynar_push(res,&q); } - free(str_to_free); + xbt_free(str_to_free); xbt_dynar_shrink(res, 0); xbt_dynar_free(&parsed); return res;