Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics: enforce prototype checking on callbacks in SIMIX_function_register_process...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 11 Jul 2007 07:46:56 +0000 (07:46 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 11 Jul 2007 07:46:56 +0000 (07:46 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3723 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/include/simix/simix.h
src/msg/deployment.c
src/msg/m_process.c
src/msg/private.h
src/simix/private.h
src/simix/smx_global.c

index 4fefabb..5e2e97b 100644 (file)
@@ -45,8 +45,15 @@ XBT_PUBLIC(void) __SIMIX_main(void);
  * int argc, char **argv: parameters passed to code
  *
  * */
-XBT_PUBLIC(void) SIMIX_function_register_process_create(void * function);
-XBT_PUBLIC(void) SIMIX_function_register_process_kill(void * function);
+typedef void *(smx_creation_func_t)(/*name*/     const char *,
+                                    /*code*/     xbt_main_func_t, 
+                                    /*userdata*/ void *,
+                                    /*hostname*/ char *, 
+                                    /* argc */   int,
+                                    /* argv */   char **);
+XBT_PUBLIC(void) SIMIX_function_register_process_create(smx_creation_func_t *function);
+
+XBT_PUBLIC(void) SIMIX_function_register_process_kill(void_f_pvoid_t *function);
 
 /************************** Host handling ***********************************/
 
index 97308f2..4e05ed1 100644 (file)
@@ -31,8 +31,8 @@ void MSG_launch_application(const char *file)
 {
 
   xbt_assert0(msg_global,"MSG_global_init_args has to be called before MSG_launch_application.");
-       SIMIX_function_register_process_create(&__MSG_process_create_with_arguments);
-       SIMIX_function_register_process_kill(&MSG_process_kill);
+       SIMIX_function_register_process_create(_MSG_process_create_from_SIMIX);
+       SIMIX_function_register_process_kill(_MSG_process_kill_from_SIMIX);
        SIMIX_launch_application(file);
 
        return;
index 586e756..96a8e45 100644 (file)
@@ -57,6 +57,16 @@ void __MSG_process_cleanup(void *arg)
    return;
 }
 
+/* This function creates a MSG process. It has the prototype by SIMIX_function_register_process_create */
+void *_MSG_process_create_from_SIMIX(const char *name,
+                                    xbt_main_func_t code, void *data,
+                                    char * hostname, int argc, char **argv)
+{
+       m_host_t host = MSG_get_host_by_name(hostname);
+       return (void*)MSG_process_create_with_arguments(name,code,data,host,argc,argv);
+}
+
+
 /** \ingroup m_process_management
  * \brief Creates and runs a new #m_process_t.
 
@@ -82,16 +92,6 @@ void __MSG_process_cleanup(void *arg)
  * \return The new corresponding object.
  */
 
-
-
-m_process_t __MSG_process_create_with_arguments(const char *name,
-                                             xbt_main_func_t code, void *data,
-                                             char * hostname, int argc, char **argv)
-{
-       m_host_t host = MSG_get_host_by_name(hostname);
-       return MSG_process_create_with_arguments(name,code,data,host,argc,argv);
-}
-
 m_process_t MSG_process_create_with_arguments(const char *name,
                                              xbt_main_func_t code, void *data,
                                              m_host_t host, int argc, char **argv)
@@ -128,6 +128,11 @@ m_process_t MSG_process_create_with_arguments(const char *name,
   return process;
 }
 
+
+void _MSG_process_kill_from_SIMIX(void *p) {
+   MSG_process_kill((m_process_t)p);
+}
+
 /** \ingroup m_process_management
  * \param process poor victim
  *
index 459a10b..d193688 100644 (file)
@@ -105,9 +105,10 @@ void __MSG_host_destroy(m_host_t host);
 void __MSG_display_process_status(void);
 
 void __MSG_process_cleanup(void *arg);
-m_process_t __MSG_process_create_with_arguments(const char *name,
-                                               xbt_main_func_t code, void *data,
-                                               char * hostname, int argc, char **argv);
+void *_MSG_process_create_from_SIMIX(const char *name,
+                                    xbt_main_func_t code, void *data,
+                                    char * hostname, int argc, char **argv);
+void _MSG_process_kill_from_SIMIX(void *p);
 
 
 #endif
index 1c7ac7d..2c70b1e 100644 (file)
@@ -38,8 +38,8 @@ typedef struct SIMIX_Global {
 
   smx_process_t current_process;
   xbt_dict_t registered_functions;
-       void* (*create_process_function) ();
-       void* (*kill_process_function)();
+  smx_creation_func_t *create_process_function;
+  void_f_pvoid_t* kill_process_function;
 } s_SIMIX_Global_t, *SIMIX_Global_t;
 
 extern SIMIX_Global_t simix_global;
index 98aca67..81f097b 100644 (file)
@@ -354,7 +354,7 @@ int SIMIX_timer_get(void **function, void **arg)
  *     \param function Create process function
  *
  */
-void SIMIX_function_register_process_create(void * function)
+void SIMIX_function_register_process_create(smx_creation_func_t* function)
 {
   xbt_assert0((simix_global->create_process_function == NULL), "Data already set");
 
@@ -371,7 +371,7 @@ void SIMIX_function_register_process_create(void * function)
  *     \param function Kill process function
  *
  */
-void SIMIX_function_register_process_kill(void * function)
+void SIMIX_function_register_process_kill(void_f_pvoid_t* function)
 {
   xbt_assert0((simix_global->kill_process_function == NULL), "Data already set");