Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of github.com:simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 13 Jul 2017 10:01:49 +0000 (12:01 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 13 Jul 2017 10:01:49 +0000 (12:01 +0200)
22 files changed:
examples/java/dht/chord/Node.java
examples/msg/io-file/io-file.c
examples/msg/io-file/io-file.tesh
examples/s4u/app-pingpong/s4u_app-pingpong.cpp
include/simgrid/s4u/File.hpp
include/simgrid/simix.h
src/bindings/java/jmsg_process.cpp
src/msg/msg_io.cpp
src/s4u/s4u_file.cpp
src/simix/libsmx.cpp
src/simix/popping_accessors.h
src/simix/popping_bodies.cpp
src/simix/popping_generated.cpp
src/simix/simcalls.in
src/simix/smx_io.cpp
src/simix/smx_io_private.h
src/surf/StorageImpl.cpp
src/surf/StorageImpl.hpp
src/surf/storage_n11.cpp
src/surf/storage_n11.hpp
src/xbt/mmalloc/mfree.c
src/xbt/mmalloc/mm_module.c

index 87c4e50..f29ead5 100644 (file)
@@ -58,8 +58,8 @@ public class Node extends Process {
       create();
       joinSuccess = true;
     } else {
-      int knownId = Integer.valueOf(args[1]);
-      deadline = Integer.valueOf(args[3]);
+      int knownId = Integer.parseInt(args[1]);
+      deadline = Integer.parseInt(args[3]);
       Msg.debug("Hey! Let's join the system with the id " + id + ".");
 
       joinSuccess = join(knownId);
@@ -202,7 +202,6 @@ public class Node extends Process {
       }
       catch (MsgException e) {
         commReceive = null;
-        stop = true;
       }
     }
     catch (MsgException e) {
index 4f7f079..c0ad633 100644 (file)
@@ -99,6 +99,6 @@ int main(int argc, char **argv)
   xbt_dynar_free(&hosts);
 
   int res = MSG_main();
-  XBT_INFO("Simulation time %g", MSG_get_clock());
+  XBT_INFO("Simulation time %.6f", MSG_get_clock());
   return res != MSG_OK;
 }
index c6915ff..e0483eb 100644 (file)
@@ -53,4 +53,4 @@ $ ${bindir:=.}/io-file ${srcdir:=.}/storage/storage.xml "--log=root.fmt:[%10.6r]
 > [  0.008326] (3:host@carl)   Have written 110000 in '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'. Size now is: 110000
 > [  0.008326] (3:host@carl)   Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' is stored on: 37020686 / 536870912000
 > [  0.008326] (3:host@carl)   Close file '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
-> [  0.008326] (0:maestro@) Simulation time 0.00832645
+> [  0.008326] (0:maestro@) Simulation time 0.008326
index d8c0384..eebe6e7 100644 (file)
@@ -20,12 +20,13 @@ static void pinger(std::vector<std::string> args)
 
   simgrid::s4u::Mailbox::byName(args[0])->put(payload, 1);
   /* - ... then wait for the (large) pong */
-  double sender_time =
-      *(static_cast<double*>(simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::getHost()->getName())->get()));
+  double* sender_time =
+      static_cast<double*>(simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::getHost()->getName())->get());
 
-  double communication_time = simgrid::s4u::Engine::getClock() - sender_time;
+  double communication_time = simgrid::s4u::Engine::getClock() - *sender_time;
   XBT_INFO("Task received : large communication (bandwidth bound)");
   XBT_INFO("Pong time (bandwidth bound): %.3f", communication_time);
+  delete sender_time;
 }
 
 static void ponger(std::vector<std::string> args)
@@ -41,6 +42,7 @@ static void ponger(std::vector<std::string> args)
   double communication_time = simgrid::s4u::Engine::getClock() - *sender_time;
   XBT_INFO("Task received : small communication (latency bound)");
   XBT_INFO(" Ping time (latency bound) %f", communication_time);
+  delete sender_time;
 
   /*  - ... Then send a 1GB pong back (bandwidth bound) */
   double* payload = new double();
