-/* 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) \
+ }