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:
*
* One 'receiver' actor is instantiated within the simulation later in this file.
*/
*
* 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]);
{
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]);
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.");
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.");
}
/* Our second class of actors, in charge of sending stuff */
}
/* 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");
{
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");
sg_mailbox_put(mailbox, xbt_strdup(sent_data), strlen(sent_data));
XBT_INFO("I'm done. See you.");
sg_mailbox_put(mailbox, xbt_strdup(sent_data), strlen(sent_data));
XBT_INFO("I'm done. See you.");
}
/* Here comes the main function of your program */
}
/* Here comes the main function of your program */
XBT_LOG_NEW_DEFAULT_CATEGORY(async_waitany, "Messages specific for this example");
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");
{
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");
free(mboxes);
XBT_INFO("Goodbye now!");
free(mboxes);
XBT_INFO("Goodbye now!");
-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");
{
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");
}
XBT_INFO("I'm done. See you!");
}
XBT_INFO("I'm done. See you!");
}
int main(int argc, char* argv[])
}
int main(int argc, char* argv[])
}
/* Our second class of actors is also a function */
}
/* 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]);
{
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]);
std::string* msg = static_cast<std::string*>(in->get());
XBT_INFO("Forward '%s'.", msg->c_str());
out->put(msg, msg->size());
std::string* msg = static_cast<std::string*>(in->get());
XBT_INFO("Forward '%s'.", msg->c_str());
out->put(msg, msg->size());
}
/* Declares a third class of actors which sends a message to the mailbox 'mb42'.
}
/* Declares a third class of actors which sends a message to the mailbox 'mb42'.
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_async_ready, "Messages specific for this s4u example");
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 */
{
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 */
simgrid::s4u::Comm::wait_all(&pending_comms);
XBT_INFO("Goodbye now!");
simgrid::s4u::Comm::wait_all(&pending_comms);
XBT_INFO("Goodbye now!");
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_async_wait, "Messages specific for this s4u example");
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 */
{
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 */
}
XBT_INFO("Goodbye now!");
}
XBT_INFO("Goodbye now!");
}
/* Receiver actor expects 1 argument: its ID */
}
/* 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]);
{
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]);
cont = false; // If it's a finalize message, we're done.
delete received;
}
cont = false; // If it's a finalize message, we're done.
delete received;
}
}
int main(int argc, char *argv[])
}
int main(int argc, char *argv[])
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_async_waituntil, "Messages specific for this s4u example");
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 */
{
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 */
}
XBT_INFO("Goodbye now!");
}
XBT_INFO("Goodbye now!");
}
/* Receiver actor expects 1 argument: its ID */
}
/* 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]);
{
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]);
cont = false; // If it's a finalize message, we're done.
delete received;
}
cont = false; // If it's a finalize message, we're done.
delete received;
}
}
int main(int argc, char* argv[])
}
int main(int argc, char* argv[])
* @param the ID of the person I know in the system (or not)
* @param Time before I leave the system because I'm bored
*/
* @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);
{
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);
- 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);
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]);
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());
- 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");
// 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) {
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 !
// 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);
- node->handleFindNode(msg);
+ node.handleFindNode(msg);
delete msg->answer_;
delete 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) {
} 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) {
next_lookup_time += RANDOM_LOOKUP_INTERVAL;
} else {
// Didn't get a message: sleep for a while...
next_lookup_time += RANDOM_LOOKUP_INTERVAL;
} else {
// Didn't get a message: sleep for a while...
XBT_INFO("I couldn't join the network :(");
}
XBT_DEBUG("I'm leaving the network");
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 */
}
/** @brief Main function */
XBT_LOG_NEW_DEFAULT_CATEGORY(remote_io, "Messages specific for this io example");
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();
{
simgrid::s4u::File file(argv[1], nullptr);
const char* filename = file.get_path();
file.remote_copy(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
}
}
file.remote_copy(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
}
}
}
int main(int argc, char** argv)
}
int main(int argc, char** argv)
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
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");
{
xbt_assert(argc == 5, "Expecting one parameter");
}
XBT_INFO("Goodbye now!");
}
XBT_INFO("Goodbye now!");
-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");
{
xbt_assert(argc == 2, "Expecting one parameter");
long id = xbt_str_parse_int(argv[1], "Invalid argument %s");
XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!");
}
}
XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!");
}
}
}
int main(int argc, char* argv[])
}
int main(int argc, char* argv[])
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
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];
const char* instance_id = argv[1];
int rank = xbt_str_parse_int(argv[2], "Cannot parse rank '%s'");
const char* trace_filename = argv[3];
}
smpi_replay_run(instance_id, rank, start_delay_flops, trace_filename);
}
smpi_replay_run(instance_id, rank, start_delay_flops, trace_filename);
}
int main(int argc, char *argv[]){
}
int main(int argc, char *argv[]){
XBT_INFO("Exiting now.");
}
XBT_INFO("Exiting now.");
}
-static int master_mpi(int argc, char* argv[])
+static void master_mpi(int argc, char* argv[])
{
MPI_Init(&argc, &argv);
{
MPI_Init(&argc, &argv);
MPI_Finalize();
XBT_INFO("After finalize %d %d", rank, test[0]);
MPI_Finalize();
XBT_INFO("After finalize %d %d", rank, test[0]);
-static int alltoall_mpi(int argc, char* argv[])
+static void alltoall_mpi(int argc, char* argv[])
{
MPI_Init(&argc, &argv);
{
MPI_Init(&argc, &argv);
XBT_INFO("after alltoall %d", rank);
MPI_Finalize();
XBT_INFO("after alltoall %d", rank);
MPI_Finalize();
}
int main(int argc, char* argv[])
}
int main(int argc, char* argv[])
/** 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 */
/** 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).
*/
/** 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 */
/** Retrieve the simulation time (in seconds) */
XBT_PUBLIC double simgrid_get_clock();
/** Retrieve the number of actors in the simulation */
* @param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char
* *argv[]))
*/
* @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
/** @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
* @param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char
* *argv[]))
*/
* @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 */
/** @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 */
XBT_PUBLIC unsigned long int MSG_get_sent_msg();
/************************** Process handling *********************************/
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);
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);
msg_host_t host, int argc, char** argv,
xbt_dict_t properties);
void load_platform(const std::string& platf);
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_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)
{
template <class F> void register_actor(const std::string& name)
{
typedef int (*int_f_pvoid_pvoid_t) (void *, void *);
typedef int (*int_f_cpvoid_cpvoid_t) (const void *, const 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 */
SG_END_DECL
#endif /* XBT_FUNCTION_TYPE_H */
* Unsortable functions *
***************************************************************************************/
* 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();
}
{
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);
{
env->GetJavaVM(&__java_vm);
JAVA_HOST_LEVEL = simgrid::s4u::Host::extension_create(nullptr);
}
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");
{
/* Run everything */
XBT_DEBUG("Ready to run MSG_MAIN");
env->CallStaticVoidMethod(clsProcess, idDebug);
}
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);
{
const char *platformFile = env->GetStringUTFChars(jplatformFile, 0);
env->ReleaseStringUTFChars(jplatformFile, platformFile);
}
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);
{
msg_netzone_t as = MSG_zone_get_root();
jobject jas = jnetzone_new_instance(env);
-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);
}
{
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);
}
{
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);
}
{
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);
}
{
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);
}
{
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);
}
{
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);
{
const char *deploymentFile = env->GetStringUTFChars(jdeploymentFile, 0);
}
/** Create a Java org.simgrid.msg.Process with the arguments and run it */
}
/** 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 =
{
JNIEnv *env = get_current_thread_env();
simgrid::kernel::context::JavaContext* context =
jprocess_bind(jprocess, process, env);
run_jprocess(env, context->jprocess_);
jprocess_bind(jprocess, process, env);
run_jprocess(env, context->jprocess_);
surf_parse();
surf_parse_close();
}
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) {
void EngineImpl::register_function(const std::string& name, xbt_main_func_t code)
{
simix_global->registered_functions[name] = [code](std::vector<std::string> args) {
+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) {
void EngineImpl::register_default(xbt_main_func_t code)
{
simix_global->default_function = [code](std::vector<std::string> args) {
virtual ~EngineImpl();
void load_deployment(const std::string& file);
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_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;
void register_default(xbt_main_func_t code);
routing::NetZoneImpl* netzone_root_ = nullptr;
simgrid_run();
return MSG_OK;
}
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()
{
}
double MSG_get_clock()
{
* 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).
*/
* 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);
}
{
return MSG_process_create_with_environment(name == nullptr ? "" : name, code, data, host, 0, nullptr, nullptr);
}
* @param argv second argument passed to @a code
*/
* @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);
}
{
return MSG_process_create_with_environment(name, code, data, host, argc, argv, nullptr);
}
* @see msg_process_t
* @return The new corresponding object.
*/
* @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);
{
xbt_assert(host != nullptr, "Invalid parameters: host param must not be nullptr");
sg_actor_t actor = sg_actor_init(std::move(name), host);
xbt_dict_foreach (properties, cursor, key, value)
actor->set_property(key, value);
}
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());
}
} catch (simgrid::HostFailureException const&) {
xbt_die("Could not launch a new process on failed host %s.", host->get_cname());
}
XBT_DEBUG("PARSE TIME: %g", (end - start));
}
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 */
/** 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);
}
{
pimpl->register_function(name, code);
}
* 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).
*/
* 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);
}
{
pimpl->register_default(code);
}
{
simgrid::s4u::Engine::get_instance()->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);
}
{
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);
}
{
simgrid::s4u::Engine::get_instance()->register_default(code);
}
// Thread creation helper
// 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();
{
int the_global_rank = global_rank;
struct threadwrap* t = (struct threadwrap*)sg_actor_self_data();
t->f(t->param);
sg_actor_self_data_set(NULL);
free(t);
t->f(t->param);
sg_actor_self_data_set(NULL);
free(t);
}
static void mpi_thread_create(const char* name, void* (*f)(void*), void* param)
}
static void mpi_thread_create(const char* name, void* (*f)(void*), void* param)
set_property(TARGET simgrid
APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
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)
add_dependencies(simgrid maintainer_files)
if(enable_model-checking)