index 9fbc6f2..18d2926 100644 (file)
@@ -37,7 +37,6 @@ public:
 
   /** Simulates a write action. Returns the size of data actually written. */
   sg_size_t write(sg_size_t size);
-  sg_size_t write(sg_size_t size, sg_host_t host);
 
   /** Allows to store user data on that host */
   void setUserdata(void* data) { userdata_ = data; }
index 6a117c1..6921451 100644 (file)
@@ -289,8 +289,8 @@ XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem, double max_duration)
 XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
 
 /*****************************   File   **********************************/
-XBT_PUBLIC(sg_size_t) simcall_file_read(surf_file_t fd, sg_size_t size, sg_host_t host);
-XBT_PUBLIC(sg_size_t) simcall_file_write(surf_file_t fd, sg_size_t size, sg_host_t host);
+XBT_PUBLIC(sg_size_t) simcall_file_read(surf_file_t fd, sg_size_t size);
+XBT_PUBLIC(sg_size_t) simcall_file_write(surf_file_t fd, sg_size_t size);
 /************************** MC simcalls   **********************************/
 XBT_PUBLIC(int) simcall_mc_random(int min, int max);
 
index 8fcbe02..2676857 100644 (file)
@@ -74,9 +74,9 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv* env, jobject
   /* Actually build the MSG process */
   jstring jname         = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
   const char* name      = env->GetStringUTFChars(jname, 0);
-  msg_process_t process = MSG_process_create_from_stdfunc(
-      name, [jprocess]() -> void { simgrid::kernel::context::java_main_jprocess(jprocess); },
-      /*data*/ nullptr, jhost_get_native(env, jhost), /* properties*/ nullptr);
+  msg_process_t process =
+      MSG_process_create_from_stdfunc(name, [jprocess]() { simgrid::kernel::context::java_main_jprocess(jprocess); },
+                                      /*data*/ nullptr, jhost_get_native(env, jhost), /* properties*/ nullptr);
   env->ReleaseStringUTFChars(jname, name);
 
   /* bind the java process instance to the native process */
index 0203ed7..1913d3b 100644 (file)
@@ -323,7 +323,7 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa
 
   /* Create file on remote host, write it and close it */
   msg_file_t fd = new simgrid::s4u::File(fullpath, dst_host, nullptr);
-  fd->write(read_size, dst_host);
+  fd->write(read_size);
   delete fd;
   return MSG_OK;
 }
index db1c5b2..043f6d5 100644 (file)
@@ -56,17 +56,12 @@ File::~File()
 
 sg_size_t File::read(sg_size_t size)
 {
-  return simcall_file_read(pimpl_, size, Host::current());
+  return simcall_file_read(pimpl_, size);
 }
 
 sg_size_t File::write(sg_size_t size)
 {
-  return simcall_file_write(pimpl_,size, Host::current());
-}
-
-sg_size_t File::write(sg_size_t size, sg_host_t host)
-{
-  return simcall_file_write(pimpl_, size, host);
+  return simcall_file_write(pimpl_, size);
 }
 
 sg_size_t File::size()
index d5c9811..f05e1f1 100644 (file)
@@ -609,18 +609,18 @@ int simcall_sem_get_capacity(smx_sem_t sem)
  * \ingroup simix_file_management
  *
  */
-sg_size_t simcall_file_read(surf_file_t fd, sg_size_t size, sg_host_t host)
+sg_size_t simcall_file_read(surf_file_t fd, sg_size_t size)
 {
-  return simcall_BODY_file_read(fd, size, host);
+  return simcall_BODY_file_read(fd, size);
 }
 
 /**
  * \ingroup simix_file_management
  *
  */
-sg_size_t simcall_file_write(surf_file_t fd, sg_size_t size, sg_host_t host)
+sg_size_t simcall_file_write(surf_file_t fd, sg_size_t size)
 {
-  return simcall_BODY_file_write(fd, size, host);
+  return simcall_BODY_file_write(fd, size);
 }
 
 void simcall_run_kernel(std::function<void()> const& code)
