Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of github.com:simgrid/simgrid into dev_7
authorEhsan Azimi <eazimi@ehsan.irisa.fr>
Thu, 19 Nov 2020 11:22:48 +0000 (12:22 +0100)
committerEhsan Azimi <eazimi@ehsan.irisa.fr>
Thu, 19 Nov 2020 11:22:48 +0000 (12:22 +0100)
45 files changed:
doc/doxygen/inside_extending.doc
examples/s4u/app-bittorrent/s4u-bittorrent.hpp
examples/s4u/app-bittorrent/s4u-peer.cpp
examples/s4u/app-bittorrent/s4u-peer.hpp
examples/s4u/dht-chord/s4u-dht-chord-node.cpp
examples/s4u/dht-chord/s4u-dht-chord.hpp
include/simgrid/Exception.hpp
include/simgrid/msg.h
include/simgrid/s4u/Engine.hpp
include/simgrid/smpi/replay.hpp
include/simgrid/vm.h
include/xbt/config.hpp
include/xbt/random.hpp
include/xbt/string.hpp
src/bindings/java/jmsg_vm.cpp
src/instr/instr_config.cpp
src/instr/instr_paje_events.cpp
src/instr/instr_paje_events.hpp
src/instr/instr_paje_header.cpp
src/instr/instr_paje_trace.cpp
src/instr/instr_paje_types.cpp
src/instr/instr_paje_types.hpp
src/instr/jedule/jedule_sd_binding.cpp
src/kernel/actor/ActorImpl.cpp
src/kernel/lmm/maxmin.hpp
src/kernel/routing/DragonflyZone.cpp
src/mc/inspect/DwarfExpression.hpp
src/mc/remote/RemoteSimulation.cpp
src/mc/sosp/Snapshot.cpp
src/mc/sosp/Snapshot_test.cpp
src/msg/msg_legacy.cpp
src/plugins/host_dvfs.cpp
src/plugins/vm/s4u_VirtualMachine.cpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_Engine.cpp
src/smpi/internals/smpi_global.cpp
src/surf/HostImpl.cpp
src/surf/cpu_interface.hpp
src/surf/network_cm02.hpp
src/surf/network_interface.hpp
src/surf/sg_platf.cpp
src/surf/xml/surfxml_sax_cb.cpp
teshsuite/mc/random-bug/random-bug.cpp
teshsuite/s4u/cloud-sharing/cloud-sharing.cpp
tools/cmake/Flags.cmake

index 2aba2a5..d9ae393 100644 (file)
@@ -168,7 +168,7 @@ generates the following files:
   Definition of type `enum e_smx_simcall_t` (one value per existing simcall)
 - popping_generated.cpp:
   Definitions of `simcall_names[]` (debug name of each simcall), and
-  SIMIX_simcall_enter() that deals with the simcall from within the kernel
+  ActorImpl::simcall_handle() that deals with the simcall from within the kernel
 
 The simcall.in file list all the simcalls in sections. A line starting by "##"
 define a new section which will be replace by a "ifdef" in the generated code.
index 1c53685..29c8cb6 100644 (file)
@@ -23,49 +23,23 @@ constexpr int MAX_UNCHOKED_PEERS = 4;
 /** Interval between each update of the choked peers */
 constexpr int UPDATE_CHOKED_INTERVAL = 30;
 
-/** Message sizes
- * Sizes based on report by A. Legout et al, Understanding BitTorrent: An Experimental Perspective
- * http://hal.inria.fr/inria-00000156/en
- */
-constexpr unsigned MESSAGE_HANDSHAKE_SIZE     = 68;
-constexpr unsigned MESSAGE_CHOKE_SIZE         = 5;
-constexpr unsigned MESSAGE_UNCHOKE_SIZE       = 5;
-constexpr unsigned MESSAGE_INTERESTED_SIZE    = 5;
-constexpr unsigned MESSAGE_NOTINTERESTED_SIZE = 5;
-constexpr unsigned MESSAGE_HAVE_SIZE          = 9;
-constexpr unsigned MESSAGE_BITFIELD_SIZE      = 5;
-constexpr unsigned MESSAGE_REQUEST_SIZE       = 17;
-constexpr unsigned MESSAGE_PIECE_SIZE         = 13;
-constexpr unsigned MESSAGE_CANCEL_SIZE        = 17;
-
 /** Types of messages exchanged between two peers. */
-enum e_message_type {
-  MESSAGE_HANDSHAKE,
-  MESSAGE_CHOKE,
-  MESSAGE_UNCHOKE,
-  MESSAGE_INTERESTED,
-  MESSAGE_NOTINTERESTED,
-  MESSAGE_HAVE,
-  MESSAGE_BITFIELD,
-  MESSAGE_REQUEST,
-  MESSAGE_PIECE,
-  MESSAGE_CANCEL
-};
+enum class MessageType { HANDSHAKE, CHOKE, UNCHOKE, INTERESTED, NOTINTERESTED, HAVE, BITFIELD, REQUEST, PIECE, CANCEL };
 
 class Message {
 public:
-  e_message_type type;
+  MessageType type;
   int peer_id;
   simgrid::s4u::Mailbox* return_mailbox;
   unsigned int bitfield = 0U;
   int piece             = 0;
   int block_index       = 0;
   int block_length      = 0;
-  Message(e_message_type type, int peer_id, simgrid::s4u::Mailbox* return_mailbox)
+  Message(MessageType type, int peer_id, simgrid::s4u::Mailbox* return_mailbox)
       : type(type), peer_id(peer_id), return_mailbox(return_mailbox){};
-  Message(e_message_type type, int peer_id, unsigned int bitfield, simgrid::s4u::Mailbox* return_mailbox)
+  Message(MessageType type, int peer_id, unsigned int bitfield, simgrid::s4u::Mailbox* return_mailbox)
       : type(type), peer_id(peer_id), return_mailbox(return_mailbox), bitfield(bitfield){};
-  Message(e_message_type type, int peer_id, simgrid::s4u::Mailbox* return_mailbox, int piece, int block_index,
+  Message(MessageType type, int peer_id, simgrid::s4u::Mailbox* return_mailbox, int piece, int block_index,
           int block_length)
       : type(type)
       , peer_id(peer_id)
@@ -73,7 +47,7 @@ public:
       , piece(piece)
       , block_index(block_index)
       , block_length(block_length){};
-  Message(e_message_type type, int peer_id, simgrid::s4u::Mailbox* return_mailbox, int piece)
+  Message(MessageType type, int peer_id, simgrid::s4u::Mailbox* return_mailbox, int piece)
       : type(type), peer_id(peer_id), return_mailbox(return_mailbox), piece(piece){};
 };
 
index 67b6516..f147320 100644 (file)
@@ -26,8 +26,31 @@ constexpr unsigned long BLOCKS_REQUESTED = 2UL;
 constexpr double SLEEP_DURATION     = 1.0;
 #define BITS_TO_BYTES(x) (((x) / 8 + (x) % 8) ? 1 : 0)
 
-constexpr std::array<const char*, 10> message_type_names{
-    {"HANDSHAKE", "CHOKE", "UNCHOKE", "INTERESTED", "NOTINTERESTED", "HAVE", "BITFIELD", "REQUEST", "PIECE", "CANCEL"}};
+/** Message sizes
+ * Sizes based on report by A. Legout et al, Understanding BitTorrent: An Experimental Perspective
+ * http://hal.inria.fr/inria-00000156/en
+ */
+constexpr unsigned message_size(MessageType type)
+{
+  constexpr std::array<unsigned, 10> sizes{{/* HANDSHAKE     */ 68,
+                                            /* CHOKE         */ 5,
+                                            /* UNCHOKE       */ 5,
+                                            /* INTERESTED    */ 5,
+                                            /* NOTINTERESTED */ 5,
+                                            /* HAVE          */ 9,
+                                            /* BITFIELD      */ 5,
+                                            /* REQUEST       */ 17,
+                                            /* PIECE         */ 13,
+                                            /* CANCEL        */ 17}};
+  return sizes[static_cast<int>(type)];
+}
+
+constexpr const char* message_name(MessageType type)
+{
+  constexpr std::array<const char*, 10> names{{"HANDSHAKE", "CHOKE", "UNCHOKE", "INTERESTED", "NOTINTERESTED", "HAVE",
+                                               "BITFIELD", "REQUEST", "PIECE", "CANCEL"}};
+  return names[static_cast<int>(type)];
+}
 
 Peer::Peer(std::vector<std::string> args)
 {
@@ -110,15 +133,15 @@ void Peer::sendHandshakeToAllPeers()
 {
   for (auto const& kv : connected_peers) {
     const Connection& remote_peer = kv.second;
-    auto* handshake               = new Message(MESSAGE_HANDSHAKE, id, mailbox_);
-    remote_peer.mailbox_->put_init(handshake, MESSAGE_HANDSHAKE_SIZE)->detach();
+    auto* handshake               = new Message(MessageType::HANDSHAKE, id, mailbox_);
+    remote_peer.mailbox_->put_init(handshake, message_size(MessageType::HANDSHAKE))->detach();
     XBT_DEBUG("Sending a HANDSHAKE to %d", remote_peer.id);
   }
 }
 
-void Peer::sendMessage(simgrid::s4u::Mailbox* mailbox, e_message_type type, uint64_t size)
+void Peer::sendMessage(simgrid::s4u::Mailbox* mailbox, MessageType type, uint64_t size)
 {
-  XBT_DEBUG("Sending %s to %s", message_type_names.at(type), mailbox->get_cname());
+  XBT_DEBUG("Sending %s to %s", message_name(type), mailbox->get_cname());
   mailbox->put_init(new Message(type, id, bitfield_, mailbox_), size)->detach();
 }
 
@@ -126,8 +149,8 @@ void Peer::sendBitfield(simgrid::s4u::Mailbox* mailbox)
 {
   XBT_DEBUG("Sending a BITFIELD to %s", mailbox->get_cname());
   mailbox
-      ->put_init(new Message(MESSAGE_BITFIELD, id, bitfield_, mailbox_),
-                 MESSAGE_BITFIELD_SIZE + BITS_TO_BYTES(FILE_PIECES))
+      ->put_init(new Message(MessageType::BITFIELD, id, bitfield_, mailbox_),
+                 message_size(MessageType::BITFIELD) + BITS_TO_BYTES(FILE_PIECES))
       ->detach();
 }
 
@@ -135,7 +158,8 @@ void Peer::sendPiece(simgrid::s4u::Mailbox* mailbox, unsigned int piece, int blo
 {
   xbt_assert(not hasNotPiece(piece), "Tried to send a unavailable piece.");
   XBT_DEBUG("Sending the PIECE %u (%d,%d) to %s", piece, block_index, block_length, mailbox->get_cname());
-  mailbox->put_init(new Message(MESSAGE_PIECE, id, mailbox_, piece, block_index, block_length), BLOCK_SIZE)->detach();
+  mailbox->put_init(new Message(MessageType::PIECE, id, mailbox_, piece, block_index, block_length), BLOCK_SIZE)
+      ->detach();
 }
 
 void Peer::sendHaveToAllPeers(unsigned int piece)
@@ -143,7 +167,8 @@ void Peer::sendHaveToAllPeers(unsigned int piece)
   XBT_DEBUG("Sending HAVE message to all my peers");
   for (auto const& kv : connected_peers) {
     const Connection& remote_peer = kv.second;
-    remote_peer.mailbox_->put_init(new Message(MESSAGE_HAVE, id, mailbox_, piece), MESSAGE_HAVE_SIZE)->detach();
+    remote_peer.mailbox_->put_init(new Message(MessageType::HAVE, id, mailbox_, piece), message_size(MessageType::HAVE))
+        ->detach();
   }
 }
 
@@ -157,7 +182,8 @@ void Peer::sendRequestTo(Connection* remote_peer, unsigned int piece)
     XBT_DEBUG("Sending a REQUEST to %s for piece %u (%d,%d)", remote_peer->mailbox_->get_cname(), piece, block_index,
               block_length);
     remote_peer->mailbox_
-        ->put_init(new Message(MESSAGE_REQUEST, id, mailbox_, piece, block_index, block_length), MESSAGE_REQUEST_SIZE)
+        ->put_init(new Message(MessageType::REQUEST, id, mailbox_, piece, block_index, block_length),
+                   message_size(MessageType::REQUEST))
         ->detach();
   }
 }
