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
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);
/************************** 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_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);
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 */
{"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.
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;
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
#include "xbt/misc.h"
#include "xbt/fifo.h"
+#include "xbt/function_types.h"
#include "simix/datatypes.h"
#include "surf/surf.h"
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);
/* 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
/************************** 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);
/** @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);
-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[]);
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[]) {
}
/** \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.
- * \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
- * \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.
*/
-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);
}
* \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_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);
}
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);
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 );
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 __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);
#include "xbt/dict.h"
#include "xbt/context.h"
#include "xbt/config.h"
+#include "xbt/function_types.h"
/******************************* Datatypes **********************************/
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;
"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;
* \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.");
* \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.");
- code = xbt_dict_get_or_null(simix_global->registered_functions,name);
-
- return code;
+ return xbt_dict_get_or_null(simix_global->registered_functions,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)
{
* \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[])
#endif
/* What to run */
- xbt_context_function_t code; /* the scheduled fonction */
+ xbt_main_func_t code; /* the scheduled fonction */
int argc;
char **argv;