X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/017cf40352819fcf7bbf2926cbbc7b6b5cbc66d5..cfa2c6d8bd499b438e9f88e2e72e3b81e53b466a:/src/simix/smx_smurf_private.h diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index 91af60dd20..b90f25eb10 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -9,8 +9,14 @@ /********************************* Simcalls *********************************/ -/* we want to build the e_smx_simcall_t enumeration and the table of the - * corresponding strings automatically, using macros */ +/* we want to build the e_smx_simcall_t enumeration, the table of the + * corresponding simcalls string names, and the simcall handlers table + * automatically, using macros. + * To add a new simcall follow the following syntax: + * + * SIMCALL_ENUM_ELEMENT(, ) + * + * */ #define SIMCALL_LIST1 \ SIMCALL_ENUM_ELEMENT(SIMCALL_NONE),\ @@ -107,14 +113,14 @@ SIMCALL_ENUM_ELEMENT(SIMCALL_NEW_API_INIT) * because they are not always present */ #ifdef HAVE_LATENCY_BOUND_TRACKING #define SIMCALL_LIST2 \ -,SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IS_LATENCY_BOUNDED) +,SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IS_LATENCY_BOUNDED, SIMIX_comm_is_latency_bounded) #else #define SIMCALL_LIST2 #endif #ifdef HAVE_TRACING #define SIMCALL_LIST3 \ -,SIMCALL_ENUM_ELEMENT(SIMCALL_SET_CATEGORY) +,SIMCALL_ENUM_ELEMENT(SIMCALL_SET_CATEGORY, SIMIX_set_category) #else #define SIMCALL_LIST3 #endif @@ -132,7 +138,7 @@ SIMCALL_ENUM_ELEMENT(SIMCALL_NEW_API_INIT) /* you can redefine the following macro differently to generate something else * with the list of enumeration values (e.g. a table of strings or a table of function pointers) */ -#define SIMCALL_ENUM_ELEMENT(x) x +#define SIMCALL_ENUM_ELEMENT(x, y) x /** * \brief All possible simcalls. @@ -147,6 +153,8 @@ SIMCALL_LIST typedef struct s_smx_simcall { e_smx_simcall_t call; smx_process_t issuer; + union u_smx_scalar *args; + //FIXME: union u_smx_scalar retval; union { @@ -648,8 +656,9 @@ const char *SIMIX_simcall_name(e_smx_simcall_t kind); /*************************** New simcall interface ****************************/ /* Pack all possible scalar types in an union */ -typedef union { +union u_smx_scalar { char c; + const char* cc; short s; int i; long l; @@ -659,14 +668,15 @@ typedef union { unsigned long ul; float f; double d; - void *p; -} u_smx_scalar_t; + void* p; +}; /* * Define scalar type wrappers to ease the use of simcalls. * These are used to wrap the arguments in SIMIX_simcall macro. */ #define CHAR(x) (c,x) +#define STRING(x) (cc,x) #define SHORT(x) (s,x) #define INT(x) (i,x) #define LONG(x) (l,x) @@ -704,7 +714,7 @@ typedef union { /* Generate code to initialize the field 'x' with value 'y' of an structure or union */ #define INIT_FIELD_(x,y) {.x = y} -#define INIT_FIELD(t) INIT_FIELD t +#define INIT_FIELD(t) INIT_FIELD_ t /* Project the second element of a tuple */ #define SECOND_(x, y) y @@ -720,7 +730,7 @@ typedef union { */ #define SIMIX_simcall(id, ...) \ SIMIX_simcall_typecheck(simcall_types[id], MAP(SECOND, __VA_ARGS__)); \ - __SIMIX_simcall(id, (mytype_t[]){MAP(INIT_FIELD, __VA_ARGS__)}) + __SIMIX_simcall(id, (u_smx_scalar_t[]){MAP(INIT_FIELD, __VA_ARGS__)}) void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args); @@ -730,6 +740,10 @@ void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args); */ void SIMIX_simcall_typecheck(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); +typedef smx_action_t (*simcall_handler_t)(u_smx_scalar_t *); + +extern const char *simcall_types[]; +extern simcall_handler_t simcall_table[]; #endif