@@ -286,26 +312,25 @@ void Peer::updateActivePeersSet(Connection* remote_peer)
 
 void Peer::handleMessage()
 {
-  XBT_DEBUG("Received a %s message from %s", message_type_names.at(message->type),
-            message->return_mailbox->get_cname());
+  XBT_DEBUG("Received a %s message from %s", message_name(message->type), message->return_mailbox->get_cname());
 
   auto known_peer         = connected_peers.find(message->peer_id);
   Connection* remote_peer = (known_peer == connected_peers.end()) ? nullptr : &known_peer->second;
-  xbt_assert(remote_peer != nullptr || message->type == MESSAGE_HANDSHAKE,
+  xbt_assert(remote_peer != nullptr || message->type == MessageType::HANDSHAKE,
              "The impossible did happened: A not-in-our-list peer sent us a message.");
 
   switch (message->type) {
-    case MESSAGE_HANDSHAKE:
+    case MessageType::HANDSHAKE:
       // Check if the peer is in our connection list.
       if (remote_peer == nullptr) {
         XBT_DEBUG("This peer %d was unknown, answer to its handshake", message->peer_id);
         connected_peers.emplace(message->peer_id, Connection(message->peer_id));
-        sendMessage(message->return_mailbox, MESSAGE_HANDSHAKE, MESSAGE_HANDSHAKE_SIZE);
+        sendMessage(message->return_mailbox, MessageType::HANDSHAKE, message_size(MessageType::HANDSHAKE));
       }
       // Send our bitfield to the peer
       sendBitfield(message->return_mailbox);
       break;
-    case MESSAGE_BITFIELD:
+    case MessageType::BITFIELD:
       // Update the pieces list
       updatePiecesCountFromBitfield(message->bitfield);
       // Store the bitfield
@@ -313,32 +338,32 @@ void Peer::handleMessage()
       xbt_assert(not remote_peer->am_interested, "Should not be interested at first");
       if (isInterestedBy(remote_peer)) {
         remote_peer->am_interested = true;
-        sendMessage(message->return_mailbox, MESSAGE_INTERESTED, MESSAGE_INTERESTED_SIZE);
+        sendMessage(message->return_mailbox, MessageType::INTERESTED, message_size(MessageType::INTERESTED));
       }
       break;
-    case MESSAGE_INTERESTED:
+    case MessageType::INTERESTED:
       // Update the interested state of the peer.
       remote_peer->interested = true;
       updateActivePeersSet(remote_peer);
       break;
-    case MESSAGE_NOTINTERESTED:
+    case MessageType::NOTINTERESTED:
       remote_peer->interested = false;
       updateActivePeersSet(remote_peer);
       break;
-    case MESSAGE_UNCHOKE:
+    case MessageType::UNCHOKE:
       xbt_assert(remote_peer->choked_download);
       remote_peer->choked_download = false;
       // Send requests to the peer, since it has unchoked us
       if (remote_peer->am_interested)
         requestNewPieceTo(remote_peer);
       break;
-    case MESSAGE_CHOKE:
+    case MessageType::CHOKE:
       xbt_assert(not remote_peer->choked_download);
       remote_peer->choked_download = true;
       if (remote_peer->current_piece != -1)
         removeCurrentPiece(remote_peer, remote_peer->current_piece);
       break;
-    case MESSAGE_HAVE:
+    case MessageType::HAVE:
       XBT_DEBUG("\t for piece %d", message->piece);
       xbt_assert((message->piece >= 0 && static_cast<unsigned int>(message->piece) < FILE_PIECES),
                  "Wrong HAVE message received");
@@ -347,12 +372,12 @@ void Peer::handleMessage()
       // If the piece is in our pieces, we tell the peer that we are interested.
       if (not remote_peer->am_interested && hasNotPiece(message->piece)) {
         remote_peer->am_interested = true;
-        sendMessage(message->return_mailbox, MESSAGE_INTERESTED, MESSAGE_INTERESTED_SIZE);
+        sendMessage(message->return_mailbox, MessageType::INTERESTED, message_size(MessageType::INTERESTED));
         if (not remote_peer->choked_download)
           requestNewPieceTo(remote_peer);
       }
       break;
-    case MESSAGE_REQUEST:
+    case MessageType::REQUEST:
       xbt_assert(remote_peer->interested);
       xbt_assert((message->piece >= 0 && static_cast<unsigned int>(message->piece) < FILE_PIECES),
                  "Wrong HAVE message received");
@@ -366,7 +391,7 @@ void Peer::handleMessage()
         XBT_DEBUG("\t for piece %d but he is choked.", message->peer_id);
       }
       break;
-    case MESSAGE_PIECE:
+    case MessageType::PIECE:
       XBT_DEBUG(" \t for piece %d (%d,%d)", message->piece, message->block_index,
                 message->block_index + message->block_length);
       xbt_assert(not remote_peer->choked_download);
@@ -394,7 +419,7 @@ void Peer::handleMessage()
         requestNewPieceTo(remote_peer);
       }
       break;
-    case MESSAGE_CANCEL:
+    case MessageType::CANCEL:
       break;
     default:
       THROW_IMPOSSIBLE;
@@ -585,7 +610,7 @@ void Peer::updateChokedPeers()
       choked_peer->choked_upload = true;
       updateActivePeersSet(choked_peer);
       XBT_DEBUG("(%d) Sending a CHOKE to %d", id, choked_peer->id);
-      sendMessage(choked_peer->mailbox_, MESSAGE_CHOKE, MESSAGE_CHOKE_SIZE);
+      sendMessage(choked_peer->mailbox_, MessageType::CHOKE, message_size(MessageType::CHOKE));
     }
     if (chosen_peer != nullptr) {
       xbt_assert((chosen_peer->choked_upload), "Tries to unchoked an unchoked peer");
@@ -594,7 +619,7 @@ void Peer::updateChokedPeers()
       chosen_peer->last_unchoke = simgrid::s4u::Engine::get_clock();
       XBT_DEBUG("(%d) Sending a UNCHOKE to %d", id, chosen_peer->id);
       updateActivePeersSet(chosen_peer);
-      sendMessage(chosen_peer->mailbox_, MESSAGE_UNCHOKE, MESSAGE_UNCHOKE_SIZE);
+      sendMessage(chosen_peer->mailbox_, MessageType::UNCHOKE, message_size(MessageType::UNCHOKE));
     }
   }
 }
@@ -615,7 +640,7 @@ void Peer::updateInterestedAfterReceive()
 
       if (not interested) { // no more piece to download from connection
         remote_peer.am_interested = false;
-        sendMessage(remote_peer.mailbox_, MESSAGE_NOTINTERESTED, MESSAGE_NOTINTERESTED_SIZE);
+        sendMessage(remote_peer.mailbox_, MessageType::NOTINTERESTED, message_size(MessageType::NOTINTERESTED));
       }
     }
   }
index 4a3c84c..a9ea46b 100644 (file)
@@ -79,7 +79,7 @@ public:
   void requestNewPieceTo(Connection* remote_peer);
 
   bool getPeersFromTracker();
-  void sendMessage(simgrid::s4u::Mailbox* mailbox, e_message_type type, uint64_t size);
+  void sendMessage(simgrid::s4u::Mailbox* mailbox, MessageType type, uint64_t size);
   void sendBitfield(simgrid::s4u::Mailbox* mailbox);
   void sendPiece(simgrid::s4u::Mailbox* mailbox, unsigned int piece, int block_index, int block_length);
   void sendHandshakeToAllPeers();