index 9bdee47..1966f28 100644 (file)
@@ -1480,18 +1480,6 @@ static inline void simcall_file_read__set__size(smx_simcall_t simcall, sg_size_t
 {
   simgrid::simix::marshal<sg_size_t>(simcall->args[1], arg);
 }
-static inline sg_host_t simcall_file_read__get__host(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<sg_host_t>(simcall->args[2]);
-}
-static inline sg_host_t simcall_file_read__getraw__host(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<sg_host_t>(simcall->args[2]);
-}
-static inline void simcall_file_read__set__host(smx_simcall_t simcall, sg_host_t arg)
-{
-  simgrid::simix::marshal<sg_host_t>(simcall->args[2], arg);
-}
 static inline sg_size_t simcall_file_read__get__result(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<sg_size_t>(simcall->result);
@@ -1528,18 +1516,6 @@ static inline void simcall_file_write__set__size(smx_simcall_t simcall, sg_size_
 {
   simgrid::simix::marshal<sg_size_t>(simcall->args[1], arg);
 }
-static inline sg_host_t simcall_file_write__get__host(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<sg_host_t>(simcall->args[2]);
-}
-static inline sg_host_t simcall_file_write__getraw__host(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<sg_host_t>(simcall->args[2]);
-}
-static inline void simcall_file_write__set__host(smx_simcall_t simcall, sg_host_t arg)
-{
-  simgrid::simix::marshal<sg_host_t>(simcall->args[2], arg);
-}
 static inline sg_size_t simcall_file_write__get__result(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<sg_size_t>(simcall->result);
@@ -1689,6 +1665,6 @@ XBT_PRIVATE int simcall_HANDLER_sem_would_block(smx_simcall_t simcall, smx_sem_t
 XBT_PRIVATE void simcall_HANDLER_sem_acquire(smx_simcall_t simcall, smx_sem_t sem);
 XBT_PRIVATE void simcall_HANDLER_sem_acquire_timeout(smx_simcall_t simcall, smx_sem_t sem, double timeout);
 XBT_PRIVATE int simcall_HANDLER_sem_get_capacity(smx_simcall_t simcall, smx_sem_t sem);
-XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host);
-XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host);
+XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size);
+XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size);
 XBT_PRIVATE int simcall_HANDLER_mc_random(smx_simcall_t simcall, int min, int max);
\ No newline at end of file
index 8d0c849..486da23 100644 (file)
@@ -314,18 +314,20 @@ inline static int simcall_BODY_sem_get_capacity(smx_sem_t sem) {
     return simcall<int, smx_sem_t>(SIMCALL_SEM_GET_CAPACITY, sem);
   }
 
-  inline static sg_size_t simcall_BODY_file_read(surf_file_t fd, sg_size_t size, sg_host_t host)
+  inline static sg_size_t simcall_BODY_file_read(surf_file_t fd, sg_size_t size)
   {
     /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) simcall_HANDLER_file_read(&SIMIX_process_self()->simcall, fd, size, host);
-    return simcall<sg_size_t, surf_file_t, sg_size_t, sg_host_t>(SIMCALL_FILE_READ, fd, size, host);
+    if (0)
+      simcall_HANDLER_file_read(&SIMIX_process_self()->simcall, fd, size);
+    return simcall<sg_size_t, surf_file_t, sg_size_t>(SIMCALL_FILE_READ, fd, size);
   }
 
-  inline static sg_size_t simcall_BODY_file_write(surf_file_t fd, sg_size_t size, sg_host_t host)
+  inline static sg_size_t simcall_BODY_file_write(surf_file_t fd, sg_size_t size)
   {
     /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) simcall_HANDLER_file_write(&SIMIX_process_self()->simcall, fd, size, host);
