Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Clearly state that we don't care about the return code of actors
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 4 Feb 2020 12:21:51 +0000 (13:21 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 4 Feb 2020 12:21:57 +0000 (13:21 +0100)
Earlier, the actor had the exact same prototype than the C main()
function. In particular, it was supposed to return an integer. But
that value is ignored in simgrid since years (or maybe since ever).

So, change the expected return code to 'void' to make this clear and
reduce the clutter in user code.

The deprecation code should be in place until v3.30 for s4u code.

The MSG clients are not modified, and the MSG implementation is only
slightly modified with a crude cast (that mandates the
-Wno-error=cast-function-type flag on the command line when compiling
MSG).

23 files changed:
examples/c/actor-create/actor-create.c
examples/c/async-waitany/async-waitany.c
examples/s4u/actor-create/s4u-actor-create.cpp
examples/s4u/async-ready/s4u-async-ready.cpp
examples/s4u/async-wait/s4u-async-wait.cpp
examples/s4u/async-waituntil/s4u-async-waituntil.cpp
examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp
examples/s4u/io-file-remote/s4u-io-file-remote.cpp
examples/s4u/platform-failures/s4u-platform-failures.cpp
examples/smpi/replay_multiple/replay_multiple.c
examples/smpi/smpi_s4u_masterslave/masterslave_mailbox_smpi.cpp
include/simgrid/engine.h
include/simgrid/msg.h
include/simgrid/s4u/Engine.hpp
include/xbt/function_types.h
src/bindings/java/jmsg.cpp
src/kernel/EngineImpl.cpp
src/kernel/EngineImpl.hpp
src/msg/msg_legacy.cpp
src/msg/msg_process.cpp
src/s4u/s4u_Engine.cpp
teshsuite/smpi/gh-139/gh-139.c
tools/cmake/MakeLib.cmake

index 044d446..9715ea0 100644 (file)
@@ -32,7 +32,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_create, "The logging channel used in this
  *
  * One 'receiver' actor is instantiated within the simulation later in this file.
  */
-static int receiver(int argc, char** argv)
+static void receiver(int argc, char** argv)
 {
   xbt_assert(argc == 2, "This actor expects a single argument: the mailbox on which to get messages");
   sg_mailbox_t mailbox = sg_mailbox_by_name(argv[1]);
@@ -44,11 +44,10 @@ static int receiver(int argc, char** argv)
   const char* msg3 = sg_mailbox_get(mailbox);
   XBT_INFO("I received '%s', '%s' and '%s'", msg1, msg2, msg3);
   XBT_INFO("I'm done. See you.");
-  return 0;
 }
 
 /* Our second class of actors, in charge of sending stuff */
-static int sender(int argc, char** argv)
+static void sender(int argc, char** argv)
 {
   xbt_assert(argc == 3, "Actor 'sender' requires 2 parameters (mailbox and data to send), but got only %d", argc - 1);
   XBT_INFO("Hello s4u, I have something to send");
@@ -57,7 +56,6 @@ static int sender(int argc, char** argv)
 
   sg_mailbox_put(mailbox, xbt_strdup(sent_data), strlen(sent_data));
   XBT_INFO("I'm done. See you.");
-  return 0;
 }
 
 /* Here comes the main function of your program */
index 73eaae3..3871f00 100644 (file)
@@ -16,7 +16,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(async_waitany, "Messages specific for this example");
 
-static int sender(int argc, char* argv[])
+static void sender(int argc, char* argv[])
 {
   xbt_assert(argc == 4, "Expecting 3 parameters from the XML deployment file but got %d", argc);
   long messages_count  = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
@@ -77,10 +77,9 @@ static int sender(int argc, char* argv[])
   free(mboxes);
 
   XBT_INFO("Goodbye now!");
-  return 0;
 }
 
-static int receiver(int argc, char* argv[])
+static void receiver(int argc, char* argv[])
 {
   xbt_assert(argc == 2, "Expecting one parameter from the XML deployment file but got %d", argc);
   int id = xbt_str_parse_int(argv[1], "ID should be numerical, not %s");
@@ -99,7 +98,6 @@ static int receiver(int argc, char* argv[])
   }
 
   XBT_INFO("I'm done. See you!");
-  return 0;
 }
 
 int main(int argc, char* argv[])