index abb632b..d727cf3 100644 (file)
@@ -104,7 +104,7 @@ void Node::leave()
 void Node::notifyAndQuit()
 {
   // send the PREDECESSOR_LEAVING to our successor
-  auto* pred_msg         = new ChordMessage(PREDECESSOR_LEAVING);
+  auto* pred_msg         = new ChordMessage(MessageType::PREDECESSOR_LEAVING);
   pred_msg->request_id   = pred_id_;
   pred_msg->answer_to    = mailbox_;
 
@@ -118,7 +118,7 @@ void Node::notifyAndQuit()
 
   if (pred_id_ != -1 && pred_id_ != id_) {
     // send the SUCCESSOR_LEAVING to our predecessor (only if I have one that is not me)
-    auto* succ_msg         = new ChordMessage(SUCCESSOR_LEAVING);
+    auto* succ_msg         = new ChordMessage(MessageType::SUCCESSOR_LEAVING);
     succ_msg->request_id   = fingers_[0];
     succ_msg->answer_to    = mailbox_;
     XBT_DEBUG("Sending a 'SUCCESSOR_LEAVING' to my predecessor %d", pred_id_);
@@ -208,7 +208,7 @@ void Node::checkPredecessor()
   simgrid::s4u::Mailbox* mailbox        = simgrid::s4u::Mailbox::by_name(std::to_string(pred_id_));
   simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_is_alive");
 
-  auto* message         = new ChordMessage(PREDECESSOR_ALIVE);
+  auto* message         = new ChordMessage(MessageType::PREDECESSOR_ALIVE);
   message->request_id   = pred_id_;
   message->answer_to    = return_mailbox;
 
@@ -248,7 +248,7 @@ int Node::remoteGetPredecessor(int ask_to)
   simgrid::s4u::Mailbox* mailbox          = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
   simgrid::s4u::Mailbox* return_mailbox   = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_pred");
 
-  auto* message         = new ChordMessage(GET_PREDECESSOR);
+  auto* message         = new ChordMessage(MessageType::GET_PREDECESSOR);
   message->request_id   = id_;
   message->answer_to    = return_mailbox;
 
@@ -320,7 +320,7 @@ int Node::remoteFindSuccessor(int ask_to, int id)
   simgrid::s4u::Mailbox* mailbox          = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
   simgrid::s4u::Mailbox* return_mailbox   = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_succ");
 
-  auto* message         = new ChordMessage(FIND_SUCCESSOR);
+  auto* message         = new ChordMessage(MessageType::FIND_SUCCESSOR);
   message->request_id   = id_;
   message->answer_to    = return_mailbox;
 
@@ -366,7 +366,7 @@ void Node::notify(int predecessor_candidate_id)
 /* Notifies a remote node that its predecessor may have changed. */
 void Node::remoteNotify(int notify_id, int predecessor_candidate_id) const
 {
-  auto* message         = new ChordMessage(NOTIFY);
+  auto* message         = new ChordMessage(MessageType::NOTIFY);
   message->request_id   = predecessor_candidate_id;
   message->answer_to    = nullptr;
 
@@ -403,77 +403,78 @@ void Node::stabilize()
 void Node::handleMessage(ChordMessage* message)
 {
   switch (message->type) {
-  case FIND_SUCCESSOR:
-    XBT_DEBUG("Received a 'Find Successor' request from %s for id %d", message->issuer_host_name.c_str(),
-        message->request_id);
-    // is my successor the successor?
-    if (is_in_interval(message->request_id, id_ + 1, fingers_[0])) {
-      message->type = FIND_SUCCESSOR_ANSWER;
-      message->answer_id = fingers_[0];
-      XBT_DEBUG("Sending back a 'Find Successor Answer' to %s (mailbox %s): the successor of %d is %d",
-                message->issuer_host_name.c_str(), message->answer_to->get_cname(), message->request_id,
-                message->answer_id);
+    case MessageType::FIND_SUCCESSOR:
+      XBT_DEBUG("Received a 'Find Successor' request from %s for id %d", message->issuer_host_name.c_str(),
+                message->request_id);
+      // is my successor the successor?
+      if (is_in_interval(message->request_id, id_ + 1, fingers_[0])) {
+        message->type      = MessageType::FIND_SUCCESSOR_ANSWER;
+        message->answer_id = fingers_[0];
+        XBT_DEBUG("Sending back a 'Find Successor Answer' to %s (mailbox %s): the successor of %d is %d",
+                  message->issuer_host_name.c_str(), message->answer_to->get_cname(), message->request_id,
+                  message->answer_id);
+        message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy);
+      } else {
+        // otherwise, forward the request to the closest preceding finger in my table
+        int closest = closestPrecedingFinger(message->request_id);
+        XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d",
+                  message->request_id, closest);
+        simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(closest));
+        mailbox->put_init(message, 10)->detach(ChordMessage::destroy);
+      }
+      break;
+
+    case MessageType::GET_PREDECESSOR:
+      XBT_DEBUG("Receiving a 'Get Predecessor' request from %s", message->issuer_host_name.c_str());
+      message->type      = MessageType::GET_PREDECESSOR_ANSWER;
+      message->answer_id = pred_id_;
+      XBT_DEBUG("Sending back a 'Get Predecessor Answer' to %s via mailbox '%s': my predecessor is %d",
+                message->issuer_host_name.c_str(), message->answer_to->get_cname(), message->answer_id);
       message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy);
-    } else {
-      // otherwise, forward the request to the closest preceding finger in my table
-      int closest = closestPrecedingFinger(message->request_id);
-      XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d",
-          message->request_id, closest);
-      simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(closest));
-      mailbox->put_init(message, 10)->detach(ChordMessage::destroy);
-    }
-    break;
-
-  case GET_PREDECESSOR:
-    XBT_DEBUG("Receiving a 'Get Predecessor' request from %s", message->issuer_host_name.c_str());
-    message->type = GET_PREDECESSOR_ANSWER;
-    message->answer_id = pred_id_;
-    XBT_DEBUG("Sending back a 'Get Predecessor Answer' to %s via mailbox '%s': my predecessor is %d",
-              message->issuer_host_name.c_str(), message->answer_to->get_cname(), message->answer_id);
-    message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy);
-    break;
-
-  case NOTIFY:
-    // someone is telling me that he may be my new predecessor
-    XBT_DEBUG("Receiving a 'Notify' request from %s", message->issuer_host_name.c_str());
-    notify(message->request_id);
-    delete message;
-    break;
+      break;
+
+    case MessageType::NOTIFY:
+      // someone is telling me that he may be my new predecessor
+      XBT_DEBUG("Receiving a 'Notify' request from %s", message->issuer_host_name.c_str());
+      notify(message->request_id);
+      delete message;
+      break;
+
+    case MessageType::PREDECESSOR_LEAVING:
+      // my predecessor is about to quit
+      XBT_DEBUG("Receiving a 'Predecessor Leaving' message from %s", message->issuer_host_name.c_str());
+      // modify my predecessor
+      setPredecessor(message->request_id);
+      delete message;
+      /*TODO :
+        >> notify my new predecessor
+        >> send a notify_predecessors !!
+       */
+      break;
+
+    case MessageType::SUCCESSOR_LEAVING:
+      // my successor is about to quit
+      XBT_DEBUG("Receiving a 'Successor Leaving' message from %s", message->issuer_host_name.c_str());
+      // modify my successor FIXME : this should be implicit ?
+      setFinger(0, message->request_id);
+      delete message;
+      /* TODO
+         >> notify my new successor
+         >> update my table & predecessors table */
+      break;
+
+    case MessageType::PREDECESSOR_ALIVE:
+      XBT_DEBUG("Receiving a 'Predecessor Alive' request from %s", message->issuer_host_name.c_str());
+      message->type = MessageType::PREDECESSOR_ALIVE_ANSWER;
+      XBT_DEBUG("Sending back a 'Predecessor Alive Answer' to %s (mailbox %s)", message->issuer_host_name.c_str(),
+                message->answer_to->get_cname());
+      message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy);
+      break;
 
-  case PREDECESSOR_LEAVING:
-    // my predecessor is about to quit
-    XBT_DEBUG("Receiving a 'Predecessor Leaving' message from %s", message->issuer_host_name.c_str());
-    // modify my predecessor
-    setPredecessor(message->request_id);
-    delete message;
-    /*TODO :
-      >> notify my new predecessor
-      >> send a notify_predecessors !!
-     */
-    break;
-
-  case SUCCESSOR_LEAVING:
-    // my successor is about to quit
-    XBT_DEBUG("Receiving a 'Successor Leaving' message from %s", message->issuer_host_name.c_str());
-    // modify my successor FIXME : this should be implicit ?
-    setFinger(0, message->request_id);
-    delete message;
-    /* TODO
-       >> notify my new successor
-       >> update my table & predecessors table */
-    break;
-
-  case PREDECESSOR_ALIVE:
-    XBT_DEBUG("Receiving a 'Predecessor Alive' request from %s", message->issuer_host_name.c_str());
-    message->type = PREDECESSOR_ALIVE_ANSWER;
-    XBT_DEBUG("Sending back a 'Predecessor Alive Answer' to %s (mailbox %s)", message->issuer_host_name.c_str(),
-              message->answer_to->get_cname());
-    message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy);
-    break;
-
-  default:
-    XBT_DEBUG("Ignoring unexpected message: %d from %s", message->type, message->issuer_host_name.c_str());
-    delete message;
+    default:
+      XBT_DEBUG("Ignoring unexpected message: %d from %s", static_cast<int>(message->type),
+                message->issuer_host_name.c_str());
+      delete message;
   }
 }
 
index 4b9e85f..d303e7f 100644 (file)
@@ -22,7 +22,7 @@ extern int nb_keys;
 extern int timeout;
 
 /* Types of tasks exchanged between nodes. */
