Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sanitize the process_create simcall
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 21 Jul 2015 12:50:27 +0000 (14:50 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 21 Jul 2015 13:03:16 +0000 (15:03 +0200)
It was receiving a pointer to its result as first parameter, and it
now simply returns that result.

It could be further improved by returning a smx_process_t instead of a
void*, but our simcall mechanism does not seem to allow to cast results.

13 files changed:
include/simgrid/simix.h
src/msg/msg_private.h
src/msg/msg_process.c
src/simix/libsmx.c
src/simix/popping_accessors.h
src/simix/popping_bodies.c
src/simix/popping_generated.c
src/simix/simcalls.in
src/simix/smx_deployment.c
src/simix/smx_host.c
src/simix/smx_process.c
src/simix/smx_process_private.h
src/xbt/xbt_sg_synchro.c

index aa16226..44535e3 100644 (file)
@@ -79,7 +79,7 @@ typedef struct s_smx_synchro *smx_synchro_t; /* FIXME: replace by specialized sy
 /** @brief Process datatype
     @ingroup simix_process_management
 
 /** @brief Process datatype
     @ingroup simix_process_management
 
-    A processt may be defined as a <em>code</em>, with some <em>private
+    A process may be defined as a <em>code</em>, with some <em>private
     data</em>, executing in a <em>location</em>.
     \see m_process_management
   @{ */
     data</em>, executing in a <em>location</em>.
     \see m_process_management
   @{ */
@@ -102,7 +102,7 @@ typedef enum {
  * int argc, char **argv: parameters passed to code
  * xbt_dict_t pros: properties
  */
  * int argc, char **argv: parameters passed to code
  * xbt_dict_t pros: properties
  */
-typedef void (*smx_creation_func_t) ( /* process */ smx_process_t*,
+typedef smx_process_t (*smx_creation_func_t) (
                                       /* name */ const char*,
                                       /* code */ xbt_main_func_t,
                                       /* userdata */ void*,
                                       /* name */ const char*,
                                       /* code */ xbt_main_func_t,
                                       /* userdata */ void*,
@@ -363,8 +363,7 @@ XBT_PUBLIC(void) simcall_vm_shutdown(sg_host_t vm);
 
 /**************************** Process simcalls ********************************/
 /* Constructor and Destructor */
 
 /**************************** Process simcalls ********************************/
 /* Constructor and Destructor */
-XBT_PUBLIC(void) simcall_process_create(smx_process_t *process,
-                                          const char *name,
+XBT_PUBLIC(smx_process_t) simcall_process_create(const char *name,
                                           xbt_main_func_t code,
                                           void *data,
                                           const char *hostname,
                                           xbt_main_func_t code,
                                           void *data,
                                           const char *hostname,
index c3cfcdb..a8c25c2 100644 (file)
@@ -162,7 +162,7 @@ void __MSG_storage_destroy(msg_storage_priv_t host);
 void __MSG_file_destroy(msg_file_priv_t host);
 
 void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
 void __MSG_file_destroy(msg_file_priv_t host);
 
 void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
-void MSG_process_create_from_SIMIX(smx_process_t *process, const char *name,
+smx_process_t MSG_process_create_from_SIMIX(const char *name,
                                    xbt_main_func_t code, void *data,
                                    const char *hostname, double kill_time,
                                    int argc, char **argv,
                                    xbt_main_func_t code, void *data,
                                    const char *hostname, double kill_time,
                                    int argc, char **argv,
index cf3266e..0589483 100644 (file)
@@ -53,7 +53,7 @@ void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc)
 }
 
 /* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
 }
 
 /* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
-void MSG_process_create_from_SIMIX(smx_process_t* process, const char *name,
+smx_process_t MSG_process_create_from_SIMIX(const char *name,
                                    xbt_main_func_t code, void *data,
                                    const char *hostname, double kill_time,
                                    int argc, char **argv,
                                    xbt_main_func_t code, void *data,
                                    const char *hostname, double kill_time,
                                    int argc, char **argv,
@@ -68,7 +68,7 @@ void MSG_process_create_from_SIMIX(smx_process_t* process, const char *name,
     MSG_process_set_kill_time(p,kill_time);
     MSG_process_auto_restart_set(p,auto_restart);
   }
     MSG_process_set_kill_time(p,kill_time);
     MSG_process_auto_restart_set(p,auto_restart);
   }
-  *((msg_process_t*) process) = p;
+  return p;
 }
 
 /** \ingroup m_process_management
 }
 
 /** \ingroup m_process_management
@@ -166,7 +166,7 @@ msg_process_t MSG_process_create_with_environment(const char *name,
 
   /* Let's create the process: SIMIX may decide to start it right now,
    * even before returning the flow control to us */
 
   /* Let's create the process: SIMIX may decide to start it right now,
    * even before returning the flow control to us */
simcall_process_create(&process, name, code, simdata, sg_host_name(host), -1,
process = simcall_process_create(name, code, simdata, sg_host_name(host), -1,
                            argc, argv, properties,0);
 
   TRACE_msg_process_create(name, SIMIX_process_get_PID(process), host);
                            argc, argv, properties,0);
 
   TRACE_msg_process_create(name, SIMIX_process_get_PID(process), host);
index 5bbfc58..6287ac4 100644 (file)
@@ -582,7 +582,7 @@ void simcall_vm_migratefrom_resumeto(sg_host_t vm, sg_host_t src_pm, sg_host_t d
  * \param properties the properties of the process
  * \param auto_restart either it is autorestarting or not.
  */
  * \param properties the properties of the process
  * \param auto_restart either it is autorestarting or not.
  */
-void simcall_process_create(smx_process_t *process, const char *name,
+smx_process_t simcall_process_create(const char *name,
                               xbt_main_func_t code,
                               void *data,
                               const char *hostname,
                               xbt_main_func_t code,
                               void *data,
                               const char *hostname,
@@ -591,7 +591,7 @@ void simcall_process_create(smx_process_t *process, const char *name,
                               xbt_dict_t properties,
                               int auto_restart)
 {
                               xbt_dict_t properties,
                               int auto_restart)
 {
-  simcall_BODY_process_create(process, name, code, data, hostname,
+  return (smx_process_t) simcall_BODY_process_create(name, code, data, hostname,
                               kill_time, argc, argv, properties,
                               auto_restart);
 }
                               kill_time, argc, argv, properties,
                               auto_restart);
 }
index 78fbb22..c08b835 100644 (file)
@@ -641,65 +641,65 @@ static inline void simcall_vm_migratefrom_resumeto__set__dst_pm(smx_simcall_t si
     simcall->args[2].dp = arg;
 }
 
     simcall->args[2].dp = arg;
 }
 
-static inline smx_process_t* simcall_process_create__get__process(smx_simcall_t simcall) {
-  return (smx_process_t*) simcall->args[0].dp;
-}
-static inline void simcall_process_create__set__process(smx_simcall_t simcall, void* arg) {
-    simcall->args[0].dp = arg;
-}
 static inline const char* simcall_process_create__get__name(smx_simcall_t simcall) {
 static inline const char* simcall_process_create__get__name(smx_simcall_t simcall) {
-  return  simcall->args[1].cc;
+  return  simcall->args[0].cc;
 }
 static inline void simcall_process_create__set__name(smx_simcall_t simcall, const char* arg) {
 }
 static inline void simcall_process_create__set__name(smx_simcall_t simcall, const char* arg) {
-    simcall->args[1].cc = arg;
+    simcall->args[0].cc = arg;
 }
 static inline xbt_main_func_t simcall_process_create__get__code(smx_simcall_t simcall) {
 }
 static inline xbt_main_func_t simcall_process_create__get__code(smx_simcall_t simcall) {
-  return (xbt_main_func_t) simcall->args[2].fp;
+  return (xbt_main_func_t) simcall->args[1].fp;
 }
 static inline void simcall_process_create__set__code(smx_simcall_t simcall, FPtr arg) {
 }
 static inline void simcall_process_create__set__code(smx_simcall_t simcall, FPtr arg) {
-    simcall->args[2].fp = arg;
+    simcall->args[1].fp = arg;
 }
 static inline void* simcall_process_create__get__data(smx_simcall_t simcall) {
 }
 static inline void* simcall_process_create__get__data(smx_simcall_t simcall) {
-  return  simcall->args[3].dp;
+  return  simcall->args[2].dp;
 }
 static inline void simcall_process_create__set__data(smx_simcall_t simcall, void* arg) {
 }
 static inline void simcall_process_create__set__data(smx_simcall_t simcall, void* arg) {
-    simcall->args[3].dp = arg;
+    simcall->args[2].dp = arg;
 }
 static inline const char* simcall_process_create__get__hostname(smx_simcall_t simcall) {
 }
 static inline const char* simcall_process_create__get__hostname(smx_simcall_t simcall) {
-  return  simcall->args[4].cc;
+  return  simcall->args[3].cc;
 }
 static inline void simcall_process_create__set__hostname(smx_simcall_t simcall, const char* arg) {
 }
 static inline void simcall_process_create__set__hostname(smx_simcall_t simcall, const char* arg) {
-    simcall->args[4].cc = arg;
+    simcall->args[3].cc = arg;
 }
 static inline double simcall_process_create__get__kill_time(smx_simcall_t simcall) {
 }
 static inline double simcall_process_create__get__kill_time(smx_simcall_t simcall) {
-  return  simcall->args[5].d;
+  return  simcall->args[4].d;
 }
 static inline void simcall_process_create__set__kill_time(smx_simcall_t simcall, double arg) {
 }
 static inline void simcall_process_create__set__kill_time(smx_simcall_t simcall, double arg) {
-    simcall->args[5].d = arg;
+    simcall->args[4].d = arg;
 }
 static inline int simcall_process_create__get__argc(smx_simcall_t simcall) {
 }
 static inline int simcall_process_create__get__argc(smx_simcall_t simcall) {
-  return  simcall->args[6].i;
+  return  simcall->args[5].i;
 }
 static inline void simcall_process_create__set__argc(smx_simcall_t simcall, int arg) {
 }
 static inline void simcall_process_create__set__argc(smx_simcall_t simcall, int arg) {
-    simcall->args[6].i = arg;
+    simcall->args[5].i = arg;
 }
 static inline char** simcall_process_create__get__argv(smx_simcall_t simcall) {
 }
 static inline char** simcall_process_create__get__argv(smx_simcall_t simcall) {
-  return (char**) simcall->args[7].dp;
+  return (char**) simcall->args[6].dp;
 }
 static inline void simcall_process_create__set__argv(smx_simcall_t simcall, void* arg) {
 }
 static inline void simcall_process_create__set__argv(smx_simcall_t simcall, void* arg) {
-    simcall->args[7].dp = arg;
+    simcall->args[6].dp = arg;
 }
 static inline xbt_dict_t simcall_process_create__get__properties(smx_simcall_t simcall) {
 }
 static inline xbt_dict_t simcall_process_create__get__properties(smx_simcall_t simcall) {
-  return (xbt_dict_t) simcall->args[8].dp;
+  return (xbt_dict_t) simcall->args[7].dp;
 }
 static inline void simcall_process_create__set__properties(smx_simcall_t simcall, void* arg) {
 }
 static inline void simcall_process_create__set__properties(smx_simcall_t simcall, void* arg) {
-    simcall->args[8].dp = arg;
+    simcall->args[7].dp = arg;
 }
 static inline int simcall_process_create__get__auto_restart(smx_simcall_t simcall) {
 }
 static inline int simcall_process_create__get__auto_restart(smx_simcall_t simcall) {
-  return  simcall->args[9].i;
+  return  simcall->args[8].i;
 }
 static inline void simcall_process_create__set__auto_restart(smx_simcall_t simcall, int arg) {
 }
 static inline void simcall_process_create__set__auto_restart(smx_simcall_t simcall, int arg) {
-    simcall->args[9].i = arg;
+    simcall->args[8].i = arg;
+}
+static inline void* simcall_process_create__get__result(smx_simcall_t simcall){
+    return  simcall->result.dp;
+}
+static inline void simcall_process_create__set__result(smx_simcall_t simcall, void* result){
+    simcall->result.dp = result;
 }
 
 static inline smx_process_t simcall_process_kill__get__process(smx_simcall_t simcall) {
 }
 
 static inline smx_process_t simcall_process_kill__get__process(smx_simcall_t simcall) {
@@ -1943,7 +1943,7 @@ void simcall_HANDLER_vm_resume(smx_simcall_t simcall, sg_host_t ind_vm);
 void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t ind_vm);
 void simcall_HANDLER_vm_save(smx_simcall_t simcall, sg_host_t ind_vm);
 void simcall_HANDLER_vm_restore(smx_simcall_t simcall, sg_host_t ind_vm);
 void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t ind_vm);
 void simcall_HANDLER_vm_save(smx_simcall_t simcall, sg_host_t ind_vm);
 void simcall_HANDLER_vm_restore(smx_simcall_t simcall, sg_host_t ind_vm);
-void simcall_HANDLER_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* simcall_HANDLER_process_create(smx_simcall_t simcall, 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 simcall_HANDLER_process_kill(smx_simcall_t simcall, smx_process_t process);
 void simcall_HANDLER_process_killall(smx_simcall_t simcall, int reset_pid);
 void simcall_HANDLER_process_change_host(smx_simcall_t simcall, smx_process_t process, sg_host_t dest);
 void simcall_HANDLER_process_kill(smx_simcall_t simcall, smx_process_t process);
 void simcall_HANDLER_process_killall(smx_simcall_t simcall, int reset_pid);
 void simcall_HANDLER_process_change_host(smx_simcall_t simcall, smx_process_t process, sg_host_t dest);
index 4384ea1..e8e13bc 100644 (file)
@@ -990,26 +990,25 @@ inline static void simcall_BODY_vm_migratefrom_resumeto(sg_host_t vm, sg_host_t
     
   }
   
     
   }
   
-inline static void simcall_BODY_process_create(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) {
+inline static void* simcall_BODY_process_create(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) {
     smx_process_t self = SIMIX_process_self();
 
     /* Go to that function to follow the code flow through the simcall barrier */
     smx_process_t self = SIMIX_process_self();
 
     /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) simcall_HANDLER_process_create(&self->simcall, process, name, code, data, hostname, kill_time, argc, argv, properties, auto_restart);
+    if (0) simcall_HANDLER_process_create(&self->simcall, name, code, data, hostname, kill_time, argc, argv, properties, auto_restart);
     /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */
 
     self->simcall.call = SIMCALL_PROCESS_CREATE;
     memset(&self->simcall.result, 0, sizeof(self->simcall.result));
     memset(self->simcall.args, 0, sizeof(self->simcall.args));
     /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */
 
     self->simcall.call = SIMCALL_PROCESS_CREATE;
     memset(&self->simcall.result, 0, sizeof(self->simcall.result));
     memset(self->simcall.args, 0, sizeof(self->simcall.args));
-    self->simcall.args[0].dp = (void*) process;
-    self->simcall.args[1].cc = (const char*) name;
-    self->simcall.args[2].fp = (FPtr) code;
-    self->simcall.args[3].dp = (void*) data;
-    self->simcall.args[4].cc = (const char*) hostname;
-    self->simcall.args[5].d = (double) kill_time;
-    self->simcall.args[6].i = (int) argc;
-    self->simcall.args[7].dp = (void*) argv;
-    self->simcall.args[8].dp = (void*) properties;
-    self->simcall.args[9].i = (int) auto_restart;
+    self->simcall.args[0].cc = (const char*) name;
+    self->simcall.args[1].fp = (FPtr) code;
+    self->simcall.args[2].dp = (void*) data;
+    self->simcall.args[3].cc = (const char*) hostname;
+    self->simcall.args[4].d = (double) kill_time;
+    self->simcall.args[5].i = (int) argc;
+    self->simcall.args[6].dp = (void*) argv;
+    self->simcall.args[7].dp = (void*) properties;
+    self->simcall.args[8].i = (int) auto_restart;
     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);
     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);
@@ -1017,7 +1016,7 @@ inline static void simcall_BODY_process_create(smx_process_t* process, const cha
     } else {
       SIMIX_simcall_handle(&self->simcall, 0);
     }    
     } else {
       SIMIX_simcall_handle(&self->simcall, 0);
     }    
-    
+    return self->simcall.result.dp;
   }
   
 inline static void simcall_BODY_process_kill(smx_process_t process) {
   }
   
 inline static void simcall_BODY_process_kill(smx_process_t process) {
index be4dc47..5b1b9ad 100644 (file)
@@ -392,7 +392,7 @@ case SIMCALL_VM_MIGRATEFROM_RESUMETO:
       break;  
 
 case SIMCALL_PROCESS_CREATE:
       break;  
 
 case SIMCALL_PROCESS_CREATE:
-       simcall_HANDLER_process_create(simcall , (smx_process_t*) simcall->args[0].dp,  simcall->args[1].cc, (xbt_main_func_t) simcall->args[2].fp,  simcall->args[3].dp,  simcall->args[4].cc,  simcall->args[5].d,  simcall->args[6].i, (char**) simcall->args[7].dp, (xbt_dict_t) simcall->args[8].dp,  simcall->args[9].i);
+      simcall->result.dp = simcall_HANDLER_process_create(simcall ,  simcall->args[0].cc, (xbt_main_func_t) simcall->args[1].fp,  simcall->args[2].dp,  simcall->args[3].cc,  simcall->args[4].d,  simcall->args[5].i, (char**) simcall->args[6].dp, (xbt_dict_t) simcall->args[7].dp,  simcall->args[8].i);
       SIMIX_simcall_answer(simcall);
       break;  
 
       SIMIX_simcall_answer(simcall);
       break;  
 
index 83044b4..e5fcd2d 100644 (file)
@@ -92,7 +92,7 @@ Proc H vm_shutdown (void) (ind_vm, void*, sg_host_t)
 Proc H vm_save (void) (ind_vm, void*, sg_host_t)
 Proc H vm_restore (void) (ind_vm, void*, sg_host_t)
 Proc - vm_migratefrom_resumeto (void) (vm, void*, sg_host_t)(src_pm, void*, sg_host_t) (dst_pm, void*, sg_host_t)
 Proc H vm_save (void) (ind_vm, void*, sg_host_t)
 Proc H vm_restore (void) (ind_vm, void*, sg_host_t)
 Proc - vm_migratefrom_resumeto (void) (vm, void*, sg_host_t)(src_pm, void*, sg_host_t) (dst_pm, void*, sg_host_t)
-Proc H process_create (void) (process, void*, smx_process_t*) (name, const char*) (code, FPtr, xbt_main_func_t) (data, void*) (hostname, const char*) (kill_time, double) (argc, int) (argv, void*, char**) (properties, void*, xbt_dict_t) (auto_restart, int)
+Func H process_create (void*) (name, const char*) (code, FPtr, xbt_main_func_t) (data, void*) (hostname, const char*) (kill_time, double) (argc, int) (argv, void*, char**) (properties, void*, xbt_dict_t) (auto_restart, int)
 Proc H process_kill (void) (process, void*, smx_process_t)
 Proc H process_killall (void) (reset_pid, int)
 Proc - process_cleanup (void) (process, void*, smx_process_t)
 Proc H process_kill (void) (process, void*, smx_process_t)
 Proc H process_killall (void) (reset_pid, int)
 Proc - process_cleanup (void) (process, void*, smx_process_t)
index 7a3b025..9e59e32 100644 (file)
@@ -71,7 +71,7 @@ static void parse_process(sg_platf_process_cbarg_t process)
     XBT_DEBUG("Starting Process %s(%s) right now", process->argv[0], sg_host_name(host));
 
     if (simix_global->create_process_function)
     XBT_DEBUG("Starting Process %s(%s) right now", process->argv[0], sg_host_name(host));
 
     if (simix_global->create_process_function)
-      simix_global->create_process_function(&process_created,
+      process_created = simix_global->create_process_function(
                                             (char*)(process->argv)[0],
                                             parse_code,
                                             NULL,
                                             (char*)(process->argv)[0],
                                             parse_code,
                                             NULL,
@@ -82,7 +82,7 @@ static void parse_process(sg_platf_process_cbarg_t process)
                                             current_property_set,
                                             auto_restart, NULL);
     else
                                             current_property_set,
                                             auto_restart, NULL);
     else
-      simcall_process_create(&process_created, (char*)(process->argv)[0], parse_code, NULL, sg_host_name(host), kill_time, process->argc,
+      process_created = simcall_process_create((char*)(process->argv)[0], parse_code, NULL, sg_host_name(host), kill_time, process->argc,
           (char**)process->argv, current_property_set,auto_restart);
     
     /* verify if process has been created (won't be the case if the host is currently dead, but that's fine) */
           (char**)process->argv, current_property_set,auto_restart);
     
     /* verify if process has been created (won't be the case if the host is currently dead, but that's fine) */
index 6a367b2..73b150f 100644 (file)
@@ -50,7 +50,6 @@ void SIMIX_host_on(sg_host_t h)
     unsigned int cpt;
     smx_process_arg_t arg;
     xbt_dynar_foreach(host->boot_processes,cpt,arg) {
     unsigned int cpt;
     smx_process_arg_t arg;
     xbt_dynar_foreach(host->boot_processes,cpt,arg) {
-      smx_process_t process;
 
       char** argv = xbt_new(char*, arg->argc);
       for (int i=0; i<arg->argc; i++)
 
       char** argv = xbt_new(char*, arg->argc);
       for (int i=0; i<arg->argc; i++)
@@ -58,8 +57,7 @@ void SIMIX_host_on(sg_host_t h)
 
       XBT_DEBUG("Booting Process %s(%s) right now", arg->argv[0], arg->hostname);
       if (simix_global->create_process_function) {
 
       XBT_DEBUG("Booting Process %s(%s) right now", arg->argv[0], arg->hostname);
       if (simix_global->create_process_function) {
-        simix_global->create_process_function(&process,
-                                              argv[0],
+        simix_global->create_process_function(argv[0],
                                               arg->code,
                                               NULL,
                                               arg->hostname,
                                               arg->code,
                                               NULL,
                                               arg->hostname,
@@ -70,8 +68,7 @@ void SIMIX_host_on(sg_host_t h)
                                               arg->auto_restart,
                                               NULL);
       } else {
                                               arg->auto_restart,
                                               NULL);
       } else {
-        simcall_process_create(&process,
-                               arg->argv[0],
+        simcall_process_create(arg->argv[0],
                                arg->code,
                                NULL,
                                arg->hostname,
                                arg->code,
                                NULL,
                                arg->hostname,
@@ -291,12 +288,9 @@ void SIMIX_host_restart_processes(sg_host_t host)
 
   xbt_dynar_foreach (process_list, cpt, arg) {
 
 
   xbt_dynar_foreach (process_list, cpt, arg) {
 
-    smx_process_t process;
-
     XBT_DEBUG("Restarting Process %s(%s) right now", arg->argv[0], arg->hostname);
     if (simix_global->create_process_function) {
     XBT_DEBUG("Restarting Process %s(%s) right now", arg->argv[0], arg->hostname);
     if (simix_global->create_process_function) {
-      simix_global->create_process_function(&process,
-                                            arg->argv[0],
+      simix_global->create_process_function(arg->argv[0],
                                             arg->code,
                                             NULL,
                                             arg->hostname,
                                             arg->code,
                                             NULL,
                                             arg->hostname,
@@ -307,8 +301,7 @@ void SIMIX_host_restart_processes(sg_host_t host)
                                             arg->auto_restart,
                                             NULL);
     } else {
                                             arg->auto_restart,
                                             NULL);
     } else {
-      simcall_process_create(&process,
-                             arg->argv[0],
+      simcall_process_create(arg->argv[0],
                              arg->code,
                              NULL,
                              arg->hostname,
                              arg->code,
                              NULL,
                              arg->hostname,
index 57cc594..51c2859 100644 (file)
@@ -182,8 +182,7 @@ void SIMIX_process_stop(smx_process_t arg) {
  */
 smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args) {
 
  */
 smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args) {
 
-  smx_process_t process;
-  simix_global->create_process_function(&process,
+  smx_process_t process = simix_global->create_process_function(
                                         args->name,
                                         args->code,
                                         args->data,
                                         args->name,
                                         args->code,
                                         args->data,
@@ -199,8 +198,7 @@ smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args) {
 }
 
 
 }
 
 
-void simcall_HANDLER_process_create(smx_simcall_t simcall,
-                         smx_process_t *process,
+void* simcall_HANDLER_process_create(smx_simcall_t simcall,
                           const char *name,
                           xbt_main_func_t code,
                           void *data,
                           const char *name,
                           xbt_main_func_t code,
                           void *data,
@@ -209,7 +207,7 @@ void simcall_HANDLER_process_create(smx_simcall_t simcall,
                           int argc, char **argv,
                           xbt_dict_t properties,
                           int auto_restart){
                           int argc, char **argv,
                           xbt_dict_t properties,
                           int auto_restart){
-  SIMIX_process_create(process, name, code, data, hostname,
+  return (void*)SIMIX_process_create(name, code, data, hostname,
                        kill_time, argc, argv, properties, auto_restart,
                        simcall->issuer);
 }
                        kill_time, argc, argv, properties, auto_restart,
                        simcall->issuer);
 }
@@ -222,7 +220,7 @@ void simcall_HANDLER_process_create(smx_simcall_t simcall,
  *
  * \return the process created
  */
  *
  * \return the process created
  */
-void SIMIX_process_create(smx_process_t *process,
+smx_process_t SIMIX_process_create(
                           const char *name,
                           xbt_main_func_t code,
                           void *data,
                           const char *name,
                           xbt_main_func_t code,
                           void *data,
@@ -233,7 +231,7 @@ void SIMIX_process_create(smx_process_t *process,
                           int auto_restart,
                           smx_process_t parent_process)
 {
                           int auto_restart,
                           smx_process_t parent_process)
 {
-  *process = NULL;
+  smx_process_t process = NULL;
   sg_host_t host = sg_host_by_name(hostname);
 
   XBT_DEBUG("Start process %s on host '%s'", name, hostname);
   sg_host_t host = sg_host_by_name(hostname);
 
   XBT_DEBUG("Start process %s on host '%s'", name, hostname);
@@ -247,60 +245,60 @@ void SIMIX_process_create(smx_process_t *process,
     xbt_free(argv);
   }
   else {
     xbt_free(argv);
   }
   else {
-    *process = xbt_new0(s_smx_process_t, 1);
+    process = xbt_new0(s_smx_process_t, 1);
 
     xbt_assert(((code != NULL) && (host != NULL)), "Invalid parameters");
     /* Process data */
 
     xbt_assert(((code != NULL) && (host != NULL)), "Invalid parameters");
     /* Process data */
-    (*process)->pid = simix_process_maxpid++;
-    (*process)->name = xbt_strdup(name);
-    (*process)->host = host;
-    (*process)->data = data;
-    (*process)->comms = xbt_fifo_new();
-    (*process)->simcall.issuer = *process;
+    process->pid = simix_process_maxpid++;
+    process->name = xbt_strdup(name);
+    process->host = host;
+    process->data = data;
+    process->comms = xbt_fifo_new();
+    process->simcall.issuer = process;
 
      if (parent_process) {
 
      if (parent_process) {
-       (*process)->ppid = SIMIX_process_get_PID(parent_process);
+       process->ppid = SIMIX_process_get_PID(parent_process);
      } else {
      } else {
-       (*process)->ppid = -1;
+       process->ppid = -1;
      }
 
     /* Process data for auto-restart */
      }
 
     /* Process data for auto-restart */
-    (*process)->auto_restart = auto_restart;
-    (*process)->code = code;
-    (*process)->argc = argc;
-    (*process)->argv = argv;
+    process->auto_restart = auto_restart;
+    process->code = code;
+    process->argc = argc;
+    process->argv = argv;
 
 
 
 
-    XBT_VERB("Create context %s", (*process)->name);
-    (*process)->context = SIMIX_context_new(code, argc, argv,
-      simix_global->cleanup_process_function, *process);
+    XBT_VERB("Create context %s", process->name);
+    process->context = SIMIX_context_new(code, argc, argv, simix_global->cleanup_process_function, process);
 
 
-    (*process)->running_ctx = xbt_new(xbt_running_ctx_t, 1);
-    XBT_RUNNING_CTX_INITIALIZE((*process)->running_ctx);
+    process->running_ctx = xbt_new(xbt_running_ctx_t, 1);
+    XBT_RUNNING_CTX_INITIALIZE(process->running_ctx);
 
     if(MC_is_active()){
 
     if(MC_is_active()){
-      MC_ignore_heap((*process)->running_ctx, sizeof(*(*process)->running_ctx));
+      MC_ignore_heap(process->running_ctx, sizeof(*process->running_ctx));
     }
 
     /* Add properties */
     }
 
     /* Add properties */
-    (*process)->properties = properties;
+    process->properties = properties;
 
     /* Add the process to it's host process list */
 
     /* Add the process to it's host process list */
-    xbt_swag_insert(*process, sg_host_simix(host)->process_list);
+    xbt_swag_insert(process, sg_host_simix(host)->process_list);
 
 
-    XBT_DEBUG("Start context '%s'", (*process)->name);
+    XBT_DEBUG("Start context '%s'", process->name);
 
     /* Now insert it in the global process list and in the process to run list */
 
     /* Now insert it in the global process list and in the process to run list */
-    xbt_swag_insert(*process, simix_global->process_list);
-    XBT_DEBUG("Inserting %s(%s) in the to_run list", (*process)->name, sg_host_name(host));
-    xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, *process);
+    xbt_swag_insert(process, simix_global->process_list);
+    XBT_DEBUG("Inserting %s(%s) in the to_run list", process->name, sg_host_name(host));
+    xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, process);
 
     if (kill_time > SIMIX_get_clock() && simix_global->kill_process_function) {
 
     if (kill_time > SIMIX_get_clock() && simix_global->kill_process_function) {
-      XBT_DEBUG("Process %s(%s) will be kill at time %f", (*process)->name,
-          sg_host_name((*process)->host), kill_time);
-      (*process)->kill_timer = SIMIX_timer_set(kill_time, simix_global->kill_process_function, *process);
+      XBT_DEBUG("Process %s(%s) will be kill at time %f", process->name,
+          sg_host_name(process->host), kill_time);
+      process->kill_timer = SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
     }
   }
     }
   }
+  return process;
 }
 
 /**
 }
 
 /**
@@ -986,7 +984,7 @@ smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer)
   //start the new process
   smx_process_t new_process;
   if (simix_global->create_process_function) {
   //start the new process
   smx_process_t new_process;
   if (simix_global->create_process_function) {
-    simix_global->create_process_function(&new_process,
+    new_process = simix_global->create_process_function(
                                           arg.argv[0],
                                           arg.code,
                                           arg.data,
                                           arg.argv[0],
                                           arg.code,
                                           arg.data,
@@ -998,7 +996,7 @@ smx_process_t SIMIX_process_restart(smx_process_t process, smx_process_t issuer)
                                           arg.auto_restart,
                                           NULL);
   } else {
                                           arg.auto_restart,
                                           NULL);
   } else {
-    simcall_process_create(&new_process,
+    new_process = simcall_process_create(
                            arg.argv[0],
                            arg.code,
                            arg.data,
                            arg.argv[0],
                            arg.code,
                            arg.data,
index 64dcc64..1aadc50 100644 (file)
@@ -62,7 +62,7 @@ typedef struct s_smx_process {
 } s_smx_process_t;
 
 
 } s_smx_process_t;
 
 
-void SIMIX_process_create(smx_process_t *process,
+smx_process_t SIMIX_process_create(
                           const char *name,
                           xbt_main_func_t code,
                           void *data,
                           const char *name,
                           xbt_main_func_t code,
                           void *data,
index 3221ba8..b086b9a 100644 (file)
@@ -62,7 +62,7 @@ xbt_thread_t xbt_thread_create(const char *name, void_f_pvoid_t code,
   res->code = code;
   res->father_data = SIMIX_process_self_get_data(SIMIX_process_self());
   /*   char*name = bprintf("%s#%p",SIMIX_process_self_get_name(), param); */
   res->code = code;
   res->father_data = SIMIX_process_self_get_data(SIMIX_process_self());
   /*   char*name = bprintf("%s#%p",SIMIX_process_self_get_name(), param); */
-  simcall_process_create(&res->s_process, name,
+  res->s_process = simcall_process_create(name,
                            xbt_thread_create_wrapper, res,
                            SIMIX_host_self_get_name(), -1.0, 0, NULL,
                            /*props */ NULL,0);
                            xbt_thread_create_wrapper, res,
                            SIMIX_host_self_get_name(), -1.0, 0, NULL,
                            /*props */ NULL,0);