index 9809d5f..bff3790 100644 (file)
@@ -44,7 +44,7 @@ static void receiver(const std::string& mailbox_name)
 }
 
 /* Our second class of actors is also a function */
-static int forwarder(int argc, char** argv)
+static void forwarder(int argc, char** argv)
 {
   xbt_assert(argc >= 3, "Actor forwarder requires 2 parameters, but got only %d", argc - 1);
   simgrid::s4u::Mailbox* in    = simgrid::s4u::Mailbox::by_name(argv[1]);
@@ -52,7 +52,6 @@ static int forwarder(int argc, char** argv)
   std::string* msg             = static_cast<std::string*>(in->get());
   XBT_INFO("Forward '%s'.", msg->c_str());
   out->put(msg, msg->size());
-  return 0;
 }
 
 /* Declares a third class of actors which sends a message to the mailbox 'mb42'.
index 8bebb50..6745ee3 100644 (file)
@@ -25,7 +25,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_async_ready, "Messages specific for this s4u example");
 
-static int peer(int argc, char** argv)
+static void peer(int argc, char** argv)
 {
   xbt_assert(argc == 5, "Expecting 4 parameters from the XML deployment file but got %d", argc);
   int my_id           = std::stoi(argv[1]); /* - my id */
@@ -90,7 +90,6 @@ static int peer(int argc, char** argv)
   simgrid::s4u::Comm::wait_all(&pending_comms);
 
   XBT_INFO("Goodbye now!");
-  return 0;
 }
 
 
index 8dec966..03da3fd 100644 (file)
@@ -18,7 +18,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_async_wait, "Messages specific for this s4u example");
 
-static int sender(int argc, char** argv)
+static void sender(int argc, char** argv)
 {
   xbt_assert(argc == 4, "Expecting 3 parameters from the XML deployment file but got %d", argc);
   long messages_count  = std::stol(argv[1]); /* - number of tasks */
@@ -63,11 +63,10 @@ static int sender(int argc, char** argv)
   }
 
   XBT_INFO("Goodbye now!");
-  return 0;
 }
 
 /* Receiver actor expects 1 argument: its ID */
-static int receiver(int argc, char** argv)
+static void receiver(int argc, char** argv)
 {
   xbt_assert(argc == 2, "Expecting one parameter from the XML deployment file but got %d", argc);
   simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(std::string("receiver-") + argv[1]);
@@ -80,7 +79,6 @@ static int receiver(int argc, char** argv)
       cont = false; // If it's a finalize message, we're done.
     delete received;
   }
-  return 0;
 }
 
 int main(int argc, char *argv[])
index ae9039f..bce6ec6 100644 (file)
@@ -17,7 +17,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_async_waituntil, "Messages specific for this s4u example");
 
-static int sender(int argc, char** argv)
+static void sender(int argc, char** argv)
 {
   xbt_assert(argc == 4, "Expecting 3 parameters from the XML deployment file but got %d", argc);
   long messages_count  = std::stol(argv[1]); /* - number of tasks */
@@ -61,11 +61,10 @@ static int sender(int argc, char** argv)
   }
 
   XBT_INFO("Goodbye now!");
-  return 0;
 }
 
 /* Receiver actor expects 1 argument: its ID */
-static int receiver(int argc, char** argv)
+static void receiver(int argc, char** argv)
 {
   xbt_assert(argc == 2, "Expecting one parameter from the XML deployment file but got %d", argc);
   simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(std::string("receiver-") + argv[1]);
@@ -78,7 +77,6 @@ static int receiver(int argc, char** argv)
       cont = false; // If it's a finalize message, we're done.
     delete received;
   }