-    return simcall<sg_size_t, surf_file_t, sg_size_t, sg_host_t>(SIMCALL_FILE_WRITE, fd, size, host);
+    if (0)
+      simcall_HANDLER_file_write(&SIMIX_process_self()->simcall, fd, size);
+    return simcall<sg_size_t, surf_file_t, sg_size_t>(SIMCALL_FILE_WRITE, fd, size);
   }
 
 inline static int simcall_BODY_mc_random(int min, int max) {
index cf13847..0de896d 100644 (file)
@@ -313,14 +313,12 @@ case SIMCALL_SEM_GET_CAPACITY:
 
 case SIMCALL_FILE_READ:
   simcall_HANDLER_file_read(simcall, simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]),
-                            simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]),
-                            simgrid::simix::unmarshal<sg_host_t>(simcall->args[2]));
+                            simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]));
   break;
 
 case SIMCALL_FILE_WRITE:
   simcall_HANDLER_file_write(simcall, simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]),
-                             simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]),
-                             simgrid::simix::unmarshal<sg_host_t>(simcall->args[2]));
+                             simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]));
   break;
 
 case SIMCALL_MC_RANDOM:
index d5b7cc1..69734e4 100644 (file)
@@ -81,8 +81,8 @@ void      sem_acquire(smx_sem_t sem) [[block]];
 void      sem_acquire_timeout(smx_sem_t sem, double timeout) [[block]];
 int       sem_get_capacity(smx_sem_t sem);
 
-sg_size_t   file_read(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]];
-sg_size_t   file_write(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]];
+sg_size_t   file_read(surf_file_t fd, sg_size_t size) [[block]];
+sg_size_t   file_write(surf_file_t fd, sg_size_t size) [[block]];
 
 int        mc_random(int min, int max);
 void       set_category(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> synchro, const char* category) [[nohandler]];
index 9d6ccb2..9361f1d 100644 (file)
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)");
 
 //SIMIX FILE READ
-void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host)
+void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size)
 {
-  smx_activity_t synchro = SIMIX_file_read(fd, size, host);
+  smx_activity_t synchro = SIMIX_file_read(fd, size);
   synchro->simcalls.push_back(simcall);
   simcall->issuer->waiting_synchro = synchro;
 }
 
-smx_activity_t SIMIX_file_read(surf_file_t file, sg_size_t size, sg_host_t host)
+smx_activity_t SIMIX_file_read(surf_file_t file, sg_size_t size)
 {
-  /* check if the host is active */
-  if (host->isOff())
-    THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->getCname());
-
   simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl();
   synchro->surf_io                           = file->read(size);
 
@@ -45,18 +41,15 @@ smx_activity_t SIMIX_file_read(surf_file_t file, sg_size_t size, sg_host_t host)
 }
 
 //SIMIX FILE WRITE
-void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host)
+void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size)
 {
-  smx_activity_t synchro = SIMIX_file_write(fd,  size, host);
+  smx_activity_t synchro = SIMIX_file_write(fd, size);
   synchro->simcalls.push_back(simcall);
   simcall->issuer->waiting_synchro = synchro;
 }
 
-smx_activity_t SIMIX_file_write(surf_file_t file, sg_size_t size, sg_host_t host)
+smx_activity_t SIMIX_file_write(surf_file_t file, sg_size_t size)
 {
-  if (host->isOff())
-    THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->getCname());
-
   simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl();
   synchro->surf_io                           = file->write(size);
   synchro->surf_io->setData(synchro);
index e51804d..db1c66d 100644 (file)
@@ -11,8 +11,8 @@
 #include "simgrid/simix.h"
 #include "popping_private.h"
 
-XBT_PRIVATE smx_activity_t SIMIX_file_read(surf_file_t fd, sg_size_t size, sg_host_t host);
-XBT_PRIVATE smx_activity_t SIMIX_file_write(surf_file_t fd, sg_size_t size, sg_host_t host);
+XBT_PRIVATE smx_activity_t SIMIX_file_read(surf_file_t fd, sg_size_t size);
+XBT_PRIVATE smx_activity_t SIMIX_file_write(surf_file_t fd, sg_size_t size);
 
 XBT_PRIVATE void SIMIX_io_destroy(smx_activity_t synchro);
 XBT_PRIVATE void SIMIX_io_finish(smx_activity_t synchro);
