Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 21 Nov 2017 17:14:59 +0000 (18:14 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 21 Nov 2017 17:14:59 +0000 (18:14 +0100)
14 files changed:
src/bindings/java/org/simgrid/msg/Msg.java
src/bindings/java/org/simgrid/msg/Process.java
src/simix/smx_deployment.cpp
src/smpi/internals/smpi_shared.cpp
src/surf/StorageImpl.cpp
src/surf/network_cm02.cpp
src/surf/ptask_L07.cpp
src/surf/sg_platf.cpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_sax_cb.cpp
src/xbt/dynar.cpp
src/xbt/ex.cpp
src/xbt/xbt_main.cpp
src/xbt/xbt_str.cpp

index 0cc18d0..c58b213 100644 (file)
@@ -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). */
index 055939e..e4c7900 100644 (file)
@@ -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)
index f380ffe..18bf778 100644 (file)
@@ -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<const char**>(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);
index 8ed34e8..ce65e1b 100644 (file)
@@ -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 "
index 51d1368..cc888dd 100644 (file)
@@ -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);
index bd5b18a..c7b6abc 100644 (file)
@@ -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();
index c62664e..bc65a38 100644 (file)
@@ -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()
index b22b8b8..81a15d0 100644 (file)
@@ -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<std::string> args(process->argv, process->argv + process->argc);
-  std::function<void()> code = factory(std::move(args));
+  std::string process_name   = process->args[0];
+  std::function<void()> code = factory(std::move(process->args));
   std::shared_ptr<std::map<std::string, std::string>> 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;
index 82def2f..13b3012 100644 (file)
@@ -174,8 +174,7 @@ public:
 };
 
 struct s_sg_platf_process_cbarg_t {
-  const char** argv = nullptr;
-  int argc          = 0;
+  std::vector<std::string> args;
   std::map<std::string, std::string>* properties = nullptr;
   const char* host                       = nullptr;
   const char* function                   = nullptr;
index 67f14a4..3d6ead1 100644 (file)
@@ -877,8 +877,7 @@ void ETag_surfxml_config()
   current_property_set = nullptr;
 }
 
-static int argc;
-static char **argv;
+static std::vector<std::string> 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(){
index 63bbc44..c6a637c 100644 (file)
@@ -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 */
 }
index e6dfd96..c439569 100644 (file)
@@ -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;
index 92a311b..810cd26 100644 (file)
@@ -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 */
index 9a1a893..06f1860 100644 (file)
@@ -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;