X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/60059959d6d517261ca7f4176b0267bc37caf04d..578dd56a4a07709db1922ff5edd98f0c8f3090f9:/src/simix/popping_private.h diff --git a/src/simix/popping_private.h b/src/simix/popping_private.h index cc2d741f29..71bd4ed173 100644 --- a/src/simix/popping_private.h +++ b/src/simix/popping_private.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2010, 2012-2014. The SimGrid Team. +/* Copyright (c) 2007-2010, 2012-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -7,15 +7,18 @@ #ifndef _POPPING_PRIVATE_H #define _POPPING_PRIVATE_H +#include +#include + SG_BEGIN_DECL() /********************************* Simcalls *********************************/ -XBT_PUBLIC(const char*) simcall_names[]; /* Name of each simcall */ +XBT_PUBLIC_DATA(const char*) simcall_names[]; /* Name of each simcall */ #include "popping_enum.h" /* Definition of e_smx_simcall_t, with one value per simcall */ -typedef int (*simix_match_func_t)(void *, void *, smx_action_t); -typedef void (*simix_copy_data_func_t)(smx_action_t, void*, size_t); +typedef int (*simix_match_func_t)(void *, void *, smx_synchro_t); +typedef void (*simix_copy_data_func_t)(smx_synchro_t, void*, size_t); typedef void (*simix_clean_func_t)(void *); typedef void (*FPtr)(void); // Hide the ugliness @@ -46,32 +49,201 @@ union u_smx_scalar { typedef struct s_smx_simcall { e_smx_simcall_t call; smx_process_t issuer; -#ifdef HAVE_MC int mc_value; -#endif union u_smx_scalar args[11]; union u_smx_scalar result; } s_smx_simcall_t, *smx_simcall_t; -#if HAVE_MC #define SIMCALL_SET_MC_VALUE(simcall, value) ((simcall)->mc_value = (value)) #define SIMCALL_GET_MC_VALUE(simcall) ((simcall)->mc_value) -#else -#define SIMCALL_SET_MC_VALUE(simcall, value) ((void)0) -#define SIMCALL_GET_MC_VALUE(simcall) 0 -#endif #include "popping_accessors.h" /******************************** General *************************************/ -void SIMIX_simcall_answer(smx_simcall_t); -void SIMIX_simcall_handle(smx_simcall_t, int); -void SIMIX_simcall_exit(smx_action_t); -const char *SIMIX_simcall_name(e_smx_simcall_t kind); -//FIXME put it in a better place -xbt_dict_t SIMIX_pre_asr_get_properties(smx_simcall_t simcall, const char *name); +XBT_PRIVATE void SIMIX_simcall_answer(smx_simcall_t); +XBT_PRIVATE void SIMIX_simcall_handle(smx_simcall_t, int); +XBT_PRIVATE void SIMIX_simcall_exit(smx_synchro_t); +XBT_PRIVATE const char *SIMIX_simcall_name(e_smx_simcall_t kind); +XBT_PRIVATE void SIMIX_run_kernel(void* code); SG_END_DECL() +#ifdef __cplusplus + +namespace simgrid { +namespace simix { + +template struct marshal_t {}; +#define SIMIX_MARSHAL(T, field) \ + template<> struct marshal_t { \ + static void marshal(u_smx_scalar& simcall, T value) \ + { \ + simcall.field = value; \ + } \ + static T unmarshal(u_smx_scalar const& simcall) \ + { \ + return simcall.field; \ + } \ + }; + +SIMIX_MARSHAL(char, c); +SIMIX_MARSHAL(short, s); +SIMIX_MARSHAL(int, i); +SIMIX_MARSHAL(long, l); +SIMIX_MARSHAL(unsigned char, uc); +SIMIX_MARSHAL(unsigned short, us); +SIMIX_MARSHAL(unsigned int, ui); +SIMIX_MARSHAL(unsigned long, ul); +SIMIX_MARSHAL(float, f); +SIMIX_MARSHAL(double, d); +SIMIX_MARSHAL(FPtr, fp); + +template struct marshal_t { + static void marshal(u_smx_scalar& simcall, T* value) + { + simcall.dp = value; + } + static T* unmarshal(u_smx_scalar const& simcall) + { + return simcall.dp; + } +}; + +template<> struct marshal_t { + static void unmarshal(u_smx_scalar const& simcall) {} +}; + +template inline +void marshal(u_smx_scalar& simcall, T const& value) +{ + marshal_t::marshal(simcall, value); +} + +template inline +T unmarshal(u_smx_scalar const& simcall) +{ + return marshal_t::unmarshal(simcall); +} + +template inline +void marshal(smx_simcall_t simcall, e_smx_simcall_t call, A&& a) +{ + simcall->call = call; + memset(&simcall->result, 0, sizeof(simcall->result)); + marshal(simcall->args[0], std::forward(a)); +} + +template inline +void marshal(smx_simcall_t simcall, e_smx_simcall_t call, A&& a, B&& b) +{ + simcall->call = call; + memset(&simcall->result, 0, sizeof(simcall->result)); + marshal(simcall->args[0], std::forward(a)); + marshal(simcall->args[1], std::forward(b)); +} + +template inline +void marshal(smx_simcall_t simcall, e_smx_simcall_t call, A&& a, B&& b, C&& c) +{ + simcall->call = call; + memset(&simcall->result, 0, sizeof(simcall->result)); + marshal(simcall->args[0], std::forward(a)); + marshal(simcall->args[1], std::forward(b)); + marshal(simcall->args[2], std::forward(c)); +} + +template inline +void marshal(smx_simcall_t simcall, e_smx_simcall_t call, A&& a, B&& b, C&& c, D&& d) +{ + simcall->call = call; + memset(&simcall->result, 0, sizeof(simcall->result)); + marshal(simcall->args[0], std::forward(a)); + marshal(simcall->args[1], std::forward(b)); + marshal(simcall->args[2], std::forward(c)); + marshal(simcall->args[3], std::forward(d)); +} + +template inline +void marshal(smx_simcall_t simcall, e_smx_simcall_t call, A&& a, B&& b, C&& c, D&& d, E&& e) +{ + simcall->call = call; + memset(&simcall->result, 0, sizeof(simcall->result)); + marshal(simcall->args[0], std::forward(a)); + marshal(simcall->args[1], std::forward(b)); + marshal(simcall->args[2], std::forward(c)); + marshal(simcall->args[3], std::forward(d)); + marshal(simcall->args[4], std::forward(e)); +} + +template inline +void marshal(smx_simcall_t simcall, e_smx_simcall_t call, + A&& a, B&& b, C&& c, D&& d, E&& e, F&& f) +{ + simcall->call = call; + memset(&simcall->result, 0, sizeof(simcall->result)); + marshal(simcall->args[0], std::forward(a)); + marshal(simcall->args[1], std::forward(b)); + marshal(simcall->args[2], std::forward(c)); + marshal(simcall->args[3], std::forward(d)); + marshal(simcall->args[4], std::forward(e)); + marshal(simcall->args[5], std::forward(f)); +} + +template inline +void marshal(smx_simcall_t simcall, e_smx_simcall_t call, + A&& a, B&& b, C&& c, D&& d, E&& e, F&& f, G&& g) +{ + simcall->call = call; + memset(&simcall->result, 0, sizeof(simcall->result)); + marshal(simcall->args[0], std::forward(a)); + marshal(simcall->args[1], std::forward(b)); + marshal(simcall->args[2], std::forward(c)); + marshal(simcall->args[3], std::forward(d)); + marshal(simcall->args[4], std::forward(e)); + marshal(simcall->args[5], std::forward(f)); + marshal(simcall->args[6], std::forward(g)); +} + +template inline +void marshal(smx_simcall_t simcall, e_smx_simcall_t call, + A&& a, B&& b, C&& c, D&& d, E&& e, F&& f, G&& g, H&& h) +{ + simcall->call = call; + memset(&simcall->result, 0, sizeof(simcall->result)); + marshal(simcall->args[0], std::forward(a)); + marshal(simcall->args[1], std::forward(b)); + marshal(simcall->args[2], std::forward(c)); + marshal(simcall->args[3], std::forward(d)); + marshal(simcall->args[4], std::forward(e)); + marshal(simcall->args[5], std::forward(f)); + marshal(simcall->args[6], std::forward(g)); + marshal(simcall->args[7], std::forward(h)); +} + +template inline +void marshal(smx_simcall_t simcall, e_smx_simcall_t call, + A&& a, B&& b, C&& c, D&& d, E&& e, F&& f, G&& g, H&& h, I&& i) +{ + simcall->call = call; + memset(&simcall->result, 0, sizeof(simcall->result)); + marshal(simcall->args[0], std::forward(a)); + marshal(simcall->args[1], std::forward(b)); + marshal(simcall->args[2], std::forward(c)); + marshal(simcall->args[3], std::forward(d)); + marshal(simcall->args[4], std::forward(e)); + marshal(simcall->args[5], std::forward(f)); + marshal(simcall->args[6], std::forward(g)); + marshal(simcall->args[7], std::forward(h)); + marshal(simcall->args[8], std::forward(i)); +} + +} +} + +#endif + #endif