X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c882e24932c718fad85c22cb546f30e158f1b31d..e1648ed1227078a777534d9b24bb4a4970e6df01:/src/simix/smx_smurf_private.h diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index ac677cddec..a418dd0908 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -115,8 +115,8 @@ #define SIMCALL_ARG(i, v) SIMCALL_ARG_ v /* get the parameter initialisation field */ -#define SIMCALL_INIT_FIELD_(name, type, field) {.field = name} -#define SIMCALL_INIT_FIELD(i, v) SIMCALL_INIT_FIELD_ v +#define SIMCALL_INIT_FIELD_(name, type, field) .field = name +#define SIMCALL_INIT_FIELD(i, d, v) self->simcall.args[i]SIMCALL_INIT_FIELD_ v; /* get the case of the parameter */ #define SIMCALL_CASE_PARAM_(name, type, field) field @@ -147,7 +147,7 @@ (name, type, __VA_ARGS__) #define SIMCALL_FUNC_SIMCALL(res) SIMCALL_FUNC_SIMCALL_ res -#define SIMCALL_WITH_FUNC_RETURN(name, type, field) return simcall->result.field; +#define SIMCALL_WITH_FUNC_RETURN(name, type, field) return self->simcall.result.field; #define SIMCALL_WITHOUT_FUNC_RETURN(name, type, field) #define SIMCALL_FUNC_RETURN_(name, type, ...)\ MAYBE2(,##__VA_ARGS__, SIMCALL_WITH_FUNC_RETURN, SIMCALL_WITHOUT_FUNC_RETURN)\ @@ -159,22 +159,30 @@ #define SIMCALL_ENUM(type, ...)\ type +/* generate the strings name from the enumeration values */ +#define SIMCALL_STRING_TYPE(type, name, answer, res, ...)\ + [type] = STRINGIFY(type) + /* generate strings from the enumeration values */ #define SIMCALL_TYPE(type, name, answer, res, ...)\ [type] = STRINGIFY(MAP(SIMCALL_FORMAT, __VA_ARGS__)) -/* generate the simcalls functions */ -#define SIMCALL_FUNC(type, name, answer, res, ...)\ - inline static SIMCALL_FUNC_RETURN_TYPE(res) simcall_BODY_##name(MAP(SIMCALL_ARG, ##__VA_ARGS__)) { \ - SIMCALL_FUNC_SIMCALL(res) __SIMIX_simcall(type, (u_smx_scalar_t[]){MAP(SIMCALL_INIT_FIELD, ##__VA_ARGS__)}); \ - SIMCALL_FUNC_RETURN(res)\ - } - -/* generate the simcalls prototypes functions */ -#define VOID_IF_EMPTY(...) GET_CLEAN(,##__VA_ARGS__,,,,,,,,,,,void) -#define SIMCALL_FUNC_PROTO(type, name, answer, res, ...)\ - inline static SIMCALL_FUNC_RETURN_TYPE(res) simcall_BODY_##name(VOID_IF_EMPTY(__VA_ARGS__) MAP(SIMCALL_ARG, ##__VA_ARGS__)); - +/* generate the simcalls BODY functions */ +#define SIMCALL_FUNC(TYPE, NAME, ANSWER, RES, ...)\ + inline static SIMCALL_FUNC_RETURN_TYPE(RES) simcall_BODY_##NAME(MAP(SIMCALL_ARG, ##__VA_ARGS__)) { \ + smx_process_t self = SIMIX_process_self(); \ + self->simcall.call = TYPE; \ + memset(self->simcall.args, 0, sizeof(self->simcall.args)); \ + MAP_WITH_DEFAULT_ARGS(SIMCALL_INIT_FIELD, (), ##__VA_ARGS__) \ + if (self != simix_global->maestro_process) { \ + XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, \ + SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); \ + SIMIX_process_yield(self); \ + } else { \ + SIMIX_simcall_pre(&self->simcall, 0); \ + } \ + SIMCALL_FUNC_RETURN(RES) \ + } /* generate a comma if there is an argument*/ #define WITHOUT_COMMA @@ -186,7 +194,7 @@ #define WITH_ANSWER(...) __VA_ARGS__ #define WITHOUT_ANSWER(...) #define SIMCALL_CASE(type, name, answer, res, ...)\ - case type:;\ + case type:\ SIMCALL_RESULT_BEGIN(answer, res) SIMIX_pre_ ## name(simcall MAYBE_COMMA(__VA_ARGS__) MAP(SIMCALL_CASE_PARAM, ##__VA_ARGS__));\ SIMCALL_RESULT_END(answer, res)\ break; @@ -206,30 +214,22 @@ /* generate the simcalls args getter/setter */ #define SIMCALL_ARG_GETSET_(i, name, v) \ - inline SIMCALL_FUNC_RETURN_TYPE(v) SIMCALL_GS_FUNC(SIMCALL_GS_SC_NAME(name), get, SIMCALL_GS_ARG_NAME(v))(smx_simcall_t simcall){\ + static inline SIMCALL_FUNC_RETURN_TYPE(v) SIMCALL_GS_FUNC(SIMCALL_GS_SC_NAME(name), get, SIMCALL_GS_ARG_NAME(v))(smx_simcall_t simcall){\ return simcall->args[i].SIMCALL_FIELD_ v ;\ }\ - inline void SIMCALL_GS_FUNC(SIMCALL_GS_SC_NAME(name), set, SIMCALL_GS_ARG_NAME(v))(smx_simcall_t simcall, SIMCALL_ARG_ v){\ + static inline void SIMCALL_GS_FUNC(SIMCALL_GS_SC_NAME(name), set, SIMCALL_GS_ARG_NAME(v))(smx_simcall_t simcall, SIMCALL_ARG_ v){\ simcall->args[i].SIMCALL_FIELD_ v = SIMCALL_NAME_ v ;\ } #define SIMCALL_ARG_GETSET(type, name, answer, res, ...)\ MAP_WITH_DEFAULT_ARGS(SIMCALL_ARG_GETSET_, (name), ##__VA_ARGS__) -/* generate the simcalls args getter/setter protos*/ -#define SIMCALL_ARG_GETSET_PROTO_(i, name, v) \ - inline SIMCALL_FUNC_RETURN_TYPE(v) SIMCALL_GS_FUNC(SIMCALL_GS_SC_NAME(name), get, SIMCALL_GS_ARG_NAME(v))(smx_simcall_t simcall);\ - inline void SIMCALL_GS_FUNC(SIMCALL_GS_SC_NAME(name), set, SIMCALL_GS_ARG_NAME(v))(smx_simcall_t simcall, SIMCALL_ARG_ v); - -#define SIMCALL_ARG_GETSET_PROTO(type, name, answer, res, ...)\ - MAP_WITH_DEFAULT_ARGS(SIMCALL_ARG_GETSET_PROTO_, (name), ##__VA_ARGS__) - /* generate the simcalls result getter/setter */ #define SIMCALL_WITH_RES_GETSET(name, v) \ - inline SIMCALL_FUNC_RETURN_TYPE(v) SIMCALL_GS_FUNC(SIMCALL_GS_SC_NAME((name)), get, SIMCALL_GS_ARG_NAME(v))(smx_simcall_t simcall){\ + static inline SIMCALL_FUNC_RETURN_TYPE(v) SIMCALL_GS_FUNC(SIMCALL_GS_SC_NAME((name)), get, SIMCALL_GS_ARG_NAME(v))(smx_simcall_t simcall){\ return simcall->result.SIMCALL_FIELD_ v ;\ }\ - inline void SIMCALL_GS_FUNC(SIMCALL_GS_SC_NAME((name)), set, SIMCALL_GS_ARG_NAME(v))(smx_simcall_t simcall, SIMCALL_ARG_ v){\ + static inline void SIMCALL_GS_FUNC(SIMCALL_GS_SC_NAME((name)), set, SIMCALL_GS_ARG_NAME(v))(smx_simcall_t simcall, SIMCALL_ARG_ v){\ simcall->result.SIMCALL_FIELD_ v = SIMCALL_NAME_ v ;\ } #define SIMCALL_WITHOUT_RES_GETSET(name, v) @@ -252,9 +252,6 @@ #define SIMCALL_RES_GETSET_PROTO(type, name, answer, res, ...)\ SIMCALL_RES_GETSET_PROTO_(name, res) - - - /* stringify arguments */ #define STRINGIFY_(...) #__VA_ARGS__ #define STRINGIFY(...) STRINGIFY_(__VA_ARGS__) @@ -395,12 +392,6 @@ NUM_SIMCALLS typedef int (*simix_match_func_t)(void *, void *, smx_action_t); typedef void (*simix_clean_func_t)(void *); -/** - * \brief Prototypes of SIMIX - */ -SIMCALL_LIST(SIMCALL_FUNC_PROTO, SIMCALL_SEP_NOTHING) - - /* Pack all possible scalar types in an union */ union u_smx_scalar { char c; @@ -426,7 +417,7 @@ typedef struct s_smx_simcall { e_smx_simcall_t call; smx_process_t issuer; int mc_value; - union u_smx_scalar *args; + union u_smx_scalar args[10]; union u_smx_scalar result; //FIXME: union u_smx_scalar retval; union { @@ -439,8 +430,8 @@ typedef struct s_smx_simcall { }; } s_smx_simcall_t, *smx_simcall_t; -SIMCALL_LIST(SIMCALL_RES_GETSET_PROTO, SIMCALL_SEP_NOTHING) -SIMCALL_LIST(SIMCALL_ARG_GETSET_PROTO, SIMCALL_SEP_NOTHING) +SIMCALL_LIST(SIMCALL_RES_GETSET, SIMCALL_SEP_NOTHING) +SIMCALL_LIST(SIMCALL_ARG_GETSET, SIMCALL_SEP_NOTHING) /******************************** General *************************************/