index 1fb0fbc..03e1f87 100644 (file)
@@ -154,20 +154,6 @@ sg_size_t StorageImpl::getUsedSize()
 /**********
  * Action *
  **********/
-StorageAction::StorageAction(Model* model, double cost, bool failed, StorageImpl* storage,
-                             e_surf_action_storage_type_t type)
-    : Action(model, cost, failed), type_(type), storage_(storage), file_(nullptr)
-{
-  progress_ = 0;
-};
-
-StorageAction::StorageAction(Model* model, double cost, bool failed, lmm_variable_t var, StorageImpl* storage,
-                             e_surf_action_storage_type_t type)
-    : Action(model, cost, failed, var), type_(type), storage_(storage), file_(nullptr)
-{
-  progress_ = 0;
-}
-
 void StorageAction::setState(Action::State state)
 {
   Action::State old = getState();
index 97a3e7d..c2ea20b 100644 (file)
@@ -185,7 +185,8 @@ public:
    * @param storage The Storage associated to this StorageAction
    * @param type [description]
    */
-  StorageAction(Model* model, double cost, bool failed, StorageImpl* storage, e_surf_action_storage_type_t type);
+  StorageAction(Model* model, double cost, bool failed, StorageImpl* storage, e_surf_action_storage_type_t type)
+      : Action(model, cost, failed), type_(type), storage_(storage){};
 
   /**
  * @brief StorageAction constructor
@@ -198,14 +199,14 @@ public:
  * @param type [description]
  */
   StorageAction(Model* model, double cost, bool failed, lmm_variable_t var, StorageImpl* storage,
-                e_surf_action_storage_type_t type);
+                e_surf_action_storage_type_t type)
+      : Action(model, cost, failed, var), type_(type), storage_(storage){};
 
   void setState(simgrid::surf::Action::State state) override;
 
   e_surf_action_storage_type_t type_;
   StorageImpl* storage_;
-  FileImpl* file_;
-  double progress_;
+  FileImpl* file_ = nullptr;
 };
 }
 }
index 2ab9fce..dd44583 100644 (file)
@@ -80,34 +80,18 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
 
     StorageAction *action = static_cast<StorageAction*>(&*it);
 