-  return 0;
 }
 
 int main(int argc, char* argv[])
index 50349e1..ac5231c 100644 (file)
@@ -17,53 +17,53 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(kademlia, "Messages specific for this example");
   * @param the ID of the person I know in the system (or not)
   * @param Time before I leave the system because I'm bored
   */
-static int node(int argc, char* argv[])
+static void node(int argc, char* argv[])
 {
   bool join_success = true;
   double deadline;
   xbt_assert(argc == 3 || argc == 4, "Wrong number of arguments");
   /* Node initialization */
   unsigned int node_id = strtoul(argv[1], nullptr, 0);
-  kademlia::Node* node = new kademlia::Node(node_id);
+  kademlia::Node node(node_id);
 
   if (argc == 4) {
-    XBT_INFO("Hi, I'm going to join the network with id %u", node->getId());
+    XBT_INFO("Hi, I'm going to join the network with id %u", node.getId());
     unsigned int known_id = strtoul(argv[2], NULL, 0);
-    join_success          = node->join(known_id);
+    join_success          = node.join(known_id);
     deadline              = std::stod(argv[3]);
   } else {
     deadline = std::stod(argv[2]);
-    XBT_INFO("Hi, I'm going to create the network with id %u", node->getId());
-    node->routingTableUpdate(node->getId());
+    XBT_INFO("Hi, I'm going to create the network with id %u", node.getId());
+    node.routingTableUpdate(node.getId());
   }
 
   if (join_success) {
-    XBT_VERB("Ok, I'm joining the network with id %u", node->getId());
+    XBT_VERB("Ok, I'm joining the network with id %u", node.getId());
     // We start the main loop
     double next_lookup_time = simgrid::s4u::Engine::get_clock() + RANDOM_LOOKUP_INTERVAL;
 
     XBT_VERB("Main loop start");
 
-    simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(node->getId()));
+    simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(node.getId()));
 
     while (simgrid::s4u::Engine::get_clock() < deadline) {
-      if (node->receive_comm == nullptr)
-        node->receive_comm = mailbox->get_async(&node->received_msg);
+      if (node.receive_comm == nullptr)
+        node.receive_comm = mailbox->get_async(&node.received_msg);
 
-      if (node->receive_comm->test()) {
+      if (node.receive_comm->test()) {
         // There has been a message, we need to handle it !
-        const kademlia::Message* msg = static_cast<kademlia::Message*>(node->received_msg);
+        const kademlia::Message* msg = static_cast<kademlia::Message*>(node.received_msg);
         if (msg) {
-          node->handleFindNode(msg);
+          node.handleFindNode(msg);
           delete msg->answer_;
           delete msg;
-          node->receive_comm = nullptr;
+          node.receive_comm = nullptr;
         } else
           simgrid::s4u::this_actor::sleep_for(1);
       } else {
         /* We search for a pseudo random node */
         if (simgrid::s4u::Engine::get_clock() >= next_lookup_time) {
-          node->randomLookup();
+          node.randomLookup();
           next_lookup_time += RANDOM_LOOKUP_INTERVAL;
         } else {
           // Didn't get a message: sleep for a while...
@@ -75,10 +75,7 @@ static int node(int argc, char* argv[])
     XBT_INFO("I couldn't join the network :(");
   }
   XBT_DEBUG("I'm leaving the network");
-  XBT_INFO("%u/%u FIND_NODE have succeeded", node->find_node_success, node->find_node_success + node->find_node_failed);
-  delete node;
-
-  return 0;
+  XBT_INFO("%u/%u FIND_NODE have succeeded", node.find_node_success, node.find_node_success + node.find_node_failed);
 }
 
 /** @brief Main function */
index 7994ee0..a3b2fd9 100644 (file)
@@ -11,7 +11,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(remote_io, "Messages specific for this io example");
 
-static int host(int argc, char* argv[])
+static void host(int argc, char* argv[])
 {
   simgrid::s4u::File file(argv[1], nullptr);
   const char* filename = file.get_path();
@@ -32,7 +32,6 @@ static int host(int argc, char* argv[])
       file.remote_copy(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
     }
   }
-  return 0;
 }
 
 int main(int argc, char** argv)
index e33bdbd..68a2211 100644 (file)
@@ -22,7 +22,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
 
-static int master(int argc, char* argv[])
+static void master(int argc, char* argv[])
 {
   xbt_assert(argc == 5, "Expecting one parameter");
 
@@ -67,10 +67,9 @@ static int master(int argc, char* argv[])
   }
 
   XBT_INFO("Goodbye now!");
-  return 0;
 }
 
