Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill the types xbt_context_function_t, smx_process_code_t and m_process_code_t; use...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 10 Jul 2007 20:36:12 +0000 (20:36 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 10 Jul 2007 20:36:12 +0000 (20:36 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3719 48e7efb5-ca39-0410-a469-dd3cf9ba447f

17 files changed:
include/msg/datatypes.h
include/msg/msg.h
include/xbt/function_types.h
src/gras/Msg/gras_msg_exchange.c
src/gras/Virtu/sg_emul.c
src/include/simix/datatypes.h
src/include/simix/simix.h
src/include/xbt/context.h
src/java/jxbt_context.c
src/msg/deployment.c
src/msg/m_process.c
src/msg/private.h
src/simix/private.h
src/simix/smx_deployment.c
src/simix/smx_process.c
src/xbt/context.c
src/xbt/context_private.h

index d6d9afb..e8b5ce1 100644 (file)
@@ -84,15 +84,6 @@ typedef struct m_process {
 typedef struct m_process *m_process_t;
 /** @} */
 
 typedef struct m_process *m_process_t;
 /** @} */
 
-/** @brief Agent code
-    @ingroup m_datatypes_management 
-    The code of an agent is a m_process_code_t, i.e. a function with no arguments 
-    returning no value.
-    \see m_process_management
-  @{ */
-typedef int(*m_process_code_t)(int argc,char *argv[]) ;
-/** @} */
-
 /* ********************************* Channel ******************************** */
 /** @brief Channel datatype  
     @ingroup m_datatypes_management 
 /* ********************************* Channel ******************************** */
 /** @brief Channel datatype  
     @ingroup m_datatypes_management 
index e593310..16f4e12 100644 (file)
@@ -22,8 +22,8 @@ XBT_PUBLIC(MSG_error_t) MSG_set_channel_number(int number);
 XBT_PUBLIC(int) MSG_get_channel_number(void);
 XBT_PUBLIC(MSG_error_t) MSG_main(void);
 XBT_PUBLIC(MSG_error_t) MSG_clean(void);
 XBT_PUBLIC(int) MSG_get_channel_number(void);
 XBT_PUBLIC(MSG_error_t) MSG_main(void);
 XBT_PUBLIC(MSG_error_t) MSG_clean(void);
-XBT_PUBLIC(void) MSG_function_register(const char *name, m_process_code_t code);
-XBT_PUBLIC(m_process_code_t) MSG_get_registered_function(const char *name);
+XBT_PUBLIC(void) MSG_function_register(const char *name, xbt_main_func_t code);
+XBT_PUBLIC(xbt_main_func_t) MSG_get_registered_function(const char *name);
 XBT_PUBLIC(void) MSG_launch_application(const char *file);
 XBT_PUBLIC(void) MSG_paje_output(const char *filename);
 
 XBT_PUBLIC(void) MSG_launch_application(const char *file);
 XBT_PUBLIC(void) MSG_paje_output(const char *filename);
 
@@ -47,10 +47,10 @@ XBT_PUBLIC(m_host_t *)MSG_get_host_table(void);
 
 /************************** Process handling *********************************/
 XBT_PUBLIC(m_process_t) MSG_process_create(const char *name,
 
 /************************** Process handling *********************************/
 XBT_PUBLIC(m_process_t) MSG_process_create(const char *name,
-                              m_process_code_t code, void *data,
+                              xbt_main_func_t code, void *data,
                               m_host_t host);
 XBT_PUBLIC(m_process_t) MSG_process_create_with_arguments(const char *name,
                               m_host_t host);
 XBT_PUBLIC(m_process_t) MSG_process_create_with_arguments(const char *name,
-                                             m_process_code_t code, void *data,
+                                             xbt_main_func_t code, void *data,
                                              m_host_t host, int argc, char **argv);
 XBT_PUBLIC(void) MSG_process_kill(m_process_t process);
 XBT_PUBLIC(int) MSG_process_killall(int reset_PIDs);
                                              m_host_t host, int argc, char **argv);
 XBT_PUBLIC(void) MSG_process_kill(m_process_t process);
 XBT_PUBLIC(int) MSG_process_killall(int reset_PIDs);
index 0994fef..801a695 100644 (file)
@@ -26,6 +26,7 @@ SG_BEGIN_DECL()
 
    typedef int  (int_f_pvoid_pvoid_t) (void*,void*);
 
 
    typedef int  (int_f_pvoid_pvoid_t) (void*,void*);
 
+   typedef int  (*xbt_main_func_t)(int argc, char *argv[]);
 SG_END_DECL()
 
 #endif /* XBT_FUNCTION_TYPE_H */
 SG_END_DECL()
 
 #endif /* XBT_FUNCTION_TYPE_H */
index aef58b4..65b30f9 100644 (file)
@@ -22,7 +22,6 @@ const char *e_gras_msg_kind_names[e_gras_msg_kind_count]=
   {"UNKNOWN","ONEWAY","RPC call","RPC answer","RPC error"};
 
 
   {"UNKNOWN","ONEWAY","RPC call","RPC answer","RPC error"};
 
 
-
 /** \brief Waits for a message to come in over a given socket. 
  *
  * @param timeout: How long should we wait for this message.
 /** \brief Waits for a message to come in over a given socket. 
  *
  * @param timeout: How long should we wait for this message.
index d4e0779..65ac32f 100644 (file)
@@ -175,8 +175,8 @@ return SIMIX_global_init(argc,argv);
 void gras_create_environment(const char *file) {
 return SIMIX_create_environment(file);
 }
 void gras_create_environment(const char *file) {
 return SIMIX_create_environment(file);
 }
-void gras_function_register(const char *name, void *code) {
-return SIMIX_function_register(name, (smx_process_code_t)code);
+void gras_function_register(const char *name, xbt_main_func_t code) {
+   return SIMIX_function_register(name, code);
 }
 void gras_main() {
        smx_cond_t cond = NULL;
 }
 void gras_main() {
        smx_cond_t cond = NULL;
index dfcc5a9..93ddc97 100644 (file)
@@ -90,14 +90,5 @@ typedef struct s_smx_process {
 typedef struct s_smx_process *smx_process_t;
 /** @} */
 
 typedef struct s_smx_process *smx_process_t;
 /** @} */
 
-/** @brief Agent code
-    @ingroup m_datatypes_management 
-    The code of an agent is a m_process_code_t, i.e. a function with no arguments 
-    returning no value.
-    \see m_process_management
-  @{ */
-typedef int(*smx_process_code_t)(int argc,char *argv[]) ;
-/** @} */
-
 SG_END_DECL()
 #endif
 SG_END_DECL()
 #endif
index d7be651..4fefabb 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "xbt/misc.h"
 #include "xbt/fifo.h"
 
 #include "xbt/misc.h"
 #include "xbt/fifo.h"
+#include "xbt/function_types.h"
 #include "simix/datatypes.h"
 #include "surf/surf.h"
 
 #include "simix/datatypes.h"
 #include "surf/surf.h"
 
@@ -21,8 +22,8 @@ SG_BEGIN_DECL()
 XBT_PUBLIC(void) SIMIX_config(const char *name, va_list pa);
 XBT_PUBLIC(void) SIMIX_global_init(int *argc, char **argv);
 XBT_PUBLIC(void) SIMIX_clean(void);
 XBT_PUBLIC(void) SIMIX_config(const char *name, va_list pa);
 XBT_PUBLIC(void) SIMIX_global_init(int *argc, char **argv);
 XBT_PUBLIC(void) SIMIX_clean(void);
-XBT_PUBLIC(void) SIMIX_function_register(const char *name, smx_process_code_t code);
-XBT_PUBLIC(smx_process_code_t) SIMIX_get_registered_function(const char *name);
+XBT_PUBLIC(void) SIMIX_function_register(const char *name, xbt_main_func_t code);
+XBT_PUBLIC(xbt_main_func_t) SIMIX_get_registered_function(const char *name);
 
 XBT_PUBLIC(void) SIMIX_launch_application(const char *file);
 
 
 XBT_PUBLIC(void) SIMIX_launch_application(const char *file);
 
@@ -38,7 +39,7 @@ XBT_PUBLIC(void) __SIMIX_main(void);
 
 /* User create and kill process, the function must accept the folling parameters:
  * const char *name: a name for the object. It is for user-level information and can be NULL
 
 /* User create and kill process, the function must accept the folling parameters:
  * const char *name: a name for the object. It is for user-level information and can be NULL
- * smx_process_code_t code: is a function describing the behavior of the agent
+ * xbt_main_func_t code: is a function describing the behavior of the agent
  * void *data: data a pointer to any data one may want to attach to the new object.
  * smx_host_t host: the location where the new agent is executed
  * int argc, char **argv: parameters passed to code
  * void *data: data a pointer to any data one may want to attach to the new object.
  * smx_host_t host: the location where the new agent is executed
  * int argc, char **argv: parameters passed to code
@@ -68,7 +69,7 @@ XBT_PUBLIC(int) SIMIX_host_get_state(smx_host_t host);
 
 /************************** Process handling *********************************/
 XBT_PUBLIC(smx_process_t) SIMIX_process_create(const char *name,
 
 /************************** Process handling *********************************/
 XBT_PUBLIC(smx_process_t) SIMIX_process_create(const char *name,
-                                              smx_process_code_t code, void *data,
+                                              xbt_main_func_t code, void *data,
                                               const char * hostname, int argc, char **argv,
                                               void * clean_process_function);
 
                                               const char * hostname, int argc, char **argv,
                                               void * clean_process_function);
 
index a032454..6a7aa6f 100644 (file)
 
   /** @brief A context */
   typedef struct s_xbt_context *xbt_context_t;
 
   /** @brief A context */
   typedef struct s_xbt_context *xbt_context_t;
-  /** @brief A context function */
-  typedef int(*xbt_context_function_t)(int argc, char *argv[]);
 
 /* @}*/
 
 void xbt_context_empty_trash(void);
 
 /* @}*/
 
 void xbt_context_empty_trash(void);
-XBT_PUBLIC(xbt_context_t) xbt_context_new(xbt_context_function_t code, 
+XBT_PUBLIC(xbt_context_t) xbt_context_new(xbt_main_func_t code,
                                          void_f_pvoid_t startup_func, void *startup_arg,
                                          void_f_pvoid_t cleanup_func, void *cleanup_arg,
                                          int argc, char *argv[]);
                                          void_f_pvoid_t startup_func, void *startup_arg,
                                          void_f_pvoid_t cleanup_func, void *cleanup_arg,
                                          int argc, char *argv[]);
index 4934ce7..9ca20d8 100644 (file)
@@ -270,7 +270,7 @@ xbt_context_start(xbt_context_t context)  {
 
 
 xbt_context_t 
 
 
 xbt_context_t 
-xbt_context_new(xbt_context_function_t code, 
+xbt_context_new(xbt_main_func_t code, 
                void_f_pvoid_t startup_func, void *startup_arg,
                void_f_pvoid_t cleanup_func, void *cleanup_arg,
                int argc, char *argv[]) {
                void_f_pvoid_t startup_func, void *startup_arg,
                void_f_pvoid_t cleanup_func, void *cleanup_arg,
                int argc, char *argv[]) {
index 516834e..97308f2 100644 (file)
@@ -39,32 +39,28 @@ void MSG_launch_application(const char *file)
 }
 
 /** \ingroup msg_easier_life
 }
 
 /** \ingroup msg_easier_life
- * \brief Registers a #m_process_code_t code in a global table.
+ * \brief Registers the main function of an agent in a global table.
  *
  * Registers a code function in a global table. 
  * This table is then used by #MSG_launch_application. 
  * \param name the reference name of the function.
  *
  * Registers a code function in a global table. 
  * This table is then used by #MSG_launch_application. 
  * \param name the reference name of the function.
- * \param code the function
+ * \param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char *argv[]))
  */
  */
-void MSG_function_register(const char *name,m_process_code_t code)
+void MSG_function_register(const char *name,xbt_main_func_t code)
 {
        SIMIX_function_register(name, code);
        return;
 }
 
 /** \ingroup msg_easier_life
 {
        SIMIX_function_register(name, code);
        return;
 }
 
 /** \ingroup msg_easier_life
- * \brief Registers a #m_process_t code in a global table.
+ * \brief Retrieves a registered main function
  *
  * Registers a code function in a global table. 
  * This table is then used by #MSG_launch_application. 
  * \param name the reference name of the function.
  */
  *
  * Registers a code function in a global table. 
  * This table is then used by #MSG_launch_application. 
  * \param name the reference name of the function.
  */
-m_process_code_t MSG_get_registered_function(const char *name)
+xbt_main_func_t MSG_get_registered_function(const char *name)
 {
 {
-  m_process_code_t code = NULL;
-
-       code = (m_process_code_t)SIMIX_get_registered_function(name);
-
-  return code;
+  return SIMIX_get_registered_function(name);
 }
 
 }
 
index b53bb5a..586e756 100644 (file)
@@ -36,7 +36,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_process, msg, "Logging specific to MSG (proc
  * \sa MSG_process_create_with_arguments
  */
 m_process_t MSG_process_create(const char *name,
  * \sa MSG_process_create_with_arguments
  */
 m_process_t MSG_process_create(const char *name,
-                              m_process_code_t code, void *data,
+                              xbt_main_func_t code, void *data,
                               m_host_t host)
 {
   return MSG_process_create_with_arguments(name, code, data, host, -1, NULL);
                               m_host_t host)
 {
   return MSG_process_create_with_arguments(name, code, data, host, -1, NULL);
@@ -85,7 +85,7 @@ void __MSG_process_cleanup(void *arg)
 
 
 m_process_t __MSG_process_create_with_arguments(const char *name,
 
 
 m_process_t __MSG_process_create_with_arguments(const char *name,
-                                             m_process_code_t code, void *data,
+                                             xbt_main_func_t code, void *data,
                                              char * hostname, int argc, char **argv)
 {
        m_host_t host = MSG_get_host_by_name(hostname);
                                              char * hostname, int argc, char **argv)
 {
        m_host_t host = MSG_get_host_by_name(hostname);
@@ -93,7 +93,7 @@ m_process_t __MSG_process_create_with_arguments(const char *name,
 }
 
 m_process_t MSG_process_create_with_arguments(const char *name,
 }
 
 m_process_t MSG_process_create_with_arguments(const char *name,
-                                             m_process_code_t code, void *data,
+                                             xbt_main_func_t code, void *data,
                                              m_host_t host, int argc, char **argv)
 {
   simdata_process_t simdata = xbt_new0(s_simdata_process_t,1);
                                              m_host_t host, int argc, char **argv)
 {
   simdata_process_t simdata = xbt_new0(s_simdata_process_t,1);
@@ -106,7 +106,7 @@ m_process_t MSG_process_create_with_arguments(const char *name,
   simdata->m_host = host;
   simdata->argc = argc;
   simdata->argv = argv;
   simdata->m_host = host;
   simdata->argc = argc;
   simdata->argv = argv;
-  simdata->s_process = SIMIX_process_create(name, (smx_process_code_t)code, 
+  simdata->s_process = SIMIX_process_create(name, code, 
                                            (void*)process, host->name, argc, argv, 
                                            __MSG_process_cleanup );
 
                                            (void*)process, host->name, argc, argv, 
                                            __MSG_process_cleanup );
 
index 98cd856..459a10b 100644 (file)
@@ -69,7 +69,7 @@ typedef struct simdata_process {
 
 typedef struct process_arg {
   const char *name;
 
 typedef struct process_arg {
   const char *name;
-  m_process_code_t code;
+  xbt_main_func_t code;
   void *data;
   m_host_t m_host;
   int argc;
   void *data;
   m_host_t m_host;
   int argc;
@@ -106,7 +106,7 @@ void __MSG_display_process_status(void);
 
 void __MSG_process_cleanup(void *arg);
 m_process_t __MSG_process_create_with_arguments(const char *name,
 
 void __MSG_process_cleanup(void *arg);
 m_process_t __MSG_process_create_with_arguments(const char *name,
-                                               m_process_code_t code, void *data,
+                                               xbt_main_func_t code, void *data,
                                                char * hostname, int argc, char **argv);
 
 
                                                char * hostname, int argc, char **argv);
 
 
index 91252f0..1c7ac7d 100644 (file)
@@ -17,6 +17,7 @@
 #include "xbt/dict.h"
 #include "xbt/context.h"
 #include "xbt/config.h"
 #include "xbt/dict.h"
 #include "xbt/context.h"
 #include "xbt/config.h"
+#include "xbt/function_types.h"
 
 /******************************* Datatypes **********************************/
 
 
 /******************************* Datatypes **********************************/
 
@@ -58,7 +59,7 @@ typedef struct s_smx_simdata_process {
 
 typedef struct s_smx_process_arg {
   const char *name;
 
 typedef struct s_smx_process_arg {
   const char *name;
-  smx_process_code_t code;
+  xbt_main_func_t code;
   void *data;
   char *hostname;
   int argc;
   void *data;
   char *hostname;
   int argc;
index 9fa7617..afdc09d 100644 (file)
@@ -16,7 +16,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_deployment, simix,
                                "Logging specific to SIMIX (deployment)");
 static int parse_argc = -1 ;
 static char **parse_argv = NULL;
                                "Logging specific to SIMIX (deployment)");
 static int parse_argc = -1 ;
 static char **parse_argv = NULL;
-static smx_process_code_t parse_code = NULL;
+static xbt_main_func_t parse_code = NULL;
 static char * parse_host = NULL;
 static double start_time = 0.0;
 static double kill_time = -1.0;
 static char * parse_host = NULL;
 static double start_time = 0.0;
 static double kill_time = -1.0;
@@ -116,7 +116,7 @@ void SIMIX_launch_application(const char *file)
  * \param name the reference name of the function.
  * \param code the function
  */
  * \param name the reference name of the function.
  * \param code the function
  */
-void SIMIX_function_register(const char *name,smx_process_code_t code)
+void SIMIX_function_register(const char *name,xbt_main_func_t code)
 {
   xbt_assert0(simix_global,"SIMIX_global_init has to be called before SIMIX_function_register.");
 
 {
   xbt_assert0(simix_global,"SIMIX_global_init has to be called before SIMIX_function_register.");
 
@@ -131,14 +131,10 @@ void SIMIX_function_register(const char *name,smx_process_code_t code)
  * \param name the reference name of the function.
  * \return The #smx_process_t or NULL.
  */
  * \param name the reference name of the function.
  * \return The #smx_process_t or NULL.
  */
-smx_process_code_t SIMIX_get_registered_function(const char *name)
+xbt_main_func_t SIMIX_get_registered_function(const char *name)
 {
 {
-  smx_process_code_t code = NULL;
-
   xbt_assert0(simix_global,"SIMIX_global_init has to be called before SIMIX_get_registered_function.");
 
   xbt_assert0(simix_global,"SIMIX_global_init has to be called before SIMIX_get_registered_function.");
 
-  code = xbt_dict_get_or_null(simix_global->registered_functions,name);
-
-  return code;
+  return xbt_dict_get_or_null(simix_global->registered_functions,name);
 }
 
 }
 
index efbf7ea..9b9fc84 100644 (file)
@@ -50,7 +50,7 @@ void SIMIX_process_cleanup(void *arg)
  * \return The new corresponding object.
  */
 smx_process_t SIMIX_process_create(const char *name,
  * \return The new corresponding object.
  */
 smx_process_t SIMIX_process_create(const char *name,
-                                  smx_process_code_t code, void *data,
+                                  xbt_main_func_t code, void *data,
                                   const char * hostname, int argc, char **argv, 
                                   void * clean_process_function)
 {
                                   const char * hostname, int argc, char **argv, 
                                   void * clean_process_function)
 {
index 25cc9e6..d332492 100644 (file)
@@ -315,7 +315,7 @@ void xbt_context_start(xbt_context_t context)
  * \param argc first argument of function \a code
  * \param argv seconde argument of function \a code
  */
  * \param argc first argument of function \a code
  * \param argv seconde argument of function \a code
  */
-xbt_context_t xbt_context_new(xbt_context_function_t code, 
+xbt_context_t xbt_context_new(xbt_main_func_t code, 
                              void_f_pvoid_t startup_func, void *startup_arg,
                              void_f_pvoid_t cleanup_func, void *cleanup_arg,
                              int argc, char *argv[])
                              void_f_pvoid_t startup_func, void *startup_arg,
                              void_f_pvoid_t cleanup_func, void *cleanup_arg,
                              int argc, char *argv[])
index 2cf2a2e..85d35e3 100644 (file)
@@ -53,7 +53,7 @@ typedef struct s_xbt_context {
 #endif
 
        /* What to run */
 #endif
 
        /* What to run */
-       xbt_context_function_t code;    /* the scheduled fonction           */
+       xbt_main_func_t code;   /* the scheduled fonction           */
        int argc;
        char **argv;
    
        int argc;
        char **argv;