-    if (action->type_ == WRITE) {
-      // Update the disk usage
-      // Update the file size
-      // For each action of type write
-      double current_progress = delta * lmm_variable_getvalue(action->getVariable());
-      long int incr = current_progress;
-
-      XBT_DEBUG("%s:\n\t progress =  %.2f, current_progress = %.2f, incr = %ld, lrint(1) = %ld, lrint(2) = %ld",
-                action->file_->cname(), action->progress_, current_progress, incr,
-                lrint(action->progress_ + current_progress), lrint(action->progress_) + incr);
-
-      /* take care of rounding error accumulation */
-      if (lrint(action->progress_ + current_progress) > lrint(action->progress_) + incr)
-        incr++;
+    double current_progress = lrint(lmm_variable_getvalue(action->getVariable()) * delta);
 
-      action->progress_ += current_progress;
-
-      action->storage_->usedSize_ += incr;     // disk usage
-      action->file_->incrPosition(incr);       // current_position
-      //  which becomes the new file size
+    action->updateRemains(current_progress);
+    if (action->type_ == WRITE) {
+      action->storage_->usedSize_ += current_progress;
+      action->file_->incrPosition(current_progress);
       action->file_->setSize(action->file_->tell());
 
       action->storage_->getContent()->erase(action->file_->cname());
       action->storage_->getContent()->insert({action->file_->cname(), action->file_->size()});
     }
 
-    action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
-
     if (action->getMaxDuration() > NO_MAX_DURATION)
       action->updateMaxDuration(delta);
 
index 2da0174..42793eb 100644 (file)
@@ -44,11 +44,8 @@ public:
   StorageN11(StorageModel* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
              const char* type_id, char* content_name, sg_size_t size, char* attach);
   virtual ~StorageN11() = default;
-  StorageAction *open(const char* mount, const char* path);
-  StorageAction *ls(const char *path);
   StorageAction* read(sg_size_t size);
   StorageAction* write(sg_size_t size);
-  void rename(const char *src, const char *dest);
 };
 
 /**********
index 66ec157..38b5fc0 100644 (file)
@@ -20,8 +20,7 @@
 /* Return memory to the heap.  */
 void mfree(struct mdesc *mdp, void *ptr)
 {
-  int type;
-  size_t block, frag_nb;
+  size_t frag_nb;
   size_t i;
   int it;
 
@@ -31,14 +30,14 @@ void mfree(struct mdesc *mdp, void *ptr)
   if (ptr == NULL)
     return;
 
-  block = BLOCK(ptr);
+  size_t block = BLOCK(ptr);
 
   if ((char *) ptr < (char *) mdp->heapbase || block > mdp->heapsize) {
     fprintf(stderr,"Ouch, this pointer is not mine, I refuse to free it. Give me valid pointers, or give me death!!\n");
     abort();
   }
 
-  type = mdp->heapinfo[block].type;
+  int type = mdp->heapinfo[block].type;
 
   switch (type) {
   case MMALLOC_TYPE_HEAPINFO:
@@ -59,10 +58,8 @@ void mfree(struct mdesc *mdp, void *ptr)
     mdp -> heapstats.bytes_free +=
       mdp -> heapinfo[block].busy_block.size * BLOCKSIZE;
 
-    if(MC_is_active()){
-      if(mdp->heapinfo[block].busy_block.ignore > 0)
-        MC_remove_ignore_heap(ptr, mdp -> heapinfo[block].busy_block.busy_size);
-    }
+    if (MC_is_active() && mdp->heapinfo[block].busy_block.ignore > 0)
+      MC_remove_ignore_heap(ptr, mdp->heapinfo[block].busy_block.busy_size);
 
     /* Find the free cluster previous to this one in the free list.
        Start searching at the last block referenced; this may benefit
@@ -171,10 +168,8 @@ void mfree(struct mdesc *mdp, void *ptr)
       THROWF(system_error, 0, "Asked to free a fragment that is already free. I'm puzzled\n");
     }
 
-    if(MC_is_active()){
-      if(mdp->heapinfo[block].busy_frag.ignore[frag_nb] > 0)
-        MC_remove_ignore_heap(ptr, mdp->heapinfo[block].busy_frag.frag_size[frag_nb]);
-    }
+    if (MC_is_active() && mdp->heapinfo[block].busy_frag.ignore[frag_nb] > 0)
+      MC_remove_ignore_heap(ptr, mdp->heapinfo[block].busy_frag.frag_size[frag_nb]);
 
     /* Set size used in the fragment to -1 */
     mdp->heapinfo[block].busy_frag.frag_size[frag_nb] = -1;
index eac80c8..6c04fdf 100644 (file)
@@ -120,7 +120,8 @@ xbt_mheap_t xbt_mheap_new_options(int fd, void *baseaddr, int options)
          unsuccessful for some reason. */
 
       struct mdesc newmd;
-      struct mdesc *mdptr = NULL, *mdptemp = NULL;
+      struct mdesc* mdptr   = NULL;
+      struct mdesc* mdptemp = NULL;
 
       if (lseek(fd, 0L, SEEK_SET) != 0)
         return NULL;
@@ -156,15 +157,13 @@ xbt_mheap_t xbt_mheap_new_options(int fd, void *baseaddr, int options)
     }
   }
 
-  /* NULL is not a valid baseaddr as we cannot map anything there.
-     C'mon, user. Think! */
+  /* NULL is not a valid baseaddr as we cannot map anything there. C'mon, user. Think! */
   if (baseaddr == NULL)
     return (NULL);
 