-enum e_message_type_t {
+enum class MessageType {
   FIND_SUCCESSOR,
   FIND_SUCCESSOR_ANSWER,
   GET_PREDECESSOR,
@@ -36,14 +36,14 @@ enum e_message_type_t {
 
 class ChordMessage {
 public:
-  e_message_type_t type;              // type of message
+  MessageType type;                                                                    // type of message
   std::string issuer_host_name     = simgrid::s4u::this_actor::get_host()->get_name(); // used for logging
   int request_id     = -1;            // id (used by some types of messages)
   int request_finger = 1;             // finger parameter (used by some types of messages)
   int answer_id      = -1;            // answer (used by some types of messages)
   simgrid::s4u::Mailbox* answer_to = nullptr;       // mailbox to send an answer to (if any)
 
-  explicit ChordMessage(e_message_type_t type) : type(type) {}
+  explicit ChordMessage(MessageType type) : type(type) {}
 
   static void destroy(void* message);
 };
index 2369503..833cc02 100644 (file)
@@ -60,19 +60,19 @@ public:
 
 class XBT_PUBLIC ImpossibleError : public std::logic_error {
 public:
-  explicit ImpossibleError(const std::string& arg) : std::logic_error(arg) {}
+  using std::logic_error::logic_error;
   ~ImpossibleError() override;
 };
 
 class XBT_PUBLIC InitializationError : public std::logic_error {
 public:
-  explicit InitializationError(const std::string& arg) : std::logic_error(arg) {}
+  using std::logic_error::logic_error;
   ~InitializationError() override;
 };
 
 class XBT_PUBLIC UnimplementedError : public std::logic_error {
 public:
-  explicit UnimplementedError(const std::string& arg) : std::logic_error(arg) {}
+  using std::logic_error::logic_error;
   ~UnimplementedError() override;
 };
 
@@ -81,8 +81,8 @@ public:
 /** Ancestor class of all SimGrid exception */
 class Exception : public std::runtime_error {
 public:
-  Exception(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message)
-      : std::runtime_error(std::move(message)), throwpoint_(std::move(throwpoint))
+  Exception(const simgrid::xbt::ThrowPoint& throwpoint, const std::string& message)
+      : std::runtime_error(message), throwpoint_(throwpoint)
   {
   }
   Exception(const Exception&)     = default;
@@ -104,12 +104,7 @@ private:
 /** Exception raised when a timeout elapsed */
 class TimeoutException : public Exception {
 public:
-  TimeoutException(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message)
-      : Exception(std::move(throwpoint), std::move(message))
-  {
-  }
-  TimeoutException(const TimeoutException&)     = default;
-  TimeoutException(TimeoutException&&) noexcept = default;
+  using Exception::Exception;
   ~TimeoutException() override;
 };
 
@@ -118,72 +113,42 @@ using TimeoutError XBT_ATTRIB_DEPRECATED_v328("Please use simgrid::TimeoutExcept
 /** Exception raised when a host fails */
 class HostFailureException : public Exception {
 public:
-  HostFailureException(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message)
-      : Exception(std::move(throwpoint), std::move(message))
-  {
-  }
-  HostFailureException(const HostFailureException&)     = default;
-  HostFailureException(HostFailureException&&) noexcept = default;
+  using Exception::Exception;
   ~HostFailureException() override;
 };
 
 /** Exception raised when a communication fails because of the network or because of the remote host */
 class NetworkFailureException : public Exception {
 public:
-  NetworkFailureException(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message)
-      : Exception(std::move(throwpoint), std::move(message))
-  {
-  }
-  NetworkFailureException(const NetworkFailureException&)     = default;
-  NetworkFailureException(NetworkFailureException&&) noexcept = default;
+  using Exception::Exception;
   ~NetworkFailureException() override;
 };
 
 /** Exception raised when a storage fails */
 class StorageFailureException : public Exception {
 public:
-  StorageFailureException(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message)
-      : Exception(std::move(throwpoint), std::move(message))
-  {
-  }
-  StorageFailureException(const StorageFailureException&)     = default;
-  StorageFailureException(StorageFailureException&&) noexcept = default;
+  using Exception::Exception;
   ~StorageFailureException() override;
 };
 
 /** Exception raised when a VM fails */
 class VmFailureException : public Exception {
 public:
-  VmFailureException(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message)
-      : Exception(std::move(throwpoint), std::move(message))
-  {
-  }
-  VmFailureException(const VmFailureException&)     = default;
-  VmFailureException(VmFailureException&&) noexcept = default;
+  using Exception::Exception;
   ~VmFailureException() override;
 };
 
 /** Exception raised when something got canceled before completion */
 class CancelException : public Exception {
 public:
-  CancelException(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message)
-      : Exception(std::move(throwpoint), std::move(message))
-  {
-  }
-  CancelException(const CancelException&)     = default;
-  CancelException(CancelException&&) noexcept = default;
+  using Exception::Exception;
   ~CancelException() override;
 };
 
 /** Exception raised when something is going wrong during the simulation tracing */
 class TracingError : public Exception {
 public:
-  TracingError(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message)
-      : Exception(std::move(throwpoint), std::move(message))
-  {
-  }
-  TracingError(const TracingError&)     = default;
-  TracingError(TracingError&&) noexcept = default;
+  using Exception::Exception;
   ~TracingError() override;
 };
 
index a0e5a84..5dcdece 100644 (file)
@@ -146,9 +146,9 @@ typedef sg_vm_t msg_vm_t;
 XBT_PUBLIC msg_vm_t MSG_vm_create_core(msg_host_t pm, const char* name);
 XBT_PUBLIC msg_vm_t MSG_vm_create_multicore(msg_host_t pm, const char* name, int coreAmount);
 
-XBT_PUBLIC int MSG_vm_is_created(msg_vm_t vm);
-XBT_PUBLIC int MSG_vm_is_running(msg_vm_t vm);
-XBT_PUBLIC int MSG_vm_is_suspended(msg_vm_t vm);
+XBT_PUBLIC int MSG_vm_is_created(const_sg_vm_t vm);
+XBT_PUBLIC int MSG_vm_is_running(const_sg_vm_t vm);
+XBT_PUBLIC int MSG_vm_is_suspended(const_sg_vm_t vm);
 
 XBT_PUBLIC const char* MSG_vm_get_name(const_sg_vm_t vm);
 XBT_PUBLIC void MSG_vm_set_ramsize(msg_vm_t vm, size_t size);
index 141cd5d..764bc08 100644 (file)
@@ -63,19 +63,19 @@ public:
   template <class F> void register_actor(const std::string& name)
   {
     kernel::actor::ActorCodeFactory code_factory = [](std::vector<std::string> args) {
-      return kernel::actor::ActorCode([args] {
+      return kernel::actor::ActorCode([args = std::move(args)]() mutable {
         F code(std::move(args));
         code();
       });
     };
-    register_function(name, std::move(code_factory));
+    register_function(name, code_factory);
   }
   template <class F> void register_actor(const std::string& name, F code)
   {
     kernel::actor::ActorCodeFactory code_factory = [code](std::vector<std::string> args) {
-      return kernel::actor::ActorCode([code, args] { code(std::move(args)); });
+      return kernel::actor::ActorCode([code, args = std::move(args)]() mutable { code(std::move(args)); });
     };
-    register_function(name, std::move(code_factory));
+    register_function(name, code_factory);
   }
 
   void load_deployment(const std::string& deploy) const;
index 4da7a7e..4b27c49 100644 (file)
@@ -312,13 +312,13 @@ public:
 
 class GatherAction : public ReplayAction<GatherArgParser> {
 public:
-  explicit GatherAction(const std::string& name) : ReplayAction(name) {}
+  using ReplayAction::ReplayAction;
   void kernel(xbt::ReplayAction& action) override;
 };
 
 class GatherVAction : public ReplayAction<GatherVArgParser> {
 public:
-  explicit GatherVAction(const std::string& name) : ReplayAction(name) {}
+  using ReplayAction::ReplayAction;
   void kernel(xbt::ReplayAction& action) override;
 };
 
index a89e274..8a6592a 100644 (file)
@@ -17,9 +17,9 @@ SG_BEGIN_DECL
 XBT_PUBLIC sg_vm_t sg_vm_create_core(sg_host_t pm, const char* name);
 XBT_PUBLIC sg_vm_t sg_vm_create_multicore(sg_host_t pm, const char* name, int core_amount);
 
-XBT_PUBLIC int sg_vm_is_created(sg_vm_t vm);
-XBT_PUBLIC int sg_vm_is_running(sg_vm_t vm);
-XBT_PUBLIC int sg_vm_is_suspended(sg_vm_t vm);
+XBT_PUBLIC int sg_vm_is_created(const_sg_vm_t vm);
+XBT_PUBLIC int sg_vm_is_running(const_sg_vm_t vm);
+XBT_PUBLIC int sg_vm_is_suspended(const_sg_vm_t vm);
 
 XBT_PUBLIC const char* sg_vm_get_name(const_sg_vm_t vm);
 XBT_PUBLIC void sg_vm_set_ramsize(sg_vm_t vm, size_t size);
index 1044009..7d5572c 100644 (file)
@@ -117,7 +117,7 @@ template <class T>
 void bind_flag(T& value, const char* name, std::initializer_list<const char*> aliases, const char* description)
 {
   bind_flag(value, name, description);
-  alias(name, std::move(aliases));
+  alias(name, aliases);
 }
 
 /** Bind a variable to configuration flag
@@ -146,7 +146,7 @@ typename std::enable_if<std::is_same<void, decltype(std::declval<F>()(std::declv
 bind_flag(T& value, const char* name, std::initializer_list<const char*> aliases, const char* description, F callback)
 {
   bind_flag(value, name, description, std::move(callback));
-  alias(name, std::move(aliases));
+  alias(name, aliases);
 }
 
 template <class T, class F>
@@ -177,7 +177,7 @@ bind_flag(T& value, const char* name, std::initializer_list<const char*> aliases
           const std::map<T, std::string>& valid_values, F callback)
 {
   bind_flag(value, name, description, valid_values, std::move(callback));
-  alias(name, std::move(aliases));
+  alias(name, aliases);
 }
 
 /** Bind a variable to configuration flag
@@ -228,7 +228,7 @@ public:
   Flag(const char* name, std::initializer_list<const char*> aliases, const char* desc, T value)
       : value_(value), name_(name)
   {
-    simgrid::config::bind_flag(value_, name, std::move(aliases), desc);
+    simgrid::config::bind_flag(value_, name, aliases, desc);
   }
 
   /* A constructor accepting a callback that will be passed the parameter.
@@ -243,7 +243,7 @@ public:
   Flag(const char* name, std::initializer_list<const char*> aliases, const char* desc, T value, F callback)
       : value_(value), name_(name)
   {
-    simgrid::config::bind_flag(value_, name, std::move(aliases), desc, std::move(callback));
+    simgrid::config::bind_flag(value_, name, aliases, desc, std::move(callback));
   }
 
   /* A constructor accepting a map of valid values -> their description,
@@ -262,7 +262,7 @@ public:
        const std::map<T, std::string>& valid_values, F callback)
       : value_(value), name_(name)
   {
-    simgrid::config::bind_flag(value_, name, std::move(aliases), desc, valid_values, std::move(callback));
+    simgrid::config::bind_flag(value_, name, aliases, desc, valid_values, std::move(callback));
   }
 
   // No copy:
index 7d4e4ef..b8a2474 100644 (file)
@@ -85,8 +85,7 @@ public:
  */
 class XBT_PUBLIC StdRandom : public Random {
 public:
-  StdRandom() = default;
-  explicit StdRandom(int seed) : Random(seed) {}
+  using Random::Random;
 
   int uniform_int(int min, int max) override;
   double uniform_real(double min, double max) override;
@@ -100,8 +99,7 @@ public:
  */
 class XBT_PUBLIC XbtRandom : public Random {
 public:
-  XbtRandom() = default;
-  explicit XbtRandom(int seed) : Random(seed) {}
+  using Random::Random;
 
   int uniform_int(int min, int max) override;
   double uniform_real(double min, double max) override;
index 8ae6756..0a50fb6 100644 (file)
@@ -101,7 +101,7 @@ public:
   string() : string(&NUL, 0) {}
   explicit string(const char* s) : string(s, strlen(s)) {}
   string(string const& s) : string(s.c_str(), s.size()) {}
-  string(string&& s) noexcept : str(std::move(s.str))
+  string(string&& s) noexcept : str(s.str)
   {
     s.str.len  = 0;
     s.str.data = &NUL;
index 639c15d..96a9550 100644 (file)
@@ -37,13 +37,13 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_nativeInit(JNIEnv *env, jclass cl
 
 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isCreated(JNIEnv* env, jobject jvm)
 {
-  sg_vm_t vm = jvm_get_native(env, jvm);
+  const_sg_vm_t vm = jvm_get_native(env, jvm);
   return sg_vm_is_created(vm);
 }
 
 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isRunning(JNIEnv* env, jobject jvm)
 {
-  sg_vm_t vm = jvm_get_native(env, jvm);
+  const_sg_vm_t vm = jvm_get_native(env, jvm);
   return sg_vm_is_running(vm);
 }
 
@@ -55,7 +55,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isMigrating(JNIEnv* env, jobj
 
 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isSuspended(JNIEnv* env, jobject jvm)
 {
-  sg_vm_t vm = jvm_get_native(env, jvm);
+  const_sg_vm_t vm = jvm_get_native(env, jvm);
   return sg_vm_is_suspended(vm);
 }
 
index a1be187..cf95509 100644 (file)
@@ -218,7 +218,7 @@ int trace_precision;
  *************/
 xbt::signal<void(Container const&)> Container::on_creation;
 xbt::signal<void(Container const&)> Container::on_destruction;
-xbt::signal<void(Type const&, e_event_type)> Type::on_creation;
+xbt::signal<void(Type const&, PajeEventType)> Type::on_creation;
 xbt::signal<void(LinkType const&, Type const&, Type const&)> LinkType::on_creation;
 xbt::signal<void(PajeEvent&)> PajeEvent::on_creation;
 xbt::signal<void(PajeEvent const&)> PajeEvent::on_destruction;
@@ -230,9 +230,10 @@ static void on_container_creation_paje(const Container& c)
   double timestamp = SIMIX_get_clock();
   std::stringstream stream;
 
-  XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_CreateContainer, timestamp);
+  XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, static_cast<unsigned>(PajeEventType::CreateContainer),
+            timestamp);
 
-  stream << std::fixed << std::setprecision(trace_precision) << PAJE_CreateContainer << " ";
+  stream << std::fixed << std::setprecision(trace_precision) << PajeEventType::CreateContainer << " ";
   stream << timestamp << " " << c.get_id() << " " << c.type_->get_id() << " " << c.father_->get_id() << " \"";
   if (c.get_name().find("rank-") != 0)
     stream << c.get_name() << "\"";
@@ -251,9 +252,10 @@ static void on_container_destruction_paje(const Container& c)
     std::stringstream stream;
     double timestamp = SIMIX_get_clock();
 
-    XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_DestroyContainer, timestamp);
+    XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, static_cast<unsigned>(PajeEventType::DestroyContainer),
+              timestamp);
 
-    stream << std::fixed << std::setprecision(trace_precision) << PAJE_DestroyContainer << " ";
+    stream << std::fixed << std::setprecision(trace_precision) << PajeEventType::DestroyContainer << " ";
     stream << timestamp << " " << c.type_->get_id() << " " << c.get_id();
     XBT_DEBUG("Dump %s", stream.str().c_str());
     tracing_file << stream.str() << std::endl;
@@ -262,7 +264,8 @@ static void on_container_destruction_paje(const Container& c)
 
 static void on_container_creation_ti(const Container& c)
 {
-  XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_CreateContainer, SIMIX_get_clock());
+  XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, static_cast<unsigned>(PajeEventType::CreateContainer),
+            SIMIX_get_clock());
   // if we are in the mode with only one file
   static std::ofstream* ti_unique_file = nullptr;
 
@@ -300,8 +303,8 @@ static void on_container_destruction_ti(const Container& c)
 static void on_entity_value_creation(const EntityValue& value)
 {
   std::stringstream stream;
-  XBT_DEBUG("%s: event_type=%u", __func__, PAJE_DefineEntityValue);
-  stream << std::fixed << std::setprecision(trace_precision) << PAJE_DefineEntityValue;
+  XBT_DEBUG("%s: event_type=%u", __func__, static_cast<unsigned>(PajeEventType::DefineEntityValue));
+  stream << std::fixed << std::setprecision(trace_precision) << PajeEventType::DefineEntityValue;
   stream << " " << value.get_id() << " " << value.get_father()->get_id() << " " << value.get_name();
   if (not value.get_color().empty())
     stream << " \"" << value.get_color() << "\"";
@@ -311,7 +314,8 @@ static void on_entity_value_creation(const EntityValue& value)
 
 static void on_event_creation(PajeEvent& event)
 {
-  XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, event.eventType_, trace_precision, event.timestamp_);
+  XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, static_cast<unsigned>(event.eventType_), trace_precision,
+            event.timestamp_);
   event.stream_ << std::fixed << std::setprecision(trace_precision);
   event.stream_ << event.eventType_ << " " << event.timestamp_ << " ";
   event.stream_ << event.get_type()->get_id() << " " << event.get_container()->get_id();
@@ -329,14 +333,14 @@ static void on_state_event_destruction(const StateEvent& event)
     *tracing_files.at(event.get_container()) << event.stream_.str() << std::endl;
 }
 
-static void on_type_creation(const Type& type, e_event_type event_type)
+static void on_type_creation(const Type& type, PajeEventType event_type)
 {
-  if (event_type == PAJE_DefineLinkType)
+  if (event_type == PajeEventType::DefineLinkType)
     return; // this kind of type has to be handled differently
 
   std::stringstream stream;
   stream << std::fixed << std::setprecision(trace_precision);
-  XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, event_type, trace_precision, 0.);
+  XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, static_cast<unsigned>(event_type), trace_precision, 0.);
   stream << event_type << " " << type.get_id() << " " << type.get_father()->get_id() << " " << type.get_name();
   if (type.is_colored())
     stream << " \"" << type.get_color() << "\"";
@@ -347,8 +351,9 @@ static void on_type_creation(const Type& type, e_event_type event_type)
 static void on_link_type_creation(const Type& type, const Type& source, const Type& dest)
 {
   std::stringstream stream;
-  XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, PAJE_DefineLinkType, trace_precision, 0.);
-  stream << PAJE_DefineLinkType << " " << type.get_id() << " " << type.get_father()->get_id();
+  XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, static_cast<unsigned>(PajeEventType::DefineLinkType),
+            trace_precision, 0.);
+  stream << PajeEventType::DefineLinkType << " " << type.get_id() << " " << type.get_father()->get_id();
   stream << " " << source.get_id() << " " << dest.get_id() << " " << type.get_name();
   XBT_DEBUG("Dump %s", stream.str().c_str());
   tracing_file << stream.str() << std::endl;
index 6ba97ee..d469422 100644 (file)
@@ -13,7 +13,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_events, instr, "Paje tracing event sy
 namespace simgrid {
 namespace instr {
 
-PajeEvent::PajeEvent(Container* container, Type* type, double timestamp, e_event_type eventType)
+PajeEvent::PajeEvent(Container* container, Type* type, double timestamp, PajeEventType eventType)
     : container_(container), type_(type), timestamp_(timestamp), eventType_(eventType)
 {
   on_creation(*this);
@@ -25,7 +25,7 @@ PajeEvent::~PajeEvent()
   on_destruction(*this);
 }
 
-StateEvent::StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra)
+StateEvent::StateEvent(Container* container, Type* type, PajeEventType event_type, EntityValue* value, TIData* extra)
     : PajeEvent::PajeEvent(container, type, SIMIX_get_clock(), event_type), value(value), extra_(extra)
 {
 #if HAVE_SMPI
@@ -53,7 +53,7 @@ void LinkEvent::print()
 void StateEvent::print()
 {
   if (trace_format == TraceFormat::Paje) {
-    if (value != nullptr) // PAJE_PopState Event does not need to have a value
+    if (value != nullptr) // PajeEventType::PopState Event does not need to have a value
       stream_ << " " << value->get_id();
 
     if (TRACE_display_sizes())
index 2527bd7..dd24ec5 100644 (file)
@@ -17,27 +17,32 @@ namespace instr {
 class EntityValue;
 class TIData;
 
-enum e_event_type : unsigned int {
-  PAJE_DefineContainerType,
-  PAJE_DefineVariableType,
-  PAJE_DefineStateType,
-  PAJE_DefineEventType,
-  PAJE_DefineLinkType,
-  PAJE_DefineEntityValue,
-  PAJE_CreateContainer,
-  PAJE_DestroyContainer,
-  PAJE_SetVariable,
-  PAJE_AddVariable,
-  PAJE_SubVariable,
-  PAJE_SetState,
-  PAJE_PushState,
-  PAJE_PopState,
-  PAJE_ResetState,
-  PAJE_StartLink,
-  PAJE_EndLink,
-  PAJE_NewEvent
+enum class PajeEventType : unsigned int {
+  DefineContainerType,
+  DefineVariableType,
+  DefineStateType,
+  DefineEventType,
+  DefineLinkType,
+  DefineEntityValue,
+  CreateContainer,
+  DestroyContainer,
+  SetVariable,
+  AddVariable,
+  SubVariable,
+  SetState,
+  PushState,
+  PopState,
+  ResetState,
+  StartLink,
+  EndLink,
+  NewEvent
 };
 
+inline std::ostream& operator<<(std::ostream& os, PajeEventType event)
+{
+  return os << static_cast<std::underlying_type<PajeEventType>::type>(event);
+}
+
 class PajeEvent {
   Container* container_;
   Type* type_;
@@ -46,10 +51,10 @@ public:
   static xbt::signal<void(PajeEvent const&)> on_destruction;
 
   double timestamp_;
-  e_event_type eventType_;
+  PajeEventType eventType_;
   std::stringstream stream_;
 
-  PajeEvent(Container* container, Type* type, double timestamp, e_event_type eventType);
+  PajeEvent(Container* container, Type* type, double timestamp, PajeEventType eventType);
   virtual ~PajeEvent();
 
   Container* get_container() const { return container_; }
@@ -63,7 +68,7 @@ class VariableEvent : public PajeEvent {
   double value_;
 
 public:
-  VariableEvent(double timestamp, Container* container, Type* type, e_event_type event_type, double value)
+  VariableEvent(double timestamp, Container* container, Type* type, PajeEventType event_type, double value)
       : PajeEvent::PajeEvent(container, type, timestamp, event_type), value_(value)
   {
   }
@@ -80,7 +85,7 @@ class StateEvent : public PajeEvent {
 
 public:
   static xbt::signal<void(StateEvent const&)> on_destruction;
-  StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra);
+  StateEvent(Container* container, Type* type, PajeEventType event_type, EntityValue* value, TIData* extra);
   ~StateEvent() override { on_destruction(*this); }
   bool has_extra() const { return extra_ != nullptr; }
   void print() override;
@@ -93,7 +98,7 @@ class LinkEvent : public PajeEvent {
   int size_ = -1;
 
 public:
-  LinkEvent(Container* container, Type* type, e_event_type event_type, Container* sourceContainer,
+  LinkEvent(Container* container, Type* type, PajeEventType event_type, Container* sourceContainer,
             const std::string& value, const std::string& key, int size)
       : PajeEvent(container, type, SIMIX_get_clock(), event_type)
       , endpoint_(sourceContainer)
@@ -110,7 +115,7 @@ class NewEvent : public PajeEvent {
 
 public:
   NewEvent(double timestamp, Container* container, Type* type, EntityValue* value)
-      : PajeEvent::PajeEvent(container, type, timestamp, PAJE_NewEvent), value(value)
+      : PajeEvent::PajeEvent(container, type, timestamp, PajeEventType::NewEvent), value(value)
   {
   }
   void print() override;
index 5944628..73f4559 100644 (file)
@@ -45,7 +45,7 @@ void dump_comment_file(const std::string& filename)
 void dump_header(bool basic, bool display_sizes)
 {
   // Types
-  tracing_file << "%EventDef PajeDefineContainerType " << PAJE_DefineContainerType << std::endl;
+  tracing_file << "%EventDef PajeDefineContainerType " << PajeEventType::DefineContainerType << std::endl;
   tracing_file << "%       Alias string" << std::endl;
   if (basic)
     tracing_file << "%       ContainerType string" << std::endl;
@@ -55,26 +55,26 @@ void dump_header(bool basic, bool display_sizes)
   tracing_file << "%       Name string" << std::endl;
   tracing_file << "%EndEventDef" << std::endl;
 
-  tracing_file << "%EventDef PajeDefineVariableType " << PAJE_DefineVariableType << std::endl;
+  tracing_file << "%EventDef PajeDefineVariableType " << PajeEventType::DefineVariableType << std::endl;
   tracing_file << "%       Alias string" << std::endl;
   tracing_file << "%       " << (basic ? "Container" : "") << "Type string" << std::endl;
   tracing_file << "%       Name string" << std::endl;
   tracing_file << "%       Color color" << std::endl;
   tracing_file << "%EndEventDef" << std::endl;
 
-  tracing_file << "%EventDef PajeDefineStateType " << PAJE_DefineStateType << std::endl;
+  tracing_file << "%EventDef PajeDefineStateType " << PajeEventType::DefineStateType << std::endl;
   tracing_file << "%       Alias string" << std::endl;
   tracing_file << "%       " << (basic ? "Container" : "") << "Type string" << std::endl;
   tracing_file << "%       Name string" << std::endl;
   tracing_file << "%EndEventDef" << std::endl;
 
-  tracing_file << "%EventDef PajeDefineEventType " << PAJE_DefineEventType << std::endl;
+  tracing_file << "%EventDef PajeDefineEventType " << PajeEventType::DefineEventType << std::endl;
   tracing_file << "%       Alias string" << std::endl;
   tracing_file << "%       " << (basic ? "Container" : "") << "Type string" << std::endl;
   tracing_file << "%       Name string" << std::endl;
   tracing_file << "%EndEventDef" << std::endl;
 
-  tracing_file << "%EventDef PajeDefineLinkType " << PAJE_DefineLinkType << std::endl;
+  tracing_file << "%EventDef PajeDefineLinkType " << PajeEventType::DefineLinkType << std::endl;
   tracing_file << "%       Alias string" << std::endl;
   tracing_file << "%       " << (basic ? "Container" : "") << "Type string" << std::endl;
   tracing_file << "%       " << (basic ? "Source" : "Start") << "ContainerType string" << std::endl;
@@ -83,7 +83,7 @@ void dump_header(bool basic, bool display_sizes)
   tracing_file << "%EndEventDef" << std::endl;
 
   // EntityValue
-  tracing_file << "%EventDef PajeDefineEntityValue " << PAJE_DefineEntityValue << std::endl;
+  tracing_file << "%EventDef PajeDefineEntityValue " << PajeEventType::DefineEntityValue << std::endl;
   tracing_file << "%       Alias string" << std::endl;
   tracing_file << "%       " << (basic ? "Entity" : "") << "Type string" << std::endl;
   tracing_file << "%       Name string" << std::endl;
@@ -91,7 +91,7 @@ void dump_header(bool basic, bool display_sizes)
   tracing_file << "%EndEventDef" << std::endl;
 
   // Container
-  tracing_file << "%EventDef PajeCreateContainer " << PAJE_CreateContainer << std::endl;
+  tracing_file << "%EventDef PajeCreateContainer " << PajeEventType::CreateContainer << std::endl;
   tracing_file << "%       Time date" << std::endl;
   tracing_file << "%       Alias string" << std::endl;
   tracing_file << "%       Type string" << std::endl;
@@ -99,28 +99,28 @@ void dump_header(bool basic, bool display_sizes)
   tracing_file << "%       Name string" << std::endl;
   tracing_file << "%EndEventDef" << std::endl;
 
-  tracing_file << "%EventDef PajeDestroyContainer " << PAJE_DestroyContainer << std::endl;
+  tracing_file << "%EventDef PajeDestroyContainer " << PajeEventType::DestroyContainer << std::endl;
   tracing_file << "%       Time date" << std::endl;
   tracing_file << "%       Type string" << std::endl;
   tracing_file << "%       Name string" << std::endl;
   tracing_file << "%EndEventDef" << std::endl;
 
   // Variable
-  tracing_file << "%EventDef PajeSetVariable " << PAJE_SetVariable << std::endl;
+  tracing_file << "%EventDef PajeSetVariable " << PajeEventType::SetVariable << std::endl;
   tracing_file << "%       Time date" << std::endl;
   tracing_file << "%       Type string" << std::endl;
   tracing_file << "%       Container string" << std::endl;
   tracing_file << "%       Value double" << std::endl;
   tracing_file << "%EndEventDef" << std::endl;
 
-  tracing_file << "%EventDef PajeAddVariable " << PAJE_AddVariable << std::endl;
+  tracing_file << "%EventDef PajeAddVariable " << PajeEventType::AddVariable << std::endl;
   tracing_file << "%       Time date" << std::endl;
   tracing_file << "%       Type string" << std::endl;
   tracing_file << "%       Container string" << std::endl;
   tracing_file << "%       Value double" << std::endl;
   tracing_file << "%EndEventDef" << std::endl;
 
-  tracing_file << "%EventDef PajeSubVariable " << PAJE_SubVariable << std::endl;
+  tracing_file << "%EventDef PajeSubVariable " << PajeEventType::SubVariable << std::endl;
   tracing_file << "%       Time date" << std::endl;
   tracing_file << "%       Type string" << std::endl;
   tracing_file << "%       Container string" << std::endl;
@@ -128,14 +128,14 @@ void dump_header(bool basic, bool display_sizes)
   tracing_file << "%EndEventDef" << std::endl;
 
   // State
-  tracing_file << "%EventDef PajeSetState " << PAJE_SetState << std::endl;
+  tracing_file << "%EventDef PajeSetState " << PajeEventType::SetState << std::endl;
   tracing_file << "%       Time date" << std::endl;
   tracing_file << "%       Type string" << std::endl;
   tracing_file << "%       Container string" << std::endl;
   tracing_file << "%       Value string" << std::endl;
   tracing_file << "%EndEventDef" << std::endl;
 
-  tracing_file << "%EventDef PajePushState " << PAJE_PushState << std::endl;
+  tracing_file << "%EventDef PajePushState " << PajeEventType::PushState << std::endl;
   tracing_file << "%       Time date" << std::endl;
   tracing_file << "%       Type string" << std::endl;
   tracing_file << "%       Container string" << std::endl;
@@ -151,14 +151,14 @@ void dump_header(bool basic, bool display_sizes)
 #endif
   tracing_file << "%EndEventDef" << std::endl;
 
-  tracing_file << "%EventDef PajePopState " << PAJE_PopState << std::endl;
+  tracing_file << "%EventDef PajePopState " << PajeEventType::PopState << std::endl;
   tracing_file << "%       Time date" << std::endl;
   tracing_file << "%       Type string" << std::endl;
   tracing_file << "%       Container string" << std::endl;
   tracing_file << "%EndEventDef" << std::endl;
 
   if (not basic) {
-    tracing_file << "%EventDef PajeResetState " << PAJE_ResetState << std::endl;
+    tracing_file << "%EventDef PajeResetState " << PajeEventType::ResetState << std::endl;
     tracing_file << "%       Time date" << std::endl;
     tracing_file << "%       Type string" << std::endl;
     tracing_file << "%       Container string" << std::endl;
@@ -166,7 +166,7 @@ void dump_header(bool basic, bool display_sizes)
   }
 
   // Link
-  tracing_file << "%EventDef PajeStartLink " << PAJE_StartLink << std::endl;
+  tracing_file << "%EventDef PajeStartLink " << PajeEventType::StartLink << std::endl;
   tracing_file << "%       Time date" << std::endl;
   tracing_file << "%       Type string" << std::endl;
   tracing_file << "%       Container string" << std::endl;
@@ -177,7 +177,7 @@ void dump_header(bool basic, bool display_sizes)
     tracing_file << "%       Size int" << std::endl;
   tracing_file << "%EndEventDef" << std::endl;
 
-  tracing_file << "%EventDef PajeEndLink " << PAJE_EndLink << std::endl;
+  tracing_file << "%EventDef PajeEndLink " << PajeEventType::EndLink << std::endl;
   tracing_file << "%       Time date" << std::endl;
   tracing_file << "%       Type string" << std::endl;
   tracing_file << "%       Container string" << std::endl;
@@ -187,7 +187,7 @@ void dump_header(bool basic, bool display_sizes)
   tracing_file << "%EndEventDef" << std::endl;
 
   // Event
-  tracing_file << "%EventDef PajeNewEvent " << PAJE_NewEvent << std::endl;
+  tracing_file << "%EventDef PajeNewEvent " << PajeEventType::NewEvent << std::endl;
   tracing_file << "%       Time date" << std::endl;
   tracing_file << "%       Type string" << std::endl;
   tracing_file << "%       Container string" << std::endl;
index 1c6c1c4..44dc1ea 100644 (file)
@@ -49,11 +49,12 @@ void dump_buffer(bool force)
 /* internal do the instrumentation module */
 void PajeEvent::insert_into_buffer()
 {
-  XBT_DEBUG("%s: insert event_type=%u, timestamp=%f, buffersize=%zu)", __func__, eventType_, timestamp_, buffer.size());
+  XBT_DEBUG("%s: insert event_type=%u, timestamp=%f, buffersize=%zu)", __func__, static_cast<unsigned>(eventType_),
+            timestamp_, buffer.size());
   std::vector<PajeEvent*>::reverse_iterator i;
   for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
     PajeEvent* e1 = *i;
-    XBT_DEBUG("compare to %p is of type %u; timestamp:%f", e1, e1->eventType_, e1->timestamp_);
+    XBT_DEBUG("compare to %p is of type %u; timestamp:%f", e1, static_cast<unsigned>(e1->eventType_), e1->timestamp_);
     if (e1->timestamp_ <= timestamp_)
       break;
   }
index 213c45b..a075804 100644 (file)
@@ -21,7 +21,7 @@ long long int new_paje_id()
   return type_id++;
 }
 
-Type::Type(e_event_type event_type, const std::string& name, const std::string& alias, const std::string& color,
+Type::Type(PajeEventType event_type, const std::string& name, const std::string& alias, const std::string& color,
            Type* father)
     : name_(name), color_(color), father_(father)
 {
@@ -37,17 +37,18 @@ Type::Type(e_event_type event_type, const std::string& name, const std::string&
 
 void StateType::set_event(const std::string& value_name)
 {
-  events_.push_back(new StateEvent(get_issuer(), this, PAJE_SetState, get_entity_value(value_name), nullptr));
+  events_.push_back(new StateEvent(get_issuer(), this, PajeEventType::SetState, get_entity_value(value_name), nullptr));
 }
 
 void StateType::push_event(const std::string& value_name, TIData* extra)
 {
-  events_.push_back(new StateEvent(get_issuer(), this, PAJE_PushState, get_entity_value(value_name), extra));
+  events_.push_back(new StateEvent(get_issuer(), this, PajeEventType::PushState, get_entity_value(value_name), extra));
 }
 
 void StateType::push_event(const std::string& value_name)
 {
-  events_.push_back(new StateEvent(get_issuer(), this, PAJE_PushState, get_entity_value(value_name), nullptr));
+  events_.push_back(
+      new StateEvent(get_issuer(), this, PajeEventType::PushState, get_entity_value(value_name), nullptr));
 }
 
 void StateType::pop_event()
@@ -57,7 +58,7 @@ void StateType::pop_event()
 
 void StateType::pop_event(TIData* extra)
 {
-  events_.push_back(new StateEvent(get_issuer(), this, PAJE_PopState, nullptr, extra));
+  events_.push_back(new StateEvent(get_issuer(), this, PajeEventType::PopState, nullptr, extra));
 }
 
 void VariableType::instr_event(double now, double delta, const char* resource, double value)
@@ -82,17 +83,17 @@ void VariableType::instr_event(double now, double delta, const char* resource, d
 
 void VariableType::set_event(double timestamp, double value)
 {
-  events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PAJE_SetVariable, value));
+  events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PajeEventType::SetVariable, value));
 }
 
 void VariableType::add_event(double timestamp, double value)
 {
-  events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PAJE_AddVariable, value));
+  events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PajeEventType::AddVariable, value));
 }
 
 void VariableType::sub_event(double timestamp, double value)
 {
-  events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PAJE_SubVariable, value));
+  events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PajeEventType::SubVariable, value));
 }
 
 void LinkType::start_event(Container* startContainer, const std::string& value, const std::string& key)
@@ -102,12 +103,12 @@ void LinkType::start_event(Container* startContainer, const std::string& value,
 
 void LinkType::start_event(Container* startContainer, const std::string& value, const std::string& key, int size)
 {
-  new LinkEvent(get_issuer(), this, PAJE_StartLink, startContainer, value, key, size);
+  new LinkEvent(get_issuer(), this, PajeEventType::StartLink, startContainer, value, key, size);
 }
 
 void LinkType::end_event(Container* endContainer, const std::string& value, const std::string& key)
 {
-  new LinkEvent(get_issuer(), this, PAJE_EndLink, endContainer, value, key, -1);
+  new LinkEvent(get_issuer(), this, PajeEventType::EndLink, endContainer, value, key, -1);
 }
 
 Type* Type::by_name(const std::string& name)
index 269175c..9b69640 100644 (file)
@@ -30,9 +30,9 @@ protected:
   Container* get_issuer() const { return issuer_; }
 
 public:
-  static xbt::signal<void(Type const&, e_event_type event_type)> on_creation;
+  static xbt::signal<void(Type const&, PajeEventType event_type)> on_creation;
 
-  Type(e_event_type event_type, const std::string& name, const std::string& alias, const std::string& color,
+  Type(PajeEventType event_type, const std::string& name, const std::string& alias, const std::string& color,
        Type* father);
   virtual ~Type() = default;
 
@@ -63,15 +63,16 @@ public:
 
 class ContainerType : public Type {
 public:
-  explicit ContainerType(const std::string& name) : Type(PAJE_DefineContainerType, name, name, "", nullptr){};
-  ContainerType(const std::string& name, Type* father) : Type(PAJE_DefineContainerType, name, name, "", father){};
+  explicit ContainerType(const std::string& name) : Type(PajeEventType::DefineContainerType, name, name, "", nullptr){};
+  ContainerType(const std::string& name, Type* father)
+      : Type(PajeEventType::DefineContainerType, name, name, "", father){};
 };
 
 class VariableType : public Type {
   std::vector<VariableEvent*> events_;
 public:
   VariableType(const std::string& name, const std::string& color, Type* father)
-      : Type(PAJE_DefineVariableType, name, name, color, father)
+      : Type(PajeEventType::DefineVariableType, name, name, color, father)
   {
   }
   void instr_event(double now, double delta, const char* resource, double value);
@@ -83,9 +84,9 @@ public:
 class ValueType : public Type {
 public:
   std::map<std::string, EntityValue> values_;
-  ValueType(e_event_type event_type, const std::string& name, const std::string& alias, Type* father)
+  ValueType(PajeEventType event_type, const std::string& name, const std::string& alias, Type* father)
       : Type(event_type, name, alias, "", father){};
-  ValueType(e_event_type event_type, const std::string& name, Type* father)
+  ValueType(PajeEventType event_type, const std::string& name, Type* father)
       : Type(event_type, name, name, "", father){};
   ~ValueType() override = default;
   void add_entity_value(const std::string& name, const std::string& color);
@@ -97,7 +98,7 @@ class LinkType : public ValueType {
 public:
   static xbt::signal<void(LinkType const&, Type const&, Type const&)> on_creation;
   LinkType(const std::string& name, const Type* source, const Type* dest, const std::string& alias, Type* father)
-      : ValueType(PAJE_DefineLinkType, name, alias, father)
+      : ValueType(PajeEventType::DefineLinkType, name, alias, father)
   {
     on_creation(*this, *source, *dest);
   }
@@ -108,13 +109,13 @@ public:
 
 class EventType : public ValueType {
 public:
-  EventType(const std::string& name, Type* father) : ValueType(PAJE_DefineEventType, name, father) {}
+  EventType(const std::string& name, Type* father) : ValueType(PajeEventType::DefineEventType, name, father) {}
 };
 
 class StateType : public ValueType {
   std::vector<StateEvent*> events_;
 public:
-  StateType(const std::string& name, Type* father) : ValueType(PAJE_DefineStateType, name, father) {}
+  StateType(const std::string& name, Type* father) : ValueType(PajeEventType::DefineStateType, name, father) {}
   void set_event(const std::string& value_name);
   void push_event(const std::string& value_name);
   void push_event(const std::string& value_name, TIData* extra);
index 4ca1e45..3d8e887 100644 (file)
@@ -22,7 +22,7 @@ void jedule_log_sd_event(const_SD_task_t task)
   simgrid::jedule::Event event(std::string(SD_task_get_name(task)), SD_task_get_start_time(task),
                                SD_task_get_finish_time(task), "SD");
   event.add_resources(*task->allocation);
-  my_jedule->add_event(std::move(event));
+  my_jedule->add_event(event);
 }
 
 void jedule_sd_init()
index e631755..fa893bd 100644 (file)
@@ -350,8 +350,7 @@ s4u::Actor* ActorImpl::restart()
   context::Context::self()->get_actor()->kill(this);
 
   // start the new actor
-  ActorImplPtr actor =
-      ActorImpl::create(arg.name, std::move(arg.code), arg.data, arg.host, arg.properties.get(), nullptr);
+  ActorImplPtr actor = ActorImpl::create(arg.name, arg.code, arg.data, arg.host, arg.properties.get(), nullptr);
   *actor->on_exit = std::move(*arg.on_exit);
   actor->set_kill_time(arg.kill_time);
   actor->set_auto_restart(arg.auto_restart);
index f525dfa..5fd3827 100644 (file)
@@ -553,7 +553,7 @@ private:
 
 class XBT_PUBLIC FairBottleneck : public System {
 public:
-  explicit FairBottleneck(bool selective_update) : System(selective_update) {}
+  using System::System;
   void solve() final { bottleneck_solve(); }
 
 private:
index b6f9584..e310310 100644 (file)
@@ -152,7 +152,7 @@ void DragonflyZone::generate_link(const std::string& id, int numlinks, resource:
   linkTemplate.bandwidths.push_back(this->bw_ * numlinks);
   linkTemplate.latency   = this->lat_;
   linkTemplate.policy    = this->sharing_policy_;
-  linkTemplate.id        = std::move(id);
+  linkTemplate.id        = id;
   sg_platf_new_link(&linkTemplate);
   XBT_DEBUG("Generating link %s", linkTemplate.id.c_str());
   resource::LinkImpl* link;
index c6258b3..3a94b47 100644 (file)
@@ -53,7 +53,7 @@ struct ExpressionContext {
 /** When an error happens in the execution of a DWARF expression */
 class evaluation_error : public std::runtime_error {
 public:
-  explicit evaluation_error(const char* what) : std::runtime_error(what) {}
+  using std::runtime_error::runtime_error;
 };
 
 /** A stack for evaluating a DWARF expression
index 294d641..ceb818d 100644 (file)
@@ -535,7 +535,7 @@ void RemoteSimulation::ignore_region(std::uint64_t addr, std::size_t size)
 void RemoteSimulation::ignore_heap(IgnoredHeapRegion const& region)
 {
   if (ignored_heap_.empty()) {
-    ignored_heap_.push_back(std::move(region));
+    ignored_heap_.push_back(region);
     return;
   }
 
index 5393c8f..86c806c 100644 (file)
@@ -229,7 +229,7 @@ void Snapshot::add_region(RegionType type, ObjectInformation* object_info, void*
 
   auto* region = new Region(type, start_addr, size);
   region->object_info(object_info);
-  snapshot_regions_.push_back(std::unique_ptr<Region>(std::move(region)));
+  snapshot_regions_.push_back(std::unique_ptr<Region>(region));
 }
 
 void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, ReadOptions options) const
index 633c89a..f253bff 100644 (file)
@@ -82,11 +82,7 @@ snap_test_helper::prologue_return snap_test_helper::prologue(int n)
   INFO("Could not allocate destination memory");
   REQUIRE(source != MAP_FAILED);
 
-  return {.size    = byte_size,
-          .src     = source,
-          .dstn    = destination,
-          .region0 = std::move(region0),
-          .region  = std::move(region)};
+  return {.size = byte_size, .src = source, .dstn = destination, .region0 = region0, .region = region};
 }
 
 void snap_test_helper::read_whole_region()
index 4adb631..eb5ce0c 100644 (file)
@@ -415,15 +415,15 @@ sg_vm_t MSG_vm_create_multicore(sg_host_t pm, const char* name, int coreAmount)
 {
   return sg_vm_create_multicore(pm, name, coreAmount);
 }
-int MSG_vm_is_created(sg_vm_t vm)
+int MSG_vm_is_created(const_sg_vm_t vm)
 {
   return sg_vm_is_created(vm);
 }
-int MSG_vm_is_running(sg_vm_t vm)
+int MSG_vm_is_running(const_sg_vm_t vm)
 {
   return sg_vm_is_running(vm);
 }
-int MSG_vm_is_suspended(sg_vm_t vm)
+int MSG_vm_is_suspended(const_sg_vm_t vm)
 {
   return sg_vm_is_suspended(vm);
 }
index 82c38aa..57bf368 100644 (file)
@@ -140,7 +140,7 @@ public:
  */
 class Performance : public Governor {
 public:
-  explicit Performance(simgrid::s4u::Host* ptr) : Governor(ptr) {}
+  using Governor::Governor;
   std::string get_name() const override { return "Performance"; }
 
   void update() override { get_host()->set_pstate(get_min_pstate()); }
@@ -158,7 +158,7 @@ public:
  */
 class Powersave : public Governor {
 public:
-  explicit Powersave(simgrid::s4u::Host* ptr) : Governor(ptr) {}
+  using Governor::Governor;
   std::string get_name() const override { return "Powersave"; }
 
   void update() override { get_host()->set_pstate(get_max_pstate()); }
@@ -181,7 +181,7 @@ class OnDemand : public Governor {
   double freq_up_threshold_ = 0.80;
 
 public:
-  explicit OnDemand(simgrid::s4u::Host* ptr) : Governor(ptr) {}
+  using Governor::Governor;
   std::string get_name() const override { return "OnDemand"; }
 
   void update() override
@@ -229,7 +229,7 @@ class Conservative : public Governor {
   double freq_down_threshold_ = .2;
 
 public:
-  explicit Conservative(simgrid::s4u::Host* ptr) : Governor(ptr) {}
+  using Governor::Governor;
   std::string get_name() const override { return "Conservative"; }
 
   void update() override
index 6813e18..f1bc4f7 100644 (file)
@@ -231,19 +231,19 @@ void sg_vm_set_bound(sg_vm_t vm, double bound)
 }
 
 /** @brief Returns whether the given VM has just created, not running. */
-int sg_vm_is_created(sg_vm_t vm)
+int sg_vm_is_created(const_sg_vm_t vm)
 {
   return vm->get_state() == simgrid::s4u::VirtualMachine::state::CREATED;
 }
 
 /** @brief Returns whether the given VM is currently running */
-int sg_vm_is_running(sg_vm_t vm)
+int sg_vm_is_running(const_sg_vm_t vm)
 {
   return vm->get_state() == simgrid::s4u::VirtualMachine::state::RUNNING;
 }
 
 /** @brief Returns whether the given VM is currently suspended, not running. */
-int sg_vm_is_suspended(sg_vm_t vm)
+int sg_vm_is_suspended(const_sg_vm_t vm)
 {
   return vm->get_state() == simgrid::s4u::VirtualMachine::state::SUSPENDED;
 }
index 5588ce9..1fd96f9 100644 (file)
@@ -499,13 +499,13 @@ void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, const char
   simgrid::kernel::actor::ActorCode function;
   if (code)
     function = simgrid::xbt::wrap_main(code, argc, argv);
-  actor->start(std::move(function));
+  actor->start(function);
 }
 
 sg_actor_t sg_actor_create(const char* name, sg_host_t host, xbt_main_func_t code, int argc, const char* const* argv)
 {
   simgrid::kernel::actor::ActorCode function = simgrid::xbt::wrap_main(code, argc, argv);
-  return simgrid::s4u::Actor::init(name, host)->start(std::move(function)).get();
+  return simgrid::s4u::Actor::init(name, host)->start(function).get();
 }
 
 void sg_actor_set_stacksize(sg_actor_t actor, unsigned size)
index 7737a2b..f7f8b71 100644 (file)
@@ -96,7 +96,7 @@ void Engine::register_function(const std::string& name, int (*code)(int, char**)
   kernel::actor::ActorCodeFactory code_factory = [code](std::vector<std::string> args) {
     return xbt::wrap_main(code, std::move(args));
   };
-  register_function(name, std::move(code_factory));
+  register_function(name, code_factory);
 }
 void Engine::register_default(int (*code)(int, char**)) // XBT_ATTRIB_DEPRECATED_v329
 {
@@ -109,16 +109,16 @@ void Engine::register_function(const std::string& name, const std::function<void
   kernel::actor::ActorCodeFactory code_factory = [code](std::vector<std::string> args) {
     return xbt::wrap_main(code, std::move(args));
   };
-  register_function(name, std::move(code_factory));
+  register_function(name, code_factory);
 }
 
 /** Registers the main function of an actor that will be launched from the deployment file */
 void Engine::register_function(const std::string& name, const std::function<void(std::vector<std::string>)>& code)
 {
-  kernel::actor::ActorCodeFactory code_factory = [code](std::vector<std::string> args) {
+  kernel::actor::ActorCodeFactory code_factory = [code{code}](std::vector<std::string> args) mutable {
     return std::bind(std::move(code), std::move(args));
   };
-  register_function(name, std::move(code_factory));
+  register_function(name, code_factory);
 }
 /** Registers a function as the default main function of actors
  *
index 590aada..02af4c9 100644 (file)
@@ -430,7 +430,7 @@ static void smpi_init_privatization_dlopen(const std::string& executable)
       // load the library once to add it to the local libs, to get the absolute path
       void* libhandle = dlopen(libname.c_str(), RTLD_LAZY);
       xbt_assert(libhandle != nullptr, 
-                "Cannot dlopen %s - check your settings in smpi/privatize-libs", libname.c_str());
+                     "Cannot dlopen %s - check your settings in smpi/privatize-libs", libname.c_str());
       // get library name from path
       std::string fullpath = libname;
 #if not defined(__APPLE__) && not defined(__HAIKU__)
@@ -479,9 +479,10 @@ static void smpi_init_privatization_dlopen(const std::string& executable)
           target_libs.push_back(target_lib);
           XBT_DEBUG("copy lib %s to %s, with size %lld", libpath.c_str(), target_lib.c_str(), (long long)fdin_size2);
           smpi_copy_file(libpath, target_lib, fdin_size2);
-          void* handle = dlopen(target_lib.c_str(), RTLD_LAZY | RTLD_LOCAL | WANT_RTLD_DEEPBIND);
-          xbt_assert(handle != nullptr, "dlopen of library %s failed: %s (errno: %d -- %s)", target_lib.c_str(), 
-                         dlerror(), errno, strerror(errno));
+
+          std::string sedcommand = "sed -i -e 's/" + libname + "/" + target_lib + "/g' " + target_executable;
+          int status             = system(sedcommand.c_str());
+          xbt_assert(status == 0, "error while applying sed command %s \n", sedcommand.c_str());
         }
       }
 
index 20a0394..2f23588 100644 (file)
@@ -113,7 +113,7 @@ std::vector<s4u::Disk*> HostImpl::get_disks() const
 
 void HostImpl::set_disks(const std::vector<kernel::resource::DiskImpl*>& disks, s4u::Host* host)
 {
-  disks_ = std::move(disks);
+  disks_ = disks;
   for (auto d : disks_)
     d->set_host(host);
 }
index 0215897..4ac9b2f 100644 (file)
@@ -27,7 +27,7 @@ namespace resource {
  */
 class XBT_PUBLIC CpuModel : public Model {
 public:
-  explicit CpuModel(Model::UpdateAlgo algo) : Model(algo) {}
+  using Model::Model;
 
   /**
    * @brief Create a Cpu
@@ -176,8 +176,7 @@ public:
    */
   static xbt::signal<void(CpuAction const&, Action::State)> on_state_change;
 
-  CpuAction(Model* model, double cost, bool failed) : Action(model, cost, failed) {}
-  CpuAction(Model* model, double cost, bool failed, lmm::Variable* var) : Action(model, cost, failed, var) {}
+  using Action::Action;
 
   void set_state(Action::State state) override;
 
index 42354ab..e5b1e63 100644 (file)
@@ -60,8 +60,7 @@ class NetworkCm02Action : public NetworkAction {
   friend Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate);
 
 public:
-  NetworkCm02Action(Model* model, s4u::Host& src, s4u::Host& dst, double cost, bool failed)
-      : NetworkAction(model, src, dst, cost, failed){};
+  using NetworkAction::NetworkAction;
   ~NetworkCm02Action() override = default;
   void update_remains_lazy(double now) override;
 };
index 9fffd5b..5ff4cf2 100644 (file)
@@ -35,7 +35,7 @@ public:
   static config::Flag<double> cfg_tcp_gamma;
   static config::Flag<bool> cfg_crosstraffic;
 
-  explicit NetworkModel(Model::UpdateAlgo algo) : Model(algo) {}
+  using Model::Model;
   NetworkModel(const NetworkModel&) = delete;
   NetworkModel& operator=(const NetworkModel&) = delete;
   ~NetworkModel() override;
index 9095e59..42f498c 100644 (file)
@@ -467,7 +467,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
     XBT_DEBUG("Process %s@%s will be started at time %f", arg->name.c_str(), arg->host->get_cname(), start_time);
     simgrid::simix::Timer::set(start_time, [arg, auto_restart]() {
       simgrid::kernel::actor::ActorImplPtr new_actor = simgrid::kernel::actor::ActorImpl::create(
-          arg->name.c_str(), std::move(arg->code), arg->data, arg->host, arg->properties.get(), nullptr);
+          arg->name.c_str(), arg->code, arg->data, arg->host, arg->properties.get(), nullptr);
       if (arg->kill_time >= 0)
         new_actor->set_kill_time(arg->kill_time);
       if (auto_restart)
@@ -479,7 +479,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
 
     try {
       simgrid::kernel::actor::ActorImplPtr new_actor = nullptr;
-      new_actor = simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), std::move(code), nullptr, host,
+      new_actor = simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), code, nullptr, host,
                                                             arg->properties.get(), nullptr);
       /* The actor creation will fail if the host is currently dead, but that's fine */
       if (arg->kill_time >= 0)
index c486699..2fcff2f 100644 (file)
@@ -73,7 +73,7 @@ void surf_parse_assert_netpoint(const std::string& hostname, const std::string&
       break;
     }
   }
-  surf_parse_error(std::move(msg));
+  surf_parse_error(msg);
 }
 
 double surf_parse_get_double(const std::string& s)
@@ -786,7 +786,7 @@ void ETag_surfxml_config()
   for (std::string key : keys) {
     if (simgrid::config::is_default(key.c_str())) {
       std::string cfg = key + ":" + current_property_set->at(key);
-      simgrid::config::set_parse(std::move(cfg));
+      simgrid::config::set_parse(cfg);
     } else
       XBT_INFO("The custom configuration '%s' is already defined by user!", key.c_str());
   }
index 76cc597..01a9dd8 100644 (file)
@@ -10,7 +10,9 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(random_bug, "For this example");
 
-enum { ABORT, ASSERT, PRINTF } behavior;
+enum class Behavior { ABORT, ASSERT, PRINTF };
+
+Behavior behavior;
 
 /** A fake application with a bug occurring for some random values */
 static void app()
@@ -18,12 +20,12 @@ static void app()
   int x = MC_random(0, 5);
   int y = MC_random(0, 5);
 
-  if (behavior == ASSERT) {
+  if (behavior == Behavior::ASSERT) {
     MC_assert(x != 3 || y != 4);
-  } else if (behavior == PRINTF) {
+  } else if (behavior == Behavior::PRINTF) {
     if (x == 3 && y == 4)
       XBT_ERROR("Error reached");
-  } else { // behavior == ABORT
+  } else { // behavior == Behavior::ABORT
     abort();
   }
 }
@@ -35,13 +37,13 @@ int main(int argc, char* argv[])
   xbt_assert(argc == 3, "Usage: random-bug raise|assert <platformfile>");
   if (strcmp(argv[1], "abort") == 0) {
     XBT_INFO("Behavior: abort");
-    behavior = ABORT;
+    behavior = Behavior::ABORT;
   } else if (strcmp(argv[1], "assert") == 0) {
     XBT_INFO("Behavior: assert");
-    behavior = ASSERT;
+    behavior = Behavior::ASSERT;
   } else if (strcmp(argv[1], "printf") == 0) {
     XBT_INFO("Behavior: printf");
-    behavior = PRINTF;
+    behavior = Behavior::PRINTF;
   } else {
     xbt_die("Please use either 'abort', 'assert' or 'printf' as first parameter, to specify what to do when the error "
             "is found.");
index 853b08d..5d86a64 100644 (file)
@@ -42,7 +42,7 @@ static int computation_fun(std::vector<std::string> argv)
 static void run_test_process(const std::string& name, simgrid::s4u::Host* location, int size)
 {
   std::vector<std::string> arg = {std::to_string(size)};
-  simgrid::s4u::Actor::create(std::move(name), location, computation_fun, arg);
+  simgrid::s4u::Actor::create(name, location, computation_fun, arg);
 }
 
 static void test_energy_consumption(const std::string& name, int nb_cores)
index 3e92f60..484f487 100644 (file)
@@ -22,14 +22,17 @@ if(enable_compile_warnings)
     set(warnCFLAGS "${warnCFLAGS} -Wclobbered -Wno-error=clobbered  -Wno-unused-local-typedefs -Wno-error=attributes -Wno-error=maybe-uninitialized")
   endif()
   if (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
-    # ignore remark  #1418: external function definition with no prior declaration
+    # ignore remarks:
+    # 191: type qualifier is meaningless on cast type
+    # 1418: external function definition with no prior declaration
     # 2196: routine is both "inline" and "noinline"
+    # 2651: attribute does not apply to any entity
     # 3179: deprecated conversion of string literal to char* (should be const char*)
-    # 191: type qualifier is meaningless on cast type
+    # set as warning:
     # 597: entity-kind "entity" will not be called for implicit or explicit conversions
     # 2330: argument of type "type" is incompatible with parameter of type "type" (dropping qualifiers)
     # 11003: no IR in object file xxxx; was the source file compiled with xxxx
-    set(warnCFLAGS "${warnCFLAGS} -diag-disable=1418,191,2196,3179 -diag-warning=2330,597,11003")
+    set(warnCFLAGS "${warnCFLAGS} -diag-disable=191,1418,2196,2651,3179 -diag-warning=597,2330,11003")
   endif()
 
   set(warnCXXFLAGS "${warnCFLAGS} -Wall -Wextra -Wunused -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing")