Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add macros to generate simcalls code
authorpaul bedaride <paul.bedaride@gmail.com>
Thu, 8 Nov 2012 10:20:47 +0000 (11:20 +0100)
committershenshei <paul.bedaride@gmail.com>
Wed, 28 Nov 2012 09:36:01 +0000 (10:36 +0100)
16 files changed:
include/simgrid/simix.h
src/simix/smx_global.c
src/simix/smx_host.c
src/simix/smx_host_private.h
src/simix/smx_io.c
src/simix/smx_io_private.h
src/simix/smx_network.c
src/simix/smx_network_private.h
src/simix/smx_process.c
src/simix/smx_process_private.h
src/simix/smx_smurf.c
src/simix/smx_smurf_private.h
src/simix/smx_synchro.c
src/simix/smx_synchro_private.h
src/simix/smx_user.c
src/xbt/mmalloc/mm_diff.c

index 97182b7..1faa39c 100644 (file)
@@ -255,14 +255,14 @@ XBT_PUBLIC(void) SIMIX_process_set_function(const char* process_host,
 
 /*********************************** Host *************************************/
 //XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_dict(u_smx_scalar_t *args);
 
 /*********************************** Host *************************************/
 //XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_dict(u_smx_scalar_t *args);
-XBT_PUBLIC(smx_host_t) SIMIX_host_get_by_name(u_smx_scalar_t *args);
+XBT_PUBLIC(smx_host_t) SIMIX_host_get_by_name(const char *name);
 XBT_PUBLIC(smx_host_t) SIMIX_host_self(void);
 XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
 XBT_PUBLIC(smx_host_t) SIMIX_host_self(void);
 XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
-XBT_PUBLIC(const char*) SIMIX_host_get_name(u_smx_scalar_t *args); /* FIXME: make private: only the name of SIMIX_host_self() should be public without request */
+XBT_PUBLIC(const char*) SIMIX_host_get_name(smx_host_t host); /* FIXME: make private: only the name of SIMIX_host_self() should be public without request */
 XBT_PUBLIC(void) SIMIX_host_self_set_data(void *data);
 XBT_PUBLIC(void*) SIMIX_host_self_get_data(void);
 XBT_PUBLIC(void) SIMIX_host_self_set_data(void *data);
 XBT_PUBLIC(void*) SIMIX_host_self_get_data(void);
-XBT_PUBLIC(void*) SIMIX_host_get_data(u_smx_scalar_t *args);
-XBT_PUBLIC(void) SIMIX_host_set_data(u_smx_scalar_t *args);
+XBT_PUBLIC(void*) SIMIX_host_get_data(smx_host_t host);
+XBT_PUBLIC(void) SIMIX_host_set_data(smx_host_t host, void *data);
 
 /********************************* Process ************************************/
 XBT_PUBLIC(int) SIMIX_process_count(void);
 
 /********************************* Process ************************************/
 XBT_PUBLIC(int) SIMIX_process_count(void);
index 3315b51..b82be91 100644 (file)
@@ -487,6 +487,9 @@ static void SIMIX_action_mallocator_reset_f(void* action) {
   ((smx_action_t) action)->simcalls = fifo;
 }
 
   ((smx_action_t) action)->simcalls = fifo;
 }
 
+xbt_dict_t SIMIX_pre_asr_get_properties(smx_simcall_t simcall, const char *name){
+  return SIMIX_asr_get_properties(name);
+}
 xbt_dict_t SIMIX_asr_get_properties(const char *name)
 {
   return xbt_lib_get_or_null(as_router_lib, name, ROUTING_PROP_ASR_LEVEL);
 xbt_dict_t SIMIX_asr_get_properties(const char *name)
 {
   return xbt_lib_get_or_null(as_router_lib, name, ROUTING_PROP_ASR_LEVEL);
index c3c6546..f3767bf 100644 (file)
@@ -94,10 +94,10 @@ void SIMIX_host_destroy(void *h)
 //  }
 //  return host_dict;
 //}
 //  }
 //  return host_dict;
 //}
-
-smx_host_t SIMIX_host_get_by_name(u_smx_scalar_t *args)
-{
-  const char *name = args[0].cc;
+smx_host_t SIMIX_pre_host_get_by_name(smx_simcall_t simcall, const char *name){
+   return SIMIX_host_get_by_name(name);
+}
+smx_host_t SIMIX_host_get_by_name(const char *name){
   xbt_assert(((simix_global != NULL)
                && (host_lib != NULL)),
               "Environment not set yet");
   xbt_assert(((simix_global != NULL)
                && (host_lib != NULL)),
               "Environment not set yet");
@@ -111,6 +111,9 @@ smx_host_t SIMIX_host_self(void)
   return (process == NULL) ? NULL : SIMIX_process_get_host(process);
 }
 
   return (process == NULL) ? NULL : SIMIX_process_get_host(process);
 }
 
+const char* SIMIX_pre_host_self_get_name(smx_simcall_t simcall){
+   return SIMIX_host_self_get_name();
+}
 /* needs to be public and without simcall because it is called
    by exceptions and logging events */
 const char* SIMIX_host_self_get_name(void)
 /* needs to be public and without simcall because it is called
    by exceptions and logging events */
 const char* SIMIX_host_self_get_name(void)
@@ -119,67 +122,76 @@ const char* SIMIX_host_self_get_name(void)
   if (host == NULL || SIMIX_process_self() == simix_global->maestro_process)
     return "";
 
   if (host == NULL || SIMIX_process_self() == simix_global->maestro_process)
     return "";
 
-  return SIMIX_host_get_name(SIMIX_pack_args(PTR(host)));
+  return SIMIX_host_get_name(host);
 }
 
 }
 
-const char* SIMIX_host_get_name(u_smx_scalar_t *args)
-{
-  smx_host_t host = args[0].p;
+const char* SIMIX_pre_host_get_name(smx_simcall_t simcall, smx_host_t host){
+   return SIMIX_host_get_name(host);
+}
+const char* SIMIX_host_get_name(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters");
 
   return host->name;
 }
 
   xbt_assert((host != NULL), "Invalid parameters");
 
   return host->name;
 }
 
-xbt_dict_t SIMIX_host_get_properties(u_smx_scalar_t *args)
-{
-  smx_host_t host = args[0].p;
+xbt_dict_t SIMIX_pre_host_get_properties(smx_simcall_t simcall, smx_host_t host){
+  return SIMIX_host_get_properties(host);
+}
+xbt_dict_t SIMIX_host_get_properties(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.get_properties(host->host);
 }
 
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.get_properties(host->host);
 }
 
-double SIMIX_host_get_speed(u_smx_scalar_t *args)
-{
-  smx_host_t host = args[0].p;
+double SIMIX_pre_host_get_speed(smx_simcall_t simcall, smx_host_t host){
+  return SIMIX_host_get_speed(host);
+}
+double SIMIX_host_get_speed(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.
       get_speed(host->host, 1.0);
 }
 
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.
       get_speed(host->host, 1.0);
 }
 
-double SIMIX_host_get_available_speed(u_smx_scalar_t *args)
-{
-  smx_host_t host = args[0].p;
+double SIMIX_pre_host_get_available_speed(smx_simcall_t simcall, smx_host_t host){
+  return SIMIX_host_get_available_speed(host);
+}
+double SIMIX_host_get_available_speed(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.
       get_available_speed(host->host);
 }
 
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.
       get_available_speed(host->host);
 }
 
-int SIMIX_host_get_state(u_smx_scalar_t *args)
-{
-  smx_host_t host = args[0].p;
+int SIMIX_pre_host_get_state(smx_simcall_t simcall, smx_host_t host){
+  return SIMIX_host_get_state(host);
+}
+int SIMIX_host_get_state(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.
       get_state(host->host);
 }
 
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return surf_workstation_model->extension.workstation.
       get_state(host->host);
 }
 
+void* SIMIX_pre_host_self_get_data(smx_simcall_t simcall){
+  return SIMIX_host_self_get_data();
+}
 void* SIMIX_host_self_get_data(void)
 {
   smx_host_t self = SIMIX_host_self();
 void* SIMIX_host_self_get_data(void)
 {
   smx_host_t self = SIMIX_host_self();
-  return SIMIX_host_get_data(SIMIX_pack_args(PTR(self)));
+  return SIMIX_host_get_data(self);
 }
 
 void SIMIX_host_self_set_data(void *data)
 {
   smx_host_t self = SIMIX_host_self();
 }
 
 void SIMIX_host_self_set_data(void *data)
 {
   smx_host_t self = SIMIX_host_self();
-  SIMIX_host_set_data(SIMIX_pack_args(PTR(self), PTR(data)));
+  SIMIX_host_set_data(self, data);
 }
 
 }
 
-void* SIMIX_host_get_data(u_smx_scalar_t *args)
-{
-  smx_host_t host = args[0].p;
+void* SIMIX_pre_host_get_data(smx_simcall_t simcall,smx_host_t host){
+  return SIMIX_host_get_data(host);
+}
+void* SIMIX_host_get_data(smx_host_t host){
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return host->data;
   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
 
   return host->data;
@@ -230,7 +242,7 @@ void SIMIX_host_add_auto_restart_process(smx_host_t host,
   arg->properties = properties;
   arg->auto_restart = auto_restart;
 
   arg->properties = properties;
   arg->auto_restart = auto_restart;
 
-  if( SIMIX_host_get_state(SIMIX_pack_args(PTR(host))) == SURF_RESOURCE_OFF
+  if( SIMIX_host_get_state(host) == SURF_RESOURCE_OFF
       && !xbt_dict_get_or_null(watched_hosts_lib,host->name)){
     xbt_dict_set(watched_hosts_lib,host->name,host,NULL);
     XBT_DEBUG("Have push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF",host->name);
       && !xbt_dict_get_or_null(watched_hosts_lib,host->name)){
     xbt_dict_set(watched_hosts_lib,host->name,host,NULL);
     XBT_DEBUG("Have push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF",host->name);
@@ -286,22 +298,22 @@ void SIMIX_host_autorestart(smx_host_t host)
     xbt_die("No function for simix_global->autorestart");
 }
 
     xbt_die("No function for simix_global->autorestart");
 }
 
-void SIMIX_host_set_data(u_smx_scalar_t *args)
-{
-  smx_host_t host = args[0].p;
-  void *data = args[1].p;
+void SIMIX_pre_host_set_data(smx_simcall_t simcall, smx_host_t host, void *data) {
+  SIMIX_host_set_data(host, data);
+}
+void SIMIX_host_set_data(smx_host_t host, void *data){
   xbt_assert((host != NULL), "Invalid parameters");
   xbt_assert((host->data == NULL), "Data already set");
 
   host->data = data;
 }
 
   xbt_assert((host != NULL), "Invalid parameters");
   xbt_assert((host->data == NULL), "Data already set");
 
   host->data = data;
 }
 
-smx_action_t SIMIX_host_execute(u_smx_scalar_t args[])
-{
-  const char *name = args[0].p;
-  smx_host_t host = args[1].p;
-  double computation_amount = args[2].d;
-  double priority = args[3].d;
+smx_action_t SIMIX_pre_host_execute(smx_simcall_t simcall,const char *name,
+    smx_host_t host, double computation_amount, double priority){
+  return SIMIX_host_execute(name, host, computation_amount, priority);
+}
+smx_action_t SIMIX_host_execute(const char *name,
+    smx_host_t host, double computation_amount, double priority){
 
   /* alloc structures and initialize */
   smx_action_t action = xbt_mallocator_get(simix_global->action_mallocator);
 
   /* alloc structures and initialize */
   smx_action_t action = xbt_mallocator_get(simix_global->action_mallocator);
@@ -328,15 +340,18 @@ smx_action_t SIMIX_host_execute(u_smx_scalar_t args[])
   return action;
 }
 
   return action;
 }
 
-smx_action_t SIMIX_host_parallel_execute(u_smx_scalar_t *args)
-{
-  const char *name = args[0].cc;
-  int host_nb = args[1].i;
-  smx_host_t *host_list = args[2].p;
-  double *computation_amount = args[3].p;
-  double *communication_amount = args[4].p;
-  double amount = args[5].d;
-  double rate = args[6].d;
+smx_action_t SIMIX_pre_host_parallel_execute(smx_simcall_t simcall, const char *name,
+    int host_nb, smx_host_t *host_list,
+    double *computation_amount, double *communication_amount,
+    double amount, double rate){
+  return SIMIX_host_parallel_execute(name, host_nb, host_list, computation_amount,
+                                    communication_amount, amount, rate);
+}
+smx_action_t SIMIX_host_parallel_execute(const char *name,
+    int host_nb, smx_host_t *host_list,
+    double *computation_amount, double *communication_amount,
+    double amount, double rate){
+
   void **workstation_list = NULL;
   int i;
 
   void **workstation_list = NULL;
   int i;
 
@@ -370,9 +385,10 @@ smx_action_t SIMIX_host_parallel_execute(u_smx_scalar_t *args)
   return action;
 }
 
   return action;
 }
 
-void SIMIX_host_execution_destroy(u_smx_scalar_t *args)
-{
-  smx_action_t action = args[0].p;
+void SIMIX_pre_host_execution_destroy(smx_simcall_t simcall, smx_action_t action){
+  SIMIX_host_execution_destroy(action);
+}
+void SIMIX_host_execution_destroy(smx_action_t action){
   XBT_DEBUG("Destroy action %p", action);
 
   if (action->execution.surf_exec) {
   XBT_DEBUG("Destroy action %p", action);
 
   if (action->execution.surf_exec) {
@@ -383,18 +399,20 @@ void SIMIX_host_execution_destroy(u_smx_scalar_t *args)
   xbt_mallocator_release(simix_global->action_mallocator, action);
 }
 
   xbt_mallocator_release(simix_global->action_mallocator, action);
 }
 
-void SIMIX_host_execution_cancel(u_smx_scalar_t *args)
-{
-  smx_action_t action = args[0].p;
+void SIMIX_pre_host_execution_cancel(smx_simcall_t simcall, smx_action_t action){
+  SIMIX_host_execution_cancel(action);
+}
+void SIMIX_host_execution_cancel(smx_action_t action){
   XBT_DEBUG("Cancel action %p", action);
 
   if (action->execution.surf_exec)
     surf_workstation_model->action_cancel(action->execution.surf_exec);
 }
 
   XBT_DEBUG("Cancel action %p", action);
 
   if (action->execution.surf_exec)
     surf_workstation_model->action_cancel(action->execution.surf_exec);
 }
 
-double SIMIX_host_execution_get_remains(u_smx_scalar_t *args)
-{
-  smx_action_t action = args[0].p;
+double SIMIX_pre_host_execution_get_remains(smx_simcall_t simcall, smx_action_t action){
+  return SIMIX_host_execution_get_remains(action);
+}
+double SIMIX_host_execution_get_remains(smx_action_t action){
   double result = 0.0;
 
   if (action->state == SIMIX_RUNNING)
   double result = 0.0;
 
   if (action->state == SIMIX_RUNNING)
@@ -403,24 +421,23 @@ double SIMIX_host_execution_get_remains(u_smx_scalar_t *args)
   return result;
 }
 
   return result;
 }
 
-e_smx_state_t SIMIX_host_execution_get_state(u_smx_scalar_t *args)
-{
-  smx_action_t action = args[0].p;
+e_smx_state_t SIMIX_pre_host_execution_get_state(smx_simcall_t simcall, smx_action_t action){
+  return SIMIX_host_execution_get_state(action);
+}
+e_smx_state_t SIMIX_host_execution_get_state(smx_action_t action){
   return action->state;
 }
 
   return action->state;
 }
 
-void SIMIX_host_execution_set_priority(u_smx_scalar_t *args)
-{
-  smx_action_t action = args[0].p;
-  double priority = args[1].d;
+void SIMIX_pre_host_execution_set_priority(smx_simcall_t simcall, smx_action_t action,
+                                       double priority){
+  return SIMIX_host_execution_set_priority(action, priority);
+}
+void SIMIX_host_execution_set_priority(smx_action_t action, double priority){
   if(action->execution.surf_exec)
     surf_workstation_model->set_priority(action->execution.surf_exec, priority);
 }
 
   if(action->execution.surf_exec)
     surf_workstation_model->set_priority(action->execution.surf_exec, priority);
 }
 
-void SIMIX_pre_host_execution_wait(u_smx_scalar_t *args)
-{
-  smx_simcall_t simcall = args[0].p;
-  smx_action_t action = args[1].p;
+void SIMIX_pre_host_execution_wait(smx_simcall_t simcall, smx_action_t action){
 
   XBT_DEBUG("Wait for execution of action %p, state %d", action, (int)action->state);
 
 
   XBT_DEBUG("Wait for execution of action %p, state %d", action, (int)action->state);
 
@@ -493,7 +510,7 @@ void SIMIX_execution_finish(smx_action_t action)
   }
 
   /* We no longer need it */
   }
 
   /* We no longer need it */
-  SIMIX_host_execution_destroy(SIMIX_pack_args(PTR(action)));
+  SIMIX_host_execution_destroy(action);
 }
 
 void SIMIX_post_host_execute(smx_action_t action)
 }
 
 void SIMIX_post_host_execute(smx_action_t action)
@@ -525,6 +542,10 @@ void SIMIX_post_host_execute(smx_action_t action)
 
 
 #ifdef HAVE_TRACING
 
 
 #ifdef HAVE_TRACING
+void SIMIX_pre_set_category(smx_simcall_t simcall, smx_action_t action,
+                           const char *category){
+  SIMIX_set_category(action, category);
+}
 void SIMIX_set_category(smx_action_t action, const char *category)
 {
   if (action->state != SIMIX_RUNNING) return;
 void SIMIX_set_category(smx_action_t action, const char *category)
 {
   if (action->state != SIMIX_RUNNING) return;
index 1399100..6819f61 100644 (file)
@@ -34,18 +34,42 @@ void SIMIX_host_add_auto_restart_process(smx_host_t host,
 
 void SIMIX_host_restart_processes(smx_host_t host);
 void SIMIX_host_autorestart(smx_host_t host);
 
 void SIMIX_host_restart_processes(smx_host_t host);
 void SIMIX_host_autorestart(smx_host_t host);
-xbt_dict_t SIMIX_host_get_properties(u_smx_scalar_t *args);
-double SIMIX_host_get_speed(u_smx_scalar_t *args);
-double SIMIX_host_get_available_speed(u_smx_scalar_t *args);
-int SIMIX_host_get_state(u_smx_scalar_t *args);
-smx_action_t SIMIX_host_execute(u_smx_scalar_t *args);
-smx_action_t SIMIX_host_parallel_execute(u_smx_scalar_t *args);
-void SIMIX_host_execution_destroy(u_smx_scalar_t *args);
-void SIMIX_host_execution_cancel(u_smx_scalar_t *args);
-double SIMIX_host_execution_get_remains(u_smx_scalar_t *args);
-e_smx_state_t SIMIX_host_execution_get_state(u_smx_scalar_t *args);
-void SIMIX_host_execution_set_priority(u_smx_scalar_t *args);
-void SIMIX_pre_host_execution_wait(u_smx_scalar_t *args);
+xbt_dict_t SIMIX_host_get_properties(smx_host_t host);
+double SIMIX_host_get_speed(smx_host_t host);
+double SIMIX_host_get_available_speed(smx_host_t host);
+int SIMIX_host_get_state(smx_host_t host);
+smx_action_t SIMIX_host_execute(const char *name,
+    smx_host_t host, double computation_amount, double priority);
+smx_action_t SIMIX_host_parallel_execute(const char *name,
+    int host_nb, smx_host_t *host_list,
+    double *computation_amount, double *communication_amount,
+    double amount, double rate);
+void SIMIX_host_execution_destroy(smx_action_t action);
+void SIMIX_host_execution_cancel(smx_action_t action);
+double SIMIX_host_execution_get_remains(smx_action_t action);
+e_smx_state_t SIMIX_host_execution_get_state(smx_action_t action);
+void SIMIX_host_execution_set_priority(smx_action_t action, double priority);
+void SIMIX_pre_host_execution_wait(smx_simcall_t simcall, smx_action_t action);
+
+// pre prototypes
+smx_host_t SIMIX_pre_host_get_by_name(smx_simcall_t, const char*);
+const char* SIMIX_pre_host_self_get_name(smx_simcall_t);
+const char* SIMIX_pre_host_get_name(smx_simcall_t, smx_host_t);
+xbt_dict_t SIMIX_pre_host_get_properties(smx_simcall_t, smx_host_t);
+double SIMIX_pre_host_get_speed(smx_simcall_t, smx_host_t);
+double SIMIX_pre_host_get_available_speed(smx_simcall_t, smx_host_t);
+int SIMIX_pre_host_get_state(smx_simcall_t, smx_host_t);
+void* SIMIX_pre_host_self_get_data(smx_simcall_t);
+void* SIMIX_pre_host_get_data(smx_simcall_t, smx_host_t);
+void SIMIX_pre_host_set_data(smx_simcall_t, smx_host_t, void*);
+smx_action_t SIMIX_pre_host_execute(smx_simcall_t, const char*, smx_host_t, double, double);
+smx_action_t SIMIX_pre_host_parallel_execute(smx_simcall_t, const char*, int, smx_host_t*,
+                                             double*, double*, double, double);
+void SIMIX_pre_host_execution_destroy(smx_simcall_t, smx_action_t);
+void SIMIX_pre_host_execution_cancel(smx_simcall_t, smx_action_t);
+double SIMIX_pre_host_execution_get_remains(smx_simcall_t, smx_action_t);
+e_smx_state_t SIMIX_pre_host_execution_get_state(smx_simcall_t, smx_action_t);
+void SIMIX_pre_host_execution_set_priority(smx_simcall_t, smx_action_t, double);
 
 void SIMIX_host_execution_suspend(smx_action_t action);
 void SIMIX_host_execution_resume(smx_action_t action);
 
 void SIMIX_host_execution_suspend(smx_action_t action);
 void SIMIX_host_execution_resume(smx_action_t action);
@@ -53,6 +77,8 @@ void SIMIX_host_execution_resume(smx_action_t action);
 void SIMIX_post_host_execute(smx_action_t action);
 
 #ifdef HAVE_TRACING
 void SIMIX_post_host_execute(smx_action_t action);
 
 #ifdef HAVE_TRACING
+void SIMIX_pre_set_category(smx_simcall_t simcall, smx_action_t action,
+                           const char *category);
 void SIMIX_set_category(smx_action_t action, const char *category);
 #endif
 
 void SIMIX_set_category(smx_action_t action, const char *category);
 #endif
 
index 0a11720..d2959f1 100644 (file)
@@ -15,13 +15,10 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix,
 
 
 //SIMIX FILE READ
 
 
 //SIMIX FILE READ
-void SIMIX_pre_file_read(smx_simcall_t simcall)
+void SIMIX_pre_file_read(smx_simcall_t simcall, void *ptr, size_t size,
+                        size_t nmemb, smx_file_t stream)
 {
 {
-  smx_action_t action = SIMIX_file_read(simcall->issuer,
-      simcall->file_read.ptr,
-      simcall->file_read.size,
-      simcall->file_read.nmemb,
-      simcall->file_read.stream);
+  smx_action_t action = SIMIX_file_read(simcall->issuer, ptr, size, nmemb, stream);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
@@ -55,13 +52,10 @@ smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size
 }
 
 //SIMIX FILE WRITE
 }
 
 //SIMIX FILE WRITE
-void SIMIX_pre_file_write(smx_simcall_t simcall)
+void SIMIX_pre_file_write(smx_simcall_t simcall, const void *ptr, size_t size,
+                         size_t nmemb, smx_file_t stream)
 {
 {
-  smx_action_t action = SIMIX_file_write(simcall->issuer,
-      simcall->file_write.ptr,
-      simcall->file_write.size,
-      simcall->file_write.nmemb,
-      simcall->file_write.stream);
+  smx_action_t action = SIMIX_file_write(simcall->issuer, ptr, size, nmemb, stream);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
@@ -95,12 +89,10 @@ smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t siz
 }
 
 //SIMIX FILE OPEN
 }
 
 //SIMIX FILE OPEN
-void SIMIX_pre_file_open(smx_simcall_t simcall)
+void SIMIX_pre_file_open(smx_simcall_t simcall, const char* mount,
+                        const char* path, const char* mode)
 {
 {
-  smx_action_t action = SIMIX_file_open(simcall->issuer,
-      simcall->file_open.mount,
-      simcall->file_open.path,
-      simcall->file_open.mode);
+  smx_action_t action = SIMIX_file_open(simcall->issuer, mount, path, mode);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
@@ -134,10 +126,9 @@ smx_action_t SIMIX_file_open(smx_process_t process ,const char* mount, const cha
 }
 
 //SIMIX FILE CLOSE
 }
 
 //SIMIX FILE CLOSE
-void SIMIX_pre_file_close(smx_simcall_t simcall)
+void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fp)
 {
 {
-  smx_action_t action = SIMIX_file_close(simcall->issuer,
-      simcall->file_close.fp);
+  smx_action_t action = SIMIX_file_close(simcall->issuer, fp);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
@@ -171,11 +162,9 @@ smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fp)
 }
 
 //SIMIX FILE STAT
 }
 
 //SIMIX FILE STAT
-void SIMIX_pre_file_stat(smx_simcall_t simcall)
+void SIMIX_pre_file_stat(smx_simcall_t simcall, smx_file_t fd, s_file_stat_t buf)
 {
 {
-  smx_action_t action = SIMIX_file_stat(simcall->issuer,
-      simcall->file_stat.fd,
-      simcall->file_stat.buf);
+  smx_action_t action = SIMIX_file_stat(simcall->issuer, fd, buf);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
@@ -208,10 +197,9 @@ smx_action_t SIMIX_file_stat(smx_process_t process, smx_file_t fd, s_file_stat_t
 }
 
 //SIMIX FILE UNLINK
 }
 
 //SIMIX FILE UNLINK
-void SIMIX_pre_file_unlink(smx_simcall_t simcall)
+void SIMIX_pre_file_unlink(smx_simcall_t simcall, smx_file_t fd)
 {
 {
-  smx_action_t action = SIMIX_file_unlink(simcall->issuer,
-      simcall->file_unlink.fd);
+  smx_action_t action = SIMIX_file_unlink(simcall->issuer, fd);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
@@ -244,7 +232,8 @@ smx_action_t SIMIX_file_unlink(smx_process_t process, smx_file_t fd)
 }
 
 //SIMIX FILE LS
 }
 
 //SIMIX FILE LS
-void SIMIX_pre_file_ls(smx_simcall_t simcall)
+void SIMIX_pre_file_ls(smx_simcall_t simcall,
+                       const char* mount, const char* path)
 {
   smx_action_t action = SIMIX_file_ls(simcall->issuer,
       simcall->file_ls.mount, simcall->file_ls.path);
 {
   smx_action_t action = SIMIX_file_ls(simcall->issuer,
       simcall->file_ls.mount, simcall->file_ls.path);
index b7df26c..6e7848c 100644 (file)
 #include "simgrid/simix.h"
 #include "smx_smurf_private.h"
 
 #include "simgrid/simix.h"
 #include "smx_smurf_private.h"
 
-void SIMIX_pre_file_read(smx_simcall_t simcall);
-void SIMIX_pre_file_write(smx_simcall_t simcall);
-void SIMIX_pre_file_open(smx_simcall_t simcall);
-void SIMIX_pre_file_close(smx_simcall_t simcall);
-void SIMIX_pre_file_stat(smx_simcall_t simcall);
-void SIMIX_pre_file_unlink(smx_simcall_t simcall);
-void SIMIX_pre_file_ls(smx_simcall_t simcall);
+void SIMIX_pre_file_read(smx_simcall_t simcall, void *ptr, size_t size,
+                        size_t nmemb, smx_file_t stream);
+void SIMIX_pre_file_write(smx_simcall_t simcall, const void *ptr, size_t size,
+                         size_t nmemb, smx_file_t strea);
+void SIMIX_pre_file_open(smx_simcall_t simcall, const char* mount,
+                        const char* path, const char* mode);
+void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fp);
+void SIMIX_pre_file_stat(smx_simcall_t simcall, smx_file_t fd, s_file_stat_t buf);
+void SIMIX_pre_file_unlink(smx_simcall_t simcall, smx_file_t fd);
+void SIMIX_pre_file_ls(smx_simcall_t simcall,
+                       const char* mount, const char* path);
 
 smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size_t nmemb, smx_file_t stream);
 smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
 
 smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size_t nmemb, smx_file_t stream);
 smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
@@ -30,4 +34,6 @@ void SIMIX_post_io(smx_action_t action);
 void SIMIX_io_destroy(smx_action_t action);
 void SIMIX_io_finish(smx_action_t action);
 
 void SIMIX_io_destroy(smx_action_t action);
 void SIMIX_io_finish(smx_action_t action);
 
+// pre prototypes
+
 #endif
 #endif
index 82313fb..d6ad23c 100644 (file)
@@ -43,6 +43,9 @@ void SIMIX_network_exit(void)
 /*                           Rendez-Vous Points                               */
 /******************************************************************************/
 
 /*                           Rendez-Vous Points                               */
 /******************************************************************************/
 
+smx_rdv_t SIMIX_pre_rdv_create(smx_simcall_t simcall, const char *name){
+  return SIMIX_rdv_create(name);
+}
 smx_rdv_t SIMIX_rdv_create(const char *name)
 {
   /* two processes may have pushed the same rdv_create simcall at the same time */
 smx_rdv_t SIMIX_rdv_create(const char *name)
 {
   /* two processes may have pushed the same rdv_create simcall at the same time */
@@ -63,6 +66,9 @@ smx_rdv_t SIMIX_rdv_create(const char *name)
   return rdv;
 }
 
   return rdv;
 }
 
+void SIMIX_pre_rdv_destroy(smx_simcall_t simcall, smx_rdv_t rdv){
+  return SIMIX_rdv_destroy(rdv);
+}
 void SIMIX_rdv_destroy(smx_rdv_t rdv)
 {
   if (rdv->name)
 void SIMIX_rdv_destroy(smx_rdv_t rdv)
 {
   if (rdv->name)
@@ -85,11 +91,17 @@ xbt_dict_t SIMIX_get_rdv_points()
   return rdv_points;
 }
 
   return rdv_points;
 }
 
+smx_rdv_t SIMIX_pre_rdv_get_by_name(smx_simcall_t simcall, const char *name){
+  return SIMIX_rdv_get_by_name(name);
+}
 smx_rdv_t SIMIX_rdv_get_by_name(const char *name)
 {
   return xbt_dict_get_or_null(rdv_points, name);
 }
 
 smx_rdv_t SIMIX_rdv_get_by_name(const char *name)
 {
   return xbt_dict_get_or_null(rdv_points, name);
 }
 
+int SIMIX_pre_rdv_comm_count_by_host(smx_simcall_t simcall, smx_rdv_t rdv, smx_host_t host){
+  return SIMIX_rdv_comm_count_by_host(rdv, host);
+}
 int SIMIX_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
 {
   smx_action_t comm = NULL;
 int SIMIX_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
 {
   smx_action_t comm = NULL;
@@ -104,11 +116,17 @@ int SIMIX_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
   return count;
 }
 
   return count;
 }
 
+smx_action_t SIMIX_pre_rdv_get_head(smx_simcall_t simcall, smx_rdv_t rdv){
+  return SIMIX_rdv_get_head(rdv);
+}
 smx_action_t SIMIX_rdv_get_head(smx_rdv_t rdv)
 {
   return xbt_fifo_get_item_content(xbt_fifo_get_first_item(rdv->comm_fifo));
 }
 
 smx_action_t SIMIX_rdv_get_head(smx_rdv_t rdv)
 {
   return xbt_fifo_get_item_content(xbt_fifo_get_first_item(rdv->comm_fifo));
 }
 
+smx_process_t SIMIX_pre_rdv_get_receiver(smx_simcall_t simcall, smx_rdv_t rdv){
+  return SIMIX_rdv_get_receiver(rdv);
+}
 /**
  *  \brief get the receiver (process associated to the mailbox)
  *  \param rdv The rendez-vous point
 /**
  *  \brief get the receiver (process associated to the mailbox)
  *  \param rdv The rendez-vous point
@@ -119,12 +137,16 @@ smx_process_t SIMIX_rdv_get_receiver(smx_rdv_t rdv)
   return rdv->permanent_receiver;
 }
 
   return rdv->permanent_receiver;
 }
 
+void SIMIX_pre_rdv_set_receiver(smx_simcall_t simcall, smx_rdv_t rdv,
+                           smx_process_t process){
+  SIMIX_rdv_set_receiver(rdv, process);
+}
 /**
  *  \brief set the receiver of the rendez vous point to allow eager sends
  *  \param rdv The rendez-vous point
  *  \param process The receiving process
  */
 /**
  *  \brief set the receiver of the rendez vous point to allow eager sends
  *  \param rdv The rendez-vous point
  *  \param process The receiving process
  */
-void SIMIX_rdv_set_receiver(smx_rdv_t rdv , smx_process_t process)
+void SIMIX_rdv_set_receiver(smx_rdv_t rdv, smx_process_t process)
 {
   rdv->permanent_receiver=process;
 }
 {
   rdv->permanent_receiver=process;
 }
@@ -261,6 +283,9 @@ smx_action_t SIMIX_comm_new(e_smx_comm_type_t type)
   return act;
 }
 
   return act;
 }
 
+void SIMIX_pre_comm_destroy(smx_simcall_t simcall, smx_action_t action){
+  SIMIX_comm_destroy(action);
+}
 /**
  *  \brief Destroy a communicate action
  *  \param action The communicate action to be destroyed
 /**
  *  \brief Destroy a communicate action
  *  \param action The communicate action to be destroyed
@@ -321,6 +346,27 @@ void SIMIX_comm_destroy_internal_actions(smx_action_t action)
   }
 }
 
   }
 }
 
+void SIMIX_pre_comm_send(smx_simcall_t simcall, smx_rdv_t rdv,
+                                  double task_size, double rate,
+                                  void *src_buff, size_t src_buff_size,
+                                  int (*match_fun)(void *, void *,smx_action_t),
+                                 void *data, double timeout){
+  smx_action_t comm = SIMIX_comm_isend(simcall->issuer, rdv, task_size, rate,
+                                      src_buff, src_buff_size, match_fun, NULL,
+                                      data, 0);
+  simcall->mc_value = 0;
+  SIMIX_pre_comm_wait(simcall, comm, timeout);
+}
+smx_action_t SIMIX_pre_comm_isend(smx_simcall_t simcall, smx_rdv_t rdv,
+                                  double task_size, double rate,
+                                  void *src_buff, size_t src_buff_size,
+                                  int (*match_fun)(void *, void *,smx_action_t),
+                                  void (*clean_fun)(void *), 
+                                 void *data, int detached){
+  return SIMIX_comm_isend(simcall->issuer, rdv, task_size, rate, src_buff,
+                         src_buff_size, match_fun, clean_fun, data, detached);
+
+}
 smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv,
                               double task_size, double rate,
                               void *src_buff, size_t src_buff_size,
 smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv,
                               double task_size, double rate,
                               void *src_buff, size_t src_buff_size,
@@ -397,6 +443,22 @@ smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv,
   return (detached ? NULL : other_action);
 }
 
   return (detached ? NULL : other_action);
 }
 
+void SIMIX_pre_comm_recv(smx_simcall_t simcall, smx_rdv_t rdv,
+                                  void *dst_buff, size_t *dst_buff_size,
+                                  int (*match_fun)(void *, void *, smx_action_t),
+                                 void *data, double timeout){
+  smx_action_t comm = SIMIX_comm_irecv(simcall->issuer, rdv, dst_buff,
+                                      dst_buff_size, match_fun, data);
+  simcall->mc_value = 0;
+  SIMIX_pre_comm_wait(simcall, comm, timeout);
+}
+smx_action_t SIMIX_pre_comm_irecv(smx_simcall_t simcall, smx_rdv_t rdv,
+                                  void *dst_buff, size_t *dst_buff_size,
+                                  int (*match_fun)(void *, void *, smx_action_t),
+                                 void *data){
+  return SIMIX_comm_irecv(simcall->issuer, rdv, dst_buff, dst_buff_size,
+                         match_fun, data);
+}
 smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
                               void *dst_buff, size_t *dst_buff_size,
                               int (*match_fun)(void *, void *, smx_action_t), void *data)
 smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
                               void *dst_buff, size_t *dst_buff_size,
                               int (*match_fun)(void *, void *, smx_action_t), void *data)
@@ -482,6 +544,12 @@ smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
   return other_action;
 }
 
   return other_action;
 }
 
+smx_action_t SIMIX_pre_comm_iprobe(smx_simcall_t simcall, smx_rdv_t rdv,
+                                   int src, int tag,
+                                   int (*match_fun)(void *, void *, smx_action_t),
+                                   void *data){
+  return SIMIX_comm_iprobe(simcall->issuer, rdv, src, tag, match_fun, data);
+}
 
 smx_action_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_rdv_t rdv, int src,
                               int tag, int (*match_fun)(void *, void *, smx_action_t), void *data)
 
 smx_action_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_rdv_t rdv, int src,
                               int tag, int (*match_fun)(void *, void *, smx_action_t), void *data)
@@ -509,9 +577,9 @@ smx_action_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_rdv_t rdv, int src,
   return other_action;
 }
 
   return other_action;
 }
 
-void SIMIX_pre_comm_wait(smx_simcall_t simcall, smx_action_t action, double timeout, int idx)
+void SIMIX_pre_comm_wait(smx_simcall_t simcall, smx_action_t action, double timeout)
 {
 {
-
+  int idx = simcall->mc_value;
   /* the simcall may be a wait, a send or a recv */
   surf_action_t sleep;
 
   /* the simcall may be a wait, a send or a recv */
   surf_action_t sleep;
 
@@ -555,10 +623,8 @@ void SIMIX_pre_comm_wait(smx_simcall_t simcall, smx_action_t action, double time
   }
 }
 
   }
 }
 
-void SIMIX_pre_comm_test(smx_simcall_t simcall)
+void SIMIX_pre_comm_test(smx_simcall_t simcall, smx_action_t action)
 {
 {
-  smx_action_t action = simcall->comm_test.comm;
-
   if(MC_is_active()){
     simcall->comm_test.result = action->comm.src_proc && action->comm.dst_proc;
     if(simcall->comm_test.result){
   if(MC_is_active()){
     simcall->comm_test.result = action->comm.src_proc && action->comm.dst_proc;
     if(simcall->comm_test.result){
@@ -580,11 +646,11 @@ void SIMIX_pre_comm_test(smx_simcall_t simcall)
   }
 }
 
   }
 }
 
-void SIMIX_pre_comm_testany(smx_simcall_t simcall, int idx)
+void SIMIX_pre_comm_testany(smx_simcall_t simcall, xbt_dynar_t actions)
 {
 {
+  int idx = simcall->mc_value;
   unsigned int cursor;
   smx_action_t action;
   unsigned int cursor;
   smx_action_t action;
-  xbt_dynar_t actions = simcall->comm_testany.comms;
   simcall->comm_testany.result = -1;
 
   if (MC_is_active()){
   simcall->comm_testany.result = -1;
 
   if (MC_is_active()){
@@ -611,11 +677,11 @@ void SIMIX_pre_comm_testany(smx_simcall_t simcall, int idx)
   SIMIX_simcall_answer(simcall);
 }
 
   SIMIX_simcall_answer(simcall);
 }
 
-void SIMIX_pre_comm_waitany(smx_simcall_t simcall, int idx)
+void SIMIX_pre_comm_waitany(smx_simcall_t simcall, xbt_dynar_t actions)
 {
 {
+  int idx = simcall->mc_value;
   smx_action_t action;
   unsigned int cursor = 0;
   smx_action_t action;
   unsigned int cursor = 0;
-  xbt_dynar_t actions = simcall->comm_waitany.comms;
 
   if (MC_is_active()){
     action = xbt_dynar_get_as(actions, idx, smx_action_t);
 
   if (MC_is_active()){
     action = xbt_dynar_get_as(actions, idx, smx_action_t);
@@ -860,6 +926,9 @@ void SIMIX_post_comm(smx_action_t action)
   }
 }
 
   }
 }
 
+void SIMIX_pre_comm_cancel(smx_simcall_t simcall, smx_action_t action){
+  SIMIX_comm_cancel(action);
+}
 void SIMIX_comm_cancel(smx_action_t action)
 {
   /* if the action is a waiting state means that it is still in a rdv */
 void SIMIX_comm_cancel(smx_action_t action)
 {
   /* if the action is a waiting state means that it is still in a rdv */
@@ -894,6 +963,9 @@ void SIMIX_comm_resume(smx_action_t action)
 
 /************* Action Getters **************/
 
 
 /************* Action Getters **************/
 
+double SIMIX_pre_comm_get_remains(smx_simcall_t simcall, smx_action_t action){
+  return SIMIX_comm_get_remains(action);
+}
 /**
  *  \brief get the amount remaining from the communication
  *  \param action The communication
 /**
  *  \brief get the amount remaining from the communication
  *  \param action The communication
@@ -924,11 +996,17 @@ double SIMIX_comm_get_remains(smx_action_t action)
   return remains;
 }
 
   return remains;
 }
 
+e_smx_state_t SIMIX_pre_comm_get_state(smx_simcall_t simcall, smx_action_t action){
+  return SIMIX_comm_get_state(action);
+}
 e_smx_state_t SIMIX_comm_get_state(smx_action_t action)
 {
   return action->state;
 }
 
 e_smx_state_t SIMIX_comm_get_state(smx_action_t action)
 {
   return action->state;
 }
 
+void* SIMIX_pre_comm_get_src_data(smx_simcall_t simcall, smx_action_t action){
+  return SIMIX_comm_get_src_data(action);
+}
 /**
  *  \brief Return the user data associated to the sender of the communication
  *  \param action The communication
 /**
  *  \brief Return the user data associated to the sender of the communication
  *  \param action The communication
@@ -939,6 +1017,9 @@ void* SIMIX_comm_get_src_data(smx_action_t action)
   return action->comm.src_data;
 }
 
   return action->comm.src_data;
 }
 
+void* SIMIX_pre_comm_get_dst_data(smx_simcall_t simcall, smx_action_t action){
+  return SIMIX_comm_get_dst_data(action);
+}
 /**
  *  \brief Return the user data associated to the receiver of the communication
  *  \param action The communication
 /**
  *  \brief Return the user data associated to the receiver of the communication
  *  \param action The communication
@@ -949,11 +1030,17 @@ void* SIMIX_comm_get_dst_data(smx_action_t action)
   return action->comm.dst_data;
 }
 
   return action->comm.dst_data;
 }
 
+smx_process_t SIMIX_pre_comm_get_src_proc(smx_simcall_t simcall, smx_action_t action){
+  return SIMIX_comm_get_src_proc(action);
+}
 smx_process_t SIMIX_comm_get_src_proc(smx_action_t action)
 {
   return action->comm.src_proc;
 }
 
 smx_process_t SIMIX_comm_get_src_proc(smx_action_t action)
 {
   return action->comm.src_proc;
 }
 
+smx_process_t SIMIX_pre_comm_get_dst_proc(smx_simcall_t simcall, smx_action_t action){
+  return SIMIX_comm_get_dst_proc(action);
+}
 smx_process_t SIMIX_comm_get_dst_proc(smx_action_t action)
 {
   return action->comm.dst_proc;
 smx_process_t SIMIX_comm_get_dst_proc(smx_action_t action)
 {
   return action->comm.dst_proc;
index 54b45bc..4add3ef 100644 (file)
@@ -56,13 +56,13 @@ smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
                               int (*)(void *, void *, smx_action_t), void *data);
 void SIMIX_comm_destroy(smx_action_t action);
 void SIMIX_comm_destroy_internal_actions(smx_action_t action);
                               int (*)(void *, void *, smx_action_t), void *data);
 void SIMIX_comm_destroy(smx_action_t action);
 void SIMIX_comm_destroy_internal_actions(smx_action_t action);
-void SIMIX_pre_comm_wait(smx_simcall_t simcall, smx_action_t action, double timeout, int idx);
 smx_action_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_rdv_t rdv, int src,
                               int tag, int (*match_fun)(void *, void *, smx_action_t), void *data);
 smx_action_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_rdv_t rdv, int src,
                               int tag, int (*match_fun)(void *, void *, smx_action_t), void *data);
-void SIMIX_pre_comm_waitany(smx_simcall_t simcall, int idx);
+void SIMIX_pre_comm_wait(smx_simcall_t simcall, smx_action_t action, double timeout);
+void SIMIX_pre_comm_waitany(smx_simcall_t simcall, xbt_dynar_t actions);
 void SIMIX_post_comm(smx_action_t action);
 void SIMIX_post_comm(smx_action_t action);
-void SIMIX_pre_comm_test(smx_simcall_t simcall);
-void SIMIX_pre_comm_testany(smx_simcall_t simcall, int idx);
+void SIMIX_pre_comm_test(smx_simcall_t simcall, smx_action_t action);
+void SIMIX_pre_comm_testany(smx_simcall_t simcall, xbt_dynar_t actions);
 void SIMIX_comm_cancel(smx_action_t action);
 double SIMIX_comm_get_remains(smx_action_t action);
 e_smx_state_t SIMIX_comm_get_state(smx_action_t action);
 void SIMIX_comm_cancel(smx_action_t action);
 double SIMIX_comm_get_remains(smx_action_t action);
 e_smx_state_t SIMIX_comm_get_state(smx_action_t action);
@@ -71,5 +71,45 @@ void SIMIX_comm_resume(smx_action_t action);
 smx_process_t SIMIX_comm_get_src_proc(smx_action_t action);
 smx_process_t SIMIX_comm_get_dst_proc(smx_action_t action);
 
 smx_process_t SIMIX_comm_get_src_proc(smx_action_t action);
 smx_process_t SIMIX_comm_get_dst_proc(smx_action_t action);
 
+// pre prototypes
+smx_action_t SIMIX_pre_comm_iprobe(smx_simcall_t simcall, smx_rdv_t rdv,
+                                   int src, int tag,
+                                   int (*match_fun)(void *, void *, smx_action_t),
+                                   void *data);
+smx_rdv_t SIMIX_pre_rdv_create(smx_simcall_t simcall, const char *name);
+void SIMIX_pre_rdv_destroy(smx_simcall_t simcall, smx_rdv_t rdv);
+smx_rdv_t SIMIX_pre_rdv_get_by_name(smx_simcall_t simcall, const char *name);
+int SIMIX_pre_rdv_comm_count_by_host(smx_simcall_t simcall, smx_rdv_t rdv, smx_host_t host);
+smx_action_t SIMIX_pre_rdv_get_head(smx_simcall_t simcall, smx_rdv_t rdv);
+smx_process_t SIMIX_pre_rdv_get_receiver(smx_simcall_t simcall, smx_rdv_t rdv);
+void SIMIX_pre_rdv_set_receiver(smx_simcall_t simcall, smx_rdv_t rdv,
+                           smx_process_t process);
+void SIMIX_pre_comm_send(smx_simcall_t simcall, smx_rdv_t rdv,
+                                  double task_size, double rate,
+                                  void *src_buff, size_t src_buff_size,
+                                  int (*match_fun)(void *, void *,smx_action_t),
+                                 void *data, double timeout);
+smx_action_t SIMIX_pre_comm_isend(smx_simcall_t simcall, smx_rdv_t rdv,
+                                  double task_size, double rate,
+                                  void *src_buff, size_t src_buff_size,
+                                  int (*match_fun)(void *, void *,smx_action_t),
+                                  void (*clean_fun)(void *), 
+                                 void *data, int detached);
+void SIMIX_pre_comm_recv(smx_simcall_t simcall, smx_rdv_t rdv,
+                                  void *dst_buff, size_t *dst_buff_size,
+                                  int (*match_fun)(void *, void *, smx_action_t),
+                                 void *data, double timeout);
+smx_action_t SIMIX_pre_comm_irecv(smx_simcall_t simcall, smx_rdv_t rdv,
+                                  void *dst_buff, size_t *dst_buff_size,
+                                  int (*match_fun)(void *, void *, smx_action_t),
+                                 void *data);
+void SIMIX_pre_comm_destroy(smx_simcall_t simcall, smx_action_t action);
+void SIMIX_pre_comm_cancel(smx_simcall_t simcall, smx_action_t action);
+double SIMIX_pre_comm_get_remains(smx_simcall_t simcall, smx_action_t action);
+e_smx_state_t SIMIX_pre_comm_get_state(smx_simcall_t simcall, smx_action_t action);
+void* SIMIX_pre_comm_get_src_data(smx_simcall_t simcall, smx_action_t action);
+void* SIMIX_pre_comm_get_dst_data(smx_simcall_t simcall, smx_action_t action);
+smx_process_t SIMIX_pre_comm_get_src_proc(smx_simcall_t simcall, smx_action_t action);
+smx_process_t SIMIX_pre_comm_get_dst_proc(smx_simcall_t simcall, smx_action_t action);
 #endif
 
 #endif
 
index 7ae2c2b..1a050b2 100644 (file)
@@ -38,6 +38,9 @@ int SIMIX_process_has_pending_comms(smx_process_t process) {
   return xbt_fifo_size(process->comms) > 0;
 }
 
   return xbt_fifo_size(process->comms) > 0;
 }
 
+void SIMIX_pre_process_cleanup(smx_simcall_t simcall, smx_process_t process) {
+  SIMIX_process_cleanup(process);
+}
 /**
  * \brief Moves a process to the list of processes to destroy.
  */
 /**
  * \brief Moves a process to the list of processes to destroy.
  */
@@ -192,6 +195,20 @@ smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args) {
   return process;
 }
 
   return process;
 }
 
+
+void SIMIX_pre_process_create(smx_simcall_t simcall,
+                         smx_process_t *process,
+                          const char *name,
+                          xbt_main_func_t code,
+                          void *data,
+                          const char *hostname,
+                          double kill_time,
+                          int argc, char **argv,
+                          xbt_dict_t properties,
+                          int auto_restart){
+  return SIMIX_process_create(process, name, code, data, hostname,
+                              kill_time, argc, argv, properties, auto_restart);
+}
 /**
  * \brief Internal function to create a process.
  *
 /**
  * \brief Internal function to create a process.
  *
@@ -288,6 +305,9 @@ void SIMIX_process_runall(void)
   xbt_dynar_reset(simix_global->process_to_run);
 }
 
   xbt_dynar_reset(simix_global->process_to_run);
 }
 
+void SIMIX_pre_process_kill(smx_simcall_t simcall, smx_process_t process) {
+  SIMIX_process_kill(process, simcall->issuer);
+}
 /**
  * \brief Internal function to kill a SIMIX process.
  *
 /**
  * \brief Internal function to kill a SIMIX process.
  *
@@ -349,6 +369,9 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) {
 
 }
 
 
 }
 
+void SIMIX_pre_process_killall(smx_simcall_t simcall) {
+  SIMIX_process_killall(simcall->issuer);
+}
 /**
  * \brief Kills all running processes.
  * \param issuer this one will not be killed
 /**
  * \brief Kills all running processes.
  * \param issuer this one will not be killed
@@ -368,6 +391,11 @@ void SIMIX_process_killall(smx_process_t issuer)
   SIMIX_process_empty_trash();
 }
 
   SIMIX_process_empty_trash();
 }
 
+void SIMIX_pre_process_change_host(smx_simcall_t simcall, smx_process_t process,
+                                  smx_host_t dest)
+{
+  process->new_host = dest;
+}
 void SIMIX_process_change_host(smx_process_t process,
              smx_host_t dest)
 {
 void SIMIX_process_change_host(smx_process_t process,
              smx_host_t dest)
 {
@@ -377,14 +405,9 @@ void SIMIX_process_change_host(smx_process_t process,
   xbt_swag_insert(process, dest->process_list);
 }
 
   xbt_swag_insert(process, dest->process_list);
 }
 
-void SIMIX_pre_process_change_host(smx_process_t process, smx_host_t dest)
-{
-  process->new_host = dest;
-}
 
 
-void SIMIX_pre_process_suspend(smx_simcall_t simcall)
+void SIMIX_pre_process_suspend(smx_simcall_t simcall, smx_process_t process)
 {
 {
-  smx_process_t process = simcall->process_suspend.process;
   smx_action_t action_suspend =
       SIMIX_process_suspend(process, simcall->issuer);
 
   smx_action_t action_suspend =
       SIMIX_process_suspend(process, simcall->issuer);
 
@@ -444,10 +467,14 @@ smx_action_t SIMIX_process_suspend(smx_process_t process, smx_process_t issuer)
       return NULL;
     }
   } else {
       return NULL;
     }
   } else {
-    return SIMIX_host_execute(SIMIX_pack_args(PTR("suspend"), PTR(process->smx_host), DOUBLE(0.0), DOUBLE(1.0)));
+    return SIMIX_host_execute("suspend", process->smx_host, 0.0, 1.0);
   }
 }
 
   }
 }
 
+void SIMIX_pre_process_resume(smx_simcall_t simcall, smx_process_t process){
+  SIMIX_process_resume(process, simcall->issuer);
+}
+
 void SIMIX_process_resume(smx_process_t process, smx_process_t issuer)
 {
   xbt_assert((process != NULL), "Invalid parameters");
 void SIMIX_process_resume(smx_process_t process, smx_process_t issuer)
 {
   xbt_assert((process != NULL), "Invalid parameters");
@@ -502,11 +529,18 @@ int SIMIX_process_get_maxpid(void) {
   return simix_process_maxpid;
 }
 
   return simix_process_maxpid;
 }
 
+int SIMIX_pre_process_count(smx_simcall_t simcall){
+  return SIMIX_process_count();
+}
 int SIMIX_process_count(void)
 {
   return xbt_swag_size(simix_global->process_list);
 }
 
 int SIMIX_process_count(void)
 {
   return xbt_swag_size(simix_global->process_list);
 }
 
+void* SIMIX_pre_process_self_get_data(smx_simcall_t simcall, smx_process_t self){
+  return SIMIX_process_self_get_data(self);    
+}
+
 void* SIMIX_process_self_get_data(smx_process_t self)
 {
   xbt_assert(self == SIMIX_process_self(), "This is not the current process");
 void* SIMIX_process_self_get_data(smx_process_t self)
 {
   xbt_assert(self == SIMIX_process_self(), "This is not the current process");
@@ -517,6 +551,10 @@ void* SIMIX_process_self_get_data(smx_process_t self)
   return SIMIX_process_get_data(self);
 }
 
   return SIMIX_process_get_data(self);
 }
 
+void SIMIX_pre_process_set_data(smx_simcall_t simcall, smx_process_t process,
+                                void *data){
+  SIMIX_process_set_data(process, data);
+}
 void SIMIX_process_self_set_data(smx_process_t self, void *data)
 {
   xbt_assert(self == SIMIX_process_self(), "This is not the current process");
 void SIMIX_process_self_set_data(smx_process_t self, void *data)
 {
   xbt_assert(self == SIMIX_process_self(), "This is not the current process");
@@ -524,6 +562,9 @@ void SIMIX_process_self_set_data(smx_process_t self, void *data)
   SIMIX_process_set_data(self, data);
 }
 
   SIMIX_process_set_data(self, data);
 }
 
+void* SIMIX_pre_process_get_data(smx_simcall_t simcall, smx_process_t process){
+  return SIMIX_process_get_data(process);
+}
 void* SIMIX_process_get_data(smx_process_t process)
 {
   return process->data;
 void* SIMIX_process_get_data(smx_process_t process)
 {
   return process->data;
@@ -534,6 +575,9 @@ void SIMIX_process_set_data(smx_process_t process, void *data)
   process->data = data;
 }
 
   process->data = data;
 }
 
+smx_host_t SIMIX_pre_process_get_host(smx_simcall_t simcall, smx_process_t process){
+  return SIMIX_process_get_host(process);
+}
 smx_host_t SIMIX_process_get_host(smx_process_t process)
 {
   return process->smx_host;
 smx_host_t SIMIX_process_get_host(smx_process_t process)
 {
   return process->smx_host;
@@ -550,6 +594,9 @@ const char* SIMIX_process_self_get_name(void) {
   return SIMIX_process_get_name(process);
 }
 
   return SIMIX_process_get_name(process);
 }
 
+const char* SIMIX_pre_process_get_name(smx_simcall_t simcall, smx_process_t process) {
+  return SIMIX_process_get_name(process);
+}
 const char* SIMIX_process_get_name(smx_process_t process)
 {
   return process->name;
 const char* SIMIX_process_get_name(smx_process_t process)
 {
   return process->name;
@@ -567,25 +614,31 @@ smx_process_t SIMIX_process_get_by_name(const char* name)
   return NULL;
 }
 
   return NULL;
 }
 
+int SIMIX_pre_process_is_suspended(smx_simcall_t simcall, smx_process_t process){
+  return SIMIX_process_is_suspended(process);
+}
 int SIMIX_process_is_suspended(smx_process_t process)
 {
   return process->suspended;
 }
 
 int SIMIX_process_is_suspended(smx_process_t process)
 {
   return process->suspended;
 }
 
+xbt_dict_t SIMIX_pre_process_get_properties(smx_simcall_t simcall, smx_process_t process){
+  return SIMIX_process_get_properties(process);
+}
 xbt_dict_t SIMIX_process_get_properties(smx_process_t process)
 {
   return process->properties;
 }
 
 xbt_dict_t SIMIX_process_get_properties(smx_process_t process)
 {
   return process->properties;
 }
 
-void SIMIX_pre_process_sleep(smx_simcall_t simcall)
+void SIMIX_pre_process_sleep(smx_simcall_t simcall, double duration)
 {
   if (MC_is_active()) {
 {
   if (MC_is_active()) {
-    MC_process_clock_add(simcall->issuer, simcall->process_sleep.duration);
+    MC_process_clock_add(simcall->issuer, duration);
     simcall->process_sleep.result = SIMIX_DONE;
     SIMIX_simcall_answer(simcall);
     return;
   }
     simcall->process_sleep.result = SIMIX_DONE;
     SIMIX_simcall_answer(simcall);
     return;
   }
-  smx_action_t action = SIMIX_process_sleep(simcall->issuer, simcall->process_sleep.duration);
+  smx_action_t action = SIMIX_process_sleep(simcall->issuer, duration);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
@@ -764,6 +817,8 @@ xbt_dynar_t SIMIX_processes_as_dynar(void) {
   }
   return res;
 }
   }
   return res;
 }
+
+
 void SIMIX_process_on_exit_runall(smx_process_t process) {
   s_smx_process_exit_fun_t exit_fun;
 
 void SIMIX_process_on_exit_runall(smx_process_t process) {
   s_smx_process_exit_fun_t exit_fun;
 
@@ -772,6 +827,12 @@ void SIMIX_process_on_exit_runall(smx_process_t process) {
     (exit_fun.fun)(exit_fun.arg);
   }
 }
     (exit_fun.fun)(exit_fun.arg);
   }
 }
+
+void SIMIX_pre_process_on_exit(smx_simcall_t simcall, smx_process_t process,
+                              int_f_pvoid_t fun, void *data) {
+  SIMIX_process_on_exit(process, fun, data);
+}
+
 void SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data) {
   xbt_assert(process, "current process not found: are you in maestro context ?");
 
 void SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data) {
   xbt_assert(process, "current process not found: are you in maestro context ?");
 
@@ -783,6 +844,11 @@ void SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data)
 
   xbt_dynar_push_as(process->on_exit,s_smx_process_exit_fun_t,exit_fun);
 }
 
   xbt_dynar_push_as(process->on_exit,s_smx_process_exit_fun_t,exit_fun);
 }
+
+void SIMIX_pre_process_auto_restart_set(smx_simcall_t simcall, smx_process_t process,
+                                       int auto_restart) {
+  SIMIX_process_auto_restart_set(process, auto_restart);       
+}
 /**
  * \brief Sets the auto-restart status of the process.
  * If set to 1, the process will be automatically restarted when its host
 /**
  * \brief Sets the auto-restart status of the process.
  * If set to 1, the process will be automatically restarted when its host
@@ -791,6 +857,10 @@ void SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data)
 void SIMIX_process_auto_restart_set(smx_process_t process, int auto_restart) {
   process->auto_restart = auto_restart;
 }
 void SIMIX_process_auto_restart_set(smx_process_t process, int auto_restart) {
   process->auto_restart = auto_restart;
 }
+
+smx_process_t SIMIX_pre_process_restart(smx_simcall_t simcall, smx_process_t process) {
+  return SIMIX_process_restart(process, simcall->issuer);      
+}
 /**
  * \brief Restart a process.
  * Restart a process, starting it again from the beginning.
 /**
  * \brief Restart a process.
  * Restart a process, starting it again from the beginning.
index 4e65afa..414d8b1 100644 (file)
@@ -81,12 +81,11 @@ void SIMIX_process_empty_trash(void);
 void SIMIX_process_yield(smx_process_t self);
 xbt_running_ctx_t *SIMIX_process_get_running_context(void);
 void SIMIX_process_exception_terminate(xbt_ex_t * e);
 void SIMIX_process_yield(smx_process_t self);
 xbt_running_ctx_t *SIMIX_process_get_running_context(void);
 void SIMIX_process_exception_terminate(xbt_ex_t * e);
-void SIMIX_pre_process_change_host(smx_process_t process,
+void SIMIX_pre_process_change_host(smx_simcall_t, smx_process_t process,
            smx_host_t dest);
 void SIMIX_process_change_host(smx_process_t process,
              smx_host_t dest);
            smx_host_t dest);
 void SIMIX_process_change_host(smx_process_t process,
              smx_host_t dest);
-void SIMIX_pre_process_change_host(smx_process_t process, smx_host_t host);
-void SIMIX_pre_process_suspend(smx_simcall_t simcall);
+void SIMIX_pre_process_suspend(smx_simcall_t simcall, smx_process_t process);
 smx_action_t SIMIX_process_suspend(smx_process_t process, smx_process_t issuer);
 void SIMIX_process_resume(smx_process_t process, smx_process_t issuer);
 void* SIMIX_process_get_data(smx_process_t process);
 smx_action_t SIMIX_process_suspend(smx_process_t process, smx_process_t issuer);
 void SIMIX_process_resume(smx_process_t process, smx_process_t issuer);
 void* SIMIX_process_get_data(smx_process_t process);
@@ -96,7 +95,7 @@ const char* SIMIX_process_get_name(smx_process_t process);
 smx_process_t SIMIX_process_get_by_name(const char* name);
 int SIMIX_process_is_suspended(smx_process_t process);
 xbt_dict_t SIMIX_process_get_properties(smx_process_t process);
 smx_process_t SIMIX_process_get_by_name(const char* name);
 int SIMIX_process_is_suspended(smx_process_t process);
 xbt_dict_t SIMIX_process_get_properties(smx_process_t process);
-void SIMIX_pre_process_sleep(smx_simcall_t simcall);
+void SIMIX_pre_process_sleep(smx_simcall_t simcall, double duration);
 smx_action_t SIMIX_process_sleep(smx_process_t process, double duration);
 void SIMIX_post_process_sleep(smx_action_t action);
 
 smx_action_t SIMIX_process_sleep(smx_process_t process, double duration);
 void SIMIX_post_process_sleep(smx_action_t action);
 
@@ -106,4 +105,27 @@ void SIMIX_process_sleep_destroy(smx_action_t action);
 void SIMIX_process_auto_restart_set(smx_process_t process, int auto_restart);
 smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer);
 
 void SIMIX_process_auto_restart_set(smx_process_t process, int auto_restart);
 smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer);
 
+// pre prototypes
+void SIMIX_pre_process_create(smx_simcall_t simcall, smx_process_t *process,
+                             const char *name, xbt_main_func_t code, void *data,
+                             const char *hostname, double kill_time, int argc,
+                             char **argv, xbt_dict_t properties, int auto_restart);
+void SIMIX_pre_process_kill(smx_simcall_t simcall, smx_process_t process);
+void SIMIX_pre_process_killall(smx_simcall_t simcall);
+void SIMIX_pre_process_cleanup(smx_simcall_t simcall, smx_process_t process);
+void SIMIX_pre_process_resume(smx_simcall_t simcall, smx_process_t process);
+int SIMIX_pre_process_count(smx_simcall_t simcall);
+void* SIMIX_pre_process_self_get_data(smx_simcall_t simcall, smx_process_t process);
+void* SIMIX_pre_process_get_data(smx_simcall_t simcall, smx_process_t process);
+void SIMIX_pre_process_set_data(smx_simcall_t simcall, smx_process_t process,
+                                void *data);
+smx_host_t SIMIX_pre_process_get_host(smx_simcall_t simcall, smx_process_t process);
+const char* SIMIX_pre_process_get_name(smx_simcall_t simcall, smx_process_t process);
+int SIMIX_pre_process_is_suspended(smx_simcall_t simcall, smx_process_t process);
+xbt_dict_t SIMIX_pre_process_get_properties(smx_simcall_t simcall, smx_process_t process);
+void SIMIX_pre_process_on_exit(smx_simcall_t simcall, smx_process_t process,
+                              int_f_pvoid_t fun, void *data);
+void SIMIX_pre_process_auto_restart_set(smx_simcall_t simcall, smx_process_t process,
+                                       int auto_restart);
+smx_process_t SIMIX_pre_process_restart(smx_simcall_t simcall, smx_process_t process);
 #endif
 #endif
index 366897a..6948eee 100644 (file)
@@ -48,518 +48,12 @@ void SIMIX_simcall_answer(smx_simcall_t simcall)
 void SIMIX_simcall_pre(smx_simcall_t simcall, int value)
 {
   XBT_DEBUG("Handling simcall %p: %s", simcall, SIMIX_simcall_name(simcall->call));
 void SIMIX_simcall_pre(smx_simcall_t simcall, int value)
 {
   XBT_DEBUG("Handling simcall %p: %s", simcall, SIMIX_simcall_name(simcall->call));
-
+  simcall->mc_value = value;
   switch (simcall->call) {
   switch (simcall->call) {
-    case SIMCALL_COMM_TEST:
-      SIMIX_pre_comm_test(simcall);
-      break;
-
-    case SIMCALL_COMM_TESTANY:
-      SIMIX_pre_comm_testany(simcall, value);
-      break;
-
-    case SIMCALL_COMM_WAIT:
-      SIMIX_pre_comm_wait(simcall,
-          simcall->comm_wait.comm,
-          simcall->comm_wait.timeout,
-          value);
-      break;
-
-    case SIMCALL_COMM_WAITANY:
-      SIMIX_pre_comm_waitany(simcall, value);
-      break;
-
-    case SIMCALL_COMM_SEND:
-    {
-      smx_action_t comm = SIMIX_comm_isend(
-          simcall->issuer,
-          simcall->comm_send.rdv,
-          simcall->comm_send.task_size,
-          simcall->comm_send.rate,
-          simcall->comm_send.src_buff,
-          simcall->comm_send.src_buff_size,
-          simcall->comm_send.match_fun,
-          NULL, /* no clean function since it's not detached */
-          simcall->comm_send.data,
-          0);
-      SIMIX_pre_comm_wait(simcall, comm, simcall->comm_send.timeout, 0);
-      break;
-    }
-
-    case SIMCALL_COMM_ISEND:
-      simcall->comm_isend.result = SIMIX_comm_isend(
-          simcall->issuer,
-          simcall->comm_isend.rdv,
-          simcall->comm_isend.task_size,
-          simcall->comm_isend.rate,
-          simcall->comm_isend.src_buff,
-          simcall->comm_isend.src_buff_size,
-          simcall->comm_isend.match_fun,
-          simcall->comm_isend.clean_fun,
-          simcall->comm_isend.data,
-          simcall->comm_isend.detached);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COMM_RECV:
-    {
-      smx_action_t comm = SIMIX_comm_irecv(
-          simcall->issuer,
-          simcall->comm_recv.rdv,
-          simcall->comm_recv.dst_buff,
-          simcall->comm_recv.dst_buff_size,
-          simcall->comm_recv.match_fun,
-          simcall->comm_recv.data);
-      SIMIX_pre_comm_wait(simcall, comm, simcall->comm_recv.timeout, 0);
-      break;
-    }
-
-    case SIMCALL_COMM_IRECV:
-      simcall->comm_irecv.result = SIMIX_comm_irecv(
-          simcall->issuer,
-          simcall->comm_irecv.rdv,
-          simcall->comm_irecv.dst_buff,
-          simcall->comm_irecv.dst_buff_size,
-          simcall->comm_irecv.match_fun,
-          simcall->comm_irecv.data);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COMM_IPROBE:
-      simcall->comm_iprobe.result = SIMIX_comm_iprobe(
-          simcall->issuer,
-          simcall->comm_iprobe.rdv,
-          simcall->comm_iprobe.src,
-          simcall->comm_iprobe.tag,
-          simcall->comm_iprobe.match_fun,
-          simcall->comm_iprobe.data);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COMM_DESTROY:
-      SIMIX_comm_destroy(simcall->comm_destroy.comm);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COMM_CANCEL:
-      SIMIX_comm_cancel(simcall->comm_cancel.comm);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COMM_GET_REMAINS:
-      simcall->comm_get_remains.result =
-          SIMIX_comm_get_remains(simcall->comm_get_remains.comm);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COMM_GET_STATE:
-      simcall->comm_get_state.result =
-          SIMIX_comm_get_state(simcall->comm_get_state.comm);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COMM_GET_SRC_DATA:
-      simcall->comm_get_src_data.result = SIMIX_comm_get_src_data(simcall->comm_get_src_data.comm);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COMM_GET_DST_DATA:
-      simcall->comm_get_dst_data.result = SIMIX_comm_get_dst_data(simcall->comm_get_dst_data.comm);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COMM_GET_SRC_PROC:
-      simcall->comm_get_src_proc.result =
-          SIMIX_comm_get_src_proc(simcall->comm_get_src_proc.comm);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COMM_GET_DST_PROC:
-      simcall->comm_get_dst_proc.result =
-          SIMIX_comm_get_dst_proc(simcall->comm_get_dst_proc.comm);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-#ifdef HAVE_LATENCY_BOUND_TRACKING
-    case SIMCALL_COMM_IS_LATENCY_BOUNDED:
-      simcall->comm_is_latency_bounded.result =
-          SIMIX_comm_is_latency_bounded(simcall->comm_is_latency_bounded.comm);
-      SIMIX_simcall_answer(simcall);
-      break;
-#endif
-
-    case SIMCALL_RDV_CREATE:
-      simcall->rdv_create.result = SIMIX_rdv_create(simcall->rdv_create.name);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_RDV_DESTROY:
-      SIMIX_rdv_destroy(simcall->rdv_destroy.rdv);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_RDV_GET_BY_NAME:
-      simcall->rdv_get_by_name.result =
-        SIMIX_rdv_get_by_name(simcall->rdv_get_by_name.name);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_RDV_COMM_COUNT_BY_HOST:
-      simcall->rdv_comm_count_by_host.result = SIMIX_rdv_comm_count_by_host(
-          simcall->rdv_comm_count_by_host.rdv,
-          simcall->rdv_comm_count_by_host.host);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_RDV_GET_HEAD:
-      simcall->rdv_get_head.result = SIMIX_rdv_get_head(simcall->rdv_get_head.rdv);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_RDV_SET_RECV:
-      SIMIX_rdv_set_receiver(simcall->rdv_set_rcv_proc.rdv, simcall->rdv_set_rcv_proc.receiver);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_RDV_GET_RECV:
-      simcall->rdv_get_rcv_proc.result = SIMIX_rdv_get_receiver(simcall->rdv_set_rcv_proc.rdv);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_GET_BY_NAME:
-      simcall->host_get_by_name.result =
-        SIMIX_host_get_by_name(simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_GET_NAME:
-      simcall->host_get_name.result =  SIMIX_host_get_name(simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_GET_PROPERTIES:
-      simcall->host_get_properties.result =
-        SIMIX_host_get_properties(simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_GET_SPEED:
-      simcall->host_get_speed.result = 
-        SIMIX_host_get_speed(simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_GET_AVAILABLE_SPEED:
-      simcall->host_get_available_speed.result =
-        SIMIX_host_get_available_speed(simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_GET_STATE:
-      simcall->host_get_state.result = 
-        SIMIX_host_get_state(simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_GET_DATA:
-      simcall->host_get_data.result =  SIMIX_host_get_data(simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_SET_DATA:
-      SIMIX_host_set_data(SIMIX_pack_args(PTR(simcall->host_set_data.host), PTR(simcall->host_set_data.data)));
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_EXECUTE:
-      simcall->host_execute.result = simcall_table[simcall->call](simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_PARALLEL_EXECUTE:
-      simcall->host_parallel_execute.result = SIMIX_host_parallel_execute(simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_EXECUTION_DESTROY:
-      SIMIX_host_execution_destroy(simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_EXECUTION_CANCEL:
-      SIMIX_host_execution_cancel(simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_EXECUTION_GET_REMAINS:
-      simcall->host_execution_get_remains.result =
-        SIMIX_host_execution_get_remains(simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_EXECUTION_GET_STATE:
-      simcall->host_execution_get_state.result =
-        SIMIX_host_execution_get_state(simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_EXECUTION_SET_PRIORITY:
-      SIMIX_host_execution_set_priority(simcall->args);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_HOST_EXECUTION_WAIT:
-      SIMIX_pre_host_execution_wait(simcall->args);
-      break;
-
-    case SIMCALL_PROCESS_CREATE:
-      SIMIX_process_create(
-          simcall->process_create.process,
-    simcall->process_create.name,
-    simcall->process_create.code,
-    simcall->process_create.data,
-    simcall->process_create.hostname,
-    simcall->process_create.kill_time,
-    simcall->process_create.argc,
-    simcall->process_create.argv,
-    simcall->process_create.properties,
-    simcall->process_create.auto_restart);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_PROCESS_KILL:
-      SIMIX_process_kill(simcall->process_kill.process,simcall->issuer);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_PROCESS_KILLALL:
-      SIMIX_process_killall(simcall->issuer);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_PROCESS_CLEANUP:
-      SIMIX_process_cleanup(simcall->process_cleanup.process);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_PROCESS_CHANGE_HOST:
-      SIMIX_pre_process_change_host(
-          simcall->process_change_host.process,
-          simcall->process_change_host.dest);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_PROCESS_SUSPEND:
-      SIMIX_pre_process_suspend(simcall);
-      break;
-
-    case SIMCALL_PROCESS_RESUME:
-      SIMIX_process_resume(simcall->process_resume.process, simcall->issuer);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_PROCESS_COUNT:
-      simcall->process_count.result = SIMIX_process_count();
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_PROCESS_GET_DATA:
-      simcall->process_get_data.result =
-        SIMIX_process_get_data(simcall->process_get_data.process);
-      SIMIX_simcall_answer(simcall);
-      break;
-    case SIMCALL_PROCESS_ON_EXIT:
-      SIMIX_process_on_exit(simcall->process_on_exit.process,
-                            simcall->process_on_exit.fun,
-                            simcall->process_on_exit.data);
-      SIMIX_simcall_answer(simcall);
-    break;
-    case SIMCALL_PROCESS_RESTART:
-      simcall->process_restart.result = SIMIX_process_restart(simcall->process_restart.process, simcall->issuer);
-      SIMIX_simcall_answer(simcall);
-    break;
-    case SIMCALL_PROCESS_AUTO_RESTART_SET:
-      SIMIX_process_auto_restart_set(simcall->process_auto_restart.process,simcall->process_auto_restart.auto_restart);
-      SIMIX_simcall_answer(simcall);
-    break;
-    case SIMCALL_PROCESS_SET_DATA:
-      SIMIX_process_set_data(
-    simcall->process_set_data.process,
-    simcall->process_set_data.data);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_PROCESS_GET_HOST:
-      simcall->process_get_host.result = SIMIX_process_get_host(simcall->process_get_host.process);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_PROCESS_GET_NAME:
-      simcall->process_get_name.result = SIMIX_process_get_name(simcall->process_get_name.process);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_PROCESS_IS_SUSPENDED:
-      simcall->process_is_suspended.result =
-        SIMIX_process_is_suspended(simcall->process_is_suspended.process);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_PROCESS_GET_PROPERTIES:
-      simcall->process_get_properties.result =
-        SIMIX_process_get_properties(simcall->process_get_properties.process);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_PROCESS_SLEEP:
-      SIMIX_pre_process_sleep(simcall);
-      break;
-
-#ifdef HAVE_TRACING
-    case SIMCALL_SET_CATEGORY:
-      SIMIX_set_category(
-          simcall->set_category.action,
-          simcall->set_category.category);
-      SIMIX_simcall_answer(simcall);
-      break;
-#endif
-
-    case SIMCALL_MUTEX_INIT:
-      simcall->mutex_init.result = SIMIX_mutex_init();
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_MUTEX_DESTROY:
-      SIMIX_mutex_destroy(simcall->mutex_destroy.mutex);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_MUTEX_LOCK:
-      SIMIX_pre_mutex_lock(simcall);
-      break;
-
-    case SIMCALL_MUTEX_TRYLOCK:
-      simcall->mutex_trylock.result =
-        SIMIX_mutex_trylock(simcall->mutex_trylock.mutex, simcall->issuer);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_MUTEX_UNLOCK:
-      SIMIX_mutex_unlock(simcall->mutex_unlock.mutex, simcall->issuer);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COND_INIT:
-      simcall->cond_init.result = SIMIX_cond_init();
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COND_DESTROY:
-      SIMIX_cond_destroy(simcall->cond_destroy.cond);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COND_SIGNAL:
-      SIMIX_cond_signal(simcall->cond_signal.cond);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_COND_WAIT:
-      SIMIX_pre_cond_wait(simcall);
-      break;
-
-    case SIMCALL_COND_WAIT_TIMEOUT:
-      SIMIX_pre_cond_wait_timeout(simcall);
-      break;
-
-    case SIMCALL_COND_BROADCAST:
-      SIMIX_cond_broadcast(simcall->cond_broadcast.cond);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_SEM_INIT:
-      simcall->sem_init.result = SIMIX_sem_init(simcall->sem_init.capacity);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_SEM_DESTROY:
-      SIMIX_sem_destroy(simcall->sem_destroy.sem);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_SEM_RELEASE:
-      SIMIX_sem_release(simcall->sem_release.sem);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_SEM_WOULD_BLOCK:
-      simcall->sem_would_block.result =
-        SIMIX_sem_would_block(simcall->sem_would_block.sem);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_SEM_ACQUIRE:
-      SIMIX_pre_sem_acquire(simcall);
+SIMCALL_LIST(SIMCALL_CASE, SIMCALL_SEP_NOTHING)
+    case NUM_SIMCALLS:;
       break;
       break;
-
-    case SIMCALL_SEM_ACQUIRE_TIMEOUT:
-      SIMIX_pre_sem_acquire_timeout(simcall);
-      break;
-
-    case SIMCALL_SEM_GET_CAPACITY:
-      simcall->sem_get_capacity.result = 
-        SIMIX_sem_get_capacity(simcall->sem_get_capacity.sem);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_FILE_READ:
-      SIMIX_pre_file_read(simcall);
-      break;
-
-    case SIMCALL_FILE_WRITE:
-      SIMIX_pre_file_write(simcall);
-      break;
-
-    case SIMCALL_FILE_OPEN:
-      SIMIX_pre_file_open(simcall);
-      break;
-
-    case SIMCALL_FILE_CLOSE:
-      SIMIX_pre_file_close(simcall);
-      break;
-
-    case SIMCALL_FILE_STAT:
-      SIMIX_pre_file_stat(simcall);
-      break;
-
-    case SIMCALL_FILE_UNLINK:
-      SIMIX_pre_file_unlink(simcall);
-      break;
-
-    case SIMCALL_FILE_LS:
-      SIMIX_pre_file_ls(simcall);
-      break;
-
-    case SIMCALL_ASR_GET_PROPERTIES:
-      simcall->asr_get_properties.result =
-        SIMIX_asr_get_properties(simcall->asr_get_properties.name);
-      SIMIX_simcall_answer(simcall);
-      break;
-
-#ifdef HAVE_MC
-    case SIMCALL_MC_SNAPSHOT:
-      simcall->mc_snapshot.s = MC_take_snapshot();
-      SIMIX_simcall_answer(simcall);
-      break;
-
-    case SIMCALL_MC_COMPARE_SNAPSHOTS:
-      simcall->mc_compare_snapshots.result =
-        snapshot_compare(simcall->mc_compare_snapshots.snapshot1, simcall->mc_compare_snapshots.snapshot2, NULL, NULL);
-      SIMIX_simcall_answer(simcall);
-      break;
-#endif /* HAVE_MC */
-
-    case SIMCALL_NONE:
+    case SIMCALL_NONE:;
       THROWF(arg_error,0,"Asked to do the noop syscall on %s@%s",
           SIMIX_process_get_name(simcall->issuer),
           SIMIX_host_get_name(SIMIX_process_get_host(simcall->issuer))
       THROWF(arg_error,0,"Asked to do the noop syscall on %s@%s",
           SIMIX_process_get_name(simcall->issuer),
           SIMIX_host_get_name(SIMIX_process_get_host(simcall->issuer))
@@ -612,58 +106,37 @@ void SIMIX_simcall_post(smx_action_t action)
 /* New Simcal interface */
 
 /* FIXME: add types for every simcall */
 /* New Simcal interface */
 
 /* FIXME: add types for every simcall */
-const char *simcall_types[NUM_SIMCALLS] = { [SIMCALL_HOST_EXECUTE] = "%s%p%f%f%p" };
-
+//const char *simcall_types[NUM_SIMCALLS] = { [SIMCALL_HOST_EXECUTE] = "%s%p%f%f%p" };
+/* FIXME find a way to make this work
 simcall_handler_t simcall_table[NUM_SIMCALLS] = {
 #undef SIMCALL_ENUM_ELEMENT
 simcall_handler_t simcall_table[NUM_SIMCALLS] = {
 #undef SIMCALL_ENUM_ELEMENT
-#define SIMCALL_ENUM_ELEMENT(x,y) &y /* generate strings from the enumeration values */
+#define SIMCALL_ENUM_ELEMENT(x,y) &y // generate strings from the enumeration values 
 SIMCALL_LIST
 #undef SIMCALL_ENUM_ELEMENT
 SIMCALL_LIST
 #undef SIMCALL_ENUM_ELEMENT
-};
-
-
-void SIMIX_simcall_typecheck(const char *fmt, ...)
-{
-  return;
-}
-
-void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args)
-{
-  smx_process_t self = SIMIX_process_self();
-  self->simcall.call = simcall_id;
-  self->simcall.args = args;
-
-  if (self != simix_global->maestro_process) {
-    XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
-              SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
-
-    SIMIX_process_yield(self);
-  } else {
-
-    SIMIX_simcall_pre(&self->simcall, 0);
-  }
-}
+};*/
 
 /* New Simcal interface */
 
 /* FIXME: add types for every simcall */
 
 /* New Simcal interface */
 
 /* FIXME: add types for every simcall */
-const char *simcall_types[NUM_SIMCALLS] = { [SIMCALL_HOST_EXECUTE] = "%s%p%f%f%p", [SIMCALL_HOST_EXECUTION_WAIT] = "%p%p" };
+//const char *simcall_types[NUM_SIMCALLS] = { [SIMCALL_HOST_EXECUTE] = "%s%p%f%f%p", [SIMCALL_HOST_EXECUTION_WAIT] = "%p%p" };
 
 
 
 
+/*TOFIX find a way to make this work
 simcall_handler_t simcall_table[NUM_SIMCALLS] = {
 #undef SIMCALL_ENUM_ELEMENT
 simcall_handler_t simcall_table[NUM_SIMCALLS] = {
 #undef SIMCALL_ENUM_ELEMENT
-#define SIMCALL_ENUM_ELEMENT(x,y) &y /* generate strings from the enumeration values */
+#define SIMCALL_ENUM_ELEMENT(x,y) &y // generate strings from the enumeration values
 SIMCALL_LIST
 #undef SIMCALL_ENUM_ELEMENT
 SIMCALL_LIST
 #undef SIMCALL_ENUM_ELEMENT
-};
+};*/
 
 
+SIMCALL_LIST(SIMCALL_FUNC, SIMCALL_SEP_NOTHING)
 
 void SIMIX_simcall_typecheck(const char *fmt, ...)
 {
   return;
 }
 
 
 void SIMIX_simcall_typecheck(const char *fmt, ...)
 {
   return;
 }
 
-void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args)
+smx_simcall_t __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args)
 {
   smx_process_t self = SIMIX_process_self();
   self->simcall.call = simcall_id;
 {
   smx_process_t self = SIMIX_process_self();
   self->simcall.call = simcall_id;
@@ -678,4 +151,5 @@ void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args)
 
     SIMIX_simcall_pre(&self->simcall, 0);
   }
 
     SIMIX_simcall_pre(&self->simcall, 0);
   }
+  return &(self->simcall);
 }
 }
index 61b606c..0e96f7f 100644 (file)
  *
  * */
 
  *
  * */
 
-#define SIMCALL_LIST1 \
-SIMCALL_ENUM_ELEMENT(SIMCALL_NONE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_BY_NAME),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_NAME),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_PROPERTIES),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_SPEED),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_AVAILABLE_SPEED),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_STATE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_DATA),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_SET_DATA),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_PARALLEL_EXECUTE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_DESTROY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_CANCEL),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_GET_REMAINS),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_GET_STATE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_SET_PRIORITY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_WAIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CREATE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_KILL),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_KILLALL),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CLEANUP),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CHANGE_HOST),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SUSPEND),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_RESUME),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_COUNT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_DATA),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SET_DATA),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_HOST),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_NAME),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_IS_SUSPENDED),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_PROPERTIES),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SLEEP),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_ON_EXIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_AUTO_RESTART_SET),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_RESTART),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_CREATE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_DESTROY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GEY_BY_NAME),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_COMM_COUNT_BY_HOST),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GET_HEAD),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_SET_RECV),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GET_RECV),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_SEND),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_ISEND),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_RECV),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IRECV),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_DESTROY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_CANCEL),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAITANY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TEST),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TESTANY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IPROBE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_REMAINS),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_STATE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_SRC_DATA),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_DST_DATA),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_SRC_PROC),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_DST_PROC),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_INIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_DESTROY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_LOCK),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_TRYLOCK),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_UNLOCK),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COND_INIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COND_DESTROY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COND_SIGNAL),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COND_WAIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COND_WAIT_TIMEOUT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COND_BROADCAST),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_INIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_DESTROY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_RELEASE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_WOULD_BLOCK),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE_TIMEOUT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_GET_CAPACITY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_READ),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_WRITE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_OPEN),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_CLOSE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_STAT), \
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_UNLINK),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_LS),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_ASR_GET_PROPERTIES), \
-/* ****************************************************************************************** */ \
-/* TUTORIAL: New API                                                                        */ \
-/* ****************************************************************************************** */ \
-SIMCALL_ENUM_ELEMENT(SIMCALL_NEW_API_INIT)
+/****************************
+ * SIMCALL GENERATING MACRO *
+ ****************************
+ *
+ * action(ENUM_NAME, func_name, result_type, params…) 
+ *
+ **/
+
+/*
+ * Some macro machinery to get a MAP over the arguments of a variadic macro.
+ * It uses a FOLD to apply a macro to every argument, and because there is
+ * no recursion in the C preprocessor we must create a new macro for every
+ * depth of FOLD's recursion.
+ */
+
+/* FOLD macro */
+#define FE_0(WHAT, X, ...)
+#define FE_1(I, WHAT, X) WHAT(I, X)
+#define FE_2(I, WHAT, X, ...) WHAT(I, X), FE_1(I+1, WHAT, __VA_ARGS__)
+#define FE_3(I, WHAT, X, ...) WHAT(I, X), FE_2(I+1, WHAT, __VA_ARGS__)
+#define FE_4(I, WHAT, X, ...) WHAT(I, X), FE_3(I+1, WHAT, __VA_ARGS__)
+#define FE_5(I, WHAT, X, ...) WHAT(I, X), FE_4(I+1, WHAT, __VA_ARGS__)
+#define FE_6(I, WHAT, X, ...) WHAT(I, X), FE_5(I+1, WHAT, __VA_ARGS__)
+#define FE_7(I, WHAT, X, ...) WHAT(I, X), FE_6(I+1, WHAT, __VA_ARGS__)
+#define FE_8(I, WHAT, X, ...) WHAT(I, X), FE_7(I+1, WHAT, __VA_ARGS__)
+#define FE_9(I, WHAT, X, ...) WHAT(I, X), FE_8(I+1, WHAT, __VA_ARGS__)
+#define FE_10(I, WHAT, X, ...) WHAT(I, X), FE_9(I+1, WHAT, __VA_ARGS__)
+
+
+/* NOTE: add as many FE_n as needed (maximum number of simcall arguments )*/
+
+/* Make a MAP macro usgin FOLD (will apply 'action' to the arguments.
+ * GET_MACRO is a smart hack that counts the number of arguments passed to
+ * the variadic macro, and it is used to invoke the right FOLD depth.
+ */
+#define GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
+#define MAP(action, ...) \
+  GET_MACRO(, ##__VA_ARGS__, FE_10,FE_9,FE_8,FE_7,FE_6,FE_5,FE_4,FE_3,FE_2,FE_1, FE_0) (0, action, __VA_ARGS__)
+
+/*
+ * Define scalar type wrappers to ease the use of simcalls.
+ * These are used to wrap the arguments in SIMIX_simcall macro.
+ */
+#define TCHAR(n) (n, char, c)
+#define TSTRING(n) (n, const char*, cc)
+#define TSHORT(n) (n, short, s)
+#define TINT(n) (n, int, i)
+#define TLONG(n) (n, long, l)
+#define TUCHAR(n) (n, unsigned char, uc)
+#define TUSHORT(n) (n, unsigned short, us)
+#define TUINT(n) (n, unsigned int, ui)
+#define TULONG(n) (n, unsigned long, ul)
+#define TFLOAT(n) (n, float, f)
+#define TDOUBLE(n) (n, double, d)
+#define TPTR(n) (n, void*, p)
+#define TCPTR(n) (n, const void*, cp)
+#define TSIZE(n) (n, size_t, si)
+#define TSTAT(n) (n, s_file_stat_t, fs)
+#define TVOID(n) (n, void)
+#define TSPEC(n,t) (n, t, p)
+
+/* use comma or nothing to separate elements*/
+#define SIMCALL_SEP_COMMA ,
+#define SIMCALL_SEP_NOTHING
+
+/* get the name of the parameter */
+#define SIMCALL_NAME_(name, type, field) name
+#define SIMCALL_NAME(i, v) SIMCALL_NAME_ v
+
+/* get the %s format code of the parameter */
+#define SIMCALL_FORMAT_(name, type, field) %field
+#define SIMCALL_FORMAT(i, v) SIMCALL_FORMAT_ v
+
+/* get the parameter declaration */
+#define SIMCALL_ARG_(name, type, field) type name
+#define SIMCALL_ARG(i, v) SIMCALL_ARG_ v
+
+/* get the parameter initialisation field */
+#define SIMCALL_INIT_FIELD_(name, type, field) {.field = name}
+#define SIMCALL_INIT_FIELD(i, v) SIMCALL_INIT_FIELD_ v
+
+/* get the case of the parameter */
+#define SIMCALL_CASE_PARAM_(name, type, field) field
+#define SIMCALL_CASE_PARAM(i, v) simcall->args[i].SIMCALL_CASE_PARAM_ v
+
+/* generate some code for SIMCALL_CASE if the simcall has an answer */
+#define MAYBE2(_0, _1, func, ...) func
+
+#define SIMCALL_WITH_RESULT_BEGIN(name, type, field) simcall->result.field =
+#define SIMCALL_WITHOUT_RESULT_BEGIN(name, type, field)
+#define SIMCALL_RESULT_BEGIN_(name, type, ...)\
+        MAYBE2(,##__VA_ARGS__, SIMCALL_WITH_RESULT_BEGIN, SIMCALL_WITHOUT_RESULT_BEGIN)\
+       (name, type, __VA_ARGS__)
+#define SIMCALL_RESULT_BEGIN(answer, res) answer(SIMCALL_RESULT_BEGIN_ res)
+
+#define SIMCALL_RESULT_END_(name, type, ...)\
+       SIMIX_simcall_answer(simcall);
+#define SIMCALL_RESULT_END(answer, res) answer(SIMCALL_RESULT_END_ res)
+
+/* generate some code for BODY function */
+#define SIMCALL_FUNC_RETURN_TYPE_(name, type, ...) type
+#define SIMCALL_FUNC_RETURN_TYPE(res) SIMCALL_FUNC_RETURN_TYPE_ res
+
+#define SIMCALL_WITH_FUNC_SIMCALL(name, type, field) smx_simcall_t simcall = 
+#define SIMCALL_WITHOUT_FUNC_SIMCALL(name, type, field)
+#define SIMCALL_FUNC_SIMCALL_(name, type, ...)\
+        MAYBE2(,##__VA_ARGS__, SIMCALL_WITH_FUNC_SIMCALL, SIMCALL_WITHOUT_FUNC_SIMCALL)\
+       (name, type, __VA_ARGS__)
+#define SIMCALL_FUNC_SIMCALL(res) SIMCALL_FUNC_SIMCALL_ res
+
+#define SIMCALL_WITH_FUNC_RETURN(name, type, field) return simcall->result.field;
+#define SIMCALL_WITHOUT_FUNC_RETURN(name, type, field)
+#define SIMCALL_FUNC_RETURN_(name, type, ...)\
+        MAYBE2(,##__VA_ARGS__, SIMCALL_WITH_FUNC_RETURN, SIMCALL_WITHOUT_FUNC_RETURN)\
+       (name, type, __VA_ARGS__)
+#define SIMCALL_FUNC_RETURN(res) SIMCALL_FUNC_RETURN_ res
+
+
+/* generate the simcall enumeration */
+#define SIMCALL_ENUM(type, ...)\
+       type
+
+/* generate strings from the enumeration values */
+#define SIMCALL_TYPE(type, name, answer, res, ...)\
+       [type] = STRINGIFY(MAP(SIMCALL_FORMAT, __VA_ARGS__))
+
+/* generate the simcalls functions */
+#define SIMCALL_FUNC(type, name, answer, res, ...)\
+       SIMCALL_FUNC_RETURN_TYPE(res) simcall_BODY_##name(MAP(SIMCALL_ARG, ##__VA_ARGS__)) { \
+      SIMCALL_FUNC_SIMCALL(res) __SIMIX_simcall(type, (u_smx_scalar_t[]){MAP(SIMCALL_INIT_FIELD, ##__VA_ARGS__)}); \
+      SIMCALL_FUNC_RETURN(res)\
+    }
+
+/* generate the simcalls prototypes functions */
+#define VOID_IF_EMPTY(...) GET_CLEAN(,##__VA_ARGS__,,,,,,,,,,,void)
+#define SIMCALL_FUNC_PROTO(type, name, answer, res, ...)\
+       SIMCALL_FUNC_RETURN_TYPE(res) simcall_BODY_##name(VOID_IF_EMPTY(__VA_ARGS__) MAP(SIMCALL_ARG, ##__VA_ARGS__));
+
+
+/* generate a comma if there is an argument*/
+#define WITHOUT_COMMA 
+#define WITH_COMMA ,
+#define GET_CLEAN(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10, NAME,...) NAME
+#define MAYBE_COMMA(...) GET_CLEAN(,##__VA_ARGS__,WITH_COMMA,WITH_COMMA,WITH_COMMA,WITH_COMMA,WITH_COMMA,WITH_COMMA,WITH_COMMA,WITH_COMMA,WITH_COMMA,WITH_COMMA,WITHOUT_COMMA)
+
+/* generate the simcalls cases for the SIMIX_simcall_pre function */
+#define WITH_ANSWER(...) __VA_ARGS__
+#define WITHOUT_ANSWER(...) 
+#define SIMCALL_CASE(type, name, answer, res, ...)\
+    case type:;\
+      SIMCALL_RESULT_BEGIN(answer, res) SIMIX_pre_ ## name(simcall MAYBE_COMMA(__VA_ARGS__) MAP(SIMCALL_CASE_PARAM, ##__VA_ARGS__));\
+      SIMCALL_RESULT_END(answer, res)\
+      break;
+
+/* stringify arguments */
+#define STRINGIFY_(...) #__VA_ARGS__
+#define STRINGIFY(...) STRINGIFY_(__VA_ARGS__)
+
+/* the list of simcalls definitions */
+#define SIMCALL_LIST1(action, sep) \
+action(SIMCALL_HOST_GET_BY_NAME, host_get_by_name, WITH_ANSWER, TSPEC(result, smx_host_t), TSTRING(NAME)) sep \
+action(SIMCALL_HOST_GET_NAME, host_get_name, WITH_ANSWER, TSTRING(result), TSPEC(host, smx_host_t)) sep \
+action(SIMCALL_HOST_GET_PROPERTIES, host_get_properties, WITH_ANSWER, TSPEC(result, xbt_dict_t), TSPEC(host, smx_host_t)) sep \
+action(SIMCALL_HOST_GET_SPEED, host_get_speed, WITH_ANSWER, TDOUBLE(result), TSPEC(host, smx_host_t)) sep \
+action(SIMCALL_HOST_GET_AVAILABLE_SPEED, host_get_available_speed, WITH_ANSWER, TDOUBLE(result), TSPEC(result, smx_host_t)) sep \
+action(SIMCALL_HOST_GET_STATE, host_get_state, WITH_ANSWER, TINT(result), TSPEC(host, smx_host_t)) sep \
+action(SIMCALL_HOST_GET_DATA, host_get_data, WITH_ANSWER, TPTR(result), TSPEC(host, smx_host_t)) sep \
+action(SIMCALL_HOST_SET_DATA, host_set_data, WITH_ANSWER, TVOID(result), TSPEC(host, smx_host_t), TPTR(data)) sep \
+action(SIMCALL_HOST_EXECUTE, host_execute, WITH_ANSWER, TSPEC(result, smx_action_t), TSTRING(name), TSPEC(host, smx_host_t), TDOUBLE(computation_amount), TDOUBLE(priority)) sep \
+action(SIMCALL_HOST_PARALLEL_EXECUTE, host_parallel_execute, WITH_ANSWER, TSPEC(result, smx_action_t), TSTRING(name), TINT(host_nb), TSPEC(host_list, smx_host_t*), TSPEC(computation_amount, double*), TSPEC(communication_amount, double*), TDOUBLE(amount), TDOUBLE(rate)) sep \
+action(SIMCALL_HOST_EXECUTION_DESTROY, host_execution_destroy, WITH_ANSWER, TVOID(result), TSPEC(execution, smx_action_t)) sep \
+action(SIMCALL_HOST_EXECUTION_CANCEL, host_execution_cancel, WITH_ANSWER, TVOID(result), TSPEC(execution, smx_action_t)) sep \
+action(SIMCALL_HOST_EXECUTION_GET_REMAINS, host_execution_get_remains, WITH_ANSWER, TDOUBLE(result), TSPEC(execution, smx_action_t)) sep \
+action(SIMCALL_HOST_EXECUTION_GET_STATE, host_execution_get_state, WITH_ANSWER, TINT(result), TSPEC(execution, smx_action_t)) sep \
+action(SIMCALL_HOST_EXECUTION_SET_PRIORITY, host_execution_set_priority, WITH_ANSWER, TVOID(result), TSPEC(execution, smx_action_t), TDOUBLE(priority)) sep \
+action(SIMCALL_HOST_EXECUTION_WAIT, host_execution_wait, WITHOUT_ANSWER, TINT(result), TSPEC(execution, smx_action_t)) sep \
+action(SIMCALL_PROCESS_CREATE, process_create, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t*), TSTRING(name), TSPEC(code, xbt_main_func_t), TPTR(data), TSTRING(hostname), TDOUBLE(kill_time), TINT(argc), TSPEC(argv, char**), TSPEC(properties, xbt_dict_t), TINT(auto_restart)) sep \
+action(SIMCALL_PROCESS_KILL, process_kill, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
+action(SIMCALL_PROCESS_KILLALL, process_killall, WITH_ANSWER, TVOID(result)) sep \
+action(SIMCALL_PROCESS_CLEANUP, process_cleanup, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
+action(SIMCALL_PROCESS_CHANGE_HOST, process_change_host, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t), TSPEC(dest, smx_host_t)) sep \
+action(SIMCALL_PROCESS_SUSPEND, process_suspend, WITHOUT_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
+action(SIMCALL_PROCESS_RESUME, process_resume, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
+action(SIMCALL_PROCESS_COUNT, process_count, WITH_ANSWER, TINT(result)) sep \
+action(SIMCALL_PROCESS_GET_DATA, process_get_data, WITH_ANSWER, TPTR(result), TSPEC(process, smx_process_t)) sep \
+action(SIMCALL_PROCESS_SET_DATA, process_set_data, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t), TPTR(data)) sep \
+action(SIMCALL_PROCESS_GET_HOST, process_get_host, WITH_ANSWER, TSPEC(result, smx_host_t), TSPEC(process, smx_process_t)) sep \
+action(SIMCALL_PROCESS_GET_NAME, process_get_name, WITH_ANSWER, TSTRING(result), TSPEC(process, smx_process_t)) sep \
+action(SIMCALL_PROCESS_IS_SUSPENDED, process_is_suspended, WITH_ANSWER, TINT(result), TSPEC(process, smx_process_t)) sep \
+action(SIMCALL_PROCESS_GET_PROPERTIES, process_get_properties, WITH_ANSWER, TSPEC(result, xbt_dict_t), TSPEC(process, smx_process_t)) sep \
+action(SIMCALL_PROCESS_SLEEP, process_sleep, WITHOUT_ANSWER, TINT(result), TDOUBLE(duration)) sep \
+action(SIMCALL_PROCESS_ON_EXIT, process_on_exit, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t), TSPEC(fun, int_f_pvoid_t), TPTR(data)) sep \
+action(SIMCALL_PROCESS_AUTO_RESTART_SET, process_auto_restart_set, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t), TINT(auto_restart)) sep \
+action(SIMCALL_PROCESS_RESTART, process_restart, WITH_ANSWER, TSPEC(result, smx_process_t), TSPEC(process, smx_process_t)) sep \
+action(SIMCALL_RDV_CREATE, rdv_create, WITH_ANSWER, TSPEC(result, smx_rdv_t), TSTRING(name)) sep \
+action(SIMCALL_RDV_DESTROY, rdv_destroy, WITH_ANSWER, TVOID(result), TSPEC(rdv, smx_rdv_t)) sep \
+action(SIMCALL_RDV_GET_BY_NAME, rdv_get_by_name, WITH_ANSWER, TSPEC(result, smx_host_t), TSTRING(name)) sep \
+action(SIMCALL_RDV_COMM_COUNT_BY_HOST, rdv_comm_count_by_host, WITH_ANSWER, TUINT(result), TSPEC(rdv, smx_rdv_t), TSPEC(host, smx_host_t)) sep \
+action(SIMCALL_RDV_GET_HEAD, rdv_get_head, WITH_ANSWER, TSPEC(result, smx_action_t), TSPEC(rdv, smx_rdv_t)) sep \
+action(SIMCALL_RDV_SET_RECV, rdv_set_receiver, WITH_ANSWER, TVOID(result), TSPEC(rdv, smx_rdv_t), TSPEC(receiver, smx_process_t)) sep \
+action(SIMCALL_RDV_GET_RECV, rdv_get_receiver, WITH_ANSWER, TSPEC(result, smx_process_t), TSPEC(rdv, smx_rdv_t)) sep \
+action(SIMCALL_COMM_IPROBE, comm_iprobe, WITH_ANSWER, TSPEC(result, smx_action_t), TSPEC(rdv, smx_rdv_t), TINT(src), TINT(tag), TSPEC(match_fun, simix_match_func_t), TPTR(data)) sep \
+action(SIMCALL_COMM_SEND, comm_send, WITHOUT_ANSWER, TVOID(result), TSPEC(rdv, smx_rdv_t), TDOUBLE(task_size), TDOUBLE(rate), TPTR(src_buff), TSIZE(src_buff_size), TSPEC(match_fun, simix_match_func_t), TPTR(data), TDOUBLE(timeout)) sep \
+action(SIMCALL_COMM_ISEND, comm_isend, WITH_ANSWER, TSPEC(result, smx_action_t), TSPEC(rdv, smx_rdv_t), TDOUBLE(task_size), TDOUBLE(rate), TPTR(src_buff), TSIZE(src_buff_size), TSPEC(match_fun, simix_match_func_t), TSPEC(clean_fun, simix_clean_func_t), TPTR(data), TINT(detached)) sep \
+action(SIMCALL_COMM_RECV, comm_recv, WITHOUT_ANSWER, TVOID(result), TSPEC(rdv, smx_rdv_t), TPTR(dst_buff), TSPEC(dst_buff_size, size_t*), TSPEC(match_fun, simix_match_func_t), TPTR(data), TDOUBLE(timeout)) sep \
+action(SIMCALL_COMM_IRECV, comm_irecv, WITH_ANSWER, TSPEC(result, smx_action_t), TSPEC(rdv, smx_rdv_t), TPTR(dst_buff), TSPEC(dst_buff_size, size_t*), TSPEC(match_fun, simix_match_func_t), TPTR(data)) sep \
+action(SIMCALL_COMM_DESTROY, comm_destroy, WITH_ANSWER, TVOID(result), TSPEC(comm, smx_action_t)) sep \
+action(SIMCALL_COMM_CANCEL, comm_cancel, WITH_ANSWER, TVOID(result), TSPEC(comm, smx_action_t)) sep \
+action(SIMCALL_COMM_WAITANY, comm_waitany, WITHOUT_ANSWER, TINT(result), TSPEC(comms, xbt_dynar_t)) sep \
+action(SIMCALL_COMM_WAIT, comm_wait, WITHOUT_ANSWER, TVOID(result), TSPEC(comm, smx_action_t), TDOUBLE(timeout)) sep \
+action(SIMCALL_COMM_TEST, comm_test, WITHOUT_ANSWER, TINT(result), TSPEC(comm, smx_action_t)) sep \
+action(SIMCALL_COMM_TESTANY, comm_testany, WITHOUT_ANSWER, TINT(result), TSPEC(comms, xbt_dynar_t)) sep \
+action(SIMCALL_COMM_GET_REMAINS, comm_get_remains, WITH_ANSWER, TDOUBLE(result), TSPEC(comm, smx_action_t)) sep \
+action(SIMCALL_COMM_GET_STATE, comm_get_state, WITH_ANSWER, TINT(result), TSPEC(comm, smx_action_t)) sep \
+action(SIMCALL_COMM_GET_SRC_DATA, comm_get_src_data, WITH_ANSWER, TPTR(result), TSPEC(comm, smx_action_t)) sep \
+action(SIMCALL_COMM_GET_DST_DATA, comm_get_dst_data, WITH_ANSWER, TPTR(result), TSPEC(comm, smx_action_t)) sep \
+action(SIMCALL_COMM_GET_SRC_PROC, comm_get_src_proc, WITH_ANSWER, TSPEC(result, smx_process_t), TSPEC(comm, smx_action_t)) sep \
+action(SIMCALL_COMM_GET_DST_PROC, comm_get_dst_proc, WITH_ANSWER, TSPEC(result, smx_process_t), TSPEC(comm, smx_action_t)) sep \
+action(SIMCALL_MUTEX_INIT, mutex_init, WITH_ANSWER, TSPEC(result, smx_mutex_t)) sep \
+action(SIMCALL_MUTEX_DESTROY, mutex_destroy, WITH_ANSWER, TVOID(result), TSPEC(mutex, smx_mutex_t)) sep \
+action(SIMCALL_MUTEX_LOCK, mutex_lock, WITHOUT_ANSWER, TVOID(result), TSPEC(mutex, smx_mutex_t)) sep \
+action(SIMCALL_MUTEX_TRYLOCK, mutex_trylock, WITH_ANSWER, TINT(result), TSPEC(mutex, smx_mutex_t)) sep \
+action(SIMCALL_MUTEX_UNLOCK, mutex_unlock, WITH_ANSWER, TVOID(result), TSPEC(mutex, smx_mutex_t)) sep \
+action(SIMCALL_COND_INIT, cond_init, WITH_ANSWER, TSPEC(result, smx_cond_t)) sep \
+action(SIMCALL_COND_DESTROY, cond_destroy, WITH_ANSWER, TVOID(result), TSPEC(cond, smx_cond_t)) sep \
+action(SIMCALL_COND_SIGNAL, cond_signal, WITH_ANSWER, TVOID(result), TSPEC(cond, smx_cond_t)) sep \
+action(SIMCALL_COND_WAIT, cond_wait, WITHOUT_ANSWER, TVOID(result), TSPEC(cond, smx_cond_t), TSPEC(mutex, smx_mutex_t)) sep \
+action(SIMCALL_COND_WAIT_TIMEOUT, cond_wait_timeout, WITHOUT_ANSWER, TVOID(result), TSPEC(cond, smx_cond_t), TSPEC(mutex, smx_mutex_t), TDOUBLE(timeout)) sep \
+action(SIMCALL_COND_BROADCAST, cond_broadcast, WITH_ANSWER, TVOID(result), TSPEC(cond, smx_cond_t)) sep \
+action(SIMCALL_SEM_INIT, sem_init, WITH_ANSWER, TSPEC(result, smx_sem_t), TINT(capacity)) sep \
+action(SIMCALL_SEM_DESTROY, sem_destroy, WITH_ANSWER, TVOID(result), TSPEC(sem, smx_sem_t)) sep \
+action(SIMCALL_SEM_RELEASE, sem_release, WITH_ANSWER, TVOID(result), TSPEC(sem, smx_sem_t)) sep \
+action(SIMCALL_SEM_WOULD_BLOCK, sem_would_block, WITH_ANSWER, TINT(result), TSPEC(sem, smx_sem_t)) sep \
+action(SIMCALL_SEM_ACQUIRE, sem_acquire, WITHOUT_ANSWER, TVOID(result), TSPEC(sem, smx_sem_t)) sep \
+action(SIMCALL_SEM_ACQUIRE_TIMEOUT, sem_acquire_timeout, WITHOUT_ANSWER, TVOID(result), TSPEC(sem, smx_sem_t), TDOUBLE(timeout)) sep \
+action(SIMCALL_SEM_GET_CAPACITY, sem_get_capacity, WITH_ANSWER, TINT(result), TSPEC(sem, smx_sem_t)) sep \
+action(SIMCALL_FILE_READ, file_read, WITHOUT_ANSWER, TDOUBLE(result), TPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(stream, smx_file_t)) sep \
+action(SIMCALL_FILE_WRITE, file_write, WITHOUT_ANSWER, TSIZE(result), TCPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(stream, smx_file_t)) sep \
+action(SIMCALL_FILE_OPEN, file_open, WITHOUT_ANSWER, TSPEC(result, smx_file_t), TSTRING(mount), TSTRING(path), TSTRING(mode)) sep \
+action(SIMCALL_FILE_CLOSE, file_close, WITHOUT_ANSWER, TINT(result), TSPEC(fp, smx_file_t)) sep \
+action(SIMCALL_FILE_STAT, file_stat, WITHOUT_ANSWER, TINT(result), TSPEC(fd, smx_file_t), TSTAT(buf)) sep \
+action(SIMCALL_FILE_UNLINK, file_unlink, WITHOUT_ANSWER, TINT(result), TSPEC(fd, smx_file_t)) sep \
+action(SIMCALL_FILE_LS, file_ls, WITHOUT_ANSWER, TSPEC(result, xbt_dict_t), TSTRING(mount), TSTRING(path)) sep \
+action(SIMCALL_ASR_GET_PROPERTIES, asr_get_properties, WITH_ANSWER, TSPEC(result, xbt_dict_t), TSTRING(name)) sep 
 
 /* SIMCALL_COMM_IS_LATENCY_BOUNDED and SIMCALL_SET_CATEGORY make things complicated
  * because they are not always present */
 #ifdef HAVE_LATENCY_BOUND_TRACKING
 
 /* SIMCALL_COMM_IS_LATENCY_BOUNDED and SIMCALL_SET_CATEGORY make things complicated
  * because they are not always present */
 #ifdef HAVE_LATENCY_BOUND_TRACKING
-#define SIMCALL_LIST2 \
-,SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IS_LATENCY_BOUNDED, SIMIX_comm_is_latency_bounded)
+#define SIMCALL_LIST2(action, sep) \
+action(SIMCALL_COMM_IS_LATENCY_BOUNDED, comm_is_latency_bounded, WITH_ANSWER, TINT(result), TSPEC(comm, smx_action_t)) sep
 #else
 #else
-#define SIMCALL_LIST2
+#define SIMCALL_LIST2(action, sep)
 #endif
 
 #ifdef HAVE_TRACING
 #endif
 
 #ifdef HAVE_TRACING
-#define SIMCALL_LIST3 \
-,SIMCALL_ENUM_ELEMENT(SIMCALL_SET_CATEGORY, SIMIX_set_category)
+#define SIMCALL_LIST3(action, sep) \
+action(SIMCALL_SET_CATEGORY, set_category, WITH_ANSWER, TVOID(result), TSPEC(action, smx_action_t), TSTRING(category)) sep
 #else
 #else
-#define SIMCALL_LIST3
+#define SIMCALL_LIST3(action, sep)
 #endif
 
 #ifdef HAVE_MC
 #endif
 
 #ifdef HAVE_MC
-#define SIMCALL_LIST4                                        \
-  ,SIMCALL_ENUM_ELEMENT(SIMCALL_MC_SNAPSHOT)                 \
-  ,SIMCALL_ENUM_ELEMENT(SIMCALL_MC_COMPARE_SNAPSHOTS)
+#define SIMCALL_LIST4(action, sep) \
+action(SIMCALL_MC_SNAPSHOT, mc_snapshot, WITH_ANSWER, TPTR(result)) sep \
+action(SIMCALL_MC_COMPARE_SNAPSHOTS, mc_compare_snapshots, WITH_ANSWER, TINT(result), TPTR(s1), TPTR(s2)) sep 
 #else
 #else
-#define SIMCALL_LIST4
+#define SIMCALL_LIST4(action, sep)
 #endif
 
 /* SIMCALL_LIST is the final macro to use */
 #endif
 
 /* SIMCALL_LIST is the final macro to use */
-#define SIMCALL_LIST SIMCALL_LIST1 SIMCALL_LIST2 SIMCALL_LIST3 SIMCALL_LIST4
+#define SIMCALL_LIST(action, ...) \
+  SIMCALL_LIST1(action, ##__VA_ARGS__)\
+  SIMCALL_LIST2(action, ##__VA_ARGS__)\
+  SIMCALL_LIST3(action, ##__VA_ARGS__)\
+  SIMCALL_LIST4(action, ##__VA_ARGS__)
+
 
 /* you can redefine the following macro differently to generate something else
  * with the list of enumeration values (e.g. a table of strings or a table of function pointers) */
 
 /* you can redefine the following macro differently to generate something else
  * with the list of enumeration values (e.g. a table of strings or a table of function pointers) */
@@ -144,16 +303,49 @@ SIMCALL_ENUM_ELEMENT(SIMCALL_NEW_API_INIT)
  * \brief All possible simcalls.
  */
 typedef enum {
  * \brief All possible simcalls.
  */
 typedef enum {
-SIMCALL_LIST
+SIMCALL_NONE,
+SIMCALL_LIST(SIMCALL_ENUM, SIMCALL_SEP_COMMA)
+SIMCALL_NEW_API_INIT,
+NUM_SIMCALLS
 } e_smx_simcall_t;
 
 } e_smx_simcall_t;
 
+typedef int (*simix_match_func_t)(void *, void *, smx_action_t);
+typedef void (*simix_clean_func_t)(void *);
+
+/**
+ * \brief Prototypes of SIMIX
+ */
+SIMCALL_LIST(SIMCALL_FUNC_PROTO, SIMCALL_SEP_NOTHING)
+
+
+/* Pack all possible scalar types in an union */
+union u_smx_scalar {
+  char            c;
+  const char*     cc;
+  short           s;
+  int             i;
+  long            l;
+  unsigned char   uc;
+  unsigned short  us;
+  unsigned int    ui;
+  unsigned long   ul;
+  float           f;
+  double          d;
+  size_t          si;
+  s_file_stat_t   fs;
+  void*           p;
+  const void*     cp;
+};
+
 /**
  * \brief Represents a simcall to the kernel.
  */
 typedef struct s_smx_simcall {
   e_smx_simcall_t call;
   smx_process_t issuer;
 /**
  * \brief Represents a simcall to the kernel.
  */
 typedef struct s_smx_simcall {
   e_smx_simcall_t call;
   smx_process_t issuer;
+  int mc_value;
   union u_smx_scalar *args;
   union u_smx_scalar *args;
+  union u_smx_scalar result;
   //FIXME: union u_smx_scalar retval;
 
   union {
   //FIXME: union u_smx_scalar retval;
 
   union {
@@ -646,6 +838,8 @@ typedef struct s_smx_simcall {
   };
 } s_smx_simcall_t, *smx_simcall_t;
 
   };
 } s_smx_simcall_t, *smx_simcall_t;
 
+
+
 /******************************** General *************************************/
 
 void SIMIX_simcall_push(smx_process_t self);
 /******************************** General *************************************/
 
 void SIMIX_simcall_push(smx_process_t self);
@@ -654,25 +848,11 @@ void SIMIX_simcall_pre(smx_simcall_t, int);
 void SIMIX_simcall_post(smx_action_t);
 smx_simcall_t SIMIX_simcall_mine(void);
 const char *SIMIX_simcall_name(e_smx_simcall_t kind);
 void SIMIX_simcall_post(smx_action_t);
 smx_simcall_t SIMIX_simcall_mine(void);
 const char *SIMIX_simcall_name(e_smx_simcall_t kind);
+//TOFIX put it in a better place
+xbt_dict_t SIMIX_pre_asr_get_properties(smx_simcall_t simcall, const char *name);
 
 /*************************** New simcall interface ****************************/
 
 
 /*************************** New simcall interface ****************************/
 
-/* Pack all possible scalar types in an union */
-union u_smx_scalar {
-  char            c;
-  const char*     cc;
-  short           s;
-  int             i;
-  long            l;
-  unsigned char   uc;
-  unsigned short  us;
-  unsigned int    ui;
-  unsigned long   ul;
-  float           f;
-  double          d;
-  void*           p;
-};
-
 #define SIMIX_pack_args(...) (u_smx_scalar_t[]){MAP(INIT_FIELD, __VA_ARGS__)}
 
 
 #define SIMIX_pack_args(...) (u_smx_scalar_t[]){MAP(INIT_FIELD, __VA_ARGS__)}
 
 
@@ -701,21 +881,28 @@ union u_smx_scalar {
  */
 
 /* FOLD macro */
  */
 
 /* FOLD macro */
-#define FE_1(WHAT, X) WHAT(X)
-#define FE_2(WHAT, X, ...) WHAT(X), FE_1(WHAT, __VA_ARGS__)
-#define FE_3(WHAT, X, ...) WHAT(X), FE_2(WHAT, __VA_ARGS__)
-#define FE_4(WHAT, X, ...) WHAT(X), FE_3(WHAT, __VA_ARGS__)
-#define FE_5(WHAT, X, ...) WHAT(X), FE_4(WHAT, __VA_ARGS__)
+#define FE_0(WHAT, X, ...)
+#define FE_1(I, WHAT, X) WHAT(I, X)
+#define FE_2(I, WHAT, X, ...) WHAT(I, X), FE_1(I+1, WHAT, __VA_ARGS__)
+#define FE_3(I, WHAT, X, ...) WHAT(I, X), FE_2(I+1, WHAT, __VA_ARGS__)
+#define FE_4(I, WHAT, X, ...) WHAT(I, X), FE_3(I+1, WHAT, __VA_ARGS__)
+#define FE_5(I, WHAT, X, ...) WHAT(I, X), FE_4(I+1, WHAT, __VA_ARGS__)
+#define FE_6(I, WHAT, X, ...) WHAT(I, X), FE_5(I+1, WHAT, __VA_ARGS__)
+#define FE_7(I, WHAT, X, ...) WHAT(I, X), FE_6(I+1, WHAT, __VA_ARGS__)
+#define FE_8(I, WHAT, X, ...) WHAT(I, X), FE_7(I+1, WHAT, __VA_ARGS__)
+#define FE_9(I, WHAT, X, ...) WHAT(I, X), FE_8(I+1, WHAT, __VA_ARGS__)
+#define FE_10(I, WHAT, X, ...) WHAT(I, X), FE_9(I+1, WHAT, __VA_ARGS__)
+
+
 /* NOTE: add as many FE_n as needed (maximum number of simcall arguments )*/
 
 /* Make a MAP macro usgin FOLD (will apply 'action' to the arguments.
  * GET_MACRO is a smart hack that counts the number of arguments passed to
  * the variadic macro, and it is used to invoke the right FOLD depth.
  */
 /* NOTE: add as many FE_n as needed (maximum number of simcall arguments )*/
 
 /* Make a MAP macro usgin FOLD (will apply 'action' to the arguments.
  * GET_MACRO is a smart hack that counts the number of arguments passed to
  * the variadic macro, and it is used to invoke the right FOLD depth.
  */
-#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
-#define MAP(action,...) \
-  GET_MACRO(__VA_ARGS__,FE_5,FE_4,FE_3,FE_2,FE_1) (action, __VA_ARGS__)
-
+#define GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
+#define MAP(action, ...) \
+  GET_MACRO(, ##__VA_ARGS__, FE_10,FE_9,FE_8,FE_7,FE_6,FE_5,FE_4,FE_3,FE_2,FE_1, FE_0) (0, action, __VA_ARGS__)
 
 /* Generate code to initialize the field 'x' with value 'y' of an structure or union */
 #define INIT_FIELD_(x,y) {.x = y}
 
 /* Generate code to initialize the field 'x' with value 'y' of an structure or union */
 #define INIT_FIELD_(x,y) {.x = y}
@@ -737,7 +924,7 @@ union u_smx_scalar {
   SIMIX_simcall_typecheck(simcall_types[id], MAP(SECOND, __VA_ARGS__)); \
   __SIMIX_simcall(id, (u_smx_scalar_t[]){MAP(INIT_FIELD, __VA_ARGS__)})
 
   SIMIX_simcall_typecheck(simcall_types[id], MAP(SECOND, __VA_ARGS__)); \
   __SIMIX_simcall(id, (u_smx_scalar_t[]){MAP(INIT_FIELD, __VA_ARGS__)})
 
-void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args);
+smx_simcall_t __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args);
 
 /*
  * \biref Dummy variadic function used to typecheck the arguments of a simcall
 
 /*
  * \biref Dummy variadic function used to typecheck the arguments of a simcall
index 689576c..f5f354d 100644 (file)
@@ -117,6 +117,9 @@ static void SIMIX_synchro_finish(smx_action_t action)
 }
 /*********************************** Mutex ************************************/
 
 }
 /*********************************** Mutex ************************************/
 
+smx_mutex_t SIMIX_pre_mutex_init(smx_simcall_t simcall){
+  return SIMIX_mutex_init();
+}
 /**
  * \brief Initialize a mutex.
  *
 /**
  * \brief Initialize a mutex.
  *
@@ -139,12 +142,11 @@ smx_mutex_t SIMIX_mutex_init(void)
  * \brief Handles a mutex lock simcall.
  * \param simcall the simcall
  */
  * \brief Handles a mutex lock simcall.
  * \param simcall the simcall
  */
-void SIMIX_pre_mutex_lock(smx_simcall_t simcall)
+void SIMIX_pre_mutex_lock(smx_simcall_t simcall, smx_mutex_t mutex)
 {
   XBT_IN("(%p)",simcall);
   /* FIXME: check where to validate the arguments */
   smx_action_t sync_act = NULL;
 {
   XBT_IN("(%p)",simcall);
   /* FIXME: check where to validate the arguments */
   smx_action_t sync_act = NULL;
-  smx_mutex_t mutex = simcall->mutex_lock.mutex;
   smx_process_t process = simcall->issuer;
 
   if (mutex->locked) {
   smx_process_t process = simcall->issuer;
 
   if (mutex->locked) {
@@ -163,6 +165,9 @@ void SIMIX_pre_mutex_lock(smx_simcall_t simcall)
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
+int SIMIX_pre_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex){
+  return SIMIX_mutex_trylock(mutex, simcall->issuer);
+}      
 /**
  * \brief Tries to lock a mutex.
  *
 /**
  * \brief Tries to lock a mutex.
  *
@@ -186,6 +191,9 @@ int SIMIX_mutex_trylock(smx_mutex_t mutex, smx_process_t issuer)
   return 1;
 }
 
   return 1;
 }
 
+void SIMIX_pre_mutex_unlock(smx_simcall_t simcall, smx_mutex_t mutex){
+   SIMIX_mutex_unlock(mutex, simcall->issuer);
+}
 /**
  * \brief Unlocks a mutex.
  *
 /**
  * \brief Unlocks a mutex.
  *
@@ -220,6 +228,9 @@ void SIMIX_mutex_unlock(smx_mutex_t mutex, smx_process_t issuer)
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
+void SIMIX_pre_mutex_destroy(smx_simcall_t simcall, smx_mutex_t mutex){
+  SIMIX_mutex_destroy(mutex);
+}
 /**
  * \brief Destroys a mutex.
  *
 /**
  * \brief Destroys a mutex.
  *
@@ -238,6 +249,9 @@ void SIMIX_mutex_destroy(smx_mutex_t mutex)
 
 /********************************* Condition **********************************/
 
 
 /********************************* Condition **********************************/
 
+smx_cond_t SIMIX_pre_cond_init(smx_simcall_t simcall){
+  return SIMIX_cond_init();
+}
 /**
  * \brief Initialize a condition.
  *
 /**
  * \brief Initialize a condition.
  *
@@ -245,7 +259,7 @@ void SIMIX_mutex_destroy(smx_mutex_t mutex)
  * It have to be called before the use of the condition.
  * \return A condition
  */
  * It have to be called before the use of the condition.
  * \return A condition
  */
-smx_cond_t SIMIX_cond_init()
+smx_cond_t SIMIX_cond_init(void)
 {
   XBT_IN("()");
   s_smx_process_t p;
 {
   XBT_IN("()");
   s_smx_process_t p;
@@ -260,12 +274,10 @@ smx_cond_t SIMIX_cond_init()
  * \brief Handle a condition waiting simcall without timeouts
  * \param simcall the simcall
  */
  * \brief Handle a condition waiting simcall without timeouts
  * \param simcall the simcall
  */
-void SIMIX_pre_cond_wait(smx_simcall_t simcall)
+void SIMIX_pre_cond_wait(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex)
 {
   XBT_IN("(%p)",simcall);
   smx_process_t issuer = simcall->issuer;
 {
   XBT_IN("(%p)",simcall);
   smx_process_t issuer = simcall->issuer;
-  smx_cond_t cond = simcall->cond_wait.cond;
-  smx_mutex_t mutex = simcall->cond_wait.mutex;
 
   _SIMIX_cond_wait(cond, mutex, -1, issuer, simcall);
   XBT_OUT();
 
   _SIMIX_cond_wait(cond, mutex, -1, issuer, simcall);
   XBT_OUT();
@@ -275,13 +287,11 @@ void SIMIX_pre_cond_wait(smx_simcall_t simcall)
  * \brief Handle a condition waiting simcall with timeouts
  * \param simcall the simcall
  */
  * \brief Handle a condition waiting simcall with timeouts
  * \param simcall the simcall
  */
-void SIMIX_pre_cond_wait_timeout(smx_simcall_t simcall)
+void SIMIX_pre_cond_wait_timeout(smx_simcall_t simcall, smx_cond_t cond,
+                                smx_mutex_t mutex, double timeout)
 {
   XBT_IN("(%p)",simcall);
   smx_process_t issuer = simcall->issuer;
 {
   XBT_IN("(%p)",simcall);
   smx_process_t issuer = simcall->issuer;
-  smx_cond_t cond = simcall->cond_wait_timeout.cond;
-  smx_mutex_t mutex = simcall->cond_wait_timeout.mutex;
-  double timeout = simcall->cond_wait_timeout.timeout;
 
   _SIMIX_cond_wait(cond, mutex, timeout, issuer, simcall);
   XBT_OUT();
 
   _SIMIX_cond_wait(cond, mutex, timeout, issuer, simcall);
   XBT_OUT();
@@ -310,6 +320,9 @@ static void _SIMIX_cond_wait(smx_cond_t cond, smx_mutex_t mutex, double timeout,
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
+void SIMIX_pre_cond_signal(smx_simcall_t simcall, smx_cond_t cond){
+  SIMIX_cond_signal(cond);
+}
 /**
  * \brief Signalizes a condition.
  *
 /**
  * \brief Signalizes a condition.
  *
@@ -342,13 +355,15 @@ void SIMIX_cond_signal(smx_cond_t cond)
       mutex = simcall->cond_wait_timeout.mutex;
 
     simcall->call = SIMCALL_MUTEX_LOCK;
       mutex = simcall->cond_wait_timeout.mutex;
 
     simcall->call = SIMCALL_MUTEX_LOCK;
-    simcall->mutex_lock.mutex = mutex;
 
 
-    SIMIX_pre_mutex_lock(simcall);
+    SIMIX_pre_mutex_lock(simcall, mutex);
   }
   XBT_OUT();
 }
 
   }
   XBT_OUT();
 }
 
+void SIMIX_pre_cond_broadcast(smx_simcall_t simcall, smx_cond_t cond){
+  SIMIX_cond_broadcast(cond);
+}
 /**
  * \brief Broadcasts a condition.
  *
 /**
  * \brief Broadcasts a condition.
  *
@@ -368,6 +383,9 @@ void SIMIX_cond_broadcast(smx_cond_t cond)
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
+void SIMIX_pre_cond_destroy(smx_simcall_t simcall, smx_cond_t cond){
+  SIMIX_cond_destroy(cond);
+}
 /**
  * \brief Destroys a contidion.
  *
 /**
  * \brief Destroys a contidion.
  *
@@ -391,6 +409,9 @@ void SIMIX_cond_destroy(smx_cond_t cond)
 
 /******************************** Semaphores **********************************/
 #define SMX_SEM_NOLIMIT 99999
 
 /******************************** Semaphores **********************************/
 #define SMX_SEM_NOLIMIT 99999
+smx_sem_t SIMIX_pre_sem_init(smx_simcall_t simcall, unsigned int value){
+  return SIMIX_sem_init(value);
+}
 /** @brief Initialize a semaphore */
 smx_sem_t SIMIX_sem_init(unsigned int value)
 {
 /** @brief Initialize a semaphore */
 smx_sem_t SIMIX_sem_init(unsigned int value)
 {
@@ -404,6 +425,9 @@ smx_sem_t SIMIX_sem_init(unsigned int value)
   return sem;
 }
 
   return sem;
 }
 
+void SIMIX_pre_sem_destroy(smx_simcall_t simcall, smx_sem_t sem){
+  SIMIX_sem_destroy(sem);
+}
 /** @brief Destroys a semaphore */
 void SIMIX_sem_destroy(smx_sem_t sem)
 {
 /** @brief Destroys a semaphore */
 void SIMIX_sem_destroy(smx_sem_t sem)
 {
@@ -418,6 +442,9 @@ void SIMIX_sem_destroy(smx_sem_t sem)
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
+void SIMIX_pre_sem_release(smx_simcall_t simcall, smx_sem_t sem){
+  SIMIX_sem_release(sem);
+}
 /** @brief release the semaphore
  *
  * Unlock a process waiting on the semaphore.
 /** @brief release the semaphore
  *
  * Unlock a process waiting on the semaphore.
@@ -440,6 +467,9 @@ void SIMIX_sem_release(smx_sem_t sem)
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
+XBT_INLINE int SIMIX_pre_sem_would_block(smx_simcall_t simcall, smx_sem_t sem){
+  return SIMIX_sem_would_block(sem);
+}
 /** @brief Returns true if acquiring this semaphore would block */
 XBT_INLINE int SIMIX_sem_would_block(smx_sem_t sem)
 {
 /** @brief Returns true if acquiring this semaphore would block */
 XBT_INLINE int SIMIX_sem_would_block(smx_sem_t sem)
 {
@@ -448,6 +478,9 @@ XBT_INLINE int SIMIX_sem_would_block(smx_sem_t sem)
   return (sem->value <= 0);
 }
 
   return (sem->value <= 0);
 }
 
+int SIMIX_pre_sem_get_capacity(smx_simcall_t simcall, smx_sem_t sem){
+  return SIMIX_sem_get_capacity(sem);
+}
 /** @brief Returns the current capacity of the semaphore */
 int SIMIX_sem_get_capacity(smx_sem_t sem)
 {
 /** @brief Returns the current capacity of the semaphore */
 int SIMIX_sem_get_capacity(smx_sem_t sem)
 {
@@ -479,10 +512,10 @@ static void _SIMIX_sem_wait(smx_sem_t sem, double timeout, smx_process_t issuer,
  * \brief Handles a sem acquire simcall without timeout.
  * \param simcall the simcall
  */
  * \brief Handles a sem acquire simcall without timeout.
  * \param simcall the simcall
  */
-void SIMIX_pre_sem_acquire(smx_simcall_t simcall)
+void SIMIX_pre_sem_acquire(smx_simcall_t simcall, smx_sem_t sem)
 {
   XBT_IN("(%p)",simcall);
 {
   XBT_IN("(%p)",simcall);
-  _SIMIX_sem_wait(simcall->sem_acquire.sem, -1, simcall->issuer, simcall);
+  _SIMIX_sem_wait(sem, -1, simcall->issuer, simcall);
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
@@ -490,10 +523,9 @@ void SIMIX_pre_sem_acquire(smx_simcall_t simcall)
  * \brief Handles a sem acquire simcall with timeout.
  * \param simcall the simcall
  */
  * \brief Handles a sem acquire simcall with timeout.
  * \param simcall the simcall
  */
-void SIMIX_pre_sem_acquire_timeout(smx_simcall_t simcall)
+void SIMIX_pre_sem_acquire_timeout(smx_simcall_t simcall, smx_sem_t sem, double timeout)
 {
   XBT_IN("(%p)",simcall);
 {
   XBT_IN("(%p)",simcall);
-  _SIMIX_sem_wait(simcall->sem_acquire_timeout.sem,
-                  simcall->sem_acquire_timeout.timeout, simcall->issuer, simcall);  
+  _SIMIX_sem_wait(sem, timeout, simcall->issuer, simcall);  
   XBT_OUT();
 }
   XBT_OUT();
 }
index f3ec15c..e50c106 100644 (file)
@@ -26,23 +26,38 @@ void SIMIX_synchro_destroy(smx_action_t action);
 
 smx_mutex_t SIMIX_mutex_init(void);
 void SIMIX_mutex_destroy(smx_mutex_t mutex);
 
 smx_mutex_t SIMIX_mutex_init(void);
 void SIMIX_mutex_destroy(smx_mutex_t mutex);
-void SIMIX_pre_mutex_lock(smx_simcall_t simcall);
+void SIMIX_pre_mutex_lock(smx_simcall_t simcall, smx_mutex_t mutex);
 int SIMIX_mutex_trylock(smx_mutex_t mutex, smx_process_t issuer);
 void SIMIX_mutex_unlock(smx_mutex_t mutex, smx_process_t issuer);
 
 smx_cond_t SIMIX_cond_init(void);
 void SIMIX_cond_destroy(smx_cond_t cond);
 void SIMIX_cond_signal(smx_cond_t cond);
 int SIMIX_mutex_trylock(smx_mutex_t mutex, smx_process_t issuer);
 void SIMIX_mutex_unlock(smx_mutex_t mutex, smx_process_t issuer);
 
 smx_cond_t SIMIX_cond_init(void);
 void SIMIX_cond_destroy(smx_cond_t cond);
 void SIMIX_cond_signal(smx_cond_t cond);
-void SIMIX_pre_cond_wait(smx_simcall_t simcall);
-void SIMIX_pre_cond_wait_timeout(smx_simcall_t simcall);
+void SIMIX_pre_cond_wait(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex);
+void SIMIX_pre_cond_wait_timeout(smx_simcall_t simcall, smx_cond_t cond,
+                                smx_mutex_t mutex, double timeout);
 void SIMIX_cond_broadcast(smx_cond_t cond);
 
 smx_sem_t SIMIX_sem_init(unsigned int value);
 void SIMIX_sem_destroy(smx_sem_t sem);
 void SIMIX_sem_release(smx_sem_t sem);
 int SIMIX_sem_would_block(smx_sem_t sem);
 void SIMIX_cond_broadcast(smx_cond_t cond);
 
 smx_sem_t SIMIX_sem_init(unsigned int value);
 void SIMIX_sem_destroy(smx_sem_t sem);
 void SIMIX_sem_release(smx_sem_t sem);
 int SIMIX_sem_would_block(smx_sem_t sem);
-void SIMIX_pre_sem_acquire(smx_simcall_t simcall);
-void SIMIX_pre_sem_acquire_timeout(smx_simcall_t simcall);
+void SIMIX_pre_sem_acquire(smx_simcall_t simcall, smx_sem_t sem);
+void SIMIX_pre_sem_acquire_timeout(smx_simcall_t simcall, smx_sem_t sem, double timeout);
 int SIMIX_sem_get_capacity(smx_sem_t sem);
 
 int SIMIX_sem_get_capacity(smx_sem_t sem);
 
+// pre prototypes
+smx_mutex_t SIMIX_pre_mutex_init(smx_simcall_t simcall);
+void SIMIX_pre_mutex_destroy(smx_simcall_t simcall, smx_mutex_t mutex);
+int SIMIX_pre_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex);
+void SIMIX_pre_mutex_unlock(smx_simcall_t simcall, smx_mutex_t mutex);
+smx_cond_t SIMIX_pre_cond_init(smx_simcall_t simcall);
+void SIMIX_pre_cond_destroy(smx_simcall_t simcall, smx_cond_t cond);
+void SIMIX_pre_cond_signal(smx_simcall_t simcall, smx_cond_t cond);
+void SIMIX_pre_cond_broadcast(smx_simcall_t simcall, smx_cond_t cond);
+smx_sem_t SIMIX_pre_sem_init(smx_simcall_t simcall, unsigned int value);
+void SIMIX_pre_sem_destroy(smx_simcall_t simcall, smx_sem_t sem);
+void SIMIX_pre_sem_release(smx_simcall_t simcall, smx_sem_t sem);
+XBT_INLINE int SIMIX_pre_sem_would_block(smx_simcall_t simcall, smx_sem_t sem);
+int SIMIX_pre_sem_get_capacity(smx_simcall_t simcall, smx_sem_t sem);
 #endif
 #endif
index 3331b46..40bf406 100644 (file)
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
 
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
 
+/* generate strings from the enumeration values */
 static const char* simcall_names[] = {
 static const char* simcall_names[] = {
-#undef SIMCALL_ENUM_ELEMENT
-#define SIMCALL_ENUM_ELEMENT(x,y) #x /* generate strings from the enumeration values */
-SIMCALL_LIST
-#undef SIMCALL_ENUM_ELEMENT
+SIMCALL_LIST(SIMCALL_TYPE, SIMCALL_SEP_COMMA)
+[SIMCALL_NONE] = "NONE"
 };
 
 /**
 };
 
 /**
@@ -224,8 +223,7 @@ smx_action_t simcall_host_execute(const char *name, smx_host_t host,
   if(MC_is_active()) /* Initialize result to NULL for snapshot comparison done during simcall */
     simcall->host_execute.result = NULL;
 
   if(MC_is_active()) /* Initialize result to NULL for snapshot comparison done during simcall */
     simcall->host_execute.result = NULL;
 
-  SIMIX_simcall(SIMCALL_HOST_EXECUTE, PTR(name), PTR(host), DOUBLE(computation_amount), DOUBLE(priority));
-
+  simcall_BODY_host_execute(name, host, computation_amount, priority);
   return simcall->host_execute.result;
 }
 
   return simcall->host_execute.result;
 }
 
@@ -385,7 +383,7 @@ e_smx_state_t simcall_host_execution_wait(smx_action_t execution)
   simcall->host_execution_wait.execution = execution;
   simcall->host_execution_wait.simcall = simcall;
 
   simcall->host_execution_wait.execution = execution;
   simcall->host_execution_wait.simcall = simcall;
 
-  SIMIX_simcall(SIMCALL_HOST_EXECUTION_WAIT, PTR(simcall), PTR(execution));
+  simcall_BODY_host_execution_wait(execution);
 
   if(MC_is_active()) /* Initialize result to a default value for snapshot comparison done during simcall */
     simcall->host_execution_wait.result = -1;
 
   if(MC_is_active()) /* Initialize result to a default value for snapshot comparison done during simcall */
     simcall->host_execution_wait.result = -1;
index 00a845f..e19bd95 100644 (file)
@@ -184,35 +184,6 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t *stac
     i2++; 
   }
 
     i2++; 
   }
 
-  /* Init equal information */
-  i1 = 1;
-
-  while(i1<=heaplimit){
-    if(heapinfo1[i1].type == 0){
-      heapinfo1[i1].busy_block.equal_to = -1;
-    }
-    if(heapinfo1[i1].type > 0){
-      for(j1=0; j1 < MAX_FRAGMENT_PER_BLOCK; j1++){
-        heapinfo1[i1].busy_frag.equal_to[j1] = -1;
-      }
-    }
-    i1++; 
-  }
-
-  i2 = 1;
-
-  while(i2<=heaplimit){
-    if(heapinfo2[i2].type == 0){
-      heapinfo2[i2].busy_block.equal_to = -1;
-    }
-    if(heapinfo2[i2].type > 0){
-      for(j2=0; j2 < MAX_FRAGMENT_PER_BLOCK; j2++){
-        heapinfo2[i2].busy_frag.equal_to[j2] = -1;
-      }
-    }
-    i2++; 
-  }
-
   /* Check busy blocks*/
 
   i1 = 1;
   /* Check busy blocks*/
 
   i1 = 1;
@@ -304,48 +275,6 @@ int mmalloc_compare_heap(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t *stac
         
       }
 
         
       }
 
-      if(heapinfo1[i1].busy_block.busy_size == 0){
-        i1++;
-        continue;
-      }
-      
-      i2 = 1;
-      equal = 0;
-      
-      /* Try first to associate to same block in the other heap */
-      if(heapinfo2[current_block].type == heapinfo1[current_block].type){
-        
-        if(heapinfo1[current_block].busy_block.busy_size == heapinfo2[current_block].busy_block.busy_size){
-
-          addr_block2 = ((void*) (((ADDR2UINT(current_block)) - 1) * BLOCKSIZE + (char*)heapbase2));
-          
-          add_heap_area_pair(previous, current_block, -1, current_block, -1);
-          
-          if(ignore_done < xbt_dynar_length(mmalloc_ignore)){
-            if(in_mmalloc_ignore((int)current_block, -1))
-              res_compare = compare_area(addr_block1, addr_block2, heapinfo1[current_block].busy_block.busy_size, previous, 1);
-            else
-              res_compare = compare_area(addr_block1, addr_block2, heapinfo1[current_block].busy_block.busy_size, previous, 0);
-          }else{
-            res_compare = compare_area(addr_block1, addr_block2, heapinfo1[current_block].busy_block.busy_size, previous, 0);
-          }
-          
-          if(res_compare == 0){
-            for(k=1; k < heapinfo2[current_block].busy_block.size; k++)
-              heapinfo2[current_block+k].busy_block.equal_to = 1 ;
-            for(k=1; k < heapinfo1[current_block].busy_block.size; k++)
-              heapinfo1[current_block+k].busy_block.equal_to = 1 ;
-            equal = 1;
-            match_equals(previous);
-            i1 = i1 + heapinfo1[i1].busy_block.size;
-          }
-
-          xbt_dynar_reset(previous);
-          
-        }
-
-      }
-
       while(i2 <= heaplimit && !equal){
 
         addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)heapbase2));        
       while(i2 <= heaplimit && !equal){
 
         addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)heapbase2));