-  /* We start off with the malloc descriptor allocated on the stack, until
-     we build it up enough to call _mmalloc_mmap_morecore() to allocate the
-     first page of the region and copy it there.  Ensure that it is zero'd and
-     then initialize the fields that we know values for. */
+  /* We start off with the malloc descriptor allocated on the stack, until we build it up enough to
+   * call _mmalloc_mmap_morecore() to allocate the first page of the region and copy it there.  Ensure that it is
+   * zero'd and then initialize the fields that we know values for. */
 
   mdp = &mtemp;
   memset((char *) mdp, 0, sizeof(mtemp));
@@ -187,10 +186,9 @@ xbt_mheap_t xbt_mheap_new_options(int fd, void *baseaddr, int options)
   /* If we have not been passed a valid open file descriptor for the file
      to map to, then open /dev/zero and use that to map to. */
 
-  /* Now try to map in the first page, copy the malloc descriptor structure
-     there, and arrange to return a pointer to this new copy.  If the mapping
-     fails, then close the file descriptor if it was opened by us, and arrange
-     to return a NULL. */
+  /* Now try to map in the first page, copy the malloc descriptor structure there, and arrange to return a pointer to
+   * this new copy.  If the mapping fails, then close the file descriptor if it was opened by us, and arrange to return
+   * a NULL. */
 
   if ((mbase = mmorecore(mdp, sizeof(mtemp))) != NULL) {
     memcpy(mbase, mdp, sizeof(mtemp));
@@ -229,41 +227,35 @@ void xbt_mheap_destroy_no_free(xbt_mheap_t md)
   }
 }
 
-/** Terminate access to a mmalloc managed region by unmapping all memory pages
-    associated with the region, and closing the file descriptor if it is one
-    that we opened.
+/** Terminate access to a mmalloc managed region by unmapping all memory pages associated with the region, and closing
+ *  the file descriptor if it is one that we opened.
 
     Returns NULL on success.
 
-    Returns the malloc descriptor on failure, which can subsequently be used
-    for further action, such as obtaining more information about the nature of
-    the failure.
+    Returns the malloc descriptor on failure, which can subsequently be used for further action, such as obtaining more
+    information about the nature of the failure.
 
-    Note that the malloc descriptor that we are using is currently located in
-    region we are about to unmap, so we first make a local copy of it on the
-    stack and use the copy. */
+    Note that the malloc descriptor that we are using is currently located in region we are about to unmap, so we first
+    make a local copy of it on the stack and use the copy. */
 
 void *xbt_mheap_destroy(xbt_mheap_t mdp)
 {
-  struct mdesc mtemp, *mdptemp;
-
   if (mdp != NULL) {
     /* Remove the heap from the linked list of heaps attached by mmalloc */
-    mdptemp = __mmalloc_default_mdp;
+    struct mdesc* mdptemp = __mmalloc_default_mdp;
     while(mdptemp->next_mdesc != mdp )
       mdptemp = mdptemp->next_mdesc;
 
     mdptemp->next_mdesc = mdp->next_mdesc;
 
     xbt_mheap_destroy_no_free(mdp);
-    mtemp = *mdp;
+    struct mdesc mtemp = *mdp;
 
     /* Now unmap all the pages associated with this region by asking for a
        negative increment equal to the current size of the region. */
 
     if (mmorecore(&mtemp, (char *)mtemp.base - (char *)mtemp.breakval) == NULL) {
-      /* Deallocating failed.  Update the original malloc descriptor
-         with any changes */
+      /* Deallocating failed.  Update the original malloc descriptor with any changes */
       *mdp = mtemp;
     } else {
       if (mtemp.flags & MMALLOC_DEVZERO) {
@@ -277,8 +269,7 @@ void *xbt_mheap_destroy(xbt_mheap_t mdp)
 }
 
 /* Safety gap from the heap's break address.
- * Try to increase this first if you experience strange errors under
- * valgrind. */
+ * Try to increase this first if you experience strange errors under valgrind. */
 #define HEAP_OFFSET   (128UL<<20)
 
 xbt_mheap_t mmalloc_get_default_md(void)