-static int worker(int argc, char* argv[])
+static void worker(int argc, char* argv[])
 {
   xbt_assert(argc == 2, "Expecting one parameter");
   long id                          = xbt_str_parse_int(argv[1], "Invalid argument %s");
@@ -96,7 +95,6 @@ static int worker(int argc, char* argv[])
       XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!");
     }
   }
-  return 0;
 }
 
 int main(int argc, char* argv[])
index 6bf7d76..7ad646e 100644 (file)
@@ -13,7 +13,8 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
-static int smpi_replay(int argc, char *argv[]) {
+static void smpi_replay(int argc, char* argv[])
+{
   const char* instance_id    = argv[1];
   int rank                   = xbt_str_parse_int(argv[2], "Cannot parse rank '%s'");
   const char* trace_filename = argv[3];
@@ -24,7 +25,6 @@ static int smpi_replay(int argc, char *argv[]) {
   }
 
   smpi_replay_run(instance_id, rank, start_delay_flops, trace_filename);
-  return 0;
 }
 
 int main(int argc, char *argv[]){
index 79039ff..a786889 100644 (file)
@@ -61,7 +61,7 @@ static void worker(std::vector<std::string> args)
   XBT_INFO("Exiting now.");
 }
 
-static int master_mpi(int argc, char* argv[])
+static void master_mpi(int argc, char* argv[])
 {
   MPI_Init(&argc, &argv);
 
@@ -78,10 +78,9 @@ static int master_mpi(int argc, char* argv[])
   MPI_Finalize();
 
   XBT_INFO("After finalize %d %d", rank, test[0]);
-  return 0;
 }
 
-static int alltoall_mpi(int argc, char* argv[])
+static void alltoall_mpi(int argc, char* argv[])
 {
   MPI_Init(&argc, &argv);
 
@@ -96,7 +95,6 @@ static int alltoall_mpi(int argc, char* argv[])
 
   XBT_INFO("after alltoall %d", rank);
   MPI_Finalize();
-  return 0;
 }
 
 int main(int argc, char* argv[])
index 736ba3b..95b9ae4 100644 (file)
@@ -29,13 +29,13 @@ XBT_PUBLIC void simgrid_load_deployment(const char* filename);
 /** Run the simulation after initialization */
 XBT_PUBLIC void simgrid_run();
 /** Registers the main function of an actor that will be launched from the deployment file */
-XBT_PUBLIC void simgrid_register_function(const char* name, int (*code)(int, char**));
+XBT_PUBLIC void simgrid_register_function(const char* name, void (*code)(int, char**));
 /** Registers a function as the default main function of actors
  *
  * It will be used as fallback when the function requested from the deployment file was not registered.
  * It is used for trace-based simulations (see examples/s4u/replay-comms and similar).
  */
-XBT_PUBLIC void simgrid_register_default(int (*code)(int, char**));
+XBT_PUBLIC void simgrid_register_default(void (*code)(int, char**));
 /** Retrieve the simulation time (in seconds) */
 XBT_PUBLIC double simgrid_get_clock();
 /** Retrieve the number of actors in the simulation */
index 70bc569..a9b2830 100644 (file)
@@ -300,7 +300,7 @@ XBT_PUBLIC msg_error_t MSG_main();
  * @param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char
  * *argv[]))
  */
