/*OUT*/ double *sec, double *bw);
XBT_PUBLIC(void) amok_bw_request(const char *from_name,
- unsigned int from_port, const char *to_name,
- unsigned int to_port,
+ unsigned int from_port,
+ const char *to_name, unsigned int to_port,
unsigned long int buf_size,
unsigned long int msg_size,
unsigned long int msg_amount,
XBT_PUBLIC(double *) amok_bw_matrix(xbt_dynar_t hosts, /* dynar of xbt_host_t */
int buf_size_bw, int msg_size_bw,
- int msg_amount_bw, double min_duration);
+ int msg_amount_bw,
+ double min_duration);
/* ***************************************************************************
* Link saturation
unsigned int to_port,
unsigned int msg_size,
double duration,
- /*out */ double *elapsed, double *bw);
+ /*out */ double *elapsed,
+ double *bw);
XBT_PUBLIC(void) amok_bw_saturate_stop(const char *from_name,
unsigned int from_port,
/** @} */
-#endif /* AMOK_BANDWIDTH_H */
+#endif /* AMOK_BANDWIDTH_H */
XBT_PUBLIC(void) amok_base_exit(void);
-#endif /* AMOK_BASE_H */
+#endif /* AMOK_BASE_H */
/** @} */
-#endif /* AMOK_peer_MANAGEMENT_H */
+#endif /* AMOK_peer_MANAGEMENT_H */
XBT_PUBLIC(void) gras_init(int *argc, char **argv);
XBT_PUBLIC(void) gras_exit(void);
-#endif /* GRAS_H */
+#endif /* GRAS_H */
*/
/* @{ */
/** @brief Opaque type describing a type description. */
- typedef struct s_gras_datadesc_type *gras_datadesc_type_t;
+typedef struct s_gras_datadesc_type *gras_datadesc_type_t;
/** \brief Search a type description from its name */
XBT_PUBLIC(gras_datadesc_type_t) gras_datadesc_by_name(const char *name);
/* @} */
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_parse(const char *name, const char *C_statement);
+ gras_datadesc_parse(const char *name, const char *C_statement);
/** @defgroup GRAS_dd_manual Simple manual data description
* @ingroup GRAS_dd
/** \brief Opaque type describing a type description callback persistant state. */
- typedef struct s_gras_cbps *gras_cbps_t;
+typedef struct s_gras_cbps *gras_cbps_t;
/* callbacks prototypes */
/** \brief Prototype of type callbacks returning nothing. */
- typedef void (*gras_datadesc_type_cb_void_t) (gras_datadesc_type_t
- typedesc, gras_cbps_t vars,
- void *data);
+typedef void (*gras_datadesc_type_cb_void_t) (gras_datadesc_type_t
+ typedesc, gras_cbps_t vars,
+ void *data);
/** \brief Prototype of type callbacks returning an int. */
- typedef int (*gras_datadesc_type_cb_int_t) (gras_datadesc_type_t
- typedesc, gras_cbps_t vars,
- void *data);
+typedef int (*gras_datadesc_type_cb_int_t) (gras_datadesc_type_t
+ typedesc, gras_cbps_t vars,
+ void *data);
/** \brief Prototype of type callbacks selecting a type. */
- typedef
+typedef
+
-
- gras_datadesc_type_t(*gras_datadesc_selector_t) (gras_datadesc_type_t
- typedesc,
- gras_cbps_t vars,
- void *data);
+gras_datadesc_type_t(*gras_datadesc_selector_t) (gras_datadesc_type_t
+ typedesc,
+ gras_cbps_t vars,
+ void *data);
/******************************************
******************************************/
XBT_PUBLIC(gras_datadesc_type_t) gras_datadesc_struct(const char *name);
-XBT_PUBLIC(void) gras_datadesc_struct_append(gras_datadesc_type_t struct_type,
- const char *name,
- gras_datadesc_type_t field_type);
-XBT_PUBLIC(void) gras_datadesc_struct_close(gras_datadesc_type_t struct_type);
+XBT_PUBLIC(void) gras_datadesc_struct_append(gras_datadesc_type_t
+ struct_type, const char *name,
+ gras_datadesc_type_t
+ field_type);
+XBT_PUBLIC(void) gras_datadesc_struct_close(gras_datadesc_type_t
+ struct_type);
XBT_PUBLIC(gras_datadesc_type_t) gras_datadesc_union(const char *name,
gras_datadesc_type_cb_int_t
selector);
-XBT_PUBLIC(void) gras_datadesc_union_append(gras_datadesc_type_t union_type,
- const char *name,
- gras_datadesc_type_t field_type);
-XBT_PUBLIC(void) gras_datadesc_union_close(gras_datadesc_type_t union_type);
+XBT_PUBLIC(void) gras_datadesc_union_append(gras_datadesc_type_t
+ union_type, const char *name,
+ gras_datadesc_type_t
+ field_type);
+XBT_PUBLIC(void) gras_datadesc_union_close(gras_datadesc_type_t
+ union_type);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_ref(const char *name, gras_datadesc_type_t referenced_type);
+ gras_datadesc_ref(const char *name, gras_datadesc_type_t referenced_type);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_copy(const char *name, gras_datadesc_type_t copied_type);
+ gras_datadesc_copy(const char *name, gras_datadesc_type_t copied_type);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_ref_generic(const char *name,
+ gras_datadesc_ref_generic(const char *name,
gras_datadesc_selector_t selector);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_array_fixed(const char *name,
+ gras_datadesc_array_fixed(const char *name,
gras_datadesc_type_t element_type,
long int fixed_size);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_array_dyn(const char *name,
+ gras_datadesc_array_dyn(const char *name,
gras_datadesc_type_t element_type,
gras_datadesc_type_cb_int_t dynamic_size);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_ref_pop_arr(gras_datadesc_type_t element_type);
+ gras_datadesc_ref_pop_arr(gras_datadesc_type_t element_type);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_dynar(gras_datadesc_type_t elm_t, void_f_pvoid_t free_func);
+ gras_datadesc_dynar(gras_datadesc_type_t elm_t, void_f_pvoid_t free_func);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_matrix(gras_datadesc_type_t elm_t, void_f_pvoid_t const free_f);
+ gras_datadesc_matrix(gras_datadesc_type_t elm_t,
+ void_f_pvoid_t const free_f);
/*********************************
* Change stuff within datadescs *
XBT_PUBLIC(void) gras_datadesc_cb_field_push(gras_datadesc_type_t type,
const char *field_name);
/** \brief Add a pre-send callback to the given field resulting in its value multiplied to any previously pushed value and then pushed back */
-XBT_PUBLIC(void) gras_datadesc_cb_field_push_multiplier(gras_datadesc_type_t
- type, const char
- *field_name);
+XBT_PUBLIC(void)
+gras_datadesc_cb_field_push_multiplier(gras_datadesc_type_t type,
+ const char
+ *field_name);
/******************************
* Get stuff within datadescs *
XBT_PUBLIC(void) gras_datadesc_cb_push_ulint(gras_datadesc_type_t typedesc,
gras_cbps_t vars, void *data);
-XBT_PUBLIC(void) gras_datadesc_cb_push_int_mult(gras_datadesc_type_t typedesc,
- gras_cbps_t vars, void *data);
+XBT_PUBLIC(void) gras_datadesc_cb_push_int_mult(gras_datadesc_type_t
+ typedesc, gras_cbps_t vars,
+ void *data);
XBT_PUBLIC(void) gras_datadesc_cb_push_uint_mult(gras_datadesc_type_t
- typedesc, gras_cbps_t vars,
+ typedesc,
+ gras_cbps_t vars,
void *data);
XBT_PUBLIC(void) gras_datadesc_cb_push_lint_mult(gras_datadesc_type_t
- typedesc, gras_cbps_t vars,
+ typedesc,
+ gras_cbps_t vars,
void *data);
XBT_PUBLIC(void) gras_datadesc_cb_push_ulint_mult(gras_datadesc_type_t
- typedesc, gras_cbps_t vars,
+ typedesc,
+ gras_cbps_t vars,
void *data);
/**
* Basic types we can embeed in DataDescriptors.
*/
- typedef enum
- { CHAR_TYPE, DOUBLE_TYPE, FLOAT_TYPE, INT_TYPE, LONG_TYPE, SHORT_TYPE,
- UNSIGNED_INT_TYPE, UNSIGNED_LONG_TYPE, UNSIGNED_SHORT_TYPE, STRUCT_TYPE
- } DataTypes;
+typedef enum
+ { CHAR_TYPE, DOUBLE_TYPE, FLOAT_TYPE, INT_TYPE, LONG_TYPE, SHORT_TYPE,
+ UNSIGNED_INT_TYPE, UNSIGNED_LONG_TYPE, UNSIGNED_SHORT_TYPE, STRUCT_TYPE
+} DataTypes;
#define SIMPLE_TYPE_COUNT 9
/** \brief Describe a collection of data.
** padding bytes the compiler adds to the end of the structure.
*/
- typedef struct DataDescriptorStruct {
- DataTypes type;
- size_t repetitions;
- size_t offset;
- /*@null@ */ struct DataDescriptorStruct *members;
- size_t length;
- size_t tailPadding;
- } DataDescriptor;
+typedef struct DataDescriptorStruct {
+ DataTypes type;
+ size_t repetitions;
+ size_t offset;
+ /*@null@ */ struct DataDescriptorStruct *members;
+ size_t length;
+ size_t tailPadding;
+} DataDescriptor;
/** DataDescriptor for an array */
#define SIMPLE_DATA(type,repetitions) \
{type, repetitions, 0, NULL, 0, 0}
sizeof(memberType) * repetitions
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_import_nws(const char *name,
- const DataDescriptor * desc, unsigned long howmany);
+ gras_datadesc_import_nws(const char *name,
+ const DataDescriptor * desc,
+ unsigned long howmany);
SG_END_DECL()
-#endif /* GRAS_DATADESC_H */
+#endif /* GRAS_DATADESC_H */
/** @} */
SG_END_DECL()
-#endif /* GRAS_COND_H */
+#endif /* GRAS_COND_H */
*/
/** @{ */
/** \brief Opaque type */
- typedef struct s_gras_msgtype *gras_msgtype_t;
+typedef struct s_gras_msgtype *gras_msgtype_t;
XBT_PUBLIC(void) gras_msgtype_declare(const char *name,
gras_datadesc_type_t payload);
XBT_PUBLIC(gras_msgtype_t) gras_msgtype_by_namev(const char *name,
short int version);
XBT_PUBLIC(gras_msgtype_t) gras_msgtype_by_id(int id);
-XBT_PUBLIC(const char*) gras_msgtype_get_name(gras_msgtype_t type);
+XBT_PUBLIC(const char *) gras_msgtype_get_name(gras_msgtype_t type);
XBT_PUBLIC(void) gras_msgtype_dumpall(void);
*/
/** \brief Context of callbacks (opaque structure, created by the middleware only, never by user) */
- typedef struct s_gras_msg_cb_ctx *gras_msg_cb_ctx_t;
+typedef struct s_gras_msg_cb_ctx *gras_msg_cb_ctx_t;
XBT_PUBLIC(void) gras_msg_cb_ctx_free(gras_msg_cb_ctx_t ctx);
XBT_PUBLIC(gras_socket_t) gras_msg_cb_ctx_from(gras_msg_cb_ctx_t ctx);
*
* If the callback accepts the message, it should free it after use.
*/
- typedef int (*gras_msg_cb_t) (gras_msg_cb_ctx_t ctx, void *payload);
+typedef int (*gras_msg_cb_t) (gras_msg_cb_ctx_t ctx, void *payload);
/**
* @brief Bind the given callback to the given message type (described by its name)
*/
#define gras_cb_unregister(msgtype_name, cb) gras_cb_unregister_(gras_msgtype_by_name(msgtype_name),cb)
-XBT_PUBLIC(void) gras_cb_register_(gras_msgtype_t msgtype, gras_msg_cb_t cb);
+XBT_PUBLIC(void) gras_cb_register_(gras_msgtype_t msgtype,
+ gras_msg_cb_t cb);
XBT_PUBLIC(void) gras_cb_unregister_(gras_msgtype_t msgtype,
gras_msg_cb_t cb);
* @hideinitializer
*/
#define gras_msg_rpc_async_call(server,timeout,msg,req) gras_msg_rpc_async_call_(server,timeout,gras_msgtype_by_name(msg),req)
- gras_msg_rpc_async_call_(gras_socket_t server,
+ gras_msg_rpc_async_call_(gras_socket_t server,
double timeOut,
gras_msgtype_t msgtype, void *request);
-XBT_PUBLIC(void) gras_msg_rpc_async_wait(gras_msg_cb_ctx_t ctx, void *answer);
+XBT_PUBLIC(void) gras_msg_rpc_async_wait(gras_msg_cb_ctx_t ctx,
+ void *answer);
/* server side */
XBT_PUBLIC(void) gras_msg_rpcreturn(double timeOut, gras_msg_cb_ctx_t ctx,
/** @{ */
/** @brief Message kind (internal enum) */
- typedef enum {
- e_gras_msg_kind_unknown = 0,
+typedef enum {
+ e_gras_msg_kind_unknown = 0,
- e_gras_msg_kind_oneway = 1,
+ e_gras_msg_kind_oneway = 1,
/**< good old regular messages */
- e_gras_msg_kind_rpccall = 2,
+ e_gras_msg_kind_rpccall = 2,
/**< RPC request */
- /* HACK: e_gras_msg_kind_rpccall also designate RPC message *type* in
- msgtype_t, not only in msg_t */
- e_gras_msg_kind_rpcanswer = 3,
+ /* HACK: e_gras_msg_kind_rpccall also designate RPC message *type* in
+ msgtype_t, not only in msg_t */
+ e_gras_msg_kind_rpcanswer = 3,
/**< RPC successful answer */
- e_gras_msg_kind_rpcerror = 4,
+ e_gras_msg_kind_rpcerror = 4,
/**< RPC failure on server (payload=exception); should not leak to user-space */
- /* future:
- call cancel, and others
- even after:
- forwarding request and other application level routing stuff
- group communication
- */
+ /* future:
+ call cancel, and others
+ even after:
+ forwarding request and other application level routing stuff
+ group communication
+ */
- e_gras_msg_kind_count = 5 /* sentinel, dont mess with */
- } e_gras_msg_kind_t;
+ e_gras_msg_kind_count = 5 /* sentinel, dont mess with */
+} e_gras_msg_kind_t;
/** @brief Message instance (internal struct) */
- typedef struct {
- gras_socket_t expe;
- e_gras_msg_kind_t kind;
- gras_msgtype_t type;
- unsigned long int ID;
- void *payl;
- int payl_size;
- } s_gras_msg_t, *gras_msg_t;
+typedef struct {
+ gras_socket_t expe;
+ e_gras_msg_kind_t kind;
+ gras_msgtype_t type;
+ unsigned long int ID;
+ void *payl;
+ int payl_size;
+} s_gras_msg_t, *gras_msg_t;
- typedef int (*gras_msg_filter_t) (gras_msg_t msg, void *ctx);
+typedef int (*gras_msg_filter_t) (gras_msg_t msg, void *ctx);
#define gras_msg_wait_ext(timeout, msg, expe, filter, fctx,got) gras_msg_wait_ext_(timeout, gras_msgtype_by_name(msg), expe, filter, fctx,got)
XBT_PUBLIC(void) gras_msg_wait_ext_(double timeout,
/* @} */
SG_END_DECL()
-#endif /* GRAS_MSG_H */
+#endif /* GRAS_MSG_H */
/* Functions module implementor should use */
XBT_PUBLIC(void) gras_module_add(const char *name, unsigned int data_size,
int *ID, void_f_void_t init_f,
- void_f_void_t exit_f, void_f_pvoid_t join_f,
+ void_f_void_t exit_f,
+ void_f_pvoid_t join_f,
void_f_pvoid_t leave_f);
XBT_PUBLIC(void *) gras_moddata_by_id(unsigned int ID);
-#endif /* GRAS_MODULE_H */
+#endif /* GRAS_MODULE_H */
SG_BEGIN_DECL()
- void gras_agent_spawn(const char *name, void *data, xbt_main_func_t code,
- int argc, char *argv[], xbt_dict_t properties);
+void gras_agent_spawn(const char *name, void *data, xbt_main_func_t code,
+ int argc, char *argv[], xbt_dict_t properties);
/****************************************************************************/
/* @} */
SG_END_DECL()
-#endif /* GRAS_PROCESS_H */
+#endif /* GRAS_PROCESS_H */
/** @} */
SG_END_DECL()
-#endif /* GRAS_TIMER_H */
+#endif /* GRAS_TIMER_H */
unsigned long int bufSize,
int measurement);
XBT_PUBLIC(gras_socket_t)
- gras_socket_server_range(unsigned short minport, unsigned short maxport,
+ gras_socket_server_range(unsigned short minport, unsigned short maxport,
unsigned long int buf_size, int measurement);
/* @}*/
/* @} */
-#endif /* GRAS_TRANSPORT_H */
+#endif /* GRAS_TRANSPORT_H */
/* Initialization of the simulation world. Do not call them in RL.
Indeed, do not call them at all. Let gras_stub_generator do it for you. */
- void gras_global_init(int *argc, char **argv);
- void gras_create_environment(const char *file);
- void gras_function_register(const char *name, xbt_main_func_t code);
- void gras_function_register_default(xbt_main_func_t code);
- void gras_launch_application(const char *file);
- void gras_load_environment_script(const char *file);
- void gras_clean(void);
- void gras_main(void);
+void gras_global_init(int *argc, char **argv);
+void gras_create_environment(const char *file);
+void gras_function_register(const char *name, xbt_main_func_t code);
+void gras_function_register_default(xbt_main_func_t code);
+void gras_launch_application(const char *file);
+void gras_load_environment_script(const char *file);
+void gras_clean(void);
+void gras_main(void);
/** @addtogroup GRAS_virtu
/** @} */
SG_END_DECL()
-#endif /* GRAS_VIRTU_H */
+#endif /* GRAS_VIRTU_H */
#define TRACE_ERROR_FILE_OPEN 401
#define TRACE_ERROR_START 500
-XBT_PUBLIC(int) TRACE_start (void);
-XBT_PUBLIC(int) TRACE_end (void);
-XBT_PUBLIC(int) TRACE_category (const char *category);
-XBT_PUBLIC(void) TRACE_define_type (const char *type, const char *parent_type, int final);
-XBT_PUBLIC(int) TRACE_create_category (const char *category, const char *type, const char *parent_category);
-XBT_PUBLIC(void) TRACE_msg_set_task_category (m_task_t task, const char *category);
-XBT_PUBLIC(void) TRACE_msg_set_process_category (m_process_t process, const char *category);
-XBT_PUBLIC(void) TRACE_set_mask (int mask);
-XBT_PUBLIC(void) TRACE_user_host_variable (double time, const char *variable, double value, const char *what);
-XBT_PUBLIC(void) TRACE_user_link_variable (double time, const char *src, const char *dst, const char *variable, double value, const char *what);
-XBT_PUBLIC(void) TRACE_declare_mark (const char *mark_type);
-XBT_PUBLIC(void) TRACE_mark (const char *mark_type, const char *mark_value);
-XBT_PUBLIC(int) TRACE_smpi_set_category (const char *category);
-XBT_PUBLIC(void) TRACE_sd_set_task_category(SD_task_t task, const char *category);
+XBT_PUBLIC(int) TRACE_start(void);
+XBT_PUBLIC(int) TRACE_end(void);
+XBT_PUBLIC(int) TRACE_category(const char *category);
+XBT_PUBLIC(void) TRACE_define_type(const char *type,
+ const char *parent_type, int final);
+XBT_PUBLIC(int) TRACE_create_category(const char *category,
+ const char *type,
+ const char *parent_category);
+XBT_PUBLIC(void) TRACE_msg_set_task_category(m_task_t task,
+ const char *category);
+XBT_PUBLIC(void) TRACE_msg_set_process_category(m_process_t process,
+ const char *category);
+XBT_PUBLIC(void) TRACE_set_mask(int mask);
+XBT_PUBLIC(void) TRACE_user_host_variable(double time,
+ const char *variable,
+ double value, const char *what);
+XBT_PUBLIC(void) TRACE_user_link_variable(double time, const char *src,
+ const char *dst,
+ const char *variable,
+ double value, const char *what);
+XBT_PUBLIC(void) TRACE_declare_mark(const char *mark_type);
+XBT_PUBLIC(void) TRACE_mark(const char *mark_type, const char *mark_value);
+XBT_PUBLIC(int) TRACE_smpi_set_category(const char *category);
+XBT_PUBLIC(void) TRACE_sd_set_task_category(SD_task_t task,
+ const char *category);
#define TRACE_host_variable_declare(var) \
TRACE_user_host_variable(0,var,0,"declare");
#define TRACE_link_variable_sub(src,dst,var,value) \
TRACE_user_link_variable(MSG_get_clock(),src,dst,var,value,"sub");
-#else /* HAVE_TRACING */
+#else /* HAVE_TRACING */
#define TRACE_start()
#define TRACE_end()
#define TRACE_smpi_set_category(cat)
#define TRACE_sd_set_task_category(task,cat)
-#endif /* HAVE_TRACING */
+#endif /* HAVE_TRACING */
-#endif /* INSTR_H_ */
+#endif /* INSTR_H_ */
#include "xbt.h"
XBT_PUBLIC(void) MC_assert(int);
-XBT_PUBLIC(int) MC_random(int min, int max);
\ No newline at end of file
+XBT_PUBLIC(int) MC_random(int min, int max);
#ifndef MSG_DATATYPE_H
#define MSG_DATATYPE_H
#include "xbt/misc.h"
-#include "simgrid_config.h" // for HAVE_TRACING
+#include "simgrid_config.h" // for HAVE_TRACING
SG_BEGIN_DECL()
/* ******************************** Host ************************************ */
/** @defgroup m_datatypes_management_details Details on MSG datatypes
@ingroup m_datatypes_management*/
- typedef struct simdata_host *simdata_host_t;
+typedef struct simdata_host *simdata_host_t;
/** @brief Host datatype
@ingroup m_datatypes_management_details */
- typedef struct m_host {
- char *name; /**< @brief host name if any */
- simdata_host_t simdata; /**< @brief simulator data */
- void *data; /**< @brief user data */
- } s_m_host_t;
+typedef struct m_host {
+ char *name; /**< @brief host name if any */
+ simdata_host_t simdata; /**< @brief simulator data */
+ void *data; /**< @brief user data */
+} s_m_host_t;
/** @brief Host datatype
@ingroup m_datatypes_management
\see m_host_management
@{ */
- typedef struct m_host *m_host_t;
+typedef struct m_host *m_host_t;
/** @} */
/* ******************************** Task ************************************ */
- typedef struct simdata_task *simdata_task_t;
+typedef struct simdata_task *simdata_task_t;
/** @brief Task datatype
@ingroup m_datatypes_management_details */
- typedef struct m_task {
- char *name; /**< @brief task name if any */
- simdata_task_t simdata; /**< @brief simulator data */
- void *data; /**< @brief user data */
+typedef struct m_task {
+ char *name; /**< @brief task name if any */
+ simdata_task_t simdata; /**< @brief simulator data */
+ void *data; /**< @brief user data */
#ifdef HAVE_TRACING
- long long int counter; /* task unique identifier for instrumentation */
- char *category; /* task category for instrumentation */
+ long long int counter; /* task unique identifier for instrumentation */
+ char *category; /* task category for instrumentation */
#endif
- } s_m_task_t;
+} s_m_task_t;
/** @brief Task datatype
@ingroup m_datatypes_management
data</em>.
\see m_task_management
@{ */
- typedef struct m_task *m_task_t;
+typedef struct m_task *m_task_t;
/** \brief Default value for an uninitialized #m_task_t.
\ingroup m_datatypes_management
*/
#define MSG_TASK_UNINITIALIZED NULL
- typedef struct s_smx_comm *msg_comm_t;
+typedef struct s_smx_comm *msg_comm_t;
/** @} */
/* ****************************** Process *********************************** */
- typedef struct simdata_process *simdata_process_t;
+typedef struct simdata_process *simdata_process_t;
/** @brief Process datatype
@ingroup m_datatypes_management_details @{ */
- typedef struct m_process {
- char *name; /**< @brief process name if any */
- simdata_process_t simdata;
+typedef struct m_process {
+ char *name; /**< @brief process name if any */
+ simdata_process_t simdata;
/**< @brief simulator data */
- void *data; /**< @brief user data */
- char *category; /* process category for instrumentation */
- } s_m_process_t;
+ void *data; /**< @brief user data */
+ char *category; /* process category for instrumentation */
+} s_m_process_t;
/** @} */
/** @brief Agent datatype
@ingroup m_datatypes_management
data</em>, executing in a <em>location</em>.
\see m_process_management
@{ */
- typedef struct m_process *m_process_t;
+typedef struct m_process *m_process_t;
/** @} */
/* ********************************* Channel ******************************** */
port number does).
\see m_channel_management
@{ */
- typedef int m_channel_t;
+typedef int m_channel_t;
/** @} */
/* ******************************** Mailbox ************************************ */
- typedef struct s_msg_mailbox *msg_mailbox_t;
+typedef struct s_msg_mailbox *msg_mailbox_t;
/** @brief Mailbox datatype
@ingroup m_datatypes_management_details @{ */
- msg_mailbox_t MSG_mailbox_create(const char *alias);
- void MSG_mailbox_free(void *mailbox);
+msg_mailbox_t MSG_mailbox_create(const char *alias);
+void MSG_mailbox_free(void *mailbox);
/** @} */
/* ***************************** Error handling ***************************** */
/** @brief Error handling
@ingroup m_datatypes_management
- @{
-*/ /* Keep these code as binary values: java bindings manipulate | of these values */
- typedef enum {
- MSG_OK = 0, /**< @brief Everything is right. Keep on going this way ! */
- MSG_TIMEOUT=1, /**< @brief nothing good happened before the timer you provided elapsed */
- MSG_TRANSFER_FAILURE=2,/**< @brief There has been a problem during you task
+ @{
+*//* Keep these code as binary values: java bindings manipulate | of these values */
+typedef enum {
+ MSG_OK = 0, /**< @brief Everything is right. Keep on going this way ! */
+ MSG_TIMEOUT = 1, /**< @brief nothing good happened before the timer you provided elapsed */
+ MSG_TRANSFER_FAILURE = 2, /**< @brief There has been a problem during you task
transfer. Either the network is down or the remote host has been
shutdown. */
- MSG_HOST_FAILURE=4, /**< @brief System shutdown. The host on which you are
+ MSG_HOST_FAILURE = 4, /**< @brief System shutdown. The host on which you are
running has just been rebooted. Free your datastructures and
return now !*/
- MSG_TASK_CANCELLED=8, /**< @brief Canceled task. This task has been canceled by somebody!*/
- } MSG_error_t;
+ MSG_TASK_CANCELLED = 8, /**< @brief Canceled task. This task has been canceled by somebody!*/
+} MSG_error_t;
/** @} */
SG_END_DECL()
XBT_PUBLIC(xbt_main_func_t) MSG_get_registered_function(const char *name);
XBT_PUBLIC(void) MSG_launch_application(const char *file);
/*Bypass the parser */
-XBT_PUBLIC(void) MSG_set_function(const char* host_id,const char *function_name,xbt_dynar_t arguments);
+XBT_PUBLIC(void) MSG_set_function(const char *host_id,
+ const char *function_name,
+ xbt_dynar_t arguments);
XBT_PUBLIC(double) MSG_get_clock(void);
XBT_PUBLIC(unsigned long int) MSG_get_sent_msg(void);
/************************** Process handling *********************************/
XBT_PUBLIC(m_process_t) MSG_process_create(const char *name,
- xbt_main_func_t code, void *data,
- m_host_t host);
+ xbt_main_func_t code,
+ void *data, m_host_t host);
XBT_PUBLIC(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);
-XBT_PUBLIC(m_process_t) MSG_process_create_with_environment(const char *name,
+XBT_PUBLIC(m_process_t) MSG_process_create_with_environment(const char
+ *name,
xbt_main_func_t
- code, void *data,
+ code,
+ void *data,
m_host_t host,
int argc,
char **argv,
XBT_PUBLIC(MSG_error_t) MSG_process_change_host(m_host_t host);
XBT_PUBLIC(void *) MSG_process_get_data(m_process_t process);
-XBT_PUBLIC(MSG_error_t) MSG_process_set_data(m_process_t process, void *data);
+XBT_PUBLIC(MSG_error_t) MSG_process_set_data(m_process_t process,
+ void *data);
XBT_PUBLIC(m_host_t) MSG_process_get_host(m_process_t process);
XBT_PUBLIC(m_process_t) MSG_process_from_PID(int PID);
XBT_PUBLIC(int) MSG_process_get_PID(m_process_t process);
/*property handlers*/
XBT_PUBLIC(xbt_dict_t) MSG_process_get_properties(m_process_t process);
-XBT_PUBLIC(const char *) MSG_process_get_property_value(m_process_t process,
+XBT_PUBLIC(const char *) MSG_process_get_property_value(m_process_t
+ process,
const char *name);
XBT_PUBLIC(MSG_error_t) MSG_process_suspend(m_process_t process);
XBT_PUBLIC(m_task_t) MSG_task_create(const char *name,
double compute_duration,
double message_size, void *data);
-XBT_PUBLIC(m_task_t) MSG_parallel_task_create(const char *name, int host_nb,
+XBT_PUBLIC(m_task_t) MSG_parallel_task_create(const char *name,
+ int host_nb,
const m_host_t * host_list,
double *computation_amount,
double *communication_amount,
void *data);
XBT_PUBLIC(void *) MSG_task_get_data(m_task_t task);
-XBT_PUBLIC(void) MSG_task_set_data(m_task_t task,void*data);
+XBT_PUBLIC(void) MSG_task_set_data(m_task_t task, void *data);
XBT_PUBLIC(m_process_t) MSG_task_get_sender(m_task_t task);
XBT_PUBLIC(m_host_t) MSG_task_get_source(m_task_t task);
XBT_PUBLIC(const char *) MSG_task_get_name(m_task_t task);
-XBT_PUBLIC(void) MSG_task_set_name(m_task_t task,const char*name);
+XBT_PUBLIC(void) MSG_task_set_name(m_task_t task, const char *name);
XBT_PUBLIC(MSG_error_t) MSG_task_cancel(m_task_t task);
XBT_PUBLIC(MSG_error_t) MSG_task_destroy(m_task_t task);
XBT_PUBLIC(void) MSG_task_refcount_dec(m_task_t task);
XBT_PUBLIC(MSG_error_t) MSG_task_get_with_timeout(m_task_t * task,
m_channel_t channel,
double max_duration);
-XBT_PUBLIC(MSG_error_t) MSG_task_get_from_host(m_task_t * task, int channel,
- m_host_t host);
- MSG_error_t MSG_task_receive_from_host(m_task_t * task,
- const char *alias, m_host_t host);
+XBT_PUBLIC(MSG_error_t) MSG_task_get_from_host(m_task_t * task,
+ int channel, m_host_t host);
+MSG_error_t MSG_task_receive_from_host(m_task_t * task, const char *alias,
+ m_host_t host);
XBT_PUBLIC(MSG_error_t) MSG_task_get_ext(m_task_t * task, int channel,
- double max_duration, m_host_t host);
+ double max_duration,
+ m_host_t host);
XBT_PUBLIC(MSG_error_t) MSG_task_put(m_task_t task, m_host_t dest,
XBT_PUBLIC(MSG_error_t) MSG_get_errno(void);
XBT_PUBLIC(double) MSG_task_get_compute_duration(m_task_t task);
-XBT_PUBLIC(void) MSG_task_set_compute_duration(m_task_t task,double compute_duration);
+XBT_PUBLIC(void) MSG_task_set_compute_duration(m_task_t task,
+ double compute_duration);
XBT_PUBLIC(double) MSG_task_get_remaining_computation(m_task_t task);
XBT_PUBLIC(double) MSG_task_get_remaining_communication(m_task_t task);
-XBT_PUBLIC(int) MSG_task_is_latency_bounded(m_task_t task);
+XBT_PUBLIC(int) MSG_task_is_latency_bounded(m_task_t task);
XBT_PUBLIC(double) MSG_task_get_data_size(m_task_t task);
XBT_PUBLIC(MSG_error_t)
- MSG_task_receive_ext(m_task_t * task, const char *alias, double timeout,
+ MSG_task_receive_ext(m_task_t * task, const char *alias, double timeout,
m_host_t host);
XBT_PUBLIC(MSG_error_t)
- MSG_task_receive_with_timeout(m_task_t * task, const char *alias,
+ MSG_task_receive_with_timeout(m_task_t * task, const char *alias,
double timeout);
XBT_PUBLIC(MSG_error_t)
- MSG_task_receive(m_task_t * task, const char *alias);
-
-XBT_PUBLIC(msg_comm_t) MSG_task_isend(m_task_t task, const char *alias);
-XBT_PUBLIC(msg_comm_t) MSG_task_irecv(m_task_t * task, const char *alias);
-XBT_PUBLIC(int) MSG_comm_test(msg_comm_t comm);
-XBT_PUBLIC(void) MSG_comm_destroy(msg_comm_t comm);
-XBT_PUBLIC(MSG_error_t) MSG_comm_wait(msg_comm_t comm,double timeout);
-XBT_PUBLIC(void) MSG_comm_waitall(msg_comm_t *comm,int nb_elem, double timeout);
+ MSG_task_receive(m_task_t * task, const char *alias);
+
+XBT_PUBLIC(msg_comm_t) MSG_task_isend(m_task_t task, const char *alias);
+XBT_PUBLIC(msg_comm_t) MSG_task_irecv(m_task_t * task, const char *alias);
+XBT_PUBLIC(int) MSG_comm_test(msg_comm_t comm);
+XBT_PUBLIC(void) MSG_comm_destroy(msg_comm_t comm);
+XBT_PUBLIC(MSG_error_t) MSG_comm_wait(msg_comm_t comm, double timeout);
+XBT_PUBLIC(void) MSG_comm_waitall(msg_comm_t * comm, int nb_elem,
+ double timeout);
XBT_PUBLIC(int) MSG_comm_waitany(xbt_dynar_t comms);
XBT_PUBLIC(m_task_t) MSG_comm_get_task(msg_comm_t comm);
XBT_PUBLIC(int) MSG_task_listen(const char *alias);
-XBT_PUBLIC(int) MSG_task_listen_from_host(const char *alias, m_host_t host);
+XBT_PUBLIC(int) MSG_task_listen_from_host(const char *alias,
+ m_host_t host);
XBT_PUBLIC(MSG_error_t)
- MSG_alias_select_from(const char *alias, double timeout, int *PID);
+ MSG_alias_select_from(const char *alias, double timeout, int *PID);
XBT_PUBLIC(MSG_error_t)
- MSG_task_send_with_timeout(m_task_t task, const char *alias, double timeout);
+ MSG_task_send_with_timeout(m_task_t task, const char *alias,
+ double timeout);
XBT_PUBLIC(MSG_error_t)
- MSG_task_send(m_task_t task, const char *alias);
+ MSG_task_send(m_task_t task, const char *alias);
XBT_PUBLIC(MSG_error_t)
- MSG_task_send_bounded(m_task_t task, const char *alias, double rate);
+ MSG_task_send_bounded(m_task_t task, const char *alias, double rate);
XBT_PUBLIC(int) MSG_task_listen_from(const char *alias);
/************************** Task handling ************************************/
XBT_PUBLIC(MSG_error_t)
- MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t * task,
+ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t * task,
m_host_t host, double timeout);
XBT_PUBLIC(MSG_error_t)
- MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
+ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
double timeout);
/************************** Action handling **********************************/
- typedef void (*msg_action_fun) (xbt_dynar_t args);
+typedef void (*msg_action_fun) (xbt_dynar_t args);
XBT_PUBLIC(void) MSG_action_register(const char *action_name,
msg_action_fun function);
XBT_PUBLIC(void) MSG_action_unregister(const char *action_name);
- MSG_error_t MSG_action_trace_run(char *path);
+MSG_error_t MSG_action_trace_run(char *path);
#ifdef MSG_USE_DEPRECATED
@see SD_task_management */
typedef enum {
SD_NOT_SCHEDULED = 0, /**< @brief Initial state (not valid for SD_watch and SD_unwatch). */
- SD_SCHEDULABLE = 0x0001, /**< @brief A task becomes SD_READY as soon as its dependencies are satisfied */
+ SD_SCHEDULABLE = 0x0001, /**< @brief A task becomes SD_READY as soon as its dependencies are satisfied */
SD_SCHEDULED = 0x0002, /**< @brief A task becomes SD_SCHEDULED when you call function
SD_task_schedule. SD_simulate will execute it when it becomes SD_RUNNABLE. */
SD_RUNNABLE = 0x0004, /**< @brief A scheduled task becomes runnable is SD_simulate as soon as its dependencies are satisfied. */
@see SD_task_management */
typedef enum {
SD_TASK_NOT_TYPED = 0, /**< @no specified type */
- SD_TASK_COMM_E2E = 1, /**< @brief end to end communication */
- SD_TASK_COMP_SEQ = 2, /**< @brief sequential computation */
+ SD_TASK_COMM_E2E = 1, /**< @brief end to end communication */
+ SD_TASK_COMP_SEQ = 2, /**< @brief sequential computation */
} e_SD_task_kind_t;
workstation);
XBT_PUBLIC(const char *) SD_workstation_get_property_value(SD_workstation_t
workstation,
- const char *name);
+ const char
+ *name);
XBT_PUBLIC(const SD_link_t *) SD_route_get_list(SD_workstation_t src,
SD_workstation_t dst);
-XBT_PUBLIC(int) SD_route_get_size(SD_workstation_t src, SD_workstation_t dst);
+XBT_PUBLIC(int) SD_route_get_size(SD_workstation_t src,
+ SD_workstation_t dst);
XBT_PUBLIC(double) SD_workstation_get_power(SD_workstation_t workstation);
XBT_PUBLIC(double) SD_workstation_get_available_power(SD_workstation_t
workstation);
XBT_PUBLIC(e_SD_workstation_access_mode_t)
- SD_workstation_get_access_mode(SD_workstation_t workstation);
-XBT_PUBLIC(void) SD_workstation_set_access_mode(SD_workstation_t workstation,
+ SD_workstation_get_access_mode(SD_workstation_t workstation);
+XBT_PUBLIC(void) SD_workstation_set_access_mode(SD_workstation_t
+ workstation,
e_SD_workstation_access_mode_t
access_mode);
double
communication_amount);
-XBT_PUBLIC(SD_task_t) SD_workstation_get_current_task (SD_workstation_t workstation);
+XBT_PUBLIC(SD_task_t) SD_workstation_get_current_task(SD_workstation_t
+ workstation);
/** @} */
/************************** Task handling ************************************/
XBT_PUBLIC(double) SD_task_get_execution_time(SD_task_t task,
int workstation_nb,
const SD_workstation_t *
- workstation_list, const double
+ workstation_list,
+ const double
*computation_amount, const double
*communication_amount);
XBT_PUBLIC(int) SD_task_get_kind(SD_task_t task);
XBT_PUBLIC(void) SD_task_schedule(SD_task_t task, int workstation_nb,
- const SD_workstation_t * workstation_list,
+ const SD_workstation_t *
+ workstation_list,
const double *computation_amount,
const double *communication_amount,
double rate);
XBT_PUBLIC(xbt_dynar_t) SD_task_get_parents(SD_task_t task);
XBT_PUBLIC(xbt_dynar_t) SD_task_get_children(SD_task_t task);
XBT_PUBLIC(int) SD_task_get_workstation_count(SD_task_t task);
-XBT_PUBLIC(SD_workstation_t*) SD_task_get_workstation_list(SD_task_t task);
+XBT_PUBLIC(SD_workstation_t *) SD_task_get_workstation_list(SD_task_t
+ task);
XBT_PUBLIC(void) SD_task_destroy(SD_task_t task);
XBT_PUBLIC(void) SD_task_dump(SD_task_t task);
-XBT_PUBLIC(void) SD_task_dotty(SD_task_t task,void* out_FILE);
-
-XBT_PUBLIC(SD_task_t) SD_task_create_comp_seq(const char*name,void *data,double amount);
-XBT_PUBLIC(SD_task_t) SD_task_create_comm_e2e(const char*name,void *data,double amount);
-XBT_PUBLIC(void) SD_task_schedulev(SD_task_t task, int count, const SD_workstation_t*list);
+XBT_PUBLIC(void) SD_task_dotty(SD_task_t task, void *out_FILE);
+
+XBT_PUBLIC(SD_task_t) SD_task_create_comp_seq(const char *name, void *data,
+ double amount);
+XBT_PUBLIC(SD_task_t) SD_task_create_comm_e2e(const char *name, void *data,
+ double amount);
+XBT_PUBLIC(void) SD_task_schedulev(SD_task_t task, int count,
+ const SD_workstation_t * list);
XBT_PUBLIC(void) SD_task_schedulel(SD_task_t task, int count, ...);
/** @brief A constant to use in SD_task_schedule to mean that there is no cost.
XBT_PUBLIC(void) SD_task_dependency_add(const char *name, void *data,
SD_task_t src, SD_task_t dst);
XBT_PUBLIC(void) SD_task_dependency_remove(SD_task_t src, SD_task_t dst);
-XBT_PUBLIC(void *) SD_task_dependency_get_data(SD_task_t src, SD_task_t dst);
+XBT_PUBLIC(void *) SD_task_dependency_get_data(SD_task_t src,
+ SD_task_t dst);
XBT_PUBLIC(int) SD_task_dependency_exists(SD_task_t src, SD_task_t dst);
/** @} */
XBT_PUBLIC(xbt_dynar_t) SD_simulate(double how_long);
XBT_PUBLIC(double) SD_get_clock(void);
XBT_PUBLIC(void) SD_exit(void);
-XBT_PUBLIC(xbt_dynar_t) SD_daxload(const char*filename);
-XBT_PUBLIC(xbt_dynar_t) SD_dotload(const char*filename);
+XBT_PUBLIC(xbt_dynar_t) SD_daxload(const char *filename);
+XBT_PUBLIC(xbt_dynar_t) SD_dotload(const char *filename);
XBT_PUBLIC(void) uniq_transfer_task_name(SD_task_t task);
/** @} */
#define MPI_THREAD_FUNNELED 1
#define MPI_THREAD_SERIALIZED 2
#define MPI_THREAD_MULTIPLE 3
-
//FIXME: check values
#define MPI_MAX_PROCESSOR_NAME 100
#define MPI_MAX_ERROR_STRING 100
#define MPI_MAX_INFO_VAL 100
#define MPI_MAX_OBJECT_NAME 100
#define MPI_MAX_PORT_NAME 100
-
#define SMPI_RAND_SEED 5
#define MPI_ANY_SOURCE -1
#define MPI_PROC_NULL -2
#define MPI_ANY_TAG -1
#define MPI_UNDEFINED -1
-
// errorcodes
#define MPI_SUCCESS 0
#define MPI_ERR_COMM 1
#define MPI_ERR_TRUNCATE 9
#define MPI_ERR_GROUP 10
#define MPI_ERR_OP 11
-
#define MPI_IDENT 0
#define MPI_SIMILAR 1
#define MPI_UNEQUAL 2
#define MPI_CONGRUENT 3
-
#define MPI_WTIME_IS_GLOBAL 1
-
typedef ptrdiff_t MPI_Aint;
typedef long long MPI_Offset;
struct s_smpi_mpi_datatype;
-typedef struct s_smpi_mpi_datatype* MPI_Datatype;
+typedef struct s_smpi_mpi_datatype *MPI_Datatype;
typedef struct {
int MPI_SOURCE;
extern MPI_Datatype MPI_LONG_DOUBLE_INT;
-typedef void MPI_User_function(void* invec, void* inoutvec, int* len, MPI_Datatype* datatype);
+typedef void MPI_User_function(void *invec, void *inoutvec, int *len,
+ MPI_Datatype * datatype);
struct s_smpi_mpi_op;
-typedef struct s_smpi_mpi_op* MPI_Op;
+typedef struct s_smpi_mpi_op *MPI_Op;
#define MPI_OP_NULL NULL
extern MPI_Op MPI_MAX;
extern MPI_Op MPI_BXOR;
struct s_smpi_mpi_group;
-typedef struct s_smpi_mpi_group* MPI_Group;
+typedef struct s_smpi_mpi_group *MPI_Group;
#define MPI_GROUP_NULL NULL
extern MPI_Group MPI_GROUP_EMPTY;
struct s_smpi_mpi_communicator;
-typedef struct s_smpi_mpi_communicator* MPI_Comm;
+typedef struct s_smpi_mpi_communicator *MPI_Comm;
#define MPI_COMM_NULL NULL
extern MPI_Comm MPI_COMM_WORLD;
#define MPI_COMM_SELF smpi_process_comm_self()
struct s_smpi_mpi_request;
-typedef struct s_smpi_mpi_request* MPI_Request;
+typedef struct s_smpi_mpi_request *MPI_Request;
#define MPI_REQUEST_NULL NULL
-XBT_PUBLIC(int) MPI_Init(int* argc, char*** argv);
+XBT_PUBLIC(int) MPI_Init(int *argc, char ***argv);
XBT_PUBLIC(int) MPI_Finalize(void);
-XBT_PUBLIC(int) MPI_Init_thread(int* argc, char*** argv, int required, int* provided);
-XBT_PUBLIC(int) MPI_Query_thread(int* provided);
-XBT_PUBLIC(int) MPI_Is_thread_main(int* flag);
+XBT_PUBLIC(int) MPI_Init_thread(int *argc, char ***argv, int required,
+ int *provided);
+XBT_PUBLIC(int) MPI_Query_thread(int *provided);
+XBT_PUBLIC(int) MPI_Is_thread_main(int *flag);
XBT_PUBLIC(int) MPI_Abort(MPI_Comm comm, int errorcode);
XBT_PUBLIC(double) MPI_Wtime(void);
-XBT_PUBLIC(int) MPI_Address(void *location, MPI_Aint *address);
-
-XBT_PUBLIC(int) MPI_Type_free(MPI_Datatype* datatype);
-XBT_PUBLIC(int) MPI_Type_size(MPI_Datatype datatype, int* size);
-XBT_PUBLIC(int) MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint* lb, MPI_Aint* extent);
-XBT_PUBLIC(int) MPI_Type_extent(MPI_Datatype datatype, MPI_Aint* extent);
-XBT_PUBLIC(int) MPI_Type_lb(MPI_Datatype datatype, MPI_Aint* disp);
-XBT_PUBLIC(int) MPI_Type_ub(MPI_Datatype datatype, MPI_Aint* disp);
-
-XBT_PUBLIC(int) MPI_Op_create(MPI_User_function* function, int commute, MPI_Op* op);
-XBT_PUBLIC(int) MPI_Op_free(MPI_Op* op);
-
-XBT_PUBLIC(int) MPI_Group_free(MPI_Group *group);
-XBT_PUBLIC(int) MPI_Group_size(MPI_Group group, int* size);
-XBT_PUBLIC(int) MPI_Group_rank(MPI_Group group, int* rank);
-XBT_PUBLIC(int) MPI_Group_translate_ranks (MPI_Group group1, int n, int* ranks1, MPI_Group group2, int* ranks2);
-XBT_PUBLIC(int) MPI_Group_compare(MPI_Group group1, MPI_Group group2, int* result);
-XBT_PUBLIC(int) MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup);
-XBT_PUBLIC(int) MPI_Group_intersection(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup);
-XBT_PUBLIC(int) MPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup);
-XBT_PUBLIC(int) MPI_Group_incl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup);
-XBT_PUBLIC(int) MPI_Group_excl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup);
-XBT_PUBLIC(int) MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3], MPI_Group* newgroup);
-XBT_PUBLIC(int) MPI_Group_range_excl(MPI_Group group, int n, int ranges[][3], MPI_Group* newgroup);
-
-XBT_PUBLIC(int) MPI_Comm_rank(MPI_Comm comm, int* rank);
-XBT_PUBLIC(int) MPI_Comm_size(MPI_Comm comm, int* size);
+XBT_PUBLIC(int) MPI_Address(void *location, MPI_Aint * address);
+
+XBT_PUBLIC(int) MPI_Type_free(MPI_Datatype * datatype);
+XBT_PUBLIC(int) MPI_Type_size(MPI_Datatype datatype, int *size);
+XBT_PUBLIC(int) MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb,
+ MPI_Aint * extent);
+XBT_PUBLIC(int) MPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent);
+XBT_PUBLIC(int) MPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp);
+XBT_PUBLIC(int) MPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp);
+
+XBT_PUBLIC(int) MPI_Op_create(MPI_User_function * function, int commute,
+ MPI_Op * op);
+XBT_PUBLIC(int) MPI_Op_free(MPI_Op * op);
+
+XBT_PUBLIC(int) MPI_Group_free(MPI_Group * group);
+XBT_PUBLIC(int) MPI_Group_size(MPI_Group group, int *size);
+XBT_PUBLIC(int) MPI_Group_rank(MPI_Group group, int *rank);
+XBT_PUBLIC(int) MPI_Group_translate_ranks(MPI_Group group1, int n,
+ int *ranks1, MPI_Group group2,
+ int *ranks2);
+XBT_PUBLIC(int) MPI_Group_compare(MPI_Group group1, MPI_Group group2,
+ int *result);
+XBT_PUBLIC(int) MPI_Group_union(MPI_Group group1, MPI_Group group2,
+ MPI_Group * newgroup);
+XBT_PUBLIC(int) MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
+ MPI_Group * newgroup);
+XBT_PUBLIC(int) MPI_Group_difference(MPI_Group group1, MPI_Group group2,
+ MPI_Group * newgroup);
+XBT_PUBLIC(int) MPI_Group_incl(MPI_Group group, int n, int *ranks,
+ MPI_Group * newgroup);
+XBT_PUBLIC(int) MPI_Group_excl(MPI_Group group, int n, int *ranks,
+ MPI_Group * newgroup);
+XBT_PUBLIC(int) MPI_Group_range_incl(MPI_Group group, int n,
+ int ranges[][3],
+ MPI_Group * newgroup);
+XBT_PUBLIC(int) MPI_Group_range_excl(MPI_Group group, int n,
+ int ranges[][3],
+ MPI_Group * newgroup);
+
+XBT_PUBLIC(int) MPI_Comm_rank(MPI_Comm comm, int *rank);
+XBT_PUBLIC(int) MPI_Comm_size(MPI_Comm comm, int *size);
XBT_PUBLIC(int) MPI_Get_processor_name(char *name, int *resultlen);
-XBT_PUBLIC(int) MPI_Get_count(MPI_Status* status, MPI_Datatype datatype, int* count);
-
-XBT_PUBLIC(int) MPI_Comm_group(MPI_Comm comm, MPI_Group* group);
-XBT_PUBLIC(int) MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int* result);
-XBT_PUBLIC(int) MPI_Comm_dup(MPI_Comm comm, MPI_Comm* newcomm);
-XBT_PUBLIC(int) MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm* newcomm);
-XBT_PUBLIC(int) MPI_Comm_free(MPI_Comm* comm);
-
-XBT_PUBLIC(int) MPI_Send_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request);
-XBT_PUBLIC(int) MPI_Recv_init(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request* request);
-XBT_PUBLIC(int) MPI_Start(MPI_Request* request);
-XBT_PUBLIC(int) MPI_Startall(int count, MPI_Request* requests);
-XBT_PUBLIC(int) MPI_Request_free(MPI_Request* request);
-XBT_PUBLIC(int) MPI_Irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request* request);
-XBT_PUBLIC(int) MPI_Isend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request);
-XBT_PUBLIC(int) MPI_Recv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status* status);
-XBT_PUBLIC(int) MPI_Send(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, int sendtag, void* recvbuf, int recvcount, MPI_Datatype recvtype, int src, int recvtag, MPI_Comm comm, MPI_Status* status);
-XBT_PUBLIC(int) MPI_Sendrecv_replace(void* buf, int count, MPI_Datatype datatype, int dst, int sendtag, int src, int recvtag, MPI_Comm comm, MPI_Status* status);
-
-
-XBT_PUBLIC(int) MPI_Test(MPI_Request* request, int* flag, MPI_Status* status);
-XBT_PUBLIC(int) MPI_Testany(int count, MPI_Request requests[], int* index, int* flag, MPI_Status* status);
-XBT_PUBLIC(int) MPI_Wait(MPI_Request* request, MPI_Status* status);
-XBT_PUBLIC(int) MPI_Waitany(int count, MPI_Request requests[], int* index, MPI_Status* status);
-XBT_PUBLIC(int) MPI_Waitall(int count, MPI_Request requests[], MPI_Status status[]);
-XBT_PUBLIC(int) MPI_Waitsome(int incount, MPI_Request requests[], int* outcount, int* indices, MPI_Status status[]);
-
-XBT_PUBLIC(int) MPI_Bcast(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Get_count(MPI_Status * status, MPI_Datatype datatype,
+ int *count);
+
+XBT_PUBLIC(int) MPI_Comm_group(MPI_Comm comm, MPI_Group * group);
+XBT_PUBLIC(int) MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2,
+ int *result);
+XBT_PUBLIC(int) MPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm);
+XBT_PUBLIC(int) MPI_Comm_create(MPI_Comm comm, MPI_Group group,
+ MPI_Comm * newcomm);
+XBT_PUBLIC(int) MPI_Comm_free(MPI_Comm * comm);
+
+XBT_PUBLIC(int) MPI_Send_init(void *buf, int count, MPI_Datatype datatype,
+ int dst, int tag, MPI_Comm comm,
+ MPI_Request * request);
+XBT_PUBLIC(int) MPI_Recv_init(void *buf, int count, MPI_Datatype datatype,
+ int src, int tag, MPI_Comm comm,
+ MPI_Request * request);
+XBT_PUBLIC(int) MPI_Start(MPI_Request * request);
+XBT_PUBLIC(int) MPI_Startall(int count, MPI_Request * requests);
+XBT_PUBLIC(int) MPI_Request_free(MPI_Request * request);
+XBT_PUBLIC(int) MPI_Irecv(void *buf, int count, MPI_Datatype datatype,
+ int src, int tag, MPI_Comm comm,
+ MPI_Request * request);
+XBT_PUBLIC(int) MPI_Isend(void *buf, int count, MPI_Datatype datatype,
+ int dst, int tag, MPI_Comm comm,
+ MPI_Request * request);
+XBT_PUBLIC(int) MPI_Recv(void *buf, int count, MPI_Datatype datatype,
+ int src, int tag, MPI_Comm comm,
+ MPI_Status * status);
+XBT_PUBLIC(int) MPI_Send(void *buf, int count, MPI_Datatype datatype,
+ int dst, int tag, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Sendrecv(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, int dst, int sendtag,
+ void *recvbuf, int recvcount,
+ MPI_Datatype recvtype, int src, int recvtag,
+ MPI_Comm comm, MPI_Status * status);
+XBT_PUBLIC(int) MPI_Sendrecv_replace(void *buf, int count,
+ MPI_Datatype datatype, int dst,
+ int sendtag, int src, int recvtag,
+ MPI_Comm comm, MPI_Status * status);
+
+
+XBT_PUBLIC(int) MPI_Test(MPI_Request * request, int *flag,
+ MPI_Status * status);
+XBT_PUBLIC(int) MPI_Testany(int count, MPI_Request requests[], int *index,
+ int *flag, MPI_Status * status);
+XBT_PUBLIC(int) MPI_Wait(MPI_Request * request, MPI_Status * status);
+XBT_PUBLIC(int) MPI_Waitany(int count, MPI_Request requests[], int *index,
+ MPI_Status * status);
+XBT_PUBLIC(int) MPI_Waitall(int count, MPI_Request requests[],
+ MPI_Status status[]);
+XBT_PUBLIC(int) MPI_Waitsome(int incount, MPI_Request requests[],
+ int *outcount, int *indices,
+ MPI_Status status[]);
+
+XBT_PUBLIC(int) MPI_Bcast(void *buf, int count, MPI_Datatype datatype,
+ int root, MPI_Comm comm);
XBT_PUBLIC(int) MPI_Barrier(MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Gatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, int* displs, MPI_Datatype recvtype, int root, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Allgather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Allgatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, int* displs, MPI_Datatype recvtype, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Scatter(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Scatterv(void* sendbuf, int* sendcounts, int* displs, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Allreduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Scan(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Reduce_scatter(void* sendbuf, void* recvbuf, int* recvcounts, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Alltoall(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype sendtype, void* recvbuf, int *recvcounts, int* recvdisps, MPI_Datatype recvtype, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Gather(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype, int root,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Gatherv(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int *recvcounts, int *displs,
+ MPI_Datatype recvtype, int root,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Allgather(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Allgatherv(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int *recvcounts, int *displs,
+ MPI_Datatype recvtype, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Scatter(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype, int root,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype,
+ int root, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Reduce(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, int root,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Allreduce(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Scan(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Reduce_scatter(void *sendbuf, void *recvbuf,
+ int *recvcounts, MPI_Datatype datatype,
+ MPI_Op op, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Alltoall(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Alltoallv(void *sendbuf, int *sendcounts,
+ int *senddisps, MPI_Datatype sendtype,
+ void *recvbuf, int *recvcounts,
+ int *recvdisps, MPI_Datatype recvtype,
+ MPI_Comm comm);
/*
TODO
MPI_Comm* comm_out);
*/
// smpi functions
-XBT_IMPORT_NO_EXPORT(int) smpi_simulated_main(int argc, char** argv);
+XBT_IMPORT_NO_EXPORT(int) smpi_simulated_main(int argc, char **argv);
XBT_PUBLIC(MPI_Comm) smpi_process_comm_self(void);
/*
XBT_PUBLIC(void) smpi_exit(int);
*/
XBT_PUBLIC(unsigned int) smpi_sleep(unsigned int secs);
-XBT_PUBLIC(int) smpi_gettimeofday(struct timeval* tv, struct timezone* tz);
-XBT_PUBLIC(void) smpi_sample_1(int global, const char* file, int line, int max);
-XBT_PUBLIC(int) smpi_sample_2(int global, const char* file, int line);
-XBT_PUBLIC(void) smpi_sample_3(int global, const char* file, int line);
+XBT_PUBLIC(int) smpi_gettimeofday(struct timeval *tv, struct timezone *tz);
+XBT_PUBLIC(void) smpi_sample_1(int global, const char *file, int line,
+ int max);
+XBT_PUBLIC(int) smpi_sample_2(int global, const char *file, int line);
+XBT_PUBLIC(void) smpi_sample_3(int global, const char *file, int line);
XBT_PUBLIC(void) smpi_sample_flops(double flops);
#define SMPI_SAMPLE_LOCAL(num) for(smpi_sample_1(0, __FILE__, __LINE__, num); \
#define SMPI_SAMPLE_DELAY(flops) for(smpi_sample_flops(flops); 0; )
-XBT_PUBLIC(void*) smpi_shared_malloc(size_t size, const char* file, int line);
+XBT_PUBLIC(void *) smpi_shared_malloc(size_t size, const char *file,
+ int line);
#define SMPI_SHARED_MALLOC(size) smpi_shared_malloc(size, __FILE__, __LINE__)
-XBT_PUBLIC(void) smpi_shared_free(void* data);
+XBT_PUBLIC(void) smpi_shared_free(void *data);
#define SMPI_SHARED_FREE(data) smpi_shared_free(data)
SG_END_DECL()
/* XML processor/application API for src/surf/simgrid.dtd.
- * Generated 2010/10/06 15:20:08.
+ * Generated 2010/10/11 11:35:07.
*
* This program was generated with the FleXML XML processor generator.
* FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
SG_BEGIN_DECL()
/* Hook for the different tags. All the functions which pointer to are push into here are run when the tag is encountered */
-XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_platform_cb_list;
+ XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_platform_cb_list;
XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_platform_cb_list;
XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_host_cb_list;
XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_host_cb_list;
XBT_PUBLIC(void) surf_parse_get_int(int *value, const char *string);
/* Prototypes of the functions offered by flex */
-XBT_PUBLIC(int) surf_parse_lex(void);
-XBT_PUBLIC(int) surf_parse_get_lineno(void);
+XBT_PUBLIC(int) surf_parse_lex(void);
+XBT_PUBLIC(int) surf_parse_get_lineno(void);
XBT_PUBLIC(FILE *) surf_parse_get_in(void);
XBT_PUBLIC(FILE *) surf_parse_get_out(void);
-XBT_PUBLIC(int) surf_parse_get_leng(void);
+XBT_PUBLIC(int) surf_parse_get_leng(void);
XBT_PUBLIC(char *) surf_parse_get_text(void);
-XBT_PUBLIC(void) surf_parse_set_lineno(int line_number);
-XBT_PUBLIC(void) surf_parse_set_in(FILE * in_str);
-XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
-XBT_PUBLIC(int) surf_parse_get_debug(void);
-XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
-XBT_PUBLIC(int) surf_parse_lex_destroy(void);
+XBT_PUBLIC(void) surf_parse_set_lineno(int line_number);
+XBT_PUBLIC(void) surf_parse_set_in(FILE * in_str);
+XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
+XBT_PUBLIC(int) surf_parse_get_debug(void);
+XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
+XBT_PUBLIC(int) surf_parse_lex_destroy(void);
/* What is needed to bypass the parser. */
ETag_surfxml_##tag();\
} while(0)
-XBT_PUBLIC(void) surfxml_add_callback(xbt_dynar_t cb_list, void_f_void_t function);
-XBT_PUBLIC(void) surfxml_del_callback(xbt_dynar_t* cb_list, void_f_void_t function);
+XBT_PUBLIC(void) surfxml_add_callback(xbt_dynar_t cb_list,
+ void_f_void_t function);
+XBT_PUBLIC(void) surfxml_del_callback(xbt_dynar_t * cb_list,
+ void_f_void_t function);
SG_END_DECL()
#endif
/* pimple to display the message sizes */
XBT_PUBLIC(void) SIMIX_message_sizes_output(const char *filename);
-#endif /* xbt_H */
+#endif /* xbt_H */
#define xbt_assert6(cond,msg,a,b,c,d,e,f) if (!(cond)) THROW6(0,0,msg,a,b,c,d,e,f)
#endif
/** @} */
- SG_END_DECL()
-#endif /* _XBT_ASSERTS_H */
+ SG_END_DECL()
+#endif /* _XBT_ASSERTS_H */
* @{
*/
/** @brief Configuration set are only special dynars. But don't rely on it, it may change. */
- typedef xbt_dynar_t xbt_cfg_t;
+typedef xbt_dynar_t xbt_cfg_t;
XBT_PUBLIC(void) xbt_cfg_set(xbt_cfg_t cfg, const char *name, ...);
XBT_PUBLIC(void) xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name,
Set the default value of the cell \a name in \a cfg with the provided value.
If it was already set to something (possibly from the command line), do nothing.
*/
-XBT_PUBLIC(void) xbt_cfg_setdefault_int(xbt_cfg_t cfg, const char *name, int val);
-XBT_PUBLIC(void) xbt_cfg_setdefault_double(xbt_cfg_t cfg, const char *name, double val);
-XBT_PUBLIC(void) xbt_cfg_setdefault_string(xbt_cfg_t cfg, const char *name, const char* val);
-XBT_PUBLIC(void) xbt_cfg_setdefault_peer(xbt_cfg_t cfg, const char *name, const char* host, int port);
+XBT_PUBLIC(void) xbt_cfg_setdefault_int(xbt_cfg_t cfg, const char *name,
+ int val);
+XBT_PUBLIC(void) xbt_cfg_setdefault_double(xbt_cfg_t cfg, const char *name,
+ double val);
+XBT_PUBLIC(void) xbt_cfg_setdefault_string(xbt_cfg_t cfg, const char *name,
+ const char *val);
+XBT_PUBLIC(void) xbt_cfg_setdefault_peer(xbt_cfg_t cfg, const char *name,
+ const char *host, int port);
/*
*/
/** @brief possible content of each configuration cell */
- typedef enum {
- xbt_cfgelm_int = 0,
+typedef enum {
+ xbt_cfgelm_int = 0,
/**< int */
- xbt_cfgelm_double,
+ xbt_cfgelm_double,
/**< double */
- xbt_cfgelm_string,
+ xbt_cfgelm_string,
/**< char* */
- xbt_cfgelm_peer,/**< both a char* (representing the peername) and an integer (representing the port) */
+ xbt_cfgelm_peer, /**< both a char* (representing the peername) and an integer (representing the port) */
- xbt_cfgelm_any, /* not shown to users to prevent errors */
- xbt_cfgelm_type_count
- } e_xbt_cfgelm_type_t;
+ xbt_cfgelm_any, /* not shown to users to prevent errors */
+ xbt_cfgelm_type_count
+} e_xbt_cfgelm_type_t;
/** \brief Callback types. They get the name of the modified entry, and the position of the changed value */
- typedef void (*xbt_cfg_cb_t) (const char *, int);
+typedef void (*xbt_cfg_cb_t) (const char *, int);
XBT_PUBLIC(xbt_cfg_t) xbt_cfg_new(void);
-XBT_PUBLIC(void) xbt_cfg_cpy(xbt_cfg_t tocopy, /* OUT */ xbt_cfg_t * whereto);
+XBT_PUBLIC(void) xbt_cfg_cpy(xbt_cfg_t tocopy, /* OUT */
+ xbt_cfg_t * whereto);
XBT_PUBLIC(void) xbt_cfg_free(xbt_cfg_t * cfg);
XBT_PUBLIC(void) xbt_cfg_dump(const char *name, const char *indent,
xbt_cfg_t cfg);
* @{
*/
XBT_PUBLIC(void) xbt_cfg_register(xbt_cfg_t * cfg,
- const char *name, const char *description,
+ const char *name,
+ const char *description,
e_xbt_cfgelm_type_t type,
void *default_value, int min, int max,
xbt_cfg_cb_t cb_set, xbt_cfg_cb_t cb_rm);
char **peer, int *port);
XBT_PUBLIC(xbt_dynar_t) xbt_cfg_get_dynar(xbt_cfg_t cfg, const char *name);
-XBT_PUBLIC(int) xbt_cfg_get_int_at(xbt_cfg_t cfg, const char *name, int pos);
+XBT_PUBLIC(int) xbt_cfg_get_int_at(xbt_cfg_t cfg, const char *name,
+ int pos);
XBT_PUBLIC(double) xbt_cfg_get_double_at(xbt_cfg_t cfg, const char *name,
int pos);
XBT_PUBLIC(char *) xbt_cfg_get_string_at(xbt_cfg_t cfg, const char *name,
int pos);
-XBT_PUBLIC(void) xbt_cfg_get_peer_at(xbt_cfg_t cfg, const char *name, int pos,
- char **peer, int *port);
+XBT_PUBLIC(void) xbt_cfg_get_peer_at(xbt_cfg_t cfg, const char *name,
+ int pos, char **peer, int *port);
/** @} */
SG_END_DECL()
-#endif /* _XBT_CONFIG_H_ */
+#endif /* _XBT_CONFIG_H_ */
SG_BEGIN_DECL()
/* test suite object type */
- typedef struct s_xbt_test_suite *xbt_test_suite_t;
+typedef struct s_xbt_test_suite *xbt_test_suite_t;
/* test object type */
- typedef struct s_xbt_test_unit *xbt_test_unit_t;
+typedef struct s_xbt_test_unit *xbt_test_unit_t;
/* test callback function type */
- typedef void (*ts_test_cb_t) (void);
+typedef void (*ts_test_cb_t) (void);
/* test suite operations */
XBT_PUBLIC(xbt_test_suite_t) xbt_test_suite_new(const char *name,
XBT_PUBLIC(xbt_test_suite_t) xbt_test_suite_by_name(const char *name,
const char *fmt, ...);
XBT_PUBLIC(void) xbt_test_suite_dump(xbt_test_suite_t suite);
-XBT_PUBLIC(void) xbt_test_suite_push(xbt_test_suite_t suite, const char *name,
- ts_test_cb_t func, const char *fmt, ...);
+XBT_PUBLIC(void) xbt_test_suite_push(xbt_test_suite_t suite,
+ const char *name, ts_test_cb_t func,
+ const char *fmt, ...);
/* Run all the specified tests. what_to_do allows to disable some tests.
* It is a coma (,) separated list of directives. They are applied from left to right.
#define xbt_test_add4(fmt,a,b,c,d) _xbt_test_add(__FILE__,__LINE__,fmt,a,b,c,d)
#define xbt_test_add5(fmt,a,b,c,d,e) _xbt_test_add(__FILE__,__LINE__,fmt,a,b,c,d,e)
-XBT_PUBLIC(void) _xbt_test_fail(const char *file, int line, const char *fmt,
- ...) _XBT_GNUC_PRINTF(3, 4);
+XBT_PUBLIC(void) _xbt_test_fail(const char *file, int line,
+ const char *fmt, ...) _XBT_GNUC_PRINTF(3,
+ 4);
#define xbt_test_fail0(fmt) _xbt_test_fail(__FILE__, __LINE__, fmt)
#define xbt_test_fail1(fmt,a) _xbt_test_fail(__FILE__, __LINE__, fmt,a)
#define xbt_test_fail2(fmt,a,b) _xbt_test_fail(__FILE__, __LINE__, fmt,a,b)
void func(void)
SG_END_DECL()
-#endif /* _TS_H_ */
+#endif /* _TS_H_ */
#include "xbt/misc.h" /* SG_BEGIN_DECL */
#include "xbt/dynar.h" /* void_f_pvoid_t */
-#include <stdint.h> /* uintptr_t */
+#include <stdint.h> /* uintptr_t */
SG_BEGIN_DECL();
void_f_pvoid_t free_ctn);
XBT_PUBLIC(void *) xbt_dict_get(xbt_dict_t dict, const char *key);
XBT_PUBLIC(void *) xbt_dict_get_or_null(xbt_dict_t dict, const char *key);
-XBT_PUBLIC(char *) xbt_dict_get_key(xbt_dict_t dict, const void*data);
+XBT_PUBLIC(char *) xbt_dict_get_key(xbt_dict_t dict, const void *data);
XBT_PUBLIC(void) xbt_dict_remove(xbt_dict_t dict, const char *key);
XBT_PUBLIC(void) xbt_dict_reset(xbt_dict_t dict);
void *data, void_f_pvoid_t free_ctn);
XBT_PUBLIC(void *) xbt_dict_get_ext(xbt_dict_t dict, const char *key,
int key_len);
-XBT_PUBLIC(void *) xbt_dict_get_or_null_ext(xbt_dict_t dict, const char *key,
- int key_len);
+XBT_PUBLIC(void *) xbt_dict_get_or_null_ext(xbt_dict_t dict,
+ const char *key, int key_len);
XBT_PUBLIC(void) xbt_dict_remove_ext(xbt_dict_t dict, const char *key,
int key_len);
-XBT_PUBLIC(void) xbt_dicti_set(xbt_dict_t dict, uintptr_t key, uintptr_t data);
+XBT_PUBLIC(void) xbt_dicti_set(xbt_dict_t dict, uintptr_t key,
+ uintptr_t data);
XBT_PUBLIC(uintptr_t) xbt_dicti_get(xbt_dict_t dict, uintptr_t key);
XBT_PUBLIC(void) xbt_dicti_remove(xbt_dict_t dict, uintptr_t key);
* @{ */
/** @brief Cursor on dictionaries (opaque type) */
- typedef struct xbt_dict_cursor_ *xbt_dict_cursor_t;
+typedef struct xbt_dict_cursor_ *xbt_dict_cursor_t;
XBT_PUBLIC(xbt_dict_cursor_t) xbt_dict_cursor_new(const xbt_dict_t dict);
XBT_PUBLIC(void) xbt_dict_cursor_free(xbt_dict_cursor_t * cursor);
-XBT_INLINE XBT_PUBLIC(void) xbt_dict_cursor_rewind(xbt_dict_cursor_t cursor);
+XBT_INLINE XBT_PUBLIC(void) xbt_dict_cursor_rewind(xbt_dict_cursor_t
+ cursor);
XBT_PUBLIC(char *) xbt_dict_cursor_get_key(xbt_dict_cursor_t cursor);
XBT_PUBLIC(void *) xbt_dict_cursor_get_data(xbt_dict_cursor_t cursor);
XBT_PUBLIC(void) xbt_dict_cursor_set_data(xbt_dict_cursor_t cursor,
- void *data, void_f_pvoid_t free_ctn);
+ void *data,
+ void_f_pvoid_t free_ctn);
XBT_PUBLIC(void) xbt_dict_cursor_first(const xbt_dict_t dict,
xbt_dict_cursor_t * cursor);
/*----[ xbt_multidict_get ]--------------------------------------------------*/
XBT_PUBLIC(void *) xbt_multidict_get(xbt_dict_t mdict, xbt_dynar_t keys);
-XBT_PUBLIC(void *) xbt_multidict_get_ext(xbt_dict_t mdict, xbt_dynar_t keys,
+XBT_PUBLIC(void *) xbt_multidict_get_ext(xbt_dict_t mdict,
+ xbt_dynar_t keys,
xbt_dynar_t lens);
/*----[ xbt_multidict_remove ]-----------------------------------------------*/
/*---------------------------------------------------------------------------*/
XBT_PUBLIC(void) xbt_multidict_remove(xbt_dict_t mdict, xbt_dynar_t keys);
-XBT_PUBLIC(void) xbt_multidict_remove_ext(xbt_dict_t mdict, xbt_dynar_t keys,
+XBT_PUBLIC(void) xbt_multidict_remove_ext(xbt_dict_t mdict,
+ xbt_dynar_t keys,
xbt_dynar_t lens);
/** @} */
SG_END_DECL()
-#endif /* _XBT_DICT_H */
+#endif /* _XBT_DICT_H */
#ifndef _XBT_DYNAR_H
#define _XBT_DYNAR_H
-#include <string.h> /* memcpy */
+#include <string.h> /* memcpy */
#include "xbt/misc.h" /* SG_BEGIN_DECL */
#include "xbt/function_types.h"
* @{
*/
/** \brief Dynar data type (opaque type) */
- typedef struct xbt_dynar_s *xbt_dynar_t;
+typedef struct xbt_dynar_s *xbt_dynar_t;
XBT_PUBLIC(xbt_dynar_t) xbt_dynar_new(const unsigned long elm_size,
XBT_PUBLIC(void) xbt_dynar_free_voidp(void *dynar);
XBT_PUBLIC(void) xbt_dynar_free_container(xbt_dynar_t * dynar);
-XBT_INLINE XBT_PUBLIC(unsigned long) xbt_dynar_length(const xbt_dynar_t dynar);
-XBT_INLINE XBT_PUBLIC (int) xbt_dynar_is_empty(const xbt_dynar_t dynar);
+XBT_INLINE XBT_PUBLIC(unsigned long) xbt_dynar_length(const xbt_dynar_t
+ dynar);
+XBT_INLINE XBT_PUBLIC(int) xbt_dynar_is_empty(const xbt_dynar_t dynar);
XBT_PUBLIC(void) xbt_dynar_reset(xbt_dynar_t const dynar);
XBT_PUBLIC(void) xbt_dynar_shrink(xbt_dynar_t dynar, int empty_slots);
*/
XBT_PUBLIC(void) xbt_dynar_get_cpy(const xbt_dynar_t dynar,
- const unsigned long idx, void *const dst);
+ const unsigned long idx,
+ void *const dst);
XBT_PUBLIC(void) xbt_dynar_set(xbt_dynar_t dynar, const int idx,
const void *src);
-XBT_PUBLIC(void) xbt_dynar_replace(xbt_dynar_t dynar, const unsigned long idx,
+XBT_PUBLIC(void) xbt_dynar_replace(xbt_dynar_t dynar,
+ const unsigned long idx,
const void *object);
-XBT_PUBLIC(void) xbt_dynar_insert_at(xbt_dynar_t const dynar, const int idx,
- const void *src);
-XBT_PUBLIC(void) xbt_dynar_remove_at(xbt_dynar_t const dynar, const int idx,
- void *const dst);
+XBT_PUBLIC(void) xbt_dynar_insert_at(xbt_dynar_t const dynar,
+ const int idx, const void *src);
+XBT_PUBLIC(void) xbt_dynar_remove_at(xbt_dynar_t const dynar,
+ const int idx, void *const dst);
-XBT_PUBLIC(unsigned int) xbt_dynar_search(xbt_dynar_t const dynar, void *elem);
+XBT_PUBLIC(unsigned int) xbt_dynar_search(xbt_dynar_t const dynar,
+ void *elem);
XBT_PUBLIC(int) xbt_dynar_member(xbt_dynar_t const dynar, void *elem);
-XBT_PUBLIC(void) xbt_dynar_sort(xbt_dynar_t const dynar, int_f_cpvoid_cpvoid_t compar_fn);
+XBT_PUBLIC(void) xbt_dynar_sort(xbt_dynar_t const dynar,
+ int_f_cpvoid_cpvoid_t compar_fn);
/** @} */
/** @defgroup XBT_dynar_perl Perl-like use of dynars
* @{
*/
-XBT_INLINE XBT_PUBLIC(void) xbt_dynar_push(xbt_dynar_t const dynar, const void *src);
-XBT_INLINE XBT_PUBLIC(void) xbt_dynar_pop(xbt_dynar_t const dynar, void *const dst);
-XBT_PUBLIC(void) xbt_dynar_unshift(xbt_dynar_t const dynar, const void *src);
+XBT_INLINE XBT_PUBLIC(void) xbt_dynar_push(xbt_dynar_t const dynar,
+ const void *src);
+XBT_INLINE XBT_PUBLIC(void) xbt_dynar_pop(xbt_dynar_t const dynar,
+ void *const dst);
+XBT_PUBLIC(void) xbt_dynar_unshift(xbt_dynar_t const dynar,
+ const void *src);
XBT_PUBLIC(void) xbt_dynar_shift(xbt_dynar_t const dynar, void *const dst);
XBT_PUBLIC(void) xbt_dynar_map(const xbt_dynar_t dynar,
void_f_pvoid_t const op);
*/
XBT_INLINE XBT_PUBLIC(void *) xbt_dynar_get_ptr(const xbt_dynar_t dynar,
- const unsigned long idx);
+ const unsigned long idx);
XBT_PUBLIC(void *) xbt_dynar_insert_at_ptr(xbt_dynar_t const dynar,
const int idx);
XBT_PUBLIC(void *) xbt_dynar_push_ptr(xbt_dynar_t const dynar);
*/
XBT_INLINE XBT_PUBLIC(void) xbt_dynar_cursor_rm(xbt_dynar_t dynar,
- unsigned int *const cursor);
+ unsigned int *const
+ cursor);
XBT_PUBLIC(void) xbt_dynar_cursor_unlock(xbt_dynar_t dynar);
/* do not use this structure internals directly, but use the public interface
} s_xbt_dynar_t;
static XBT_INLINE void
-_xbt_dynar_cursor_first(const xbt_dynar_t dynar, unsigned int *const cursor)
+_xbt_dynar_cursor_first(const xbt_dynar_t dynar,
+ unsigned int *const cursor)
{
/* don't test for dynar!=NULL. The segfault would tell us */
- if (dynar->mutex) /* ie _dynar_lock(dynar) but not public */
+ if (dynar->mutex) /* ie _dynar_lock(dynar) but not public */
xbt_mutex_acquire(dynar->mutex);
//DEBUG1("Set cursor on %p to the first position", (void *) dynar);
if (idx >= dynar->used) {
//DEBUG1("Cursor on %p already on last elem", (void *) dynar);
- if (dynar->mutex) /* unlock */
+ if (dynar->mutex) /* unlock */
xbt_mutex_release(dynar->mutex);
return FALSE;
}
// DEBUG2("Cash out cursor on %p at %u", (void *) dynar, *idx);
- memcpy(dst, ((char*)dynar->data) + idx * dynar->elmsize, dynar->elmsize);
+ memcpy(dst, ((char *) dynar->data) + idx * dynar->elmsize,
+ dynar->elmsize);
return TRUE;
}
/** @} */
SG_END_DECL()
-#endif /* _XBT_DYNAR_H */
+#endif /* _XBT_DYNAR_H */
/*-*-* Emergency debuging: define this when the exceptions get crazy *-*-*/
#undef __EX_MAYDAY
-
#ifdef __EX_MAYDAY
# include <stdio.h>
#include <errno.h>
-
# define MAYDAY_SAVE(m) printf("%d %s:%d save %p\n", \
(*xbt_getpid)(),__FILE__,__LINE__, \
(m)->jb \
# define MAYDAY_RESTORE(m)
# define MAYDAY_CATCH(e)
#endif
-
/*-*-* end of debugging stuff *-*-*/
-
#if defined(__EX_MCTX_MCSC__)
#include <ucontext.h> /* POSIX.1 ucontext(3) */
#define __ex_mctx_struct ucontext_t uc;
#define __ex_mctx_save(mctx) (getcontext(&(mctx)->uc) == 0)
#define __ex_mctx_restored(mctx) /* noop */
#define __ex_mctx_restore(mctx) (void)setcontext(&(mctx)->uc)
-
#elif defined(__EX_MCTX_SSJLJ__)
#include <setjmp.h> /* POSIX.1 sigjmp_buf(3) */
#define __ex_mctx_struct sigjmp_buf jb;
#define __ex_mctx_save(mctx) (sigsetjmp((mctx)->jb, 1) == 0)
#define __ex_mctx_restored(mctx) /* noop */
#define __ex_mctx_restore(mctx) (void)siglongjmp((mctx)->jb, 1)
-
#elif defined(__EX_MCTX_SJLJ__) || !defined(__EX_MCTX_CUSTOM__) || defined(__EX_MAYDAY)
#include <setjmp.h> /* ISO-C jmp_buf(3) */
#define __ex_mctx_struct jmp_buf jb;
#define __ex_mctx_restored(mctx) /* noop */
#define __ex_mctx_restore(mctx) ( MAYDAY_RESTORE(mctx) (void)longjmp((mctx)->jb, 1))
#endif
-
/* declare the machine context type */
typedef struct {
__ex_mctx_struct} __ex_mctx_t;
XBT_PUBLIC(const char *) xbt_ex_catname(xbt_errcat_t cat);
/** @brief Structure describing an exception */
- typedef struct {
- char *msg; /**< human readable message */
- xbt_errcat_t category;
+typedef struct {
+ char *msg; /**< human readable message */
+ xbt_errcat_t category;
/**< category like HTTP (what went wrong) */
- int value; /**< like errno (why did it went wrong) */
- /* throw point */
- short int remote;
+ int value; /**< like errno (why did it went wrong) */
+ /* throw point */
+ short int remote;
/**< whether it was raised remotely */
- char *host;/**< NULL locally thrown exceptions; full hostname if remote ones */
- /* FIXME: host should be hostname:port[#thread] */
- char *procname;
+ char *host; /**< NULL locally thrown exceptions; full hostname if remote ones */
+ /* FIXME: host should be hostname:port[#thread] */
+ char *procname;
/**< Name of the process who thrown this */
- int pid; /**< PID of the process who thrown this */
- char *file;/**< Thrown point */
- int line; /**< Thrown point */
- char *func;/**< Thrown point */
- /* Backtrace */
- int used;
- char **bt_strings; /* only filed on display (or before the network propagation) */
- void *bt[XBT_BACKTRACE_SIZE];
- } xbt_ex_t;
+ int pid; /**< PID of the process who thrown this */
+ char *file; /**< Thrown point */
+ int line; /**< Thrown point */
+ char *func; /**< Thrown point */
+ /* Backtrace */
+ int used;
+ char **bt_strings; /* only filed on display (or before the network propagation) */
+ void *bt[XBT_BACKTRACE_SIZE];
+} xbt_ex_t;
/* declare the context type (private) */
- typedef struct {
- __ex_mctx_t *ctx_mctx; /* permanent machine context of enclosing try/catch */
- volatile int ctx_caught; /* temporary flag whether exception was caught */
- volatile xbt_ex_t ctx_ex; /* temporary exception storage */
- } ex_ctx_t;
+typedef struct {
+ __ex_mctx_t *ctx_mctx; /* permanent machine context of enclosing try/catch */
+ volatile int ctx_caught; /* temporary flag whether exception was caught */
+ volatile xbt_ex_t ctx_ex; /* temporary exception storage */
+} ex_ctx_t;
/* the static and dynamic initializers for a context structure */
#define XBT_CTX_INITIALIZER \
} while (0)
/* the exception context */
- typedef ex_ctx_t *(*ex_ctx_cb_t) (void);
+typedef ex_ctx_t *(*ex_ctx_cb_t) (void);
XBT_PUBLIC_DATA(ex_ctx_cb_t) __xbt_ex_ctx;
- extern ex_ctx_t *__xbt_ex_ctx_default(void);
+extern ex_ctx_t *__xbt_ex_ctx_default(void);
/* the termination handler */
- typedef void (*ex_term_cb_t) (xbt_ex_t *);
+typedef void (*ex_term_cb_t) (xbt_ex_t *);
XBT_PUBLIC_DATA(ex_term_cb_t) __xbt_ex_terminate;
- extern void __xbt_ex_terminate_default(xbt_ex_t * e);
+extern void __xbt_ex_terminate_default(xbt_ex_t * e);
/** @brief Introduce a block where exception may be dealed with
* @hideinitializer
SG_END_DECL()
/** @}Â */
-#endif /* __XBT_EX_H__ */
+#endif /* __XBT_EX_H__ */
*/
/** \brief Bucket structure
*/
- typedef struct xbt_fifo_item *xbt_fifo_item_t;
+typedef struct xbt_fifo_item *xbt_fifo_item_t;
/** \brief FIFO structure
*/
- typedef struct xbt_fifo *xbt_fifo_t;
+typedef struct xbt_fifo *xbt_fifo_t;
XBT_PUBLIC(xbt_fifo_t) xbt_fifo_new(void);
XBT_PUBLIC(void) xbt_fifo_free(xbt_fifo_t);
XBT_PUBLIC(int) xbt_fifo_remove_all(xbt_fifo_t, void *);
XBT_PUBLIC(void) xbt_fifo_remove_item(xbt_fifo_t, xbt_fifo_item_t);
-XBT_INLINE XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_first_item(xbt_fifo_t l);
-XBT_INLINE XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_last_item(xbt_fifo_t l);
+XBT_INLINE XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_first_item(xbt_fifo_t
+ l);
+XBT_INLINE XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_last_item(xbt_fifo_t
+ l);
XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_next_item(xbt_fifo_item_t i);
XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_prev_item(xbt_fifo_item_t i);
SG_END_DECL()
-#endif /* _XBT_FIFO_H */
+#endif /* _XBT_FIFO_H */
typedef void (*void_f_ppvoid_t) (void **);
typedef void (*void_f_pvoid_t) (void *);
-typedef void (*void_f_int_pvoid_t) (int,void *);
- typedef void *(*pvoid_f_void_t) (void);
- typedef void *(*pvoid_f_pvoid_t) (void *);
- typedef void (*void_f_void_t) (void);
+typedef void (*void_f_int_pvoid_t) (int, void *);
+typedef void *(*pvoid_f_void_t) (void);
+typedef void *(*pvoid_f_pvoid_t) (void *);
+typedef void (*void_f_void_t) (void);
- typedef int (*int_f_void_t) (void);
+typedef int (*int_f_void_t) (void);
- typedef int (*int_f_pvoid_pvoid_t) (void *, void *);
- typedef int (*int_f_cpvoid_cpvoid_t) (const void *, const void *);
+typedef int (*int_f_pvoid_pvoid_t) (void *, void *);
+typedef int (*int_f_cpvoid_cpvoid_t) (const void *, const void *);
- typedef int (*xbt_main_func_t) (int argc, char *argv[]);
+typedef int (*xbt_main_func_t) (int argc, char *argv[]);
SG_END_DECL()
-#endif /* XBT_FUNCTION_TYPE_H */
+#endif /* XBT_FUNCTION_TYPE_H */
*
* @{
*/
- typedef struct xbt_node *xbt_node_t;
- typedef struct xbt_edge *xbt_edge_t;
- typedef struct xbt_graph *xbt_graph_t;
+typedef struct xbt_node *xbt_node_t;
+typedef struct xbt_edge *xbt_edge_t;
+typedef struct xbt_graph *xbt_graph_t;
/* API */
XBT_PUBLIC(xbt_graph_t) xbt_graph_new_graph(unsigned short int directed,
XBT_PUBLIC(xbt_node_t) xbt_graph_edge_get_source(xbt_edge_t e);
XBT_PUBLIC(xbt_node_t) xbt_graph_edge_get_target(xbt_edge_t e);
XBT_PUBLIC(xbt_graph_t) xbt_graph_read(const char *filename, void
- * (node_label_and_data) (xbt_node_t,
- const char *,
- const char *),
- void
- * (edge_label_and_data) (xbt_edge_t,
- const char *,
- const char *)
- );
+ *(node_label_and_data) (xbt_node_t,
+ const char
+ *,
+ const char
+ *), void
+ *(edge_label_and_data) (xbt_edge_t,
+ const char
+ *,
+ const char
+ *)
+ );
XBT_PUBLIC(void) xbt_graph_export_graphviz(xbt_graph_t g,
const char *filename, const char
- * (node_name) (xbt_node_t), const char
- * (edge_name) (xbt_edge_t));
+ *(node_name) (xbt_node_t), const char
+ *(edge_name) (xbt_edge_t));
XBT_PUBLIC(void) xbt_graph_export_graphxml(xbt_graph_t g,
const char *filename, const char
- * (node_name) (xbt_node_t), const char
- * (edge_name) (xbt_edge_t),
- const char *(node_data_print) (void
- *),
- const char *(edge_data_print) (void
- *));
+ *(node_name) (xbt_node_t), const char
+ *(edge_name) (xbt_edge_t), const char
+ *(node_data_print) (void *), const char
+ *(edge_data_print) (void *));
/* Not implemented yet ! */
/* void *xbt_graph_to_array(xbt_graph_t g); */
SG_END_DECL()
-#endif /* _XBT_GRAPH_H */
+#endif /* _XBT_GRAPH_H */
/** @} */
/* XML processor/application API for src/xbt/graphxml.dtd.
- * Generated 2010/10/01 22:34:15.
+ * Generated 2010/10/11 11:35:07.
*
* This program was generated with the FleXML XML processor generator.
* FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
#ifndef _XBT_GRAPHXML_PARSE_H
#define _XBT_GRAPHXML_PARSE_H
-#include <stdio.h> /* to have FILE */
+#include <stdio.h> /* to have FILE */
#include "xbt/misc.h"
#include "xbt/graphxml.h"
#include "simgrid_config.h"
XBT_PUBLIC(void) xbt_sha(const char *data, char *hash);
-#endif /* XBT_HASH_H */
+#endif /* XBT_HASH_H */
/* @brief heap datatype */
typedef struct xbt_heap *xbt_heap_t;
-XBT_PUBLIC(xbt_heap_t) xbt_heap_new(int num, void_f_pvoid_t const free_func);
+XBT_PUBLIC(xbt_heap_t) xbt_heap_new(int num,
+ void_f_pvoid_t const free_func);
XBT_PUBLIC(void) xbt_heap_free(xbt_heap_t H);
XBT_PUBLIC(int) xbt_heap_size(xbt_heap_t H);
XBT_PUBLIC(double) xbt_heap_maxkey(xbt_heap_t H);
XBT_PUBLIC(void *) xbt_heap_maxcontent(xbt_heap_t H);
-XBT_PUBLIC(void) xbt_heap_set_update_callback(xbt_heap_t H, void (*update_callback)(void*, int));
-XBT_PUBLIC(void*) xbt_heap_remove(xbt_heap_t H, int i);
+XBT_PUBLIC(void) xbt_heap_set_update_callback(xbt_heap_t H,
+ void (*update_callback) (void
+ *,
+ int));
+XBT_PUBLIC(void *) xbt_heap_remove(xbt_heap_t H, int i);
/* @} */
-#endif /* _XBT_HEAP_H */
+#endif /* _XBT_HEAP_H */
*
* The different existing priorities.
*/
- typedef enum {
- xbt_log_priority_none = 0, /* used internally (don't poke with) */
- xbt_log_priority_trace = 1, /**< enter and return of some functions */
- xbt_log_priority_debug = 2, /**< crufty output */
- xbt_log_priority_verbose = 3, /**< verbose output for the user wanting more */
- xbt_log_priority_info = 4, /**< output about the regular functionning */
- xbt_log_priority_warning = 5, /**< minor issue encountered */
- xbt_log_priority_error = 6, /**< issue encountered */
- xbt_log_priority_critical = 7, /**< major issue encountered */
+typedef enum {
+ xbt_log_priority_none = 0, /* used internally (don't poke with) */
+ xbt_log_priority_trace = 1, /**< enter and return of some functions */
+ xbt_log_priority_debug = 2, /**< crufty output */
+ xbt_log_priority_verbose = 3, /**< verbose output for the user wanting more */
+ xbt_log_priority_info = 4, /**< output about the regular functionning */
+ xbt_log_priority_warning = 5, /**< minor issue encountered */
+ xbt_log_priority_error = 6, /**< issue encountered */
+ xbt_log_priority_critical = 7, /**< major issue encountered */
- xbt_log_priority_infinite = 8, /**< value for XBT_LOG_STATIC_THRESHOLD to not log */
+ xbt_log_priority_infinite = 8, /**< value for XBT_LOG_STATIC_THRESHOLD to not log */
- xbt_log_priority_uninitialized = -1 /* used internally (don't poke with) */
- } e_xbt_log_priority_t;
+ xbt_log_priority_uninitialized = -1 /* used internally (don't poke with) */
+} e_xbt_log_priority_t;
/*
# ifdef NDEBUG
# define XBT_LOG_STATIC_THRESHOLD xbt_log_priority_verbose
-# else /* !NLOG && !NDEBUG */
+# else /* !NLOG && !NDEBUG */
# ifndef XBT_LOG_STATIC_THRESHOLD
# define XBT_LOG_STATIC_THRESHOLD xbt_log_priority_none
-# endif /* !XBT_LOG_STATIC_THRESHOLD */
-# endif /* NDEBUG */
-#endif /* !defined(NLOG) */
+# endif /* !XBT_LOG_STATIC_THRESHOLD */
+# endif /* NDEBUG */
+#endif /* !defined(NLOG) */
/* Transforms a category name to a global variable name. */
#define _XBT_LOGV(cat) _XBT_LOG_CONCAT(_simgrid_log_category__, cat)
* Indicates which category is the default one.
*/
-#if defined(XBT_LOG_MAYDAY) || defined(SUPERNOVAE_MODE) /*|| defined (NLOG) * turning logging off */
+#if defined(XBT_LOG_MAYDAY) || defined(SUPERNOVAE_MODE) /*|| defined (NLOG) * turning logging off */
# define XBT_LOG_DEFAULT_CATEGORY(cname)
#else
# define XBT_LOG_DEFAULT_CATEGORY(cname) \
XBT_PUBLIC(void) xbt_log_control_set(const char *cs);
/* Forward declarations */
- typedef struct xbt_log_appender_s s_xbt_log_appender_t,
- *xbt_log_appender_t;
- typedef struct xbt_log_layout_s s_xbt_log_layout_t, *xbt_log_layout_t;
- typedef struct xbt_log_event_s s_xbt_log_event_t, *xbt_log_event_t;
- typedef struct xbt_log_category_s s_xbt_log_category_t,
- *xbt_log_category_t;
+typedef struct xbt_log_appender_s s_xbt_log_appender_t,
+ *xbt_log_appender_t;
+typedef struct xbt_log_layout_s s_xbt_log_layout_t, *xbt_log_layout_t;
+typedef struct xbt_log_event_s s_xbt_log_event_t, *xbt_log_event_t;
+typedef struct xbt_log_category_s s_xbt_log_category_t,
+ *xbt_log_category_t;
/*
* Do NOT access any members of this structure directly. FIXME: move to private?
#else
#define XBT_LOG_BUFF_SIZE 2048 /* Size of the static string in which we build the log string */
#endif
- struct xbt_log_category_s {
- xbt_log_category_t parent;
- xbt_log_category_t firstChild;
- xbt_log_category_t nextSibling;
- const char *name;
- int threshold;
- int isThreshInherited;
- xbt_log_appender_t appender;
- xbt_log_layout_t layout;
- int additivity;
- };
-
- struct xbt_log_event_s {
- xbt_log_category_t cat;
- e_xbt_log_priority_t priority;
- const char *fileName;
- const char *functionName;
- int lineNum;
- va_list ap;
- va_list ap_copy; /* need a copy to launch dynamic layouts when the static ones overflowed */
+struct xbt_log_category_s {
+ xbt_log_category_t parent;
+ xbt_log_category_t firstChild;
+ xbt_log_category_t nextSibling;
+ const char *name;
+ int threshold;
+ int isThreshInherited;
+ xbt_log_appender_t appender;
+ xbt_log_layout_t layout;
+ int additivity;
+};
+
+struct xbt_log_event_s {
+ xbt_log_category_t cat;
+ e_xbt_log_priority_t priority;
+ const char *fileName;
+ const char *functionName;
+ int lineNum;
+ va_list ap;
+ va_list ap_copy; /* need a copy to launch dynamic layouts when the static ones overflowed */
#ifdef _XBT_WIN32
- char *buffer;
+ char *buffer;
#else
- char buffer[XBT_LOG_BUFF_SIZE];
+ char buffer[XBT_LOG_BUFF_SIZE];
#endif
- };
+};
/**
* \ingroup XBT_log_implem
XBT_PUBLIC_DATA(s_xbt_log_category_t) _XBT_LOGV(XBT_LOG_ROOT_CAT);
- extern xbt_log_appender_t xbt_log_default_appender;
- extern xbt_log_layout_t xbt_log_default_layout;
+extern xbt_log_appender_t xbt_log_default_appender;
+extern xbt_log_layout_t xbt_log_default_layout;
/* ********************** */
/* Public functions again */
* Setting the LogEvent's valist member is done inside _log_logEvent.
*/
#ifdef _XBT_WIN32
-#include <stdlib.h> /* calloc */
+#include <stdlib.h> /* calloc */
#define _XBT_LOG_PRE(catv, prio) do { \
if (_XBT_LOG_ISENABLEDV(catv, prio)) { \
s_xbt_log_event_t _log_ev; \
_log_ev.buffer = (char*) calloc(XBT_LOG_BUFF_SIZE + 1, sizeof(char)); \
_xbt_log_event_log(&_log_ev
#else
-#include <string.h> /* memset */
+#include <string.h> /* memset */
#define _XBT_LOG_PRE(catv, prio) do { \
if (_XBT_LOG_ISENABLEDV(catv, prio)) { \
s_xbt_log_event_t _log_ev; \
SG_END_DECL()
-#endif /* ! _XBT_LOG_H_ */
+#endif /* ! _XBT_LOG_H_ */
* @{
*/
/** \brief Mallocator data type (opaque structure) */
- typedef struct s_xbt_mallocator *xbt_mallocator_t;
+typedef struct s_xbt_mallocator *xbt_mallocator_t;
XBT_PUBLIC(xbt_mallocator_t) xbt_mallocator_new(int size,
pvoid_f_void_t new_f,
void_f_pvoid_t free_f,
/** @} */
SG_END_DECL()
-#endif /* _XBT_MALLOCATOR_H */
+#endif /* _XBT_MALLOCATOR_H */
SG_BEGIN_DECL()
- typedef struct {
- unsigned int lines, rows;
- unsigned long elmsize;
+typedef struct {
+ unsigned int lines, rows;
+ unsigned long elmsize;
- char *data;
- void_f_pvoid_t free_f;
- } s_xbt_matrix_t, *xbt_matrix_t;
+ char *data;
+ void_f_pvoid_t free_f;
+} s_xbt_matrix_t, *xbt_matrix_t;
/** @brief Retrieve the address of a cell (not its content)
XBT_PUBLIC(void) xbt_matrix_free(xbt_matrix_t matrix);
XBT_PUBLIC(void) xbt_matrix_free_voidp(void *d);
-XBT_PUBLIC(void) xbt_matrix_copy_values(xbt_matrix_t dest, xbt_matrix_t src,
+XBT_PUBLIC(void) xbt_matrix_copy_values(xbt_matrix_t dest,
+ xbt_matrix_t src,
unsigned int lsize,
unsigned int rsize,
unsigned int lpos_dst,
XBT_PUBLIC(void) xbt_matrix_double_addmult(xbt_matrix_t A, xbt_matrix_t B,
/*OUT*/ xbt_matrix_t C);
SG_END_DECL()
-#endif /* XBT_MATRIX_H */
+#endif /* XBT_MATRIX_H */
# define _XBT_GNUC_DESTRUCTOR __attribute__((__destructor__))
# undef _XBT_NEED_INIT_PRAGMA
-#else /* !__GNUC__ */
+#else /* !__GNUC__ */
# define _XBT_GNUC_PRINTF( format_idx, arg_idx )
# define _XBT_GNUC_SCANF( format_idx, arg_idx )
# define _XBT_GNUC_FORMAT( arg_idx )
# define _XBT_GNUC_DESTRUCTOR
# define _XBT_NEED_INIT_PRAGMA 1
-#endif /* !__GNUC__ */
+#endif /* !__GNUC__ */
/* inline and __FUNCTION__ are only in GCC when -ansi is off */
#if defined(__GNUC__) && ! defined(__STRICT_ANSI__)
# define _XBT_FUNCTION __FUNCTION__
#elif (defined(__STDC__) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
-# define _XBT_FUNCTION __func__ /* ISO-C99 compliant */
+# define _XBT_FUNCTION __func__ /* ISO-C99 compliant */
#else
# define _XBT_FUNCTION "function"
#endif
#define XBT_BACKTRACE_SIZE 10 /* FIXME: better place? Do document */
SG_END_DECL()
-#endif /* XBT_MISC_H */
+#endif /* XBT_MISC_H */
#ifdef HAVE_STDDEF_H
# include <stddef.h>
#else
-# include <sys/types.h> /* for size_t */
-# include <stdio.h> /* for NULL */
+# include <sys/types.h> /* for size_t */
+# include <stdio.h> /* for NULL */
#endif
//#include "./include/ansidecl.h"
/* Allocate SIZE bytes of memory. */
-extern void* mmalloc(void* md, size_t size);
+extern void *mmalloc(void *md, size_t size);
/* Re-allocate the previously allocated block in void*, making the new block
SIZE bytes long. */
-extern void* mrealloc(void* md, void* ptr, size_t size);
+extern void *mrealloc(void *md, void *ptr, size_t size);
/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
-extern void* mcalloc (void* md, size_t nmemb, size_t size);
+extern void *mcalloc(void *md, size_t nmemb, size_t size);
/* Free a block allocated by `mmalloc', `mrealloc' or `mcalloc'. */
-extern void mfree (void* md, void* ptr);
+extern void mfree(void *md, void *ptr);
/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */
-extern void* mmemalign (void* md, size_t alignment, size_t size);
+extern void *mmemalign(void *md, size_t alignment, size_t size);
/* Allocate SIZE bytes on a page boundary. */
-extern void* mvalloc (void* md, size_t size);
+extern void *mvalloc(void *md, size_t size);
/* Activate a standard collection of debugging hooks. */
-extern int mmcheck (void* md, void (*func) (void));
+extern int mmcheck(void *md, void (*func) (void));
-extern int mmcheckf (void* md, void (*func) (void), int force);
+extern int mmcheckf(void *md, void (*func) (void), int force);
/* Pick up the current statistics. (see FIXME elsewhere) */
-extern struct mstats mmstats (void* md);
+extern struct mstats mmstats(void *md);
-extern void* mmalloc_attach (int fd, void* baseaddr);
+extern void *mmalloc_attach(int fd, void *baseaddr);
-extern void* mmalloc_detach (void* md);
+extern void *mmalloc_detach(void *md);
-extern int mmalloc_setkey (void* md, int keynum, void* key);
+extern int mmalloc_setkey(void *md, int keynum, void *key);
-extern void* mmalloc_getkey (void* md, int keynum);
+extern void *mmalloc_getkey(void *md, int keynum);
// FIXME: this function is not implemented anymore?
//extern int mmalloc_errno (void* md);
extern int mmtrace(void);
-extern void* mmalloc_findbase(int size);
+extern void *mmalloc_findbase(int size);
/* To change the heap used when using the legacy version malloc/free/realloc and such */
void mmalloc_set_current_heap(void *new_heap);
-void* mmalloc_get_current_heap(void);
+void *mmalloc_get_current_heap(void);
-#endif /* MMALLOC_H */
+#endif /* MMALLOC_H */
XBT_PUBLIC(void) xbt_init(int *argc, char **argv);
XBT_PUBLIC(void) xbt_exit(void);
-#endif /* _XBT_MODULE_H */
+#endif /* _XBT_MODULE_H */
SG_BEGIN_DECL()
- typedef struct {
- char *name;
- int port;
- } s_xbt_peer_t, *xbt_peer_t;
+typedef struct {
+ char *name;
+ int port;
+} s_xbt_peer_t, *xbt_peer_t;
XBT_PUBLIC(xbt_peer_t) xbt_peer_new(const char *name, int port);
XBT_PUBLIC(xbt_peer_t) xbt_peer_from_string(const char *peerport);
XBT_PUBLIC(void) xbt_peer_free_voidp(void *d);
SG_END_DECL()
-#endif /* XBT_PEER_H */
+#endif /* XBT_PEER_H */
* @{
*/
/** \brief Queue data type (opaque type) */
- typedef struct s_xbt_queue_ *xbt_queue_t;
+typedef struct s_xbt_queue_ *xbt_queue_t;
-XBT_PUBLIC(xbt_queue_t) xbt_queue_new(int capacity, unsigned long elm_size);
+XBT_PUBLIC(xbt_queue_t) xbt_queue_new(int capacity,
+ unsigned long elm_size);
XBT_PUBLIC(void) xbt_queue_free(xbt_queue_t * queue);
XBT_PUBLIC(unsigned long) xbt_queue_length(const xbt_queue_t queue);
XBT_PUBLIC(void) xbt_queue_push_timed(xbt_queue_t queue, const void *src,
double delay);
-XBT_PUBLIC(void) xbt_queue_unshift_timed(xbt_queue_t queue, const void *src,
- double delay);
+XBT_PUBLIC(void) xbt_queue_unshift_timed(xbt_queue_t queue,
+ const void *src, double delay);
XBT_PUBLIC(void) xbt_queue_shift_timed(xbt_queue_t queue, void *const dst,
double delay);
XBT_PUBLIC(void) xbt_queue_pop_timed(xbt_queue_t queue, void *const dst,
/** @} */
SG_END_DECL()
-#endif /* _XBT_QUEUE_H */
+#endif /* _XBT_QUEUE_H */
* @{
*/
/** \brief Opaque type representing a set */
- typedef struct xbt_set_ *xbt_set_t;
+typedef struct xbt_set_ *xbt_set_t;
#define XBT_SET_HEADERS \
unsigned int ID; \
unsigned int name_len
/** \brief It must be possible to cast set elements to this type */
- typedef struct xbt_set_elm_ {
- unsigned int ID; /**< Identificator (system assigned) */
- char *name; /**< Name (user assigned) */
- unsigned int name_len;
+typedef struct xbt_set_elm_ {
+ unsigned int ID; /**< Identificator (system assigned) */
+ char *name; /**< Name (user assigned) */
+ unsigned int name_len;
/**< Length of the name */
- } s_xbt_set_elm_t, *xbt_set_elm_t;
+} s_xbt_set_elm_t, *xbt_set_elm_t;
/*####[ Functions ]##########################################################*/
XBT_PUBLIC(xbt_set_t) xbt_set_new(void);
int key_len);
XBT_PUBLIC(void) xbt_set_remove_by_id(xbt_set_t set, int id);
-XBT_PUBLIC(xbt_set_elm_t) xbt_set_get_by_name(xbt_set_t set, const char *key);
+XBT_PUBLIC(xbt_set_elm_t) xbt_set_get_by_name(xbt_set_t set,
+ const char *key);
XBT_PUBLIC(xbt_set_elm_t) xbt_set_get_by_name_ext(xbt_set_t set,
const char *key,
int key_len);
*/
/** @brief Cursor type */
- typedef struct xbt_set_cursor_ *xbt_set_cursor_t;
+typedef struct xbt_set_cursor_ *xbt_set_cursor_t;
XBT_PUBLIC(void) xbt_set_cursor_first(xbt_set_t set,
xbt_set_cursor_t * cursor);
/* @} */
SG_END_DECL()
-#endif /* _XBT_SET_H */
+#endif /* _XBT_SET_H */
void xbt_setset_elm_add(xbt_setset_t setset, void *obj);
/* Remove an object from the setset */
-void xbt_setset_elm_remove(xbt_setset_t setset, void * obj);
+void xbt_setset_elm_remove(xbt_setset_t setset, void *obj);
/* Create a new set in the setset */
xbt_setset_set_t xbt_setset_new_set(xbt_setset_t setset);
void xbt_setset_destroy_set(xbt_setset_set_t);
/* Insert an element into a set */
-void xbt_setset_set_insert(xbt_setset_set_t set, void* obj);
+void xbt_setset_set_insert(xbt_setset_set_t set, void *obj);
/* Remove an element from a set */
-void xbt_setset_set_remove(xbt_setset_set_t set, void* obj);
+void xbt_setset_set_remove(xbt_setset_set_t set, void *obj);
/* Remove all the elements of a set */
void xbt_setset_set_reset(xbt_setset_set_t set);
void *xbt_setset_set_extract(xbt_setset_set_t set);
/* Test if an element belongs to a set */
-int xbt_setset_set_belongs(xbt_setset_set_t set, void* obj);
+int xbt_setset_set_belongs(xbt_setset_set_t set, void *obj);
/* Get the number of elements in a set */
int xbt_setset_set_size(xbt_setset_set_t set);
void xbt_setset_intersect(xbt_setset_set_t set1, xbt_setset_set_t set2);
/* Get the cursor to point to the first element of a set */
-void xbt_setset_cursor_first(xbt_setset_set_t set, xbt_setset_cursor_t *cursor);
+void xbt_setset_cursor_first(xbt_setset_set_t set,
+ xbt_setset_cursor_t * cursor);
/* Get the data pointed by a cursor */
int xbt_setset_cursor_get_data(xbt_setset_cursor_t cursor, void **data);
#define xbt_setset_foreach(set, cursor, data) \
for(xbt_setset_cursor_first(set, &cursor); \
xbt_setset_cursor_get_data(cursor, (void **)&data); \
- xbt_setset_cursor_next(cursor))
+ xbt_setset_cursor_next(cursor))
#endif
* asprintf()), while some other are a bit more exotic.
* @{
*/
-
-
/* Trim related functions */
XBT_PUBLIC(void) xbt_str_rtrim(char *s, const char *char_list);
XBT_PUBLIC(void) xbt_str_ltrim(char *s, const char *char_list);
XBT_PUBLIC(void) xbt_str_strip_spaces(char *);
XBT_PUBLIC(char *) xbt_str_diff(char *a, char *b);
-XBT_PUBLIC(char*)xbt_str_from_file(FILE *file);
+XBT_PUBLIC(char *) xbt_str_from_file(FILE * file);
/**Â @brief Classical alias to (char*)
*
* This of almost no use, beside cosmetics and the GRAS parsing macro (see \ref GRAS_dd_auto).
*/
- typedef char *xbt_string_t;
+typedef char *xbt_string_t;
/**@}*/
SG_END_DECL()
-#endif /* XBT_STR_H */
+#endif /* XBT_STR_H */
XBT_PUBLIC(void) xbt_strbuff_append(xbt_strbuff_t b, const char *toadd);
XBT_PUBLIC(void) xbt_strbuff_chomp(xbt_strbuff_t b);
XBT_PUBLIC(void) xbt_strbuff_trim(xbt_strbuff_t b);
-XBT_PUBLIC(void) xbt_strbuff_varsubst(xbt_strbuff_t b, xbt_dict_t patterns);
+XBT_PUBLIC(void) xbt_strbuff_varsubst(xbt_strbuff_t b,
+ xbt_dict_t patterns);
#endif
those structs directly. Use them as an abstract datatype.
*/
/* @{ */
- typedef struct xbt_swag_hookup {
- void *next;
- void *prev;
- } s_xbt_swag_hookup_t;
+typedef struct xbt_swag_hookup {
+ void *next;
+ void *prev;
+} s_xbt_swag_hookup_t;
/**< This type should be added to a type that is to be used in a swag.
*
* Whenever a new object with this struct is created, all fields have
}
\endcode
*/
- typedef s_xbt_swag_hookup_t *xbt_swag_hookup_t;
+typedef s_xbt_swag_hookup_t *xbt_swag_hookup_t;
- typedef struct xbt_swag {
- void *head;
- void *tail;
- size_t offset;
- int count;
- } s_xbt_swag_t, *xbt_swag_t;
+typedef struct xbt_swag {
+ void *head;
+ void *tail;
+ size_t offset;
+ int count;
+} s_xbt_swag_t, *xbt_swag_t;
/**< A typical swag */
/* @} */
#define xbt_swag_getNext(obj,offset) (((xbt_swag_hookup_t)(((char *) (obj)) + (offset)))->prev)
#define xbt_swag_getPrev(obj,offset) (((xbt_swag_hookup_t)(((char *) (obj)) + (offset)))->next)
-static XBT_INLINE int xbt_swag_belongs(void *obj, xbt_swag_t swag) {
- return ((xbt_swag_getNext(obj, swag->offset)) || (xbt_swag_getPrev(obj, swag->offset))
- || (swag->head == obj));
+static XBT_INLINE int xbt_swag_belongs(void *obj, xbt_swag_t swag)
+{
+ return ((xbt_swag_getNext(obj, swag->offset))
+ || (xbt_swag_getPrev(obj, swag->offset))
+ || (swag->head == obj));
}
static XBT_INLINE void *xbt_swag_getFirst(xbt_swag_t swag)
/* @} */
SG_END_DECL()
-#endif /* _XBT_SWAG_H */
+#endif /* _XBT_SWAG_H */
#include "xbt/dynar.h"
SG_BEGIN_DECL()
-XBT_PUBLIC(void) xbt_dynar_dopar(xbt_dynar_t datas, void_f_int_pvoid_t function);
+XBT_PUBLIC(void) xbt_dynar_dopar(xbt_dynar_t datas,
+ void_f_int_pvoid_t function);
SG_END_DECL()
-
-#endif /* SYNCHRO_H_ */
+#endif /* SYNCHRO_H_ */
* @{
*/
/** \brief Thread data type (opaque structure) */
- typedef struct s_xbt_thread_ *xbt_thread_t;
+typedef struct s_xbt_thread_ *xbt_thread_t;
XBT_PUBLIC(xbt_thread_t) xbt_thread_create(const char *name,
void_f_pvoid_t start_routine,
- void *param,int joinable);
+ void *param, int joinable);
XBT_PUBLIC(xbt_thread_t) xbt_thread_self(void);
XBT_PUBLIC(const char *) xbt_thread_name(xbt_thread_t t);
XBT_PUBLIC(const char *) xbt_thread_self_name(void);
/** \brief Thread mutex data type (opaque structure) */
- typedef struct s_xbt_mutex_ *xbt_mutex_t;
+typedef struct s_xbt_mutex_ *xbt_mutex_t;
XBT_PUBLIC(xbt_mutex_t) xbt_mutex_init(void);
XBT_PUBLIC(void) xbt_mutex_acquire(xbt_mutex_t mutex);
/** \brief Thread condition data type (opaque structure) */
- typedef struct s_xbt_cond_ *xbt_cond_t;
+typedef struct s_xbt_cond_ *xbt_cond_t;
XBT_PUBLIC(xbt_cond_t) xbt_cond_init(void);
XBT_PUBLIC(void) xbt_cond_wait(xbt_cond_t cond, xbt_mutex_t mutex);
/** @} */
SG_END_DECL()
-#endif /* _XBT_THREAD_H */
+#endif /* _XBT_THREAD_H */
#if defined(__GNUC__) || defined(DOXYGEN)
/** @brief Like strdup, but xbt_die() on error */
-static inline __attribute__((always_inline)) char *xbt_strdup(const char *s)
+static inline __attribute__ ((always_inline))
+char *xbt_strdup(const char *s)
{
char *res = NULL;
if (s) {
/** @brief Like malloc, but xbt_die() on error
@hideinitializer */
-static inline __attribute__((always_inline)) void *xbt_malloc(unsigned int n)
+static inline __attribute__ ((always_inline))
+void *xbt_malloc(unsigned int n)
{
void *res;
/* if (n==0) {
/** @brief like malloc, but xbt_die() on error and memset data to 0
@hideinitializer */
-static inline __attribute__((always_inline)) void *xbt_malloc0(unsigned int n)
+static inline __attribute__ ((always_inline))
+void *xbt_malloc0(unsigned int n)
{
void *res;
//if (n==0) xbt_die("calloc(0) is not portable");
/** @brief like realloc, but xbt_die() on error
@hideinitializer */
-static inline __attribute__((always_inline)) void *xbt_realloc(void *p, unsigned int s)
+static inline __attribute__ ((always_inline))
+void *xbt_realloc(void *p, unsigned int s)
{
void *res = res;
//if (s==0) xbt_die("realloc(0) is not portable");
}
return res;
}
-#else /* non __GNUC__ */
+#else /* non __GNUC__ */
# define xbt_strdup(s) strdup(s)
# define xbt_malloc(n) malloc(n)
# define xbt_malloc0(n) calloc(n,1)
# define xbt_realloc(p,s) realloc(p,s)
-#endif /* __GNUC__ ? */
+#endif /* __GNUC__ ? */
/** @brief like free
@hideinitializer */
SG_END_DECL()
-#endif /* _XBT_SYSDEP_H */
+#endif /* _XBT_SYSDEP_H */
SG_BEGIN_DECL()
- /* Get the PID of the current process */
- XBT_PUBLIC_DATA(int_f_void_t) xbt_getpid;
+ /* Get the PID of the current process */
+ XBT_PUBLIC_DATA(int_f_void_t) xbt_getpid;
SG_END_DECL()
-#endif /* __XBT_VIRTU_H__ */
+#endif /* __XBT_VIRTU_H__ */
* License along with QueueUserAPCEx in the file COPYING.LIB;\r
* if not, write to the Free Software Foundation, Inc.,\r
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA\r
- */\r
-\r
+ */ \r
+ \r
#ifndef UCONTEXT_H\r
#define UCONTEXT_H\r
-\r
+ \r
#include <windows.h>\r
-\r
-typedef struct __stack {\r
- void *ss_sp;\r
- size_t ss_size;\r
- int ss_flags;\r
-} stack_t;\r
-\r
-typedef CONTEXT mcontext_t;\r
-typedef unsigned long __sigset_t;\r
-\r
-typedef struct __ucontext {\r
- unsigned long int uc_flags;\r
- struct __ucontext *uc_link;\r
- stack_t uc_stack;\r
- mcontext_t uc_mcontext;\r
- __sigset_t uc_sigmask;\r
-} ucontext_t;\r
-\r
-\r
-int getcontext(ucontext_t *ucp);\r
-int setcontext(const ucontext_t *ucp);\r
-int makecontext(ucontext_t *, void (*)(), int, ...);\r
-int swapcontext(ucontext_t *, const ucontext_t *);\r
-\r
-#endif /* UCONTEXT_H */\r
+ \rtypedef struct __stack {
+ \rvoid *ss_sp;
+ \rsize_t ss_size;
+ \rint ss_flags;
+\r} stack_t;
+\r\rtypedef CONTEXT mcontext_t;
+\rtypedef unsigned long __sigset_t;
+\r\rtypedef struct __ucontext {
+ \runsigned long int uc_flags;
+ \rstruct __ucontext *uc_link;
+ \rstack_t uc_stack;
+ \rmcontext_t uc_mcontext;
+ \r__sigset_t uc_sigmask;
+\r} ucontext_t;
+\r\r\rint getcontext(ucontext_t * ucp);
+\rint setcontext(const ucontext_t * ucp);
+\rint makecontext(ucontext_t *, void (*)(), int, ...);
+\rint swapcontext(ucontext_t *, const ucontext_t *);
+\r\r
+#endif /* UCONTEXT_H */\r
gras_datadesc_struct_close(bw_res_desc);
bw_res_desc = gras_datadesc_ref("bw_res_t", bw_res_desc);
- gras_msgtype_declare_rpc("BW handshake", bw_request_desc, bw_request_desc);
+ gras_msgtype_declare_rpc("BW handshake", bw_request_desc,
+ bw_request_desc);
gras_msgtype_declare_rpc("BW reask", bw_request_desc, NULL);
gras_msgtype_declare("BW stop", NULL);
request->peer.name = NULL;
request->peer.port = gras_socket_my_port(measMasterIn);
DEBUG6
- ("Handshaking with %s:%d to connect it back on my %d (bufsize=%ld, msg_size=%ld, msg_amount=%ld)",
- gras_socket_peer_name(peer), gras_socket_peer_port(peer),
- request->peer.port, request->buf_size, request->msg_size,
- request->msg_amount);
+ ("Handshaking with %s:%d to connect it back on my %d (bufsize=%ld, msg_size=%ld, msg_amount=%ld)",
+ gras_socket_peer_name(peer), gras_socket_peer_port(peer),
+ request->peer.port, request->buf_size, request->msg_size,
+ request->msg_amount);
TRY {
gras_msg_rpccall(peer, 15, "BW handshake", &request, &request_ack);
}
CATCH(e) {
RETHROW2
- ("Error encountered while opening the measurement socket to %s:%d for BW test: %s",
- gras_socket_peer_name(peer), request_ack->peer.port);
+ ("Error encountered while opening the measurement socket to %s:%d for BW test: %s",
+ gras_socket_peer_name(peer), request_ack->peer.port);
}
- DEBUG2("Got ACK; conduct the experiment (msg_size = %ld, msg_amount=%ld)",
- request->msg_size, request->msg_amount);
+ DEBUG2
+ ("Got ACK; conduct the experiment (msg_size = %ld, msg_amount=%ld)",
+ request->msg_size, request->msg_amount);
*sec = 0;
first_pass = 1;
And then increase the number of messages to compensate (check for overflow there, too) */
if (request->msg_size > 64 * 1024 * 1024) {
unsigned long int new_amount =
- ((request->msg_size / ((double) 64 * 1024 * 1024))
- * request->msg_amount) + 1;
+ ((request->msg_size / ((double) 64 * 1024 * 1024))
+ * request->msg_amount) + 1;
xbt_assert0(new_amount > request->msg_amount,
"Overflow on the number of messages! You must have a *really* fat pipe. Please fix your platform");
}
VERB5
- ("The experiment was too short (%f sec<%f sec). Redo it with msg_size=%lu (nb_messages=%lu) (got %fMb/s)",
- meas_duration, min_duration, request->msg_size, request->msg_amount,
- ((double) request->msg_size) * ((double) request->msg_amount /
- (*sec) / 1024.0 / 1024.0));
+ ("The experiment was too short (%f sec<%f sec). Redo it with msg_size=%lu (nb_messages=%lu) (got %fMb/s)",
+ meas_duration, min_duration, request->msg_size,
+ request->msg_amount,
+ ((double) request->msg_size) * ((double) request->msg_amount /
+ (*sec) / 1024.0 / 1024.0));
gras_msg_rpccall(peer, 60, "BW reask", &request, NULL);
}
*sec = gras_os_time() - *sec;
if (*sec != 0.0) {
*bw =
- ((double) request->msg_size) * ((double) request->msg_amount) /
- (*sec);
+ ((double) request->msg_size) * ((double) request->msg_amount) /
+ (*sec);
}
DEBUG1("Experiment done ; it took %f sec", *sec);
if (*sec <= 0) {
} while (*sec < min_duration);
- DEBUG2("This measurement was long enough (%f sec; found %f b/s). Stop peer",
- *sec, *bw);
+ DEBUG2
+ ("This measurement was long enough (%f sec; found %f b/s). Stop peer",
+ *sec, *bw);
gras_msg_send(peer, "BW stop", NULL);
free(request_ack);
static xbt_dynar_t msgtwaited = NULL;
DEBUG5
- ("Handshaked to connect to %s:%d (sizes: buf=%lu msg=%lu msg_amount=%lu)",
- gras_socket_peer_name(expeditor), request->peer.port, request->buf_size,
- request->msg_size, request->msg_amount);
+ ("Handshaked to connect to %s:%d (sizes: buf=%lu msg=%lu msg_amount=%lu)",
+ gras_socket_peer_name(expeditor), request->peer.port,
+ request->buf_size, request->msg_size, request->msg_amount);
/* Build our answer */
answer = xbt_new0(s_bw_request_t, 1);
else
/* FIXME: tell error to remote */
RETHROW0
- ("Error encountered while opening a measurement server socket: %s");
+ ("Error encountered while opening a measurement server socket: %s");
}
}
}
CATCH(e) {
RETHROW2
- ("Error encountered while opening a measurement socket back to %s:%d : %s",
- gras_socket_peer_name(expeditor), request->peer.port);
+ ("Error encountered while opening a measurement socket back to %s:%d : %s",
+ gras_socket_peer_name(expeditor), request->peer.port);
/* FIXME: tell error to remote */
}
TRY {
measIn = gras_socket_meas_accept(measMasterIn);
DEBUG4
- ("BW handshake answered. buf_size=%lu msg_size=%lu msg_amount=%lu port=%d",
- answer->buf_size, answer->msg_size, answer->msg_amount,
- answer->peer.port);
+ ("BW handshake answered. buf_size=%lu msg_size=%lu msg_amount=%lu port=%d",
+ answer->buf_size, answer->msg_size, answer->msg_amount,
+ answer->peer.port);
}
CATCH(e) {
gras_socket_close(measMasterIn);
if (i != j) {
/* Mesurements of Bandwidth */
amok_bw_request(p1->name, p1->port, p2->name, p2->port,
- buf_size_bw, msg_size_bw, msg_amount_bw, min_duration,
- &sec, &matrix_res[i * len + j]);
+ buf_size_bw, msg_size_bw, msg_amount_bw,
+ min_duration, &sec, &matrix_res[i * len + j]);
}
}
}
const char *to_name, unsigned int to_port,
unsigned int msg_size, unsigned int duration);
-#endif /* AMOK_BANDWIDTH_PRIVATE_H */
+#endif /* AMOK_BANDWIDTH_PRIVATE_H */
/* Launch the saturation */
- ctx = gras_msg_rpc_async_call(peer_cmd, 60, "amok_bw_sat begin", &request);
+ ctx =
+ gras_msg_rpc_async_call(peer_cmd, 60, "amok_bw_sat begin", &request);
free(request);
gras_msg_rpc_async_wait(ctx, &request);
meas = gras_socket_client_ext(to_name, request->peer.port,
free(answer);
} else {
INFO6
- ("Saturation from %s:%d to %s:%d elapsed after %f sec (achieving %f kb/s)",
- gras_os_myname(), gras_os_myport(), to_name, to_port, elapsed,
- bw / 1024.0);
+ ("Saturation from %s:%d to %s:%d elapsed after %f sec (achieving %f kb/s)",
+ gras_os_myname(), gras_os_myport(), to_name, to_port, elapsed,
+ bw / 1024.0);
}
gras_socket_close(meas);
xbt_ex_free(e);
else
RETHROW0
- ("Error encountered while opening a measurement server socket: %s");
+ ("Error encountered while opening a measurement server socket: %s");
}
if (measMaster == NULL)
port++; /* prepare for a new loop */
TRY {
gras_msg_rpccall(sock, 60, "amok_bw_sat stop", NULL, &answer);
} CATCH(e) {
- RETHROW2("Cannot ask %s:%d to stop saturation: %s", from_name, from_port);
+ RETHROW2("Cannot ask %s:%d to stop saturation: %s", from_name,
+ from_port);
}
gras_socket_close(sock);
if (time)
static int amok_pm_cb_join(gras_msg_cb_ctx_t ctx, void *payload)
{
amok_pm_moddata_t g = gras_moddata_by_id(amok_pm_moddata_id);
- char* group_name = *(char* *) payload;
+ char *group_name = *(char **) payload;
xbt_dynar_t group = xbt_dict_get(g->groups, group_name);
int rank;
rank = xbt_dynar_length(group);
xbt_dynar_push(group, &dude);
- VERB3("Contacted by %s:%d. Give it rank #%d", dude->name, dude->port,rank);
+ VERB3("Contacted by %s:%d. Give it rank #%d", dude->name, dude->port,
+ rank);
gras_msg_rpcreturn(10, ctx, &rank);
free(group_name);
gras_msg_rpccall(master, 30, "amok_pm_join", &group_name, &rank);
VERB4("Joined group '%s' on %s:%d. Got rank %d",
group_name, gras_socket_peer_name(master),
- gras_socket_peer_port(master),
- rank);
+ gras_socket_peer_port(master), rank);
return rank;
}
/* no world-wide globals */
/* Datatype and message declarations */
gras_datadesc_type_t pm_group_type =
- gras_datadesc_dynar(gras_datadesc_by_name("xbt_peer_t"),
- xbt_peer_free_voidp);
+ gras_datadesc_dynar(gras_datadesc_by_name("xbt_peer_t"),
+ xbt_peer_free_voidp);
gras_msgtype_declare("amok_pm_kill", NULL);
gras_msgtype_declare_rpc("amok_pm_killrpc", NULL, NULL);
gras_msgtype_declare_rpc("amok_pm_get",
gras_datadesc_by_name("string"), pm_group_type);
- gras_msgtype_declare_rpc("amok_pm_join", gras_datadesc_by_name("string"), gras_datadesc_by_name("int"));
+ gras_msgtype_declare_rpc("amok_pm_join", gras_datadesc_by_name("string"),
+ gras_datadesc_by_name("int"));
gras_msgtype_declare_rpc("amok_pm_leave",
gras_datadesc_by_name("string"), NULL);
void amok_pm_modulecreate()
{
- gras_module_add("amok_pm", sizeof(s_amok_pm_moddata_t), &amok_pm_moddata_id,
- _amok_pm_init, _amok_pm_exit, _amok_pm_join,
- _amok_pm_leave);
+ gras_module_add("amok_pm", sizeof(s_amok_pm_moddata_t),
+ &amok_pm_moddata_id, _amok_pm_init, _amok_pm_exit,
+ _amok_pm_join, _amok_pm_leave);
}
/* module creation functions */
void amok_pm_modulecreate(void);
-#endif /* AMOK_BASE_H */
+#endif /* AMOK_BASE_H */
/**********************************************/
const char *SIM_PREEMBULE =
- "/* specific to Borland Compiler */\n"
- "#ifdef __BORLANDC__\n"
- "#pragma hdrstop\n"
- "#endif\n\n"
- "#include <stdlib.h>\n"
- "#include <stdio.h>\n"
- "#include \"msg/msg.h\"\n"
- "#include <gras.h>\n" "\n" "char *gras_log=NULL;\n";
+ "/* specific to Borland Compiler */\n"
+ "#ifdef __BORLANDC__\n"
+ "#pragma hdrstop\n"
+ "#endif\n\n"
+ "#include <stdlib.h>\n"
+ "#include <stdio.h>\n"
+ "#include \"msg/msg.h\"\n"
+ "#include <gras.h>\n" "\n" "char *gras_log=NULL;\n";
#define SIM_LAUNCH_FUNC \
"}\n"
const char *SIM_MAIN_POSTEMBULE = "\n"
- "\n"
- " gras_load_environment_script(argv[1]);\n"
- "\n"
- " /* Run the simulation */\n"
- " gras_main();\n"
- "\n"
- " /* cleanup the place */\n"
- " gras_clean();\n"
- " if (gras_log)\n" " free(gras_log);\n" " return 0;\n" "}\n";
+ "\n"
+ " gras_load_environment_script(argv[1]);\n"
+ "\n"
+ " /* Run the simulation */\n"
+ " gras_main();\n"
+ "\n"
+ " /* cleanup the place */\n"
+ " gras_clean();\n"
+ " if (gras_log)\n" " free(gras_log);\n" " return 0;\n" "}\n";
/***************************************
" if (argc != 2) {\n"
" fprintf(stderr, \"Usage: lua platform_script.lua [--log=...]\\n\");\n"
" exit(1);\n" " }\n" "\n");
- fprintf(OUT,
- "\n" " /* Application deployment */\n");
+ fprintf(OUT, "\n" " /* Application deployment */\n");
xbt_dict_foreach(process_function_set, cursor, key, data) {
- fprintf(OUT, " gras_function_register(\"%s\", launch_%s);\n", key, key);
+ fprintf(OUT, " gras_function_register(\"%s\", launch_%s);\n", key,
+ key);
}
fprintf(OUT, "%s", SIM_MAIN_POSTEMBULE);
fclose(OUT);
xbt_dict_foreach(process_function_set, cursor, key, data) {
filename =
- xbt_new(char, strlen(project) + strlen(RL_SOURCENAME) + strlen(key));
+ xbt_new(char,
+ strlen(project) + strlen(RL_SOURCENAME) + strlen(key));
sprintf(filename, RL_SOURCENAME, project, key);
char *filename = NULL;
FILE *OUT = NULL;
- filename = xbt_new(char, strlen(project) + strlen(MAKEFILE_FILENAME_LOCAL));
+ filename =
+ xbt_new(char, strlen(project) + strlen(MAKEFILE_FILENAME_LOCAL));
sprintf(filename, MAKEFILE_FILENAME_LOCAL, project);
OUT = fopen(filename, "w");
#include "xbt.h"
#include "lua_stub_generator.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua,bindings,"Lua Bindings");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua, bindings, "Lua Bindings");
#define TASK_MODULE_NAME "simgrid.Task"
#define HOST_MODULE_NAME "simgrid.Host"
/* ********************************************************************************* */
/* helper functions */
/* ********************************************************************************* */
-static void stackDump (const char *msg, lua_State *L) {
+static void stackDump(const char *msg, lua_State * L)
+{
char buff[2048];
- char *p=buff;
+ char *p = buff;
int i;
int top = lua_gettop(L);
fflush(stdout);
- p+=sprintf(p,"STACK(top=%d): ",top);
+ p += sprintf(p, "STACK(top=%d): ", top);
for (i = 1; i <= top; i++) { /* repeat for each level */
int t = lua_type(L, i);
switch (t) {
- case LUA_TSTRING: /* strings */
- p+=sprintf(p,"`%s'", lua_tostring(L, i));
+ case LUA_TSTRING: /* strings */
+ p += sprintf(p, "`%s'", lua_tostring(L, i));
break;
- case LUA_TBOOLEAN: /* booleans */
- p+=sprintf(p,lua_toboolean(L, i) ? "true" : "false");
+ case LUA_TBOOLEAN: /* booleans */
+ p += sprintf(p, lua_toboolean(L, i) ? "true" : "false");
break;
- case LUA_TNUMBER: /* numbers */
- p+=sprintf(p,"%g", lua_tonumber(L, i));
+ case LUA_TNUMBER: /* numbers */
+ p += sprintf(p, "%g", lua_tonumber(L, i));
break;
case LUA_TTABLE:
- p+=sprintf(p, "Table");
+ p += sprintf(p, "Table");
break;
- default: /* other values */
- p+=sprintf(p, "???");
+ default: /* other values */
+ p += sprintf(p, "???");
/* if ((ptr = luaL_checkudata(L,i,TASK_MODULE_NAME))) {
p+=sprintf(p,"task");
} else {
break;
}
- p+=sprintf(p," "); /* put a separator */
+ p += sprintf(p, " "); /* put a separator */
}
- INFO2("%s%s",msg,buff);
+ INFO2("%s%s", msg, buff);
}
/** @brief ensures that a userdata on the stack is a task and returns the pointer inside the userdata */
-static m_task_t checkTask (lua_State *L,int index) {
- m_task_t *pi,tk;
- luaL_checktype(L,index,LUA_TTABLE);
- lua_getfield(L,index,"__simgrid_task");
- pi = (m_task_t*)luaL_checkudata(L,-1,TASK_MODULE_NAME);
- if(pi == NULL)
- luaL_typerror(L,index,TASK_MODULE_NAME);
+static m_task_t checkTask(lua_State * L, int index)
+{
+ m_task_t *pi, tk;
+ luaL_checktype(L, index, LUA_TTABLE);
+ lua_getfield(L, index, "__simgrid_task");
+ pi = (m_task_t *) luaL_checkudata(L, -1, TASK_MODULE_NAME);
+ if (pi == NULL)
+ luaL_typerror(L, index, TASK_MODULE_NAME);
tk = *pi;
- if(!tk)
- luaL_error(L,"null Task");
- lua_pop(L,1);
- return tk;
+ if (!tk)
+ luaL_error(L, "null Task");
+ lua_pop(L, 1);
+ return tk;
}
+
/* ********************************************************************************* */
/* wrapper functions */
/* ********************************************************************************* */
* If 0, then it cannot be transfered with the get() and put() methods.
* This value has to be >= 0.
*/
-static int Task_new(lua_State* L) {
- const char *name=luaL_checkstring(L,1);
- int comp_size = luaL_checkint(L,2);
- int msg_size = luaL_checkint(L,3);
- m_task_t msg_task = MSG_task_create(name,comp_size,msg_size,NULL);
- lua_newtable (L); /* create a table, put the userdata on top of it */
- m_task_t *lua_task = (m_task_t*)lua_newuserdata(L,sizeof(m_task_t));
- *lua_task = msg_task;
- luaL_getmetatable(L,TASK_MODULE_NAME);
- lua_setmetatable(L,-2);
- lua_setfield (L, -2, "__simgrid_task"); /* put the userdata as field of the table */
- /* remove the args from the stack */
- lua_remove(L,1);
- lua_remove(L,1);
- lua_remove(L,1);
- return 1;
+static int Task_new(lua_State * L)
+{
+ const char *name = luaL_checkstring(L, 1);
+ int comp_size = luaL_checkint(L, 2);
+ int msg_size = luaL_checkint(L, 3);
+ m_task_t msg_task = MSG_task_create(name, comp_size, msg_size, NULL);
+ lua_newtable(L); /* create a table, put the userdata on top of it */
+ m_task_t *lua_task = (m_task_t *) lua_newuserdata(L, sizeof(m_task_t));
+ *lua_task = msg_task;
+ luaL_getmetatable(L, TASK_MODULE_NAME);
+ lua_setmetatable(L, -2);
+ lua_setfield(L, -2, "__simgrid_task"); /* put the userdata as field of the table */
+ /* remove the args from the stack */
+ lua_remove(L, 1);
+ lua_remove(L, 1);
+ lua_remove(L, 1);
+ return 1;
}
-static int Task_get_name(lua_State *L) {
- m_task_t tk = checkTask(L,-1);
- lua_pushstring(L,MSG_task_get_name(tk));
+static int Task_get_name(lua_State * L)
+{
+ m_task_t tk = checkTask(L, -1);
+ lua_pushstring(L, MSG_task_get_name(tk));
return 1;
}
-static int Task_computation_duration(lua_State *L){
- m_task_t tk = checkTask(L,-1);
- lua_pushnumber(L,MSG_task_get_compute_duration (tk));
+static int Task_computation_duration(lua_State * L)
+{
+ m_task_t tk = checkTask(L, -1);
+ lua_pushnumber(L, MSG_task_get_compute_duration(tk));
return 1;
}
-static int Task_execute(lua_State *L){
- m_task_t tk = checkTask(L,-1);
+static int Task_execute(lua_State * L)
+{
+ m_task_t tk = checkTask(L, -1);
int res = MSG_task_execute(tk);
- lua_pushnumber(L,res);
+ lua_pushnumber(L, res);
return 1;
}
-static int Task_destroy(lua_State *L) {
- m_task_t tk = checkTask(L,-1);
+static int Task_destroy(lua_State * L)
+{
+ m_task_t tk = checkTask(L, -1);
int res = MSG_task_destroy(tk);
- lua_pushnumber(L,res);
+ lua_pushnumber(L, res);
return 1;
}
-static int Task_send(lua_State *L) {
+static int Task_send(lua_State * L)
+{
//stackDump("send ",L);
- m_task_t tk = checkTask(L,-2);
- const char *mailbox = luaL_checkstring(L,-1);
- lua_pop(L,1); // remove the string so that the task is on top of it
- MSG_task_set_data(tk,L); // Copy my stack into the task, so that the receiver can copy the lua task directly
- MSG_error_t res = MSG_task_send(tk,mailbox);
- while (MSG_task_get_data(tk)!=NULL) // Don't mess up with my stack: the receiver didn't copy the data yet
- MSG_process_sleep(0); // yield
-
- if (res != MSG_OK) switch(res) {
- case MSG_TIMEOUT :
+ m_task_t tk = checkTask(L, -2);
+ const char *mailbox = luaL_checkstring(L, -1);
+ lua_pop(L, 1); // remove the string so that the task is on top of it
+ MSG_task_set_data(tk, L); // Copy my stack into the task, so that the receiver can copy the lua task directly
+ MSG_error_t res = MSG_task_send(tk, mailbox);
+ while (MSG_task_get_data(tk) != NULL) // Don't mess up with my stack: the receiver didn't copy the data yet
+ MSG_process_sleep(0); // yield
+
+ if (res != MSG_OK)
+ switch (res) {
+ case MSG_TIMEOUT:
ERROR0("MSG_task_send failed : Timeout");
break;
- case MSG_TRANSFER_FAILURE :
+ case MSG_TRANSFER_FAILURE:
ERROR0("MSG_task_send failed : Transfer Failure");
break;
- case MSG_HOST_FAILURE :
+ case MSG_HOST_FAILURE:
ERROR0("MSG_task_send failed : Host Failure ");
break;
- default :
- ERROR0("MSG_task_send failed : Unexpected error , please report this bug");
+ default:
+ ERROR0
+ ("MSG_task_send failed : Unexpected error , please report this bug");
break;
}
return 0;
}
-static int Task_recv(lua_State *L) {
+static int Task_recv(lua_State * L)
+{
m_task_t tk = NULL;
- const char *mailbox = luaL_checkstring(L,-1);
- MSG_error_t res = MSG_task_receive(&tk,mailbox);
+ const char *mailbox = luaL_checkstring(L, -1);
+ MSG_error_t res = MSG_task_receive(&tk, mailbox);
lua_State *sender_stack = MSG_task_get_data(tk);
- lua_xmove(sender_stack,L,1); // copy the data directly from sender's stack
- MSG_task_set_data(tk,NULL);
-
- if(res != MSG_OK) switch(res){
- case MSG_TIMEOUT :
- ERROR0("MSG_task_receive failed : Timeout");
- break;
- case MSG_TRANSFER_FAILURE :
- ERROR0("MSG_task_receive failed : Transfer Failure");
- break;
- case MSG_HOST_FAILURE :
- ERROR0("MSG_task_receive failed : Host Failure ");
- break;
- default :
- ERROR0("MSG_task_receive failed : Unexpected error , please report this bug");
- break;
- }
+ lua_xmove(sender_stack, L, 1); // copy the data directly from sender's stack
+ MSG_task_set_data(tk, NULL);
+
+ if (res != MSG_OK)
+ switch (res) {
+ case MSG_TIMEOUT:
+ ERROR0("MSG_task_receive failed : Timeout");
+ break;
+ case MSG_TRANSFER_FAILURE:
+ ERROR0("MSG_task_receive failed : Transfer Failure");
+ break;
+ case MSG_HOST_FAILURE:
+ ERROR0("MSG_task_receive failed : Host Failure ");
+ break;
+ default:
+ ERROR0
+ ("MSG_task_receive failed : Unexpected error , please report this bug");
+ break;
+ }
return 1;
}
static const luaL_reg Task_methods[] = {
- {"new", Task_new},
- {"name", Task_get_name},
- {"computation_duration", Task_computation_duration},
- {"execute", Task_execute},
- {"destroy", Task_destroy},
- {"send", Task_send},
- {"recv", Task_recv},
- {0,0}
+ {"new", Task_new},
+ {"name", Task_get_name},
+ {"computation_duration", Task_computation_duration},
+ {"execute", Task_execute},
+ {"destroy", Task_destroy},
+ {"send", Task_send},
+ {"recv", Task_recv},
+ {0, 0}
};
-static int Task_gc(lua_State *L) {
- m_task_t tk=checkTask(L,-1);
- if (tk) MSG_task_destroy(tk);
+
+static int Task_gc(lua_State * L)
+{
+ m_task_t tk = checkTask(L, -1);
+ if (tk)
+ MSG_task_destroy(tk);
return 0;
}
-static int Task_tostring(lua_State *L) {
- lua_pushfstring(L, "Task :%p",lua_touserdata(L,1));
+static int Task_tostring(lua_State * L)
+{
+ lua_pushfstring(L, "Task :%p", lua_touserdata(L, 1));
return 1;
}
static const luaL_reg Task_meta[] = {
- {"__gc", Task_gc},
- {"__tostring", Task_tostring},
- {0,0}
+ {"__gc", Task_gc},
+ {"__tostring", Task_tostring},
+ {0, 0}
};
/**
* Host
*/
-static m_host_t checkHost (lua_State *L,int index) {
- m_host_t *pi,ht;
- luaL_checktype(L,index,LUA_TTABLE);
- lua_getfield(L,index,"__simgrid_host");
- pi = (m_host_t*)luaL_checkudata(L,-1,HOST_MODULE_NAME);
- if(pi == NULL)
- luaL_typerror(L,index,HOST_MODULE_NAME);
+static m_host_t checkHost(lua_State * L, int index)
+{
+ m_host_t *pi, ht;
+ luaL_checktype(L, index, LUA_TTABLE);
+ lua_getfield(L, index, "__simgrid_host");
+ pi = (m_host_t *) luaL_checkudata(L, -1, HOST_MODULE_NAME);
+ if (pi == NULL)
+ luaL_typerror(L, index, HOST_MODULE_NAME);
ht = *pi;
- if(!ht)
- luaL_error(L,"null Host");
- lua_pop(L,1);
- return ht;
+ if (!ht)
+ luaL_error(L, "null Host");
+ lua_pop(L, 1);
+ return ht;
}
-static int Host_get_by_name(lua_State *L)
+static int Host_get_by_name(lua_State * L)
{
- const char *name=luaL_checkstring(L,1);
- DEBUG0("Getting Host from name...");
- m_host_t msg_host = MSG_get_host_by_name(name);
- if (!msg_host)
- {
- luaL_error(L,"null Host : MSG_get_host_by_name failled");
- }
- lua_newtable (L); /* create a table, put the userdata on top of it */
- m_host_t *lua_host = (m_host_t*)lua_newuserdata(L,sizeof(m_host_t));
- *lua_host = msg_host;
- luaL_getmetatable(L,HOST_MODULE_NAME);
- lua_setmetatable(L,-2);
- lua_setfield (L, -2, "__simgrid_host"); /* put the userdata as field of the table */
- /* remove the args from the stack */
- lua_remove(L,1);
- return 1;
+ const char *name = luaL_checkstring(L, 1);
+ DEBUG0("Getting Host from name...");
+ m_host_t msg_host = MSG_get_host_by_name(name);
+ if (!msg_host) {
+ luaL_error(L, "null Host : MSG_get_host_by_name failled");
+ }
+ lua_newtable(L); /* create a table, put the userdata on top of it */
+ m_host_t *lua_host = (m_host_t *) lua_newuserdata(L, sizeof(m_host_t));
+ *lua_host = msg_host;
+ luaL_getmetatable(L, HOST_MODULE_NAME);
+ lua_setmetatable(L, -2);
+ lua_setfield(L, -2, "__simgrid_host"); /* put the userdata as field of the table */
+ /* remove the args from the stack */
+ lua_remove(L, 1);
+ return 1;
}
-static int Host_get_name(lua_State *L) {
- m_host_t ht = checkHost(L,-1);
- lua_pushstring(L,MSG_host_get_name(ht));
+static int Host_get_name(lua_State * L)
+{
+ m_host_t ht = checkHost(L, -1);
+ lua_pushstring(L, MSG_host_get_name(ht));
return 1;
}
-static int Host_number(lua_State *L) {
- lua_pushnumber(L,MSG_get_host_number());
+static int Host_number(lua_State * L)
+{
+ lua_pushnumber(L, MSG_get_host_number());
return 1;
}
-static int Host_at(lua_State *L)
+static int Host_at(lua_State * L)
{
- int index = luaL_checkinteger(L,1);
- m_host_t host = MSG_get_host_table()[index-1]; // lua indexing start by 1 (lua[1] <=> C[0])
- lua_newtable (L); /* create a table, put the userdata on top of it */
- m_host_t *lua_host = (m_host_t*)lua_newuserdata(L,sizeof(m_host_t));
- *lua_host = host;
- luaL_getmetatable(L,HOST_MODULE_NAME);
- lua_setmetatable(L,-2);
- lua_setfield (L, -2, "__simgrid_host"); /* put the userdata as field of the table */
- return 1;
+ int index = luaL_checkinteger(L, 1);
+ m_host_t host = MSG_get_host_table()[index - 1]; // lua indexing start by 1 (lua[1] <=> C[0])
+ lua_newtable(L); /* create a table, put the userdata on top of it */
+ m_host_t *lua_host = (m_host_t *) lua_newuserdata(L, sizeof(m_host_t));
+ *lua_host = host;
+ luaL_getmetatable(L, HOST_MODULE_NAME);
+ lua_setmetatable(L, -2);
+ lua_setfield(L, -2, "__simgrid_host"); /* put the userdata as field of the table */
+ return 1;
}
#include "surf/surfxml_parse.h" /* to override surf_parse and bypass the parser */
#include "surf/surf_private.h"
-typedef struct t_AS_attr
-{
- const char* id;
- const char *mode;
-}AS_attr,*p_AS_attr;
-
-typedef struct t_host_attr
-{
- //platform attribute
- // Mandatory attributes
- const char* id;
- double power_peak;
- // Optional attributes
- double power_scale;
- const char *power_trace;
- int state_initial;
- const char *state_trace;
- //deployment attribute
- const char* function;
- xbt_dynar_t args_list;
-}host_attr,*p_host_attr;
-
-typedef struct t_link_attr
-{
- //mandatory attributes
- const char* id;
- double bandwidth;
- double latency;
- // Optional attributes
- const char* bandwidth_trace;
- const char* latency_trace;
- const char* state_trace;
- int state_initial;
- int policy;
-}link_attr,*p_link_attr;
-
-typedef struct t_route_attr
-{
- const char *src_id;
- const char *dest_id;
- xbt_dynar_t links_id;
-
-}route_attr,*p_route_attr;
+typedef struct t_AS_attr {
+ const char *id;
+ const char *mode;
+} AS_attr, *p_AS_attr;
+
+typedef struct t_host_attr {
+ //platform attribute
+ // Mandatory attributes
+ const char *id;
+ double power_peak;
+ // Optional attributes
+ double power_scale;
+ const char *power_trace;
+ int state_initial;
+ const char *state_trace;
+ //deployment attribute
+ const char *function;
+ xbt_dynar_t args_list;
+} host_attr, *p_host_attr;
+
+typedef struct t_link_attr {
+ //mandatory attributes
+ const char *id;
+ double bandwidth;
+ double latency;
+ // Optional attributes
+ const char *bandwidth_trace;
+ const char *latency_trace;
+ const char *state_trace;
+ int state_initial;
+ int policy;
+} link_attr, *p_link_attr;
+
+typedef struct t_route_attr {
+ const char *src_id;
+ const char *dest_id;
+ xbt_dynar_t links_id;
+
+} route_attr, *p_route_attr;
//AS : One struct needed
static p_AS_attr AS;
//using xbt_dynar_t :
-static xbt_dynar_t host_list_d ;
-static xbt_dynar_t link_list_d ;
-static xbt_dynar_t route_list_d ;
+static xbt_dynar_t host_list_d;
+static xbt_dynar_t link_list_d;
+static xbt_dynar_t route_list_d;
/*
* Initialize platform model routing
*/
-static void create_AS(const char* id,const char * mode)
+static void create_AS(const char *id, const char *mode)
{
- surf_AS_new(id,mode);
+ surf_AS_new(id, mode);
}
/**
* create host resource via CPU model [for MSG]
*/
-static void create_host(const char* id,double power_peak,double power_sc,
- const char* power_tr,int state_init,
- const char* state_tr)
+static void create_host(const char *id, double power_peak, double power_sc,
+ const char *power_tr, int state_init,
+ const char *state_tr)
{
- double power_scale = 1.0;
- tmgr_trace_t power_trace = NULL;
- e_surf_resource_state_t state_initial;
- tmgr_trace_t state_trace;
- if(power_sc) // !=0
- power_scale = power_sc;
- if (state_init == -1)
- state_initial = SURF_RESOURCE_OFF;
- else
- state_initial = SURF_RESOURCE_ON;
- if(power_tr)
- power_trace = tmgr_trace_new(power_tr);
- else
- power_trace = tmgr_trace_new("");
- if(state_tr)
- state_trace = tmgr_trace_new(state_tr);
- else
- state_trace = tmgr_trace_new("");
- current_property_set = xbt_dict_new();
- surf_host_create_resource(xbt_strdup(id), power_peak, power_scale,
- power_trace, state_initial, state_trace, current_property_set);
+ double power_scale = 1.0;
+ tmgr_trace_t power_trace = NULL;
+ e_surf_resource_state_t state_initial;
+ tmgr_trace_t state_trace;
+ if (power_sc) // !=0
+ power_scale = power_sc;
+ if (state_init == -1)
+ state_initial = SURF_RESOURCE_OFF;
+ else
+ state_initial = SURF_RESOURCE_ON;
+ if (power_tr)
+ power_trace = tmgr_trace_new(power_tr);
+ else
+ power_trace = tmgr_trace_new("");
+ if (state_tr)
+ state_trace = tmgr_trace_new(state_tr);
+ else
+ state_trace = tmgr_trace_new("");
+ current_property_set = xbt_dict_new();
+ surf_host_create_resource(xbt_strdup(id), power_peak, power_scale,
+ power_trace, state_initial, state_trace,
+ current_property_set);
}
* create link resource via network model
*/
static void create_link(const char *name,
- double bw_initial,const char *trace,double lat_initial,
- const char* latency_trace,int state_init, const char* state_trace,int policy)
+ double bw_initial, const char *trace,
+ double lat_initial, const char *latency_trace,
+ int state_init, const char *state_trace,
+ int policy)
{
- tmgr_trace_t bw_trace;
- tmgr_trace_t lat_trace;
- e_surf_resource_state_t state_initial_link = SURF_RESOURCE_ON;
- e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
- tmgr_trace_t st_trace;
- if(trace)
- bw_trace = tmgr_trace_new(trace);
- else
- bw_trace = tmgr_trace_new("");
-
- if(latency_trace)
- lat_trace = tmgr_trace_new(latency_trace);
- else
- lat_trace = tmgr_trace_new("");
-
- if(state_trace)
- st_trace = tmgr_trace_new(state_trace);
- else
- st_trace = tmgr_trace_new("");
-
- if(state_init == -1)
- state_initial_link = SURF_RESOURCE_OFF;
- if(policy == -1)
- policy_initial_link = SURF_LINK_FATPIPE;
-
- surf_link_create_resource(xbt_strdup(name), bw_initial, bw_trace,
- lat_initial, lat_trace, state_initial_link, st_trace,
- policy_initial_link, xbt_dict_new());
+ tmgr_trace_t bw_trace;
+ tmgr_trace_t lat_trace;
+ e_surf_resource_state_t state_initial_link = SURF_RESOURCE_ON;
+ e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
+ tmgr_trace_t st_trace;
+ if (trace)
+ bw_trace = tmgr_trace_new(trace);
+ else
+ bw_trace = tmgr_trace_new("");
+
+ if (latency_trace)
+ lat_trace = tmgr_trace_new(latency_trace);
+ else
+ lat_trace = tmgr_trace_new("");
+
+ if (state_trace)
+ st_trace = tmgr_trace_new(state_trace);
+ else
+ st_trace = tmgr_trace_new("");
+
+ if (state_init == -1)
+ state_initial_link = SURF_RESOURCE_OFF;
+ if (policy == -1)
+ policy_initial_link = SURF_LINK_FATPIPE;
+
+ surf_link_create_resource(xbt_strdup(name), bw_initial, bw_trace,
+ lat_initial, lat_trace, state_initial_link,
+ st_trace, policy_initial_link, xbt_dict_new());
}
/*
*create host resource via workstation_ptask_L07 model [for SimDag]
*/
-static void create_host_wsL07(const char* id,double power_peak,double power_sc,
- const char* power_tr,int state_init,
- const char* state_tr)
+static void create_host_wsL07(const char *id, double power_peak,
+ double power_sc, const char *power_tr,
+ int state_init, const char *state_tr)
{
- double power_scale = 1.0;
- tmgr_trace_t power_trace = NULL;
- e_surf_resource_state_t state_initial;
- tmgr_trace_t state_trace;
- if(power_sc) // !=0
- power_scale = power_sc;
- if (state_init == -1)
- state_initial = SURF_RESOURCE_OFF;
- else
- state_initial = SURF_RESOURCE_ON;
- if(power_tr)
- power_trace = tmgr_trace_new(power_tr);
- else
- power_trace = tmgr_trace_new("");
- if(state_tr)
- state_trace = tmgr_trace_new(state_tr);
- else
- state_trace = tmgr_trace_new("");
- current_property_set = xbt_dict_new();
- surf_wsL07_host_create_resource(xbt_strdup(id), power_peak, power_scale,
- power_trace, state_initial, state_trace, current_property_set);
+ double power_scale = 1.0;
+ tmgr_trace_t power_trace = NULL;
+ e_surf_resource_state_t state_initial;
+ tmgr_trace_t state_trace;
+ if (power_sc) // !=0
+ power_scale = power_sc;
+ if (state_init == -1)
+ state_initial = SURF_RESOURCE_OFF;
+ else
+ state_initial = SURF_RESOURCE_ON;
+ if (power_tr)
+ power_trace = tmgr_trace_new(power_tr);
+ else
+ power_trace = tmgr_trace_new("");
+ if (state_tr)
+ state_trace = tmgr_trace_new(state_tr);
+ else
+ state_trace = tmgr_trace_new("");
+ current_property_set = xbt_dict_new();
+ surf_wsL07_host_create_resource(xbt_strdup(id), power_peak, power_scale,
+ power_trace, state_initial, state_trace,
+ current_property_set);
}
*/
static void create_link_wsL07(const char *name,
- double bw_initial,const char *trace,double lat_initial,
- const char* latency_trace,int state_init, const char* state_trace,int policy)
+ double bw_initial, const char *trace,
+ double lat_initial,
+ const char *latency_trace, int state_init,
+ const char *state_trace, int policy)
{
- tmgr_trace_t bw_trace;
- tmgr_trace_t lat_trace;
- e_surf_resource_state_t state_initial_link = SURF_RESOURCE_ON;
- e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
- tmgr_trace_t st_trace;
- if(trace)
- bw_trace = tmgr_trace_new(trace);
- else
- bw_trace = tmgr_trace_new("");
-
- if(latency_trace)
- lat_trace = tmgr_trace_new(latency_trace);
- else
- lat_trace = tmgr_trace_new("");
-
- if(state_trace)
- st_trace = tmgr_trace_new(state_trace);
- else
- st_trace = tmgr_trace_new("");
-
- if(state_init == -1)
- state_initial_link = SURF_RESOURCE_OFF;
- if(policy == -1)
- policy_initial_link = SURF_LINK_FATPIPE;
-
- surf_wsL07_link_create_resource(xbt_strdup(name), bw_initial, bw_trace,
- lat_initial, lat_trace, state_initial_link, st_trace,
- policy_initial_link, xbt_dict_new());
+ tmgr_trace_t bw_trace;
+ tmgr_trace_t lat_trace;
+ e_surf_resource_state_t state_initial_link = SURF_RESOURCE_ON;
+ e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
+ tmgr_trace_t st_trace;
+ if (trace)
+ bw_trace = tmgr_trace_new(trace);
+ else
+ bw_trace = tmgr_trace_new("");
+
+ if (latency_trace)
+ lat_trace = tmgr_trace_new(latency_trace);
+ else
+ lat_trace = tmgr_trace_new("");
+
+ if (state_trace)
+ st_trace = tmgr_trace_new(state_trace);
+ else
+ st_trace = tmgr_trace_new("");
+
+ if (state_init == -1)
+ state_initial_link = SURF_RESOURCE_OFF;
+ if (policy == -1)
+ policy_initial_link = SURF_LINK_FATPIPE;
+
+ surf_wsL07_link_create_resource(xbt_strdup(name), bw_initial, bw_trace,
+ lat_initial, lat_trace,
+ state_initial_link, st_trace,
+ policy_initial_link, xbt_dict_new());
}
* init AS
*/
-static int AS_new(lua_State *L)
+static int AS_new(lua_State * L)
{
- const char *id;
- const char *mode;
- if(lua_istable(L,1))
- {
- lua_pushstring(L,"id");
- lua_gettable(L,-2);
- id = lua_tostring(L,-1);
- lua_pop(L,1);
-
- lua_pushstring(L,"mode");
- lua_gettable(L,-2);
- mode = lua_tostring(L,-1);
- lua_pop(L,1);
- }
- else {
- ERROR0("Bad Arguments to AS.new, Should be a table with named arguments");
- return -1;
- }
- AS = malloc(sizeof(AS_attr));
- AS->id = id;
- AS->mode = mode;
-
- return 0;
+ const char *id;
+ const char *mode;
+ if (lua_istable(L, 1)) {
+ lua_pushstring(L, "id");
+ lua_gettable(L, -2);
+ id = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ lua_pushstring(L, "mode");
+ lua_gettable(L, -2);
+ mode = lua_tostring(L, -1);
+ lua_pop(L, 1);
+ } else {
+ ERROR0
+ ("Bad Arguments to AS.new, Should be a table with named arguments");
+ return -1;
+ }
+ AS = malloc(sizeof(AS_attr));
+ AS->id = id;
+ AS->mode = mode;
+
+ return 0;
}
/*
* add new host to platform hosts list
*/
-static int Host_new(lua_State *L)
+static int Host_new(lua_State * L)
{
- if(xbt_dynar_is_empty(host_list_d))
- host_list_d = xbt_dynar_new(sizeof(p_host_attr), &xbt_free_ref);
-
- p_host_attr host;
- const char * id;
- const char *power_trace;
- const char *state_trace;
- double power,power_scale;
- int state_initial;
- //get values from the table passed as argument
- if (lua_istable(L,-1)) {
-
- // get Id Value
- lua_pushstring(L,"id");
- lua_gettable(L, -2 );
- id = lua_tostring(L,-1);
- lua_pop(L,1);
-
- // get power value
- lua_pushstring(L,"power");
- lua_gettable(L, -2 );
- power = lua_tonumber(L,-1);
- lua_pop(L,1);
-
- //get power_scale
- lua_pushstring(L,"power_scale");
- lua_gettable(L, -2 );
- power_scale = lua_tonumber(L,-1);
- lua_pop(L,1);
-
- //get power_trace
- lua_pushstring(L,"power_trace");
- lua_gettable(L, -2 );
- power_trace = lua_tostring(L,-1);
- lua_pop(L,1);
-
- //get state initial
- lua_pushstring(L,"state_initial");
- lua_gettable(L, -2 );
- state_initial = lua_tonumber(L,-1);
- lua_pop(L,1);
-
- //get trace state
- lua_pushstring(L,"state_trace");
- lua_gettable(L, -2 );
- state_trace = lua_tostring(L,-1);
- lua_pop(L,1);
-
- } else {
- ERROR0("Bad Arguments to create host, Should be a table with named arguments");
- return -1;
- }
+ if (xbt_dynar_is_empty(host_list_d))
+ host_list_d = xbt_dynar_new(sizeof(p_host_attr), &xbt_free_ref);
+
+ p_host_attr host;
+ const char *id;
+ const char *power_trace;
+ const char *state_trace;
+ double power, power_scale;
+ int state_initial;
+ //get values from the table passed as argument
+ if (lua_istable(L, -1)) {
+
+ // get Id Value
+ lua_pushstring(L, "id");
+ lua_gettable(L, -2);
+ id = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ // get power value
+ lua_pushstring(L, "power");
+ lua_gettable(L, -2);
+ power = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ //get power_scale
+ lua_pushstring(L, "power_scale");
+ lua_gettable(L, -2);
+ power_scale = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ //get power_trace
+ lua_pushstring(L, "power_trace");
+ lua_gettable(L, -2);
+ power_trace = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ //get state initial
+ lua_pushstring(L, "state_initial");
+ lua_gettable(L, -2);
+ state_initial = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ //get trace state
+ lua_pushstring(L, "state_trace");
+ lua_gettable(L, -2);
+ state_trace = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ } else {
+ ERROR0
+ ("Bad Arguments to create host, Should be a table with named arguments");
+ return -1;
+ }
+
+ host = malloc(sizeof(host_attr));
+ host->id = id;
+ host->power_peak = power;
+ host->power_scale = power_scale;
+ host->power_trace = power_trace;
+ host->state_initial = state_initial;
+ host->state_trace = state_trace;
+ host->function = NULL;
+ xbt_dynar_push(host_list_d, &host);
- host = malloc(sizeof(host_attr));
- host->id = id;
- host->power_peak = power;
- host->power_scale = power_scale;
- host->power_trace = power_trace;
- host->state_initial = state_initial;
- host->state_trace = state_trace;
- host->function = NULL;
- xbt_dynar_push(host_list_d, &host);
-
- return 0;
+ return 0;
}
/**
* add link to platform links list
*/
-static int Link_new(lua_State *L) // (id,bandwidth,latency)
+static int Link_new(lua_State * L) // (id,bandwidth,latency)
{
- if(xbt_dynar_is_empty(link_list_d))
- link_list_d = xbt_dynar_new(sizeof(p_link_attr), &xbt_free_ref);
-
- const char* id;
- double bandwidth,latency;
- const char* bandwidth_trace;
- const char* latency_trace;
- const char* state_trace;
- int state_initial,policy;
-
- //get values from the table passed as argument
- if (lua_istable(L,-1)) {
- // get Id Value
- lua_pushstring(L,"id");
- lua_gettable(L, -2 );
- id = lua_tostring(L,-1);
- lua_pop(L,1);
-
- // get bandwidth value
- lua_pushstring(L,"bandwidth");
- lua_gettable(L, -2 );
- bandwidth = lua_tonumber(L,-1);
- lua_pop(L,1);
-
- //get latency value
- lua_pushstring(L,"latency");
- lua_gettable(L, -2 );
- latency = lua_tonumber(L,-1);
- lua_pop(L,1);
-
- /*Optional Arguments */
-
- //get bandwidth_trace value
- lua_pushstring(L,"bandwidth_trace");
- lua_gettable(L, -2 );
- bandwidth_trace = lua_tostring(L,-1);
- lua_pop(L,1);
-
- //get latency_trace value
- lua_pushstring(L,"latency_trace");
- lua_gettable(L, -2 );
- latency_trace = lua_tostring(L,-1);
- lua_pop(L,1);
-
- //get state_trace value
- lua_pushstring(L,"state_trace");
- lua_gettable(L, -2 );
- state_trace = lua_tostring(L,-1);
- lua_pop(L,1);
-
- //get state_initial value
- lua_pushstring(L,"state_initial");
- lua_gettable(L, -2 );
- state_initial = lua_tonumber(L,-1);
- lua_pop(L,1);
-
-
- //get policy value
- lua_pushstring(L,"policy");
- lua_gettable(L, -2 );
- policy = lua_tonumber(L,-1);
- lua_pop(L,1);
-
- } else {
- ERROR0("Bad Arguments to create link, Should be a table with named arguments");
- return -1;
- }
-
- p_link_attr link = malloc(sizeof(link_attr));
- link->id = id;
- link->bandwidth = bandwidth;
- link->latency = latency;
- link->bandwidth_trace = bandwidth_trace;
- link->latency_trace = latency_trace;
- link->state_trace = state_trace;
- link->state_initial= state_initial;
- link->policy = policy;
- xbt_dynar_push(link_list_d,&link);
- return 0;
+ if (xbt_dynar_is_empty(link_list_d))
+ link_list_d = xbt_dynar_new(sizeof(p_link_attr), &xbt_free_ref);
+
+ const char *id;
+ double bandwidth, latency;
+ const char *bandwidth_trace;
+ const char *latency_trace;
+ const char *state_trace;
+ int state_initial, policy;
+
+ //get values from the table passed as argument
+ if (lua_istable(L, -1)) {
+ // get Id Value
+ lua_pushstring(L, "id");
+ lua_gettable(L, -2);
+ id = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ // get bandwidth value
+ lua_pushstring(L, "bandwidth");
+ lua_gettable(L, -2);
+ bandwidth = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ //get latency value
+ lua_pushstring(L, "latency");
+ lua_gettable(L, -2);
+ latency = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ /*Optional Arguments */
+
+ //get bandwidth_trace value
+ lua_pushstring(L, "bandwidth_trace");
+ lua_gettable(L, -2);
+ bandwidth_trace = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ //get latency_trace value
+ lua_pushstring(L, "latency_trace");
+ lua_gettable(L, -2);
+ latency_trace = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ //get state_trace value
+ lua_pushstring(L, "state_trace");
+ lua_gettable(L, -2);
+ state_trace = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ //get state_initial value
+ lua_pushstring(L, "state_initial");
+ lua_gettable(L, -2);
+ state_initial = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+
+ //get policy value
+ lua_pushstring(L, "policy");
+ lua_gettable(L, -2);
+ policy = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ } else {
+ ERROR0
+ ("Bad Arguments to create link, Should be a table with named arguments");
+ return -1;
+ }
+
+ p_link_attr link = malloc(sizeof(link_attr));
+ link->id = id;
+ link->bandwidth = bandwidth;
+ link->latency = latency;
+ link->bandwidth_trace = bandwidth_trace;
+ link->latency_trace = latency_trace;
+ link->state_trace = state_trace;
+ link->state_initial = state_initial;
+ link->policy = policy;
+ xbt_dynar_push(link_list_d, &link);
+ return 0;
}
/**
* add route to platform routes list
*/
-static int Route_new(lua_State *L) // (src_id,dest_id,links_number,link_table)
+static int Route_new(lua_State * L) // (src_id,dest_id,links_number,link_table)
{
- if(xbt_dynar_is_empty(route_list_d))
- route_list_d = xbt_dynar_new(sizeof(p_route_attr), &xbt_free_ref);
- const char * link_id;
- p_route_attr route = malloc(sizeof(route_attr));
- route->src_id = luaL_checkstring(L,1);
- route->dest_id = luaL_checkstring(L,2);
- route->links_id = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
- lua_pushnil(L);
- while (lua_next(L,3) != 0) {
- link_id = lua_tostring(L, -1);
- xbt_dynar_push(route->links_id, &link_id);
- DEBUG2("index = %f , Link_id = %s \n",lua_tonumber(L, -2),lua_tostring(L, -1));
- lua_pop(L, 1);
- }
- lua_pop(L, 1);
-
- //add route to platform's route list
- xbt_dynar_push(route_list_d,&route);
- return 0;
+ if (xbt_dynar_is_empty(route_list_d))
+ route_list_d = xbt_dynar_new(sizeof(p_route_attr), &xbt_free_ref);
+ const char *link_id;
+ p_route_attr route = malloc(sizeof(route_attr));
+ route->src_id = luaL_checkstring(L, 1);
+ route->dest_id = luaL_checkstring(L, 2);
+ route->links_id = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
+ lua_pushnil(L);
+ while (lua_next(L, 3) != 0) {
+ link_id = lua_tostring(L, -1);
+ xbt_dynar_push(route->links_id, &link_id);
+ DEBUG2("index = %f , Link_id = %s \n", lua_tonumber(L, -2),
+ lua_tostring(L, -1));
+ lua_pop(L, 1);
+ }
+ lua_pop(L, 1);
+
+ //add route to platform's route list
+ xbt_dynar_push(route_list_d, &route);
+ return 0;
}
/**
* set function to process
*/
-static int Host_set_function(lua_State *L) //(host,function,nb_args,list_args)
+static int Host_set_function(lua_State * L) //(host,function,nb_args,list_args)
{
- // look for the index of host in host_list
- const char *host_id = luaL_checkstring(L,1);
- const char* argument;
- unsigned int i;
- p_host_attr p_host;
-
- xbt_dynar_foreach(host_list_d,i,p_host)
- {
- if(p_host->id == host_id)
- {
- p_host->function = luaL_checkstring(L,2);
- if(lua_istable(L,3))
- {
- p_host->args_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
- // fill the args list
- lua_pushnil(L);
- int j = 0;
- while (lua_next(L,3) != 0) {
- argument = lua_tostring(L, -1);
- xbt_dynar_push(p_host->args_list, &argument);
- DEBUG2("index = %f , Arg_id = %s \n",lua_tonumber(L, -2),lua_tostring(L, -1));
- j++;
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- return 0;
- }
- }
- ERROR1("Host : %s Not Found !!",host_id);
- return 1;
+ // look for the index of host in host_list
+ const char *host_id = luaL_checkstring(L, 1);
+ const char *argument;
+ unsigned int i;
+ p_host_attr p_host;
+
+ xbt_dynar_foreach(host_list_d, i, p_host) {
+ if (p_host->id == host_id) {
+ p_host->function = luaL_checkstring(L, 2);
+ if (lua_istable(L, 3)) {
+ p_host->args_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
+ // fill the args list
+ lua_pushnil(L);
+ int j = 0;
+ while (lua_next(L, 3) != 0) {
+ argument = lua_tostring(L, -1);
+ xbt_dynar_push(p_host->args_list, &argument);
+ DEBUG2("index = %f , Arg_id = %s \n", lua_tonumber(L, -2),
+ lua_tostring(L, -1));
+ j++;
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ return 0;
+ }
+ }
+ ERROR1("Host : %s Not Found !!", host_id);
+ return 1;
}
/*
static int surf_parse_bypass_platform()
{
- unsigned int i;
- p_host_attr p_host;
- p_link_attr p_link;
- p_route_attr p_route;
-
- // Init routing mode
- create_AS(AS->id,AS->mode);
-
-
- // Add Hosts
- xbt_dynar_foreach(host_list_d,i,p_host)
- {
- create_host(p_host->id,p_host->power_peak,p_host->power_scale,p_host->power_trace,
- p_host->state_initial,p_host->state_trace);
- //add to routing model host list
- surf_route_add_host((char*)p_host->id);
-
- }
-
- //add Links
- xbt_dynar_foreach(link_list_d,i,p_link)
- {
- create_link(p_link->id,p_link->bandwidth,p_link->bandwidth_trace,p_link->latency,
- p_link->latency_trace,p_link->state_initial,p_link->state_trace,p_link->policy);
- }
- // add route
- xbt_dynar_foreach(route_list_d,i,p_route)
- {
- surf_routing_add_route((char*)p_route->src_id,(char*)p_route->dest_id,p_route->links_id);
- }
- /* </platform> */
-
- // Finalize AS
- surf_AS_finalize(AS->id);
-
- // add traces
- surf_add_host_traces();
- surf_add_link_traces();
-
- return 0; // must return 0 ?!!
+ unsigned int i;
+ p_host_attr p_host;
+ p_link_attr p_link;
+ p_route_attr p_route;
+
+ // Init routing mode
+ create_AS(AS->id, AS->mode);
+
+
+ // Add Hosts
+ xbt_dynar_foreach(host_list_d, i, p_host) {
+ create_host(p_host->id, p_host->power_peak, p_host->power_scale,
+ p_host->power_trace, p_host->state_initial,
+ p_host->state_trace);
+ //add to routing model host list
+ surf_route_add_host((char *) p_host->id);
+
+ }
+
+ //add Links
+ xbt_dynar_foreach(link_list_d, i, p_link) {
+ create_link(p_link->id, p_link->bandwidth, p_link->bandwidth_trace,
+ p_link->latency, p_link->latency_trace,
+ p_link->state_initial, p_link->state_trace,
+ p_link->policy);
+ }
+ // add route
+ xbt_dynar_foreach(route_list_d, i, p_route) {
+ surf_routing_add_route((char *) p_route->src_id,
+ (char *) p_route->dest_id, p_route->links_id);
+ }
+ /* </platform> */
+
+ // Finalize AS
+ surf_AS_finalize(AS->id);
+
+ // add traces
+ surf_add_host_traces();
+ surf_add_link_traces();
+
+ return 0; // must return 0 ?!!
}
static int surf_wsL07_parse_bypass_platform()
{
- unsigned int i;
- p_host_attr p_host;
- p_link_attr p_link;
- p_route_attr p_route;
-
- // Init routing mode
- create_AS(AS->id,AS->mode);
-
- // Add Hosts
- xbt_dynar_foreach(host_list_d,i,p_host)
- {
- create_host_wsL07(p_host->id,p_host->power_peak,p_host->power_scale,p_host->power_trace,
- p_host->state_initial,p_host->state_trace);
- //add to routing model host list
- surf_route_add_host((char*)p_host->id);
- }
-
- //add Links
- xbt_dynar_foreach(link_list_d,i,p_link)
- {
- create_link_wsL07(p_link->id,p_link->bandwidth,p_link->bandwidth_trace,p_link->latency,
- p_link->latency_trace,p_link->state_initial,p_link->state_trace,p_link->policy);
- }
- // add route
- xbt_dynar_foreach(route_list_d,i,p_route)
- {
- surf_routing_add_route((char*)p_route->src_id,(char*)p_route->dest_id,p_route->links_id);
- }
- /* </platform> */
-
- // Finalize AS
- surf_AS_finalize(AS->id);
- // add traces
- surf_wsL07_add_traces();
-
- return 0;
+ unsigned int i;
+ p_host_attr p_host;
+ p_link_attr p_link;
+ p_route_attr p_route;
+
+ // Init routing mode
+ create_AS(AS->id, AS->mode);
+
+ // Add Hosts
+ xbt_dynar_foreach(host_list_d, i, p_host) {
+ create_host_wsL07(p_host->id, p_host->power_peak, p_host->power_scale,
+ p_host->power_trace, p_host->state_initial,
+ p_host->state_trace);
+ //add to routing model host list
+ surf_route_add_host((char *) p_host->id);
+ }
+
+ //add Links
+ xbt_dynar_foreach(link_list_d, i, p_link) {
+ create_link_wsL07(p_link->id, p_link->bandwidth,
+ p_link->bandwidth_trace, p_link->latency,
+ p_link->latency_trace, p_link->state_initial,
+ p_link->state_trace, p_link->policy);
+ }
+ // add route
+ xbt_dynar_foreach(route_list_d, i, p_route) {
+ surf_routing_add_route((char *) p_route->src_id,
+ (char *) p_route->dest_id, p_route->links_id);
+ }
+ /* </platform> */
+
+ // Finalize AS
+ surf_AS_finalize(AS->id);
+ // add traces
+ surf_wsL07_add_traces();
+
+ return 0;
}
/*
*/
static int surf_parse_bypass_application()
{
- unsigned int i;
- p_host_attr p_host;
- xbt_dynar_foreach(host_list_d,i,p_host)
- {
- if(p_host->function)
- MSG_set_function(p_host->id,p_host->function,p_host->args_list);
- }
- return 0;
+ unsigned int i;
+ p_host_attr p_host;
+ xbt_dynar_foreach(host_list_d, i, p_host) {
+ if (p_host->function)
+ MSG_set_function(p_host->id, p_host->function, p_host->args_list);
+ }
+ return 0;
}
free(p->host);
}
-static int gras_add_process_function(lua_State *L)
+static int gras_add_process_function(lua_State * L)
{
- const char * arg;
- const char* process_host = luaL_checkstring(L,1);
- const char *process_function = luaL_checkstring(L,2);
-
- if(xbt_dict_is_empty(machine_set) || xbt_dict_is_empty(process_function_set)
- || xbt_dynar_is_empty(process_list))
- {
- process_function_set = xbt_dict_new();
- process_list = xbt_dynar_new(sizeof(s_process_t), s_process_free);
- machine_set = xbt_dict_new();
- }
-
- xbt_dict_set(machine_set,process_host, NULL, NULL);
- xbt_dict_set(process_function_set,process_function, NULL, NULL);
-
- process.argc = 1;
- process.argv = xbt_new(char *, 1);
- process.argv[0] = xbt_strdup(process_function);
- process.host = strdup(process_host);
-
- lua_pushnil(L);
- while (lua_next(L,3) != 0) {
- arg = lua_tostring(L, -1);
- process.argc++;
- process.argv = xbt_realloc(process.argv, (process.argc) * sizeof(char *));
- process.argv[(process.argc) - 1] = xbt_strdup(arg);
-
- DEBUG2("index = %f , arg = %s \n",lua_tonumber(L, -2),lua_tostring(L, -1));
- lua_pop(L, 1);
- }
- lua_pop(L, 1);
- //add to the process list
- xbt_dynar_push(process_list, &process);
-
- return 0;
+ const char *arg;
+ const char *process_host = luaL_checkstring(L, 1);
+ const char *process_function = luaL_checkstring(L, 2);
+
+ if (xbt_dict_is_empty(machine_set)
+ || xbt_dict_is_empty(process_function_set)
+ || xbt_dynar_is_empty(process_list)) {
+ process_function_set = xbt_dict_new();
+ process_list = xbt_dynar_new(sizeof(s_process_t), s_process_free);
+ machine_set = xbt_dict_new();
+ }
+
+ xbt_dict_set(machine_set, process_host, NULL, NULL);
+ xbt_dict_set(process_function_set, process_function, NULL, NULL);
+
+ process.argc = 1;
+ process.argv = xbt_new(char *, 1);
+ process.argv[0] = xbt_strdup(process_function);
+ process.host = strdup(process_host);
+
+ lua_pushnil(L);
+ while (lua_next(L, 3) != 0) {
+ arg = lua_tostring(L, -1);
+ process.argc++;
+ process.argv =
+ xbt_realloc(process.argv, (process.argc) * sizeof(char *));
+ process.argv[(process.argc) - 1] = xbt_strdup(arg);
+
+ DEBUG2("index = %f , arg = %s \n", lua_tonumber(L, -2),
+ lua_tostring(L, -1));
+ lua_pop(L, 1);
+ }
+ lua_pop(L, 1);
+ //add to the process list
+ xbt_dynar_push(process_list, &process);
+
+ return 0;
}
-static int gras_generate(lua_State *L)
+static int gras_generate(lua_State * L)
{
- const char *project_name = luaL_checkstring(L,1);
+ const char *project_name = luaL_checkstring(L, 1);
generate_sim(project_name);
generate_rl(project_name);
generate_makefile_local(project_name);
* Host Methods
*/
static const luaL_reg Host_methods[] = {
- {"getByName", Host_get_by_name},
- {"name", Host_get_name},
- {"number", Host_number},
- {"at", Host_at},
- // Bypass XML Methods
- {"new", Host_new},
- {"setFunction", Host_set_function},
- {0,0}
+ {"getByName", Host_get_by_name},
+ {"name", Host_get_name},
+ {"number", Host_number},
+ {"at", Host_at},
+ // Bypass XML Methods
+ {"new", Host_new},
+ {"setFunction", Host_set_function},
+ {0, 0}
};
-static int Host_gc(lua_State *L)
+static int Host_gc(lua_State * L)
{
- m_host_t ht = checkHost(L,-1);
- if (ht) ht = NULL;
+ m_host_t ht = checkHost(L, -1);
+ if (ht)
+ ht = NULL;
return 0;
}
-static int Host_tostring(lua_State *L)
+static int Host_tostring(lua_State * L)
{
- lua_pushfstring(L,"Host :%p",lua_touserdata(L,1));
+ lua_pushfstring(L, "Host :%p", lua_touserdata(L, 1));
return 1;
}
static const luaL_reg Host_meta[] = {
- {"__gc", Host_gc},
- {"__tostring", Host_tostring},
- {0,0}
+ {"__gc", Host_gc},
+ {"__tostring", Host_tostring},
+ {0, 0}
};
/*
* AS Methods
*/
static const luaL_reg AS_methods[] = {
- {"new",AS_new},
- {0,0}
+ {"new", AS_new},
+ {0, 0}
};
* Link Methods
*/
static const luaL_reg Link_methods[] = {
- {"new",Link_new},
- {0,0}
+ {"new", Link_new},
+ {0, 0}
};
+
/*
* Route Methods
*/
-static const luaL_reg Route_methods[] ={
- {"new",Route_new},
- {0,0}
+static const luaL_reg Route_methods[] = {
+ {"new", Route_new},
+ {0, 0}
};
/*
extern lua_State *simgrid_lua_state;
-static int run_lua_code(int argc,char **argv) {
- DEBUG1("Run lua code %s",argv[0]);
+static int run_lua_code(int argc, char **argv)
+{
+ DEBUG1("Run lua code %s", argv[0]);
lua_State *L = lua_newthread(simgrid_lua_state);
- int ref = luaL_ref(simgrid_lua_state, LUA_REGISTRYINDEX); // protect the thread from being garbage collected
+ int ref = luaL_ref(simgrid_lua_state, LUA_REGISTRYINDEX); // protect the thread from being garbage collected
int res = 1;
/* Start the co-routine */
- lua_getglobal(L,argv[0]);
- xbt_assert1(lua_isfunction(L,-1),
- "The lua function %s does not seem to exist",argv[0]);
+ lua_getglobal(L, argv[0]);
+ xbt_assert1(lua_isfunction(L, -1),
+ "The lua function %s does not seem to exist", argv[0]);
// push arguments onto the stack
int i;
- for(i=1;i<argc;i++)
- lua_pushstring(L,argv[i]);
+ for (i = 1; i < argc; i++)
+ lua_pushstring(L, argv[i]);
// Call the function (in resume)
- xbt_assert2(lua_pcall(L, argc-1, 1, 0) == 0,
- "error running function `%s': %s",argv[0], lua_tostring(L, -1));
+ xbt_assert2(lua_pcall(L, argc - 1, 1, 0) == 0,
+ "error running function `%s': %s", argv[0], lua_tostring(L,
+ -1));
/* retrieve result */
if (lua_isnumber(L, -1)) {
res = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
+ lua_pop(L, 1); /* pop returned value */
}
// cleanups
- luaL_unref(simgrid_lua_state,LUA_REGISTRYINDEX,ref );
+ luaL_unref(simgrid_lua_state, LUA_REGISTRYINDEX, ref);
DEBUG1("Execution of lua code %s is over", (argv ? argv[0] : "(null)"));
return res;
}
-static int launch_application(lua_State *L) {
- const char * file = luaL_checkstring(L,1);
+
+static int launch_application(lua_State * L)
+{
+ const char *file = luaL_checkstring(L, 1);
MSG_function_register_default(run_lua_code);
MSG_launch_application(file);
return 0;
}
-#include "simix/simix.h" //FIXME: KILLME when debugging on simix internals become useless
-static int create_environment(lua_State *L) {
- const char *file = luaL_checkstring(L,1);
- DEBUG1("Loading environment file %s",file);
+
+#include "simix/simix.h" //FIXME: KILLME when debugging on simix internals become useless
+static int create_environment(lua_State * L)
+{
+ const char *file = luaL_checkstring(L, 1);
+ DEBUG1("Loading environment file %s", file);
MSG_create_environment(file);
smx_host_t *hosts = SIMIX_host_get_table();
int i;
- for (i=0;i<SIMIX_host_get_number();i++) {
+ for (i = 0; i < SIMIX_host_get_number(); i++) {
DEBUG1("We have an host %s", SIMIX_host_get_name(hosts[i]));
}
return 0;
}
-static int debug(lua_State *L) {
- const char *str = luaL_checkstring(L,1);
- DEBUG1("%s",str);
+static int debug(lua_State * L)
+{
+ const char *str = luaL_checkstring(L, 1);
+ DEBUG1("%s", str);
return 0;
}
-static int info(lua_State *L) {
- const char *str = luaL_checkstring(L,1);
- INFO1("%s",str);
+
+static int info(lua_State * L)
+{
+ const char *str = luaL_checkstring(L, 1);
+ INFO1("%s", str);
return 0;
}
-static int run(lua_State *L) {
+
+static int run(lua_State * L)
+{
MSG_main();
return 0;
}
-static int clean(lua_State *L) {
+
+static int clean(lua_State * L)
+{
MSG_clean();
return 0;
}
/*
* Register platform for MSG
*/
-static int msg_register_platform(lua_State *L)
+static int msg_register_platform(lua_State * L)
{
- /* Tell Simgrid we dont wanna use its parser*/
- surf_parse = surf_parse_bypass_platform;
- MSG_create_environment(NULL);
- return 0;
+ /* Tell Simgrid we dont wanna use its parser */
+ surf_parse = surf_parse_bypass_platform;
+ MSG_create_environment(NULL);
+ return 0;
}
/*
* Register platform for Simdag
*/
-static int sd_register_platform(lua_State *L)
+static int sd_register_platform(lua_State * L)
{
- surf_parse = surf_wsL07_parse_bypass_platform;
- SD_create_environment(NULL);
- return 0;
+ surf_parse = surf_wsL07_parse_bypass_platform;
+ SD_create_environment(NULL);
+ return 0;
}
+
/*
* Register platform for gras
*/
-static int gras_register_platform(lua_State *L)
+static int gras_register_platform(lua_State * L)
{
- /* Tell Simgrid we dont wanna use surf parser*/
- surf_parse = surf_parse_bypass_platform;
- gras_create_environment(NULL);
- return 0;
+ /* Tell Simgrid we dont wanna use surf parser */
+ surf_parse = surf_parse_bypass_platform;
+ gras_create_environment(NULL);
+ return 0;
}
/**
* Register applicaiton for MSG
*/
-static int msg_register_application(lua_State *L)
+static int msg_register_application(lua_State * L)
{
- MSG_function_register_default(run_lua_code);
- surf_parse = surf_parse_bypass_application;
- MSG_launch_application(NULL);
- return 0;
+ MSG_function_register_default(run_lua_code);
+ surf_parse = surf_parse_bypass_application;
+ MSG_launch_application(NULL);
+ return 0;
}
/*
* Register application for gras
*/
-static int gras_register_application(lua_State *L)
+static int gras_register_application(lua_State * L)
{
- gras_function_register_default(run_lua_code);
- surf_parse = surf_parse_bypass_application;
- gras_launch_application(NULL);
- return 0;
+ gras_function_register_default(run_lua_code);
+ surf_parse = surf_parse_bypass_application;
+ gras_launch_application(NULL);
+ return 0;
}
+
static const luaL_Reg simgrid_funcs[] = {
- { "create_environment", create_environment},
- { "launch_application", launch_application},
- { "debug", debug},
- { "info", info},
- { "run", run},
- { "clean", clean},
- /* short names */
- { "platform", create_environment},
- { "application", launch_application},
- /* methods to bypass XML parser*/
- { "msg_register_platform",msg_register_platform},
- { "sd_register_platform",sd_register_platform},
- { "msg_register_application",msg_register_application},
- { "gras_register_platform",gras_register_platform},
- { "gras_register_application",gras_register_application},
- /* gras sub generator method*/
- {"gras_set_process_function",gras_add_process_function},
- {"gras_generate",gras_generate},
- { NULL, NULL }
+ {"create_environment", create_environment},
+ {"launch_application", launch_application},
+ {"debug", debug},
+ {"info", info},
+ {"run", run},
+ {"clean", clean},
+ /* short names */
+ {"platform", create_environment},
+ {"application", launch_application},
+ /* methods to bypass XML parser */
+ {"msg_register_platform", msg_register_platform},
+ {"sd_register_platform", sd_register_platform},
+ {"msg_register_application", msg_register_application},
+ {"gras_register_platform", gras_register_platform},
+ {"gras_register_application", gras_register_application},
+ /* gras sub generator method */
+ {"gras_set_process_function", gras_add_process_function},
+ {"gras_generate", gras_generate},
+ {NULL, NULL}
};
/* ********************************************************************************* */
/* module management functions */
/* ********************************************************************************* */
-extern const char*xbt_ctx_factory_to_use; /*Hack: let msg load directly the right factory */
+extern const char *xbt_ctx_factory_to_use; /*Hack: let msg load directly the right factory */
-#define LUA_MAX_ARGS_COUNT 10 /* maximum amount of arguments we can get from lua on command line */
+#define LUA_MAX_ARGS_COUNT 10 /* maximum amount of arguments we can get from lua on command line */
#define TEST
-int luaopen_simgrid(lua_State* L); // Fuck gcc: we don't need that prototype
-int luaopen_simgrid(lua_State* L) {
+int luaopen_simgrid(lua_State * L); // Fuck gcc: we don't need that prototype
+int luaopen_simgrid(lua_State * L)
+{
//xbt_ctx_factory_to_use = "lua";
- char **argv=malloc(sizeof(char*)*LUA_MAX_ARGS_COUNT);
- int argc=1;
- argv[0] = (char*)"/usr/bin/lua"; /* Lie on the argv[0] so that the stack dumping facilities find the right binary. FIXME: what if lua is not in that location? */
+ char **argv = malloc(sizeof(char *) * LUA_MAX_ARGS_COUNT);
+ int argc = 1;
+ argv[0] = (char *) "/usr/bin/lua"; /* Lie on the argv[0] so that the stack dumping facilities find the right binary. FIXME: what if lua is not in that location? */
/* Get the command line arguments from the lua interpreter */
- lua_getglobal(L,"arg");
+ lua_getglobal(L, "arg");
/* if arg is a null value, it means we use lua only as a script to init platform
* else it should be a table and then take arg in consideration
*/
- if(lua_istable(L,-1))
- {
- int done=0;
- while (!done) {
- argc++;
- lua_pushinteger(L,argc-2);
- lua_gettable(L,-2);
- if (lua_isnil(L,-1)) {
- done = 1;
- } else {
- xbt_assert1(lua_isstring(L,-1),"argv[%d] got from lua is no string",argc-1);
- xbt_assert2(argc<LUA_MAX_ARGS_COUNT,
- "Too many arguments, please increase LUA_MAX_ARGS_COUNT in %s before recompiling SimGrid if you insist on having more than %d args on command line",
- __FILE__,LUA_MAX_ARGS_COUNT-1);
- argv[argc-1] = (char*)luaL_checkstring(L,-1);
- lua_pop(L,1);
- DEBUG1("Got command line argument %s from lua",argv[argc-1]);
- }
- }
- argv[argc--]=NULL;
-
- /* Initialize the MSG core */
- MSG_global_init(&argc,argv);
- DEBUG1("Still %d arguments on command line",argc); // FIXME: update the lua's arg table to reflect the changes from SimGrid
- }
+ if (lua_istable(L, -1)) {
+ int done = 0;
+ while (!done) {
+ argc++;
+ lua_pushinteger(L, argc - 2);
+ lua_gettable(L, -2);
+ if (lua_isnil(L, -1)) {
+ done = 1;
+ } else {
+ xbt_assert1(lua_isstring(L, -1),
+ "argv[%d] got from lua is no string", argc - 1);
+ xbt_assert2(argc < LUA_MAX_ARGS_COUNT,
+ "Too many arguments, please increase LUA_MAX_ARGS_COUNT in %s before recompiling SimGrid if you insist on having more than %d args on command line",
+ __FILE__, LUA_MAX_ARGS_COUNT - 1);
+ argv[argc - 1] = (char *) luaL_checkstring(L, -1);
+ lua_pop(L, 1);
+ DEBUG1("Got command line argument %s from lua", argv[argc - 1]);
+ }
+ }
+ argv[argc--] = NULL;
+
+ /* Initialize the MSG core */
+ MSG_global_init(&argc, argv);
+ DEBUG1("Still %d arguments on command line", argc); // FIXME: update the lua's arg table to reflect the changes from SimGrid
+ }
/* register the core C functions to lua */
luaL_register(L, "simgrid", simgrid_funcs);
/* register the task methods to lua */
- luaL_openlib(L,TASK_MODULE_NAME,Task_methods,0); //create methods table,add it to the globals
- luaL_newmetatable(L,TASK_MODULE_NAME); //create metatable for Task,add it to the Lua registry
- luaL_openlib(L,0,Task_meta,0);// fill metatable
- lua_pushliteral(L,"__index");
- lua_pushvalue(L,-3); //dup methods table
- lua_rawset(L,-3); //matatable.__index = methods
- lua_pushliteral(L,"__metatable");
- lua_pushvalue(L,-3); //dup methods table
- lua_rawset(L,-3); //hide metatable:metatable.__metatable = methods
- lua_pop(L,1); //drop metatable
-
- /* register the hosts methods to lua*/
- luaL_openlib(L,HOST_MODULE_NAME,Host_methods,0);
- luaL_newmetatable(L,HOST_MODULE_NAME);
- luaL_openlib(L,0,Host_meta,0);
- lua_pushliteral(L,"__index");
- lua_pushvalue(L,-3);
- lua_rawset(L,-3);
- lua_pushliteral(L,"__metatable");
- lua_pushvalue(L,-3);
- lua_rawset(L,-3);
- lua_pop(L,1);
-
- /* register the links methods to lua*/
- luaL_openlib(L,AS_MODULE_NAME,AS_methods,0);
- luaL_newmetatable(L,AS_MODULE_NAME);
- lua_pop(L,1);
-
- /* register the links methods to lua*/
- luaL_openlib(L,LINK_MODULE_NAME,Link_methods,0);
- luaL_newmetatable(L,LINK_MODULE_NAME);
- lua_pop(L,1);
-
- /*register the routes methods to lua*/
- luaL_openlib(L,ROUTE_MODULE_NAME,Route_methods,0);
- luaL_newmetatable(L,LINK_MODULE_NAME);
- lua_pop(L,1);
+ luaL_openlib(L, TASK_MODULE_NAME, Task_methods, 0); //create methods table,add it to the globals
+ luaL_newmetatable(L, TASK_MODULE_NAME); //create metatable for Task,add it to the Lua registry
+ luaL_openlib(L, 0, Task_meta, 0); // fill metatable
+ lua_pushliteral(L, "__index");
+ lua_pushvalue(L, -3); //dup methods table
+ lua_rawset(L, -3); //matatable.__index = methods
+ lua_pushliteral(L, "__metatable");
+ lua_pushvalue(L, -3); //dup methods table
+ lua_rawset(L, -3); //hide metatable:metatable.__metatable = methods
+ lua_pop(L, 1); //drop metatable
+
+ /* register the hosts methods to lua */
+ luaL_openlib(L, HOST_MODULE_NAME, Host_methods, 0);
+ luaL_newmetatable(L, HOST_MODULE_NAME);
+ luaL_openlib(L, 0, Host_meta, 0);
+ lua_pushliteral(L, "__index");
+ lua_pushvalue(L, -3);
+ lua_rawset(L, -3);
+ lua_pushliteral(L, "__metatable");
+ lua_pushvalue(L, -3);
+ lua_rawset(L, -3);
+ lua_pop(L, 1);
+
+ /* register the links methods to lua */
+ luaL_openlib(L, AS_MODULE_NAME, AS_methods, 0);
+ luaL_newmetatable(L, AS_MODULE_NAME);
+ lua_pop(L, 1);
+
+ /* register the links methods to lua */
+ luaL_openlib(L, LINK_MODULE_NAME, Link_methods, 0);
+ luaL_newmetatable(L, LINK_MODULE_NAME);
+ lua_pop(L, 1);
+
+ /*register the routes methods to lua */
+ luaL_openlib(L, ROUTE_MODULE_NAME, Route_methods, 0);
+ luaL_newmetatable(L, LINK_MODULE_NAME);
+ lua_pop(L, 1);
/* Keep the context mechanism informed of our lua world today */
simgrid_lua_state = L;
#include "bindings/ruby_bindings.h"
#include "surf/surfxml_parse.h"
-#include "msg/private.h" /* s_simdata_process_t FIXME: don't mess with MSG internals that way */
+#include "msg/private.h" /* s_simdata_process_t FIXME: don't mess with MSG internals that way */
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ruby);
// Used to instanciate the Process
-static VALUE args;
-static VALUE prop;
-static VALUE function_name;
-static VALUE host_name;
-
-static VALUE rb_process_instance(VALUE fct_name,VALUE arguments,VALUE properties) {
+static VALUE args;
+static VALUE prop;
+static VALUE function_name;
+static VALUE host_name;
+
+static VALUE rb_process_instance(VALUE fct_name, VALUE arguments,
+ VALUE properties)
+{
ruby_init();
ruby_init_loadpath();
- char * p_className = RSTRING(fct_name)->ptr; // name of process is the one of the class
- return rb_funcall(rb_const_get(rb_cObject, rb_intern(p_className)),rb_intern("new"),3,fct_name,arguments,properties);
+ char *p_className = RSTRING(fct_name)->ptr; // name of process is the one of the class
+ return rb_funcall(rb_const_get(rb_cObject, rb_intern(p_className)),
+ rb_intern("new"), 3, fct_name, arguments, properties);
}
// FIXME: don't mess with MSG internals here, use MSG_process_create_with_arguments()
static void rb_process_create_with_args(VALUE fct_name, VALUE arguments,
- VALUE properties, VALUE ht_name) {
-
- VALUE ruby_process = rb_process_instance(fct_name,arguments,properties);
- m_process_t process; // Native Process to Create
- const char * name ; // Name of C Native Processs
+ VALUE properties, VALUE ht_name)
+{
+
+ VALUE ruby_process =
+ rb_process_instance(fct_name, arguments, properties);
+ m_process_t process; // Native Process to Create
+ const char *name; // Name of C Native Processs
- if(!fct_name)
- rb_raise(rb_eRuntimeError,"Internal error: Process name cannot be NULL");
+ if (!fct_name)
+ rb_raise(rb_eRuntimeError,
+ "Internal error: Process name cannot be NULL");
name = RSTRING(fct_name)->ptr;
- DEBUG1("Create native process %s",name);
+ DEBUG1("Create native process %s", name);
// Allocate the data for the simulation
- process = xbt_new0(s_m_process_t,1);
- process->simdata = xbt_new0(s_simdata_process_t,1);
+ process = xbt_new0(s_m_process_t, 1);
+ process->simdata = xbt_new0(s_simdata_process_t, 1);
// Bind The Ruby Process instance to The Native Process
- rb_process_bind(ruby_process,process);
+ rb_process_bind(ruby_process, process);
process->name = xbt_strdup(name);
// Host
m_host_t host = MSG_get_host_by_name(RSTRING(ht_name)->ptr);
process->simdata->m_host = host;
-
- if(!(process->simdata->m_host)) { // Not Binded
+
+ if (!(process->simdata->m_host)) { // Not Binded
free(process->simdata);
free(process->data);
free(process);
- rb_raise(rb_eRuntimeError,"Host not bound while creating native process");
+ rb_raise(rb_eRuntimeError,
+ "Host not bound while creating native process");
}
- process->simdata->PID = msg_global->PID++;
+ process->simdata->PID = msg_global->PID++;
- DEBUG7("fill in process %s/%s (pid=%d) %p (sd=%p , host=%p, host->sd=%p)",
- process->name , process->simdata->m_host->name,process->simdata->PID,
- process,process->simdata, process->simdata->m_host,
- process->simdata->m_host->simdata);
+ DEBUG7
+ ("fill in process %s/%s (pid=%d) %p (sd=%p , host=%p, host->sd=%p)",
+ process->name, process->simdata->m_host->name,
+ process->simdata->PID, process, process->simdata,
+ process->simdata->m_host, process->simdata->m_host->simdata);
/* FIXME: that's mainly for debugging. We could only allocate this if XBT_LOG_ISENABLED(ruby,debug) is true since I guess this leaks */
- char **argv=xbt_new(char*,2);
- argv[0] = bprintf("%s@%s",process->name,process->simdata->m_host->simdata->smx_host->name);
+ char **argv = xbt_new(char *, 2);
+ argv[0] =
+ bprintf("%s@%s", process->name,
+ process->simdata->m_host->simdata->smx_host->name);
argv[1] = NULL;
process->simdata->s_process =
SIMIX_process_create(process->name,
- (xbt_main_func_t)ruby_process,
- (void *) process,
- process->simdata->m_host->simdata->smx_host->name,
- 1,argv,NULL);
+ (xbt_main_func_t) ruby_process,
+ (void *) process,
+ process->simdata->m_host->simdata->
+ smx_host->name, 1, argv, NULL);
- DEBUG1("context created (s_process=%p)",process->simdata->s_process);
+ DEBUG1("context created (s_process=%p)", process->simdata->s_process);
- if (SIMIX_process_self()) { // SomeOne Created Me !!
- process->simdata->PPID = MSG_process_get_PID(SIMIX_process_self()->data);
+ if (SIMIX_process_self()) { // SomeOne Created Me !!
+ process->simdata->PPID =
+ MSG_process_get_PID(SIMIX_process_self()->data);
} else {
process->simdata->PPID = -1;
}
process->simdata->last_errno = MSG_OK;
// let's Add the Process to the list of the Simulation's Processes
- xbt_fifo_unshift(msg_global->process_list,process);
+ xbt_fifo_unshift(msg_global->process_list, process);
}
-void rb_application_handler_on_start_document(void) {
-
+void rb_application_handler_on_start_document(void)
+{
+
- args = rb_ary_new(); // Max length = 16 !!
- prop = rb_ary_new();
+ args = rb_ary_new(); // Max length = 16 !!
+ prop = rb_ary_new();
}
-void rb_application_handler_on_end_document(void) {
+void rb_application_handler_on_end_document(void)
+{
args = Qnil;
prop = Qnil;
function_name = Qnil;
- host_name = Qnil;
+ host_name = Qnil;
}
-void rb_application_handler_on_begin_process(void) {
-
+void rb_application_handler_on_begin_process(void)
+{
+
host_name = rb_str_new2(A_surfxml_process_host);
function_name = rb_str_new2(A_surfxml_process_function);
- args = rb_ary_new(); // Max length = 16 ?!
+ args = rb_ary_new(); // Max length = 16 ?!
prop = rb_ary_new();
}
-void rb_application_handler_on_process_arg(void) {
-
+void rb_application_handler_on_process_arg(void)
+{
+
VALUE arg = rb_str_new2(A_surfxml_argument_value);
- rb_ary_push(args,arg);
+ rb_ary_push(args, arg);
}
-void rb_application_handler_on_property(void) {
+void rb_application_handler_on_property(void)
+{
VALUE id = rb_str_new2(A_surfxml_prop_id);
- VALUE val = rb_str_new2(A_surfxml_prop_value);
- int i_id = NUM2INT (id);
- rb_ary_store(prop,i_id,val);
+ VALUE val = rb_str_new2(A_surfxml_prop_value);
+ int i_id = NUM2INT(id);
+ rb_ary_store(prop, i_id, val);
}
-void rb_application_handler_on_end_process(void) {
+void rb_application_handler_on_end_process(void)
+{
+
+ rb_process_create_with_args(function_name, args, prop, host_name);
- rb_process_create_with_args(function_name,args,prop,host_name);
-
}
#include "bindings/ruby_bindings.h"
// Free Method
-void rb_host_free(m_host_t ht) {
+void rb_host_free(m_host_t ht)
+{
//Nothing to do !!?
}
// New Method : return a Host
-VALUE rb_host_get_by_name(VALUE class, VALUE name) {
+VALUE rb_host_get_by_name(VALUE class, VALUE name)
+{
- const char * h_name = RSTRING(name)->ptr;
+ const char *h_name = RSTRING(name)->ptr;
m_host_t host = MSG_get_host_by_name(h_name);
- if(!host)
- rb_raise(rb_eRuntimeError,bprintf("No host called '%s' found",h_name));
+ if (!host)
+ rb_raise(rb_eRuntimeError,
+ bprintf("No host called '%s' found", h_name));
- return Data_Wrap_Struct(class,0,rb_host_free,host);
+ return Data_Wrap_Struct(class, 0, rb_host_free, host);
}
//Get Name
-VALUE rb_host_name(VALUE class,VALUE host) {
+VALUE rb_host_name(VALUE class, VALUE host)
+{
// Wrap Ruby Value to m_host_t struct
m_host_t ht;
}
// Get Number
-VALUE rb_host_number(VALUE class) {
+VALUE rb_host_number(VALUE class)
+{
return INT2NUM(MSG_get_host_number());
}
// Host Speed ( Double )
-VALUE rb_host_speed(VALUE class,VALUE host) {
- m_host_t ht ;
- Data_Get_Struct(host,s_m_host_t,ht);
+VALUE rb_host_speed(VALUE class, VALUE host)
+{
+ m_host_t ht;
+ Data_Get_Struct(host, s_m_host_t, ht);
return MSG_get_host_speed(ht);
}
// Host is Avail
-VALUE rb_host_is_avail(VALUE class,VALUE host) {
+VALUE rb_host_is_avail(VALUE class, VALUE host)
+{
m_host_t ht;
- Data_Get_Struct(host,s_m_host_t,ht);
+ Data_Get_Struct(host, s_m_host_t, ht);
if (!ht) {
- rb_raise(rb_eRuntimeError,"Host not Bound");
+ rb_raise(rb_eRuntimeError, "Host not Bound");
return Qnil;
}
- if(MSG_host_is_avail(ht))
+ if (MSG_host_is_avail(ht))
return Qtrue;
return Qfalse;
}
// getHost from process
-VALUE rb_host_process(VALUE class,VALUE ruby_process)
+VALUE rb_host_process(VALUE class, VALUE ruby_process)
{
-
- m_process_t process = rb_process_to_native(ruby_process);
+
+ m_process_t process = rb_process_to_native(ruby_process);
m_host_t host;
-
+
if (!process) {
- rb_raise(rb_eRuntimeError,"Process Not Bound...while getting Host");
- return Qnil; // NULL
+ rb_raise(rb_eRuntimeError, "Process Not Bound...while getting Host");
+ return Qnil; // NULL
}
-
+
host = MSG_process_get_host(process);
-
- return Data_Wrap_Struct(class, 0, rb_host_free, host);
+
+ return Data_Wrap_Struct(class, 0, rb_host_free, host);
}
// get all hosts
VALUE rb_host_get_all_hosts(VALUE class)
{
- int nb,index;
- m_host_t *hosts;
- VALUE rb_hosts;
- nb = MSG_get_host_number();
- hosts = MSG_get_host_table();
- rb_hosts = rb_ary_new2(nb);
-
- for(index=0 ; index<nb; index++)
- rb_ary_push(rb_hosts,Data_Wrap_Struct(class, 0, rb_host_free, hosts[index]));
-
- return rb_hosts;
+ int nb, index;
+ m_host_t *hosts;
+ VALUE rb_hosts;
+ nb = MSG_get_host_number();
+ hosts = MSG_get_host_table();
+ rb_hosts = rb_ary_new2(nb);
+
+ for (index = 0; index < nb; index++)
+ rb_ary_push(rb_hosts,
+ Data_Wrap_Struct(class, 0, rb_host_free, hosts[index]));
+
+ return rb_hosts;
}
-
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "msg/private.h" /* s_simdata_process_t */
+#include "msg/private.h" /* s_simdata_process_t */
#include "bindings/ruby_bindings.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ruby,bindings,"Ruby Bindings");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ruby, bindings, "Ruby Bindings");
/*
* Functions for Ruby Process Management (Up Calls)
*/
// get Ruby Process Name
-VALUE rb_process_getName(VALUE ruby_process) {
- return rb_funcall(ruby_process,rb_intern("getName"),0);
+VALUE rb_process_getName(VALUE ruby_process)
+{
+ return rb_funcall(ruby_process, rb_intern("getName"), 0);
}
// Get Process ID
-VALUE rb_process_getID(VALUE ruby_process) {
- return rb_funcall(ruby_process,rb_intern("getID"),0);
+VALUE rb_process_getID(VALUE ruby_process)
+{
+ return rb_funcall(ruby_process, rb_intern("getID"), 0);
}
// Get Bind
-VALUE rb_process_getBind(VALUE ruby_process) {
- return rb_funcall(ruby_process,rb_intern("getBind"),0);
+VALUE rb_process_getBind(VALUE ruby_process)
+{
+ return rb_funcall(ruby_process, rb_intern("getBind"), 0);
}
// Set Bind
-void rb_process_setBind(VALUE ruby_process,long bind) {
+void rb_process_setBind(VALUE ruby_process, long bind)
+{
VALUE r_bind = LONG2FIX(bind);
- rb_funcall(ruby_process,rb_intern("setBind"),1,r_bind);
+ rb_funcall(ruby_process, rb_intern("setBind"), 1, r_bind);
}
// isAlive
-VALUE rb_process_isAlive(VALUE ruby_process) {
- return rb_funcall(ruby_process,rb_intern("alive?"),0);
+VALUE rb_process_isAlive(VALUE ruby_process)
+{
+ return rb_funcall(ruby_process, rb_intern("alive?"), 0);
}
// Kill Process
-void rb_process_kill_up(VALUE ruby_process) {
- rb_funcall(ruby_process,rb_intern("kill"),0);
+void rb_process_kill_up(VALUE ruby_process)
+{
+ rb_funcall(ruby_process, rb_intern("kill"), 0);
}
// join Process
-void rb_process_join( VALUE ruby_process ) {
- rb_funcall(ruby_process,rb_intern("join"),0);
+void rb_process_join(VALUE ruby_process)
+{
+ rb_funcall(ruby_process, rb_intern("join"), 0);
}
// FIXME: all this calls must be manually inlined I guess
// unschedule Process
-void rb_process_unschedule( VALUE ruby_process ) {
- rb_funcall(ruby_process,rb_intern("unschedule"),0);
+void rb_process_unschedule(VALUE ruby_process)
+{
+ rb_funcall(ruby_process, rb_intern("unschedule"), 0);
}
// schedule Process
-void rb_process_schedule( VALUE ruby_process ) {
- rb_funcall(ruby_process,rb_intern("schedule"),0);
+void rb_process_schedule(VALUE ruby_process)
+{
+ rb_funcall(ruby_process, rb_intern("schedule"), 0);
}
/***************************************************
****************************************************/
// Process To Native
-m_process_t rb_process_to_native(VALUE ruby_process) {
+m_process_t rb_process_to_native(VALUE ruby_process)
+{
VALUE id = rb_process_getBind(ruby_process);
if (!id) {
- rb_raise(rb_eRuntimeError,"Process Not Bound >>> id_Bind Null");
+ rb_raise(rb_eRuntimeError, "Process Not Bound >>> id_Bind Null");
return NULL;
}
- long l_id= FIX2LONG(id);
- return (m_process_t)l_id;
+ long l_id = FIX2LONG(id);
+ return (m_process_t) l_id;
}
// Bind Process
-void rb_process_bind(VALUE ruby_process,m_process_t process) {
- long bind = (long)(process);
- rb_process_setBind(ruby_process,bind);
+void rb_process_bind(VALUE ruby_process, m_process_t process)
+{
+ long bind = (long) (process);
+ rb_process_setBind(ruby_process, bind);
}
// Process Management
-void rb_process_suspend(VALUE class,VALUE ruby_process) {
+void rb_process_suspend(VALUE class, VALUE ruby_process)
+{
m_process_t process = rb_process_to_native(ruby_process);
if (!process) {
- rb_raise(rb_eRuntimeError,"Process Not Bound...while suspending process");
- return;
+ rb_raise(rb_eRuntimeError,
+ "Process Not Bound...while suspending process");
+ return;
}
-
// Trying to suspend The Process
- if ( MSG_OK != MSG_process_suspend(process))
- rb_raise(rb_eRuntimeError,"MSG_process_suspend() failed");
+ if (MSG_OK != MSG_process_suspend(process))
+ rb_raise(rb_eRuntimeError, "MSG_process_suspend() failed");
}
-void rb_process_resume(VALUE class,VALUE ruby_process) {
+void rb_process_resume(VALUE class, VALUE ruby_process)
+{
m_process_t process = rb_process_to_native(ruby_process);
if (!process) {
- rb_raise(rb_eRuntimeError,"Process not Bound...while resuming process");
- return ;
+ rb_raise(rb_eRuntimeError,
+ "Process not Bound...while resuming process");
+ return;
}
-
// Trying to resume the process
- if ( MSG_OK != MSG_process_resume(process))
- rb_raise(rb_eRuntimeError,"MSG_process_resume() failed");
+ if (MSG_OK != MSG_process_resume(process))
+ rb_raise(rb_eRuntimeError, "MSG_process_resume() failed");
}
-VALUE rb_process_isSuspended(VALUE class,VALUE ruby_process) {
+VALUE rb_process_isSuspended(VALUE class, VALUE ruby_process)
+{
m_process_t process = rb_process_to_native(ruby_process);
if (!process) {
- rb_raise (rb_eRuntimeError,"Process not Bound...while testing if suspended");
+ rb_raise(rb_eRuntimeError,
+ "Process not Bound...while testing if suspended");
return Qfalse;
}
- if(MSG_process_is_suspended(process))
+ if (MSG_process_is_suspended(process))
return Qtrue;
return Qfalse;
}
-void rb_process_kill_down(VALUE class,VALUE ruby_process) {
+void rb_process_kill_down(VALUE class, VALUE ruby_process)
+{
m_process_t process = rb_process_to_native(ruby_process);
- if(!process) {
- rb_raise (rb_eRuntimeError,"Process Not Bound...while killing process");
+ if (!process) {
+ rb_raise(rb_eRuntimeError,
+ "Process Not Bound...while killing process");
return;
}
// Delete The Global Reference / Ruby Process
MSG_process_kill(process);
}
-VALUE rb_process_getHost(VALUE class,VALUE ruby_process) {
+VALUE rb_process_getHost(VALUE class, VALUE ruby_process)
+{
m_process_t process = rb_process_to_native(ruby_process);
m_host_t host;
-
+
if (!process) {
- rb_raise(rb_eRuntimeError,"Process Not Bound...while getting Host");
- return Qnil; // NULL
+ rb_raise(rb_eRuntimeError, "Process Not Bound...while getting Host");
+ return Qnil; // NULL
}
-
+
host = MSG_process_get_host(process);
-
+
return Data_Wrap_Struct(class, 0, rb_host_free, host);
/*if(host->data) printf("Ok\n");
-
- if(!host->data) {
- rb_raise (rb_eRuntimeError,"MSG_process_get_host() failed");
- return Qnil;
- }
- printf("Houuuuuuuuuuuuuuna3!!\n");
- return Data_Wrap_Struct(class, 0, rb_host_free, host);*/
+
+ if(!host->data) {
+ rb_raise (rb_eRuntimeError,"MSG_process_get_host() failed");
+ return Qnil;
+ }
+ printf("Houuuuuuuuuuuuuuna3!!\n");
+ return Data_Wrap_Struct(class, 0, rb_host_free, host); */
}
-void rb_process_exit(VALUE class,VALUE ruby_process) {
+void rb_process_exit(VALUE class, VALUE ruby_process)
+{
m_process_t process = rb_process_to_native(ruby_process);
- if(!process) {
- rb_raise(rb_eRuntimeError,"Process Not Bound...while exiting process");
+ if (!process) {
+ rb_raise(rb_eRuntimeError,
+ "Process Not Bound...while exiting process");
return;
}
SIMIX_context_stop(SIMIX_process_self()->context);
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ruby);
// Free Method
-void rb_task_free(m_task_t tk) {
+void rb_task_free(m_task_t tk)
+{
//MSG_task_destroy(tk); ( This cause a bug !! is it really necessary ?!! not really sure !! )
}
// New Method
-VALUE rb_task_new(VALUE class, VALUE name,VALUE comp_size,VALUE comm_size) {
- m_task_t task = MSG_task_create(RSTRING(name)->ptr,NUM2INT(comp_size),NUM2INT(comm_size),NULL);
+VALUE rb_task_new(VALUE class, VALUE name, VALUE comp_size,
+ VALUE comm_size)
+{
+ m_task_t task = MSG_task_create(RSTRING(name)->ptr, NUM2INT(comp_size),
+ NUM2INT(comm_size), NULL);
rb_data_t data = malloc(sizeof(s_ruby_data_t));
data->ruby_task = NULL;
data->user_data = NULL;
- MSG_task_set_data(task,(void*)data);
+ MSG_task_set_data(task, (void *) data);
// Wrap m_task_t to a Ruby Value
return Data_Wrap_Struct(class, 0, rb_task_free, task);
}
//Get Computation Size
-VALUE rb_task_comp(VALUE class,VALUE task) {
+VALUE rb_task_comp(VALUE class, VALUE task)
+{
double size;
m_task_t tk;
// Wrap Ruby Value to m_task_t struct
}
//Get Name
-VALUE rb_task_name(VALUE class,VALUE task) {
+VALUE rb_task_name(VALUE class, VALUE task)
+{
// Wrap Ruby Value to m_task_t struct
- m_task_t tk;
+ m_task_t tk;
Data_Get_Struct(task, s_m_task_t, tk);
return rb_str_new2(MSG_task_get_name(tk));
}
// Execute Task
-VALUE rb_task_execute(VALUE class,VALUE task) {
+VALUE rb_task_execute(VALUE class, VALUE task)
+{
// Wrap Ruby Value to m_task_t struct
m_task_t tk;
}
// Sending Task
-void rb_task_send(VALUE class,VALUE task,VALUE mailbox) {
+void rb_task_send(VALUE class, VALUE task, VALUE mailbox)
+{
MSG_error_t rv;
rb_data_t data;
m_task_t tk;
Data_Get_Struct(task, s_m_task_t, tk);
data = MSG_task_get_data(tk);
- data->ruby_task =(void*)task;
- MSG_task_set_data(tk,(void*)data);
- DEBUG1("Sending task %p",tk);
- rv = MSG_task_send(tk,RSTRING(mailbox)->ptr);
- if(rv != MSG_OK)
- {
- if (rv == MSG_TRANSFER_FAILURE )
- rb_raise(rb_eRuntimeError,"Transfer failure while Sending");
- else if ( rv == MSG_HOST_FAILURE )
- rb_raise(rb_eRuntimeError,"Host failure while Sending");
- else if ( rv == MSG_TIMEOUT )
- rb_raise(rb_eRuntimeError,"Timeout failure while Sending");
- else
- rb_raise(rb_eRuntimeError,"MSG_task_send failed");
+ data->ruby_task = (void *) task;
+ MSG_task_set_data(tk, (void *) data);
+ DEBUG1("Sending task %p", tk);
+ rv = MSG_task_send(tk, RSTRING(mailbox)->ptr);
+ if (rv != MSG_OK) {
+ if (rv == MSG_TRANSFER_FAILURE)
+ rb_raise(rb_eRuntimeError, "Transfer failure while Sending");
+ else if (rv == MSG_HOST_FAILURE)
+ rb_raise(rb_eRuntimeError, "Host failure while Sending");
+ else if (rv == MSG_TIMEOUT)
+ rb_raise(rb_eRuntimeError, "Timeout failure while Sending");
+ else
+ rb_raise(rb_eRuntimeError, "MSG_task_send failed");
}
}
// Receiving Task (returns a Task)
-VALUE rb_task_receive(VALUE class, VALUE mailbox) {
+VALUE rb_task_receive(VALUE class, VALUE mailbox)
+{
// We must put the location where we copy the task
// pointer to on the heap, because the stack may move
// during the context switches (damn ruby internals)
m_task_t *ptask = malloc(sizeof(m_task_t));
m_task_t task;
*ptask = NULL;
- rb_data_t data =NULL;
- DEBUG2("Receiving a task on mailbox '%s', store it into %p",RSTRING(mailbox)->ptr,&task);
- MSG_task_receive(ptask,RSTRING(mailbox)->ptr);
+ rb_data_t data = NULL;
+ DEBUG2("Receiving a task on mailbox '%s', store it into %p",
+ RSTRING(mailbox)->ptr, &task);
+ MSG_task_receive(ptask, RSTRING(mailbox)->ptr);
task = *ptask;
free(ptask);
data = MSG_task_get_data(task);
- if(data==NULL) printf("Empty task while receving");
- return (VALUE)data->ruby_task;
+ if (data == NULL)
+ printf("Empty task while receving");
+ return (VALUE) data->ruby_task;
}
// It Return a Native Process ( m_process_t )
-VALUE rb_task_sender(VALUE class,VALUE task) {
+VALUE rb_task_sender(VALUE class, VALUE task)
+{
m_task_t tk;
- Data_Get_Struct(task,s_m_task_t,tk);
+ Data_Get_Struct(task, s_m_task_t, tk);
THROW_UNIMPLEMENTED;
- return 0;//MSG_task_get_sender(tk);
+ return 0; //MSG_task_get_sender(tk);
}
// it return a Host
-VALUE rb_task_source(VALUE class,VALUE task) {
+VALUE rb_task_source(VALUE class, VALUE task)
+{
m_task_t tk;
- Data_Get_Struct(task,s_m_task_t,tk);
+ Data_Get_Struct(task, s_m_task_t, tk);
m_host_t host = MSG_task_get_source(tk);
- if(!host->data) {
- rb_raise(rb_eRuntimeError,"MSG_task_get_source() failed");
+ if (!host->data) {
+ rb_raise(rb_eRuntimeError, "MSG_task_get_source() failed");
return Qnil;
}
THROW_UNIMPLEMENTED;
- return 0;//host;
+ return 0; //host;
}
// Return Boolean
-VALUE rb_task_listen(VALUE class,VALUE task,VALUE alias) {
+VALUE rb_task_listen(VALUE class, VALUE task, VALUE alias)
+{
m_task_t tk;
const char *p_alias;
int rv;
- Data_Get_Struct(task,s_m_task_t,tk);
+ Data_Get_Struct(task, s_m_task_t, tk);
p_alias = RSTRING(alias)->ptr;
rv = MSG_task_listen(p_alias);
- if(rv) return Qtrue;
+ if (rv)
+ return Qtrue;
return Qfalse;
}
// return Boolean
-VALUE rb_task_listen_host(VALUE class,VALUE task,VALUE alias,VALUE host) {
+VALUE rb_task_listen_host(VALUE class, VALUE task, VALUE alias, VALUE host)
+{
m_task_t tk;
m_host_t ht;
const char *p_alias;
int rv;
- Data_Get_Struct(task,s_m_task_t,tk);
- Data_Get_Struct(host,s_m_host_t,ht);
+ Data_Get_Struct(task, s_m_task_t, tk);
+ Data_Get_Struct(host, s_m_host_t, ht);
p_alias = RSTRING(alias)->ptr;
- rv = MSG_task_listen_from_host(p_alias,ht);
+ rv = MSG_task_listen_from_host(p_alias, ht);
if (rv)
return Qtrue;
return Qfalse;
// Set Priority
-void rb_task_set_priority(VALUE class,VALUE task,VALUE priority)
+void rb_task_set_priority(VALUE class, VALUE task, VALUE priority)
{
-
+
m_task_t tk;
double prt = NUM2DBL(priority);
- Data_Get_Struct(task,s_m_task_t,tk);
- MSG_task_set_priority(tk,prt);
-
+ Data_Get_Struct(task, s_m_task_t, tk);
+ MSG_task_set_priority(tk, prt);
+
}
// Cancel
-void rb_task_cancel(VALUE class,VALUE task)
+void rb_task_cancel(VALUE class, VALUE task)
{
- m_task_t tk;
- Data_Get_Struct(task,s_m_task_t,tk);
- MSG_task_cancel(tk);
+ m_task_t tk;
+ Data_Get_Struct(task, s_m_task_t, tk);
+ MSG_task_cancel(tk);
}
-void rb_task_set_data(VALUE class,VALUE task,VALUE data)
+void rb_task_set_data(VALUE class, VALUE task, VALUE data)
{
- m_task_t tk;
- rb_data_t rb_data;
- Data_Get_Struct(task,s_m_task_t,tk);
- rb_data = MSG_task_get_data(tk);
- rb_data->user_data = (void*)data;
- MSG_task_set_data(tk,(void*)rb_data);
+ m_task_t tk;
+ rb_data_t rb_data;
+ Data_Get_Struct(task, s_m_task_t, tk);
+ rb_data = MSG_task_get_data(tk);
+ rb_data->user_data = (void *) data;
+ MSG_task_set_data(tk, (void *) rb_data);
}
-VALUE rb_task_get_data(VALUE class,VALUE task)
+VALUE rb_task_get_data(VALUE class, VALUE task)
{
- m_task_t tk;
- Data_Get_Struct(task,s_m_task_t,tk);
- rb_data_t rb_data = MSG_task_get_data(tk);
- if(!rb_data->user_data)
- ERROR1("the task %s contain no user data",MSG_task_get_name(tk));
+ m_task_t tk;
+ Data_Get_Struct(task, s_m_task_t, tk);
+ rb_data_t rb_data = MSG_task_get_data(tk);
+ if (!rb_data->user_data)
+ ERROR1("the task %s contain no user data", MSG_task_get_name(tk));
- return (VALUE)rb_data->user_data;
+ return (VALUE) rb_data->user_data;
}
-VALUE rb_task_has_data(VALUE class,VALUE task)
+VALUE rb_task_has_data(VALUE class, VALUE task)
{
- m_task_t tk;
- Data_Get_Struct(task,s_m_task_t,tk);
- rb_data_t rb_data = MSG_task_get_data(tk);
- if(!rb_data->user_data)
- return Qfalse;
- return Qtrue;
+ m_task_t tk;
+ Data_Get_Struct(task, s_m_task_t, tk);
+ rb_data_t rb_data = MSG_task_get_data(tk);
+ if (!rb_data->user_data)
+ return Qfalse;
+ return Qtrue;
}
-
VALUE rb_host;
//Init Msg From Ruby
-static void msg_init(VALUE Class,VALUE args)
+static void msg_init(VALUE Class, VALUE args)
{
- char **argv=NULL;
+ char **argv = NULL;
const char *tmp;
- int argc,type,i;
- VALUE *ptr ;
+ int argc, type, i;
+ VALUE *ptr;
// Testing The Args Type
- type = TYPE(args);
- if (type != T_ARRAY ) {
- rb_raise(rb_eRuntimeError,"Bad arguments to msg_init (expecting an array)");
+ type = TYPE(args);
+ if (type != T_ARRAY) {
+ rb_raise(rb_eRuntimeError,
+ "Bad arguments to msg_init (expecting an array)");
return;
}
- ptr= RARRAY(args)->ptr;
- argc= RARRAY(args)->len;
+ ptr = RARRAY(args)->ptr;
+ argc = RARRAY(args)->len;
// Create C Array to Hold Data_Get_Struct
argc++;
argv = xbt_new0(char *, argc);
argv[0] = strdup("ruby");
- for (i=0;i<argc-1;i++) {
+ for (i = 0; i < argc - 1; i++) {
VALUE value = ptr[i];
type = TYPE(value);
// if (type == T_STRING)
tmp = RSTRING(value)->ptr;
- argv[i+1] = strdup(tmp);
+ argv[i + 1] = strdup(tmp);
}
// Calling C Msg_Init Method
- MSG_global_init(&argc,argv);
+ MSG_global_init(&argc, argv);
// Cleanups
- for (i=0;i<argc;i++)
- free(argv[i]) ;
- free (argv);
+ for (i = 0; i < argc; i++)
+ free(argv[i]);
+ free(argv);
}
+
//Init Msg_Run From Ruby
-static void msg_run(VALUE class) {
+static void msg_run(VALUE class)
+{
DEBUG0("Start Running...");
m_host_t *hosts;
- int cpt,host_count;
+ int cpt, host_count;
VALUE rbHost;
// Let's Run
//printf("msg_run3\n");
- if (MSG_OK != MSG_main()){
- rb_raise(rb_eRuntimeError,"MSG_main() failed");
+ if (MSG_OK != MSG_main()) {
+ rb_raise(rb_eRuntimeError, "MSG_main() failed");
}
DEBUG0
- ("MSG_main finished. Bail out before cleanup since there is a bug in this part.");
+ ("MSG_main finished. Bail out before cleanup since there is a bug in this part.");
/* Cleanup Ruby hosts */
DEBUG0("Clean Ruby World ");
hosts = MSG_get_host_table();
host_count = MSG_get_host_number();
- for (cpt=0;cpt<host_count;cpt++) {
- rbHost = (VALUE)((hosts[cpt])->data);
+ for (cpt = 0; cpt < host_count; cpt++) {
+ rbHost = (VALUE) ((hosts[cpt])->data);
}
return;
}
static void msg_clean(VALUE class)
{
- if (MSG_OK != MSG_clean())
- rb_raise(rb_eRuntimeError,"MSG_clean() failed");
-
+ if (MSG_OK != MSG_clean())
+ rb_raise(rb_eRuntimeError, "MSG_clean() failed");
+
}
-static void msg_createEnvironment(VALUE class,VALUE plateformFile) {
+
+static void msg_createEnvironment(VALUE class, VALUE plateformFile)
+{
int type = TYPE(plateformFile);
- if ( type != T_STRING )
- rb_raise(rb_eRuntimeError,"Bad Argument's Type");
- const char * platform = RSTRING(plateformFile)->ptr;
+ if (type != T_STRING)
+ rb_raise(rb_eRuntimeError, "Bad Argument's Type");
+ const char *platform = RSTRING(plateformFile)->ptr;
MSG_create_environment(platform);
- DEBUG1("Create Environment (%s)...Done",platform);
+ DEBUG1("Create Environment (%s)...Done", platform);
}
//deploy Application
-static void msg_deployApplication(VALUE class,VALUE deploymentFile ) {
+static void msg_deployApplication(VALUE class, VALUE deploymentFile)
+{
int type = TYPE(deploymentFile);
- if ( type != T_STRING )
- rb_raise(rb_eRuntimeError,"Bad Argument's Type for deployApplication ");
+ if (type != T_STRING)
+ rb_raise(rb_eRuntimeError,
+ "Bad Argument's Type for deployApplication ");
const char *dep_file = RSTRING(deploymentFile)->ptr;
surf_parse_reset_parser();
surfxml_add_callback(STag_surfxml_process_cb_list,
- rb_application_handler_on_begin_process);
+ rb_application_handler_on_begin_process);
surfxml_add_callback(ETag_surfxml_argument_cb_list,
- rb_application_handler_on_process_arg);
+ rb_application_handler_on_process_arg);
surfxml_add_callback(STag_surfxml_prop_cb_list,
- rb_application_handler_on_property);
+ rb_application_handler_on_property);