-XBT_PUBLIC void MSG_function_register(const char* name, xbt_main_func_t code);
+XBT_PUBLIC void MSG_function_register(const char* name, int (*code)(int, char**));
 /** @brief Registers a code function as being the default value.
  *
  * This function will get used by MSG_launch_application() when there is no registered function of the requested name
@@ -309,7 +309,7 @@ XBT_PUBLIC void MSG_function_register(const char* name, xbt_main_func_t code);
  * @param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char
  * *argv[]))
  */
-XBT_PUBLIC void MSG_function_register_default(xbt_main_func_t code);
+XBT_PUBLIC void MSG_function_register_default(int (*code)(int, char**));
 /** @brief Creates a new platform, including hosts, links and the routing_table */
 XBT_PUBLIC void MSG_create_environment(const char* file);
 /** @brief Creates the application described in the provided file */
@@ -327,10 +327,10 @@ XBT_PUBLIC double MSG_get_clock();
 XBT_PUBLIC unsigned long int MSG_get_sent_msg();
 
 /************************** Process handling *********************************/
-XBT_PUBLIC msg_process_t MSG_process_create(const char* name, xbt_main_func_t code, void* data, msg_host_t host);
-XBT_PUBLIC msg_process_t MSG_process_create_with_arguments(const char* name, xbt_main_func_t code, void* data,
+XBT_PUBLIC msg_process_t MSG_process_create(const char* name, int (*code)(int, char**), void* data, msg_host_t host);
+XBT_PUBLIC msg_process_t MSG_process_create_with_arguments(const char* name, int (*code)(int, char**), void* data,
                                                            msg_host_t host, int argc, char** argv);
-XBT_PUBLIC msg_process_t MSG_process_create_with_environment(const char* name, xbt_main_func_t code, void* data,
+XBT_PUBLIC msg_process_t MSG_process_create_with_environment(const char* name, int (*code)(int, char**), void* data,
                                                              msg_host_t host, int argc, char** argv,
                                                              xbt_dict_t properties);
 
index 6cc8c60..f62b955 100644 (file)
@@ -48,9 +48,15 @@ public:
 
   void load_platform(const std::string& platf);
 
-  void register_function(const std::string& name, int (*code)(int, char**));
+  XBT_ATTRIB_DEPRECATED_v330("Please change the return code of your actors to void") void register_function(
+      const std::string& name, int (*code)(int, char**));
+
+  void register_function(const std::string& name, void (*code)(int, char**));
   void register_function(const std::string& name, void (*code)(std::vector<std::string>));
-  void register_default(int (*code)(int, char**));
+
+  XBT_ATTRIB_DEPRECATED_v330("Please change the return code of your actors to void") void register_default(
+      int (*code)(int, char**));
+  void register_default(void (*code)(int, char**));
 
   template <class F> void register_actor(const std::string& name)
   {
index 9bd7432..4fb25ef 100644 (file)
@@ -21,7 +21,7 @@ typedef int (*int_f_int_pvoid_t)(int, void*);
 typedef int (*int_f_pvoid_pvoid_t) (void *, void *);
 typedef int (*int_f_cpvoid_cpvoid_t) (const void *, const void *);
 
-typedef int (*xbt_main_func_t) (int argc, char *argv[]);
+typedef void (*xbt_main_func_t)(int argc, char* argv[]);
 
 SG_END_DECL
 #endif                          /* XBT_FUNCTION_TYPE_H */
index 9533b5f..2f1d5d7 100644 (file)
@@ -82,12 +82,12 @@ void jmsg_throw_status(JNIEnv *env, msg_error_t status) {
  * Unsortable functions                                                        *
  ***************************************************************************************/
 
-JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Msg_getClock(JNIEnv * env, jclass cls)
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Msg_getClock(JNIEnv*, jclass)
 {
   return (jdouble) MSG_get_clock();
 }
 
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv* env, jclass, jobjectArray jargs)
 {
   env->GetJavaVM(&__java_vm);
 
@@ -131,7 +131,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, j
   JAVA_HOST_LEVEL = simgrid::s4u::Host::extension_create(nullptr);
 }
 
-JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass cls)
+JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv* env, jclass)
 {
   /* Run everything */
   XBT_DEBUG("Ready to run MSG_MAIN");
@@ -162,7 +162,7 @@ JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass
   env->CallStaticVoidMethod(clsProcess, idDebug);
 }
 
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env, jclass cls, jstring jplatformFile)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv* env, jclass, jstring jplatformFile)
 {
   const char *platformFile = env->GetStringUTFChars(jplatformFile, 0);
 
@@ -171,7 +171,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env,
   env->ReleaseStringUTFChars(jplatformFile, platformFile);
 }
 
-JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNIEnv * env, jclass cls)
+JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNIEnv* env, jclass)
 {
   msg_netzone_t as = MSG_zone_get_root();
   jobject jas      = jnetzone_new_instance(env);
@@ -189,52 +189,51 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNI
   return (jobject) jas;
 }
 
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_debug(JNIEnv * env, jclass cls, jstring js)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_debug(JNIEnv* env, jclass, jstring js)
 {
   const char *s = env->GetStringUTFChars(js, 0);
   XBT_DEBUG("%s", s);
   env->ReleaseStringUTFChars(js, s);
 }
 
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_verb(JNIEnv * env, jclass cls, jstring js)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_verb(JNIEnv* env, jclass, jstring js)
 {
   const char *s = env->GetStringUTFChars(js, 0);
   XBT_VERB("%s", s);
   env->ReleaseStringUTFChars(js, s);
 }
 
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_info(JNIEnv * env, jclass cls, jstring js)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_info(JNIEnv* env, jclass, jstring js)
 {
   const char *s = env->GetStringUTFChars(js, 0);
   XBT_INFO("%s", s);
   env->ReleaseStringUTFChars(js, s);
 }
 
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_warn(JNIEnv * env, jclass cls, jstring js)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_warn(JNIEnv* env, jclass, jstring js)
 {
   const char *s = env->GetStringUTFChars(js, 0);
   XBT_WARN("%s", s);
   env->ReleaseStringUTFChars(js, s);
 }
 
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_error(JNIEnv * env, jclass cls, jstring js)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_error(JNIEnv* env, jclass, jstring js)
 {
   const char *s = env->GetStringUTFChars(js, 0);
   XBT_ERROR("%s", s);
   env->ReleaseStringUTFChars(js, s);
 }
 
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_critical(JNIEnv * env, jclass cls, jstring js)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_critical(JNIEnv* env, jclass, jstring js)
 {
   const char *s = env->GetStringUTFChars(js, 0);
   XBT_CRITICAL("%s", s);
   env->ReleaseStringUTFChars(js, s);
 }
 
-static int java_main(int argc, char *argv[]);
+static void java_main(int argc, char* argv[]);
 
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Msg_deployApplication(JNIEnv * env, jclass cls, jstring jdeploymentFile)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_deployApplication(JNIEnv* env, jclass, jstring jdeploymentFile)
 {
   const char *deploymentFile = env->GetStringUTFChars(jdeploymentFile, 0);
 
@@ -282,7 +281,7 @@ static void run_jprocess(JNIEnv *env, jobject jprocess)
 }
 
 /** Create a Java org.simgrid.msg.Process with the arguments and run it */
-static int java_main(int argc, char *argv[])
+static void java_main(int argc, char* argv[])
 {
   JNIEnv *env = get_current_thread_env();
   simgrid::kernel::context::JavaContext* context =
@@ -321,7 +320,6 @@ static int java_main(int argc, char *argv[])
   jprocess_bind(jprocess, process, env);
 
   run_jprocess(env, context->jprocess_);
-  return 0;
 }
 
 namespace simgrid {
index 07e5ab6..e8c2235 100644 (file)
@@ -48,6 +48,12 @@ void EngineImpl::load_deployment(const std::string& file)
   surf_parse();
   surf_parse_close();
 }
+void EngineImpl::register_function(const std::string& name, int (*code)(int, char**)) // deprecated
+{
+  simix_global->registered_functions[name] = [code](std::vector<std::string> args) {
+    return xbt::wrap_main(code, std::move(args));
+  };
+}
 void EngineImpl::register_function(const std::string& name, xbt_main_func_t code)
 {
   simix_global->registered_functions[name] = [code](std::vector<std::string> args) {
@@ -62,6 +68,12 @@ void EngineImpl::register_function(const std::string& name, void (*code)(std::ve
   };
 }
 
+void EngineImpl::register_default(int (*code)(int, char**)) // deprecated
+{
+  simix_global->default_function = [code](std::vector<std::string> args) {
+    return xbt::wrap_main(code, std::move(args));
+  };
+}
 void EngineImpl::register_default(xbt_main_func_t code)
 {
   simix_global->default_function = [code](std::vector<std::string> args) {
index 386e921..cf4828f 100644 (file)
@@ -27,8 +27,10 @@ public:
   virtual ~EngineImpl();
 
   void load_deployment(const std::string& file);
+  void register_function(const std::string& name, int (*code)(int, char**)); // deprecated
   void register_function(const std::string& name, xbt_main_func_t code);
   void register_function(const std::string& name, void (*code)(std::vector<std::string>));
+  void register_default(int (*code)(int, char**)); // deprecated
   void register_default(xbt_main_func_t code);
 
   routing::NetZoneImpl* netzone_root_ = nullptr;
index da208dd..93d126e 100644 (file)
@@ -23,13 +23,13 @@ msg_error_t MSG_main()
   simgrid_run();
   return MSG_OK;
 }
-void MSG_function_register(const char* name, xbt_main_func_t code)
+void MSG_function_register(const char* name, int (*code)(int, char**))
 {
-  simgrid_register_function(name, code);
+  simgrid_register_function(name, (void (*)(int, char**))code);
 }
-void MSG_function_register_default(xbt_main_func_t code)
+void MSG_function_register_default(int (*code)(int, char**))
 {
-  simgrid_register_default(code);
+  simgrid_register_default((void (*)(int, char**))code);
 }
 double MSG_get_clock()
 {
index fc52b04..9b53e16 100644 (file)
@@ -14,7 +14,7 @@
  * Does exactly the same as #MSG_process_create_with_arguments but without providing standard arguments
  * (@a argc, @a argv, @a start_time, @a kill_time).
  */
-msg_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *data, msg_host_t host)
+msg_process_t MSG_process_create(const char* name, int (*code)(int, char**), void* data, msg_host_t host)
 {
   return MSG_process_create_with_environment(name == nullptr ? "" : name, code, data, host, 0, nullptr, nullptr);
 }
@@ -32,8 +32,8 @@ msg_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *d
  * @param argv second argument passed to @a code
  */
 
-msg_process_t MSG_process_create_with_arguments(const char *name, xbt_main_func_t code, void *data, msg_host_t host,
-                                              int argc, char **argv)
+msg_process_t MSG_process_create_with_arguments(const char* name, int (*code)(int, char**), void* data, msg_host_t host,
+                                                int argc, char** argv)
 {
   return MSG_process_create_with_environment(name, code, data, host, argc, argv, nullptr);
 }
@@ -55,8 +55,8 @@ msg_process_t MSG_process_create_with_arguments(const char *name, xbt_main_func_
  * @see msg_process_t
  * @return The new corresponding object.
  */
-msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_func_t code, void *data, msg_host_t host,
-                                                  int argc, char **argv, xbt_dict_t properties)
+msg_process_t MSG_process_create_with_environment(const char* name, int (*code)(int, char**), void* data,
+                                                  msg_host_t host, int argc, char** argv, xbt_dict_t properties)
 {
   xbt_assert(host != nullptr, "Invalid parameters: host param must not be nullptr");
   sg_actor_t actor = sg_actor_init(std::move(name), host);
@@ -70,7 +70,7 @@ msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_fun
       xbt_dict_foreach (properties, cursor, key, value)
         actor->set_property(key, value);
     }
-    sg_actor_start(actor, code, argc, argv);
+    sg_actor_start(actor, (void (*)(int, char**))code, argc, argv);
   } catch (simgrid::HostFailureException const&) {
     xbt_die("Could not launch a new process on failed host %s.", host->get_cname());
   }
index 6b00aa9..78e4b4b 100644 (file)
@@ -90,8 +90,17 @@ void Engine::load_platform(const std::string& platf)
   XBT_DEBUG("PARSE TIME: %g", (end - start));
 }
 
+void Engine::register_function(const std::string& name, int (*code)(int, char**)) // deprecated
+{
+  pimpl->register_function(name, code);
+}
+void Engine::register_default(int (*code)(int, char**)) // deprecated
+{
+  pimpl->register_default(code);
+}
+
 /** Registers the main function of an actor that will be launched from the deployment file */
-void Engine::register_function(const std::string& name, int (*code)(int, char**))
+void Engine::register_function(const std::string& name, void (*code)(int, char**))
 {
   pimpl->register_function(name, code);
 }
@@ -106,7 +115,7 @@ void Engine::register_function(const std::string& name, void (*code)(std::vector
  * It will be used as fallback when the function requested from the deployment file was not registered.
  * It is used for trace-based simulations (see examples/s4u/replay-comms and similar).
  */
-void Engine::register_default(int (*code)(int, char**))
+void Engine::register_default(void (*code)(int, char**))
 {
   pimpl->register_default(code);
 }
@@ -403,11 +412,11 @@ void simgrid_run()
 {
   simgrid::s4u::Engine::get_instance()->run();
 }
-void simgrid_register_function(const char* name, int (*code)(int, char**))
+void simgrid_register_function(const char* name, void (*code)(int, char**))
 {
   simgrid::s4u::Engine::get_instance()->register_function(name, code);
 }
-void simgrid_register_default(int (*code)(int, char**))
+void simgrid_register_default(void (*code)(int, char**))
 {
   simgrid::s4u::Engine::get_instance()->register_default(code);
 }
index 69a127f..6a9d436 100644 (file)
@@ -27,7 +27,7 @@ void* req_wait(void* bar);
 
 // Thread creation helper
 
-static int thread_create_wrapper(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+static void thread_create_wrapper(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {
   int the_global_rank  = global_rank;
   struct threadwrap* t = (struct threadwrap*)sg_actor_self_data();
@@ -37,7 +37,6 @@ static int thread_create_wrapper(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED c
   t->f(t->param);
   sg_actor_self_data_set(NULL);
   free(t);
-  return 0;
 }
 
 static void mpi_thread_create(const char* name, void* (*f)(void*), void* param)
index b29b592..38890f4 100644 (file)
@@ -24,6 +24,11 @@ set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
 set_property(TARGET simgrid
              APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
 
+# Don't complain when we cast (int (*)(int,char**)) into (void(*)(int,char**))
+# This will stop when MSG goes away
+set_property(SOURCE ${CMAKE_HOME_DIRECTORY}/src/msg/msg_legacy.cpp   PROPERTY COMPILE_FLAGS -Wno-error=cast-function-type)
+set_property(SOURCE ${CMAKE_HOME_DIRECTORY}/src/msg/msg_process.cpp  PROPERTY COMPILE_FLAGS -Wno-error=cast-function-type)
+
 add_dependencies(simgrid maintainer_files)
 
 if(enable_model-checking)