Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'mc++'
[simgrid.git] / src / simix / smx_smurf_private.h
index 6d3d645..dbd5f92 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2007-2010, 2012-2014. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -7,6 +7,8 @@
 #ifndef _SIMIX_SMURF_PRIVATE_H
 #define _SIMIX_SMURF_PRIVATE_H
 
+SG_BEGIN_DECL()
+
 /********************************* Simcalls *********************************/
 
 /* we want to build the e_smx_simcall_t enumeration, the table of the
  * automatically, using macros.
  * To add a new simcall follow the following syntax:
  *
- * SIMCALL_ENUM_ELEMENT(<simcall_enumeration_id>, <simcall_handler_function>)
- *
  * */
 
-#define SIMCALL_LIST1 \
-SIMCALL_ENUM_ELEMENT(SIMCALL_NONE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_BY_NAME),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_NAME),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_PROPERTIES),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_SPEED),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_AVAILABLE_SPEED),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_STATE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_DATA),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_SET_DATA),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_PARALLEL_EXECUTE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_DESTROY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_CANCEL),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_GET_REMAINS),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_GET_STATE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_SET_PRIORITY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_WAIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CREATE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_KILL),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_KILLALL),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CLEANUP),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CHANGE_HOST),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SUSPEND),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_RESUME),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_COUNT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_DATA),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SET_DATA),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_HOST),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_NAME),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_IS_SUSPENDED),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_PROPERTIES),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SLEEP),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_ON_EXIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_AUTO_RESTART_SET),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_RESTART),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_CREATE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_DESTROY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GEY_BY_NAME),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_COMM_COUNT_BY_HOST),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GET_HEAD),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_SET_RECV),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GET_RECV),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_SEND),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_ISEND),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_RECV),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IRECV),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_DESTROY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_CANCEL),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAITANY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TEST),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TESTANY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IPROBE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_REMAINS),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_STATE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_SRC_DATA),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_DST_DATA),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_SRC_PROC),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_DST_PROC),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_INIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_DESTROY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_LOCK),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_TRYLOCK),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_UNLOCK),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COND_INIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COND_DESTROY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COND_SIGNAL),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COND_WAIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COND_WAIT_TIMEOUT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_COND_BROADCAST),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_INIT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_DESTROY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_RELEASE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_WOULD_BLOCK),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE_TIMEOUT),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_GET_CAPACITY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_READ),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_WRITE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_OPEN),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_CLOSE),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_STAT), \
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_UNLINK),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_LS),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_ASR_GET_PROPERTIES), \
-/* ****************************************************************************************** */ \
-/* TUTORIAL: New API                                                                        */ \
-/* ****************************************************************************************** */ \
-SIMCALL_ENUM_ELEMENT(SIMCALL_NEW_API_INIT)
-
-/* SIMCALL_COMM_IS_LATENCY_BOUNDED and SIMCALL_SET_CATEGORY make things complicated
- * because they are not always present */
-#ifdef HAVE_LATENCY_BOUND_TRACKING
-#define SIMCALL_LIST2 \
-,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, SIMIX_set_category)
-#else
-#define SIMCALL_LIST3
-#endif
-
-#ifdef HAVE_MC
-#define SIMCALL_LIST4                                        \
-  ,SIMCALL_ENUM_ELEMENT(SIMCALL_MC_SNAPSHOT)                 \
-  ,SIMCALL_ENUM_ELEMENT(SIMCALL_MC_COMPARE_SNAPSHOTS)
-#else
-#define SIMCALL_LIST4
-#endif
-
-/* SIMCALL_LIST is the final macro to use */
-#define SIMCALL_LIST SIMCALL_LIST1 SIMCALL_LIST2 SIMCALL_LIST3 SIMCALL_LIST4
-
-/* 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, y) x
-
 /**
  * \brief All possible simcalls.
  */
 typedef enum {
-SIMCALL_LIST
+SIMCALL_NONE,
+#include "simcalls_generated_enum.h"
+SIMCALL_NEW_API_INIT,
+NUM_SIMCALLS
 } e_smx_simcall_t;
 
+typedef int (*simix_match_func_t)(void *, void *, smx_action_t);
+typedef void (*simix_clean_func_t)(void *);
+typedef void (*FPtr)(void); // Hide the ugliness
+
+/* Pack all possible scalar types in an union */
+union u_smx_scalar {
+  char            c;
+  const char*     cc;
+  short           s;
+  int             i;
+  long            l;
+  unsigned char   uc;
+  unsigned short  us;
+  unsigned int    ui;
+  unsigned long   ul;
+  float           f;
+  double          d;
+  size_t          sz;
+  sg_size_t       sgsz;
+  void*           dp;
+  FPtr            fp;
+  const void*     cp;
+};
+
 /**
  * \brief Represents a simcall to the kernel.
  */
 typedef struct s_smx_simcall {
   e_smx_simcall_t call;
   smx_process_t issuer;
-  union u_smx_scalar *args;
+#ifdef HAVE_MC
+  int mc_value;
+#endif
+  union u_smx_scalar args[10];
+  union u_smx_scalar result;
   //FIXME: union u_smx_scalar retval;
-
   union {
-
-    struct {
-      const char *name;
-      smx_host_t result;
-    } host_get_by_name;
-
-    struct {
-      smx_host_t host;
-      const char* result;
-    } host_get_name;
-
-    struct {
-      smx_host_t host;
-      xbt_dict_t result;
-    } host_get_properties;
-
-    struct {
-      smx_host_t host;
-      double result;
-    } host_get_speed;
-
-    struct {
-      smx_host_t host;
-      double result;
-    } host_get_available_speed;
-
-    struct {
-      smx_host_t host;
-      int result;
-    } host_get_state;
-
-    struct {
-      smx_host_t host;
-      void* result;
-    } host_get_data;
-
-    struct {
-      smx_host_t host;
-      void* data;
-    } host_set_data;
-
-    struct {
-      const char* name;
-      smx_host_t host;
-      double computation_amount;
-      double priority;
-      smx_action_t result;
-    } host_execute;
-
-    struct {
-      const char *name;
-      int host_nb;
-      smx_host_t *host_list;
-      double *computation_amount;
-      double *communication_amount;
-      double amount;
-      double rate;
-      smx_action_t result;
-    } host_parallel_execute;
-
-    struct {
-      smx_action_t execution;
-    } host_execution_destroy;
-
-    struct {
-      smx_action_t execution;
-    } host_execution_cancel;
-
-    struct {
-      smx_action_t execution;
-      double result;
-    } host_execution_get_remains;
-
-    struct {
-      smx_action_t execution;
-      e_smx_state_t result;
-    } host_execution_get_state;
-
-    struct {
-      smx_action_t execution;
-      double priority;
-    } host_execution_set_priority;
-
-    struct {
-      smx_action_t execution;
-      e_smx_state_t result;
-    } host_execution_wait;
-
-    struct {
-      smx_process_t *process;
-      const char *name;
-      xbt_main_func_t code;
-      void *data;
-      const char *hostname;
-      double kill_time;
-      int argc;
-      char **argv;
-      xbt_dict_t properties;
-      int auto_restart;
-    } process_create;
-
-    struct {
-      smx_process_t process;
-    } process_kill;
-
-    struct {
-      smx_process_t process;
-    } process_cleanup;
-
-    struct {
-      smx_process_t process;
-      smx_host_t dest;
-    } process_change_host;
-
-    struct {
-      smx_process_t process;
-    } process_suspend;
-
-    struct {
-      smx_process_t process;
-    } process_resume;
-
-    struct {
-      int result;
-    } process_count;
-
-    struct {
-      smx_process_t process;
-      void* result;
-    } process_get_data;
-
-    struct {
-      smx_process_t process;
-      void* data;
-    } process_set_data;
-
-    struct {
-      smx_process_t process;
-      smx_host_t result;
-    } process_get_host;
-
-    struct {
-      smx_process_t process;
-      const char *result;
-    } process_get_name;
-
-    struct {
-      smx_process_t process;
-      int result;
-    } process_is_suspended;
-
-    struct {
-      smx_process_t process;
-      xbt_dict_t result;
-    } process_get_properties;
-
-    struct {
-      double duration;
-      e_smx_state_t result;
-    } process_sleep;
-
-    struct {
-      smx_process_t process;
-      int_f_pvoid_t fun;
-      void *data;
-    } process_on_exit;
-
-    struct {
-      smx_process_t process;
-      int auto_restart;
-    } process_auto_restart;
-
-    struct {
-      smx_process_t process;
-      smx_process_t result;
-    } process_restart;
-
-    struct {
-      const char *name;
-      smx_rdv_t result;
-    } rdv_create;
-
-    struct {
-      smx_rdv_t rdv;
-    } rdv_destroy;
-
-    struct {
-      const char* name;
-      smx_rdv_t result;
-    } rdv_get_by_name;
-
-    struct {
-      smx_rdv_t rdv;
-      smx_host_t host;
-      unsigned int result; 
-    } rdv_comm_count_by_host;
-
-    struct {
-      smx_rdv_t rdv;
-      smx_action_t result;
-    } rdv_get_head;
-
-    struct {
-      smx_rdv_t rdv;
-      smx_process_t receiver;
-    } rdv_set_rcv_proc;
-
-    struct {
-      smx_rdv_t rdv;
-      smx_process_t result;
-    } rdv_get_rcv_proc;
-
-    struct {
-      smx_rdv_t rdv;
-      double task_size;
-      double rate;
-      void *src_buff;
-      size_t src_buff_size;
-      int (*match_fun)(void *, void *, smx_action_t);
-      void *data;
-      double timeout;
-    } comm_send;
-
-    struct {
-      smx_rdv_t rdv;
-      double task_size;
-      double rate;
-      void *src_buff;
-      size_t src_buff_size;
-      int (*match_fun)(void *, void *, smx_action_t);
-      void (*clean_fun)(void *);
-      void *data;
-      int detached;
-      smx_action_t result;
-    } comm_isend;
-
-    struct {
-      smx_rdv_t rdv;
-      void *dst_buff;
-      size_t *dst_buff_size;
-      int (*match_fun)(void *, void *, smx_action_t);
-      void *data;
-      double timeout;
-    } comm_recv;
-
-    struct {
-      smx_rdv_t rdv;
-      void *dst_buff;
-      size_t *dst_buff_size;
-      int (*match_fun)(void *, void *, smx_action_t);
-      void *data;
-      smx_action_t result;
-    } comm_irecv;
-
-    struct {
-      smx_rdv_t rdv;
-      int src;
-      int tag;
-      int (*match_fun)(void *, void *, smx_action_t);
-      void *data;
-      smx_action_t result;
-    } comm_iprobe;
-
-    struct {
-      smx_action_t comm;
-    } comm_destroy;
-
-    struct {
-      smx_action_t comm;
-    } comm_cancel;
-
-    struct {
-      xbt_dynar_t comms;
-      unsigned int result;
-    } comm_waitany;
-
-    struct {
-      smx_action_t comm;
-      double timeout;
-    } comm_wait;
-
-    struct {
-      smx_action_t comm;
-      int result;
-    } comm_test;
-
-    struct {
-      xbt_dynar_t comms;
-      int result;
-    } comm_testany;
-
-    struct {
-      smx_action_t comm;
-      double result;
-    } comm_get_remains;
-
-    struct {
-      smx_action_t comm;
-      e_smx_state_t result;
-    } comm_get_state;
-
-    struct {
-      smx_action_t comm;
-      void *result;
-    } comm_get_src_data;
-
-    struct {
-      smx_action_t comm;
-      void *result;
-    } comm_get_dst_data;
-
-    struct {
-      smx_action_t comm;
-      smx_process_t result;
-    } comm_get_src_proc;
-
-    struct {
-      smx_action_t comm;
-      smx_process_t result;
-    } comm_get_dst_proc;
-
-#ifdef HAVE_LATENCY_BOUND_TRACKING
-    struct {
-      smx_action_t comm;
-      int result;
-    } comm_is_latency_bounded;
-#endif
-
-#ifdef HAVE_TRACING
-    struct {
-      smx_action_t action;
-      const char *category;
-    } set_category;
-#endif
-
-    struct {
-      smx_mutex_t result;
-    } mutex_init;
-
-    struct {
-      smx_mutex_t mutex;
-    } mutex_lock;
-
-    struct {
-      smx_mutex_t mutex;
-      int result;
-    } mutex_trylock;
-
-    struct {
-      smx_mutex_t mutex;
-    } mutex_unlock;
-
-    struct {
-      smx_mutex_t mutex;
-    } mutex_destroy;
-
-    struct {
-      smx_cond_t result;
-    } cond_init;
-
-    struct {
-      smx_cond_t cond;
-    } cond_destroy;
-
-    struct {
-      smx_cond_t cond;
-    } cond_signal;
-
-    struct {
-      smx_cond_t cond;
-      smx_mutex_t mutex;
-    } cond_wait;
-
-    struct {
-      smx_cond_t cond;
-      smx_mutex_t mutex;
-      double timeout;
-    } cond_wait_timeout;
-
-    struct {
-      smx_cond_t cond;
-    } cond_broadcast;
-
-    struct {
-      int capacity;
-      smx_sem_t result;
-    } sem_init;
-
-    struct {
-      smx_sem_t sem;
-    } sem_destroy;
-
-    struct {
-      smx_sem_t sem;
-    } sem_release;
-
-    struct {
-      smx_sem_t sem;
-      int result;
-    } sem_would_block;
-
-    struct {
-      smx_sem_t sem;
-    } sem_acquire;
-
-    struct {
-      smx_sem_t sem;
-      double timeout;
-    } sem_acquire_timeout;
-
-    struct {
-      smx_sem_t sem;
-      int result;
-    } sem_get_capacity;
-
-    struct {
-      void *ptr;
-      size_t size;
-      size_t nmemb;
-      smx_file_t stream;
-      double result;
-    } file_read;
-
-    struct {
-      const void *ptr;
-      size_t size;
-      size_t nmemb;
-      smx_file_t stream;
-      size_t result;
-    } file_write;
-
-    struct {
-      const char* mount;
-      const char* path;
-      const char* mode;
-      smx_file_t result;
-    } file_open;
-
-    struct {
-      smx_file_t fp;
-      int result;
-    } file_close;
-
-    struct {
-      smx_file_t fd;
-      s_file_stat_t buf;
-      int result;
-    } file_stat;
-
-    struct {
-      smx_file_t fd;
-      int result;
-    } file_unlink;
-
-    struct {
-      const char *mount;
-      const char *path;
-      xbt_dict_t result;
-    } file_ls;
-
-    struct {
-      const char* name;
-      xbt_dict_t result;
-    } asr_get_properties;
-
-    struct{
-      void *s;
-    } mc_snapshot;
-
-    struct{
-      void *snapshot1;
-      void *snapshot2;
-      int result;
-    } mc_compare_snapshots;
-
-    /* ****************************************************************************************** */
-    /* TUTORIAL: New API                                                                        */
-    /* ****************************************************************************************** */
     struct {
       const char* param1;
       double param2;
@@ -644,6 +74,17 @@ typedef struct s_smx_simcall {
   };
 } 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 "simcalls_generated_res_getter_setter.h"
+#include "simcalls_generated_args_getter_setter.h"
+
 /******************************** General *************************************/
 
 void SIMIX_simcall_push(smx_process_t self);
@@ -652,101 +93,16 @@ void SIMIX_simcall_pre(smx_simcall_t, int);
 void SIMIX_simcall_post(smx_action_t);
 smx_simcall_t SIMIX_simcall_mine(void);
 const char *SIMIX_simcall_name(e_smx_simcall_t kind);
+//TOFIX put it in a better place
+xbt_dict_t SIMIX_pre_asr_get_properties(smx_simcall_t simcall, const char *name);
 
 /*************************** New simcall interface ****************************/
 
-/* Pack all possible scalar types in an union */
-union u_smx_scalar {
-  char            c;
-  const char*     cc;
-  short           s;
-  int             i;
-  long            l;
-  unsigned char   uc;
-  unsigned short  us;
-  unsigned int    ui;
-  unsigned long   ul;
-  float           f;
-  double          d;
-  void*           p;
-};
-
-#define SIMIX_pack_args(...) (u_smx_scalar_t[]){MAP(INIT_FIELD, __VA_ARGS__)}
-
-
-/*
- * 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)
-#define UCHAR(x) (uc,x)
-#define USHORT(x) (us,x)
-#define UINT(x) (ui,x)
-#define ULONG(x) (ul,x)
-#define FLOAT(x) (f,x)
-#define DOUBLE(x) (d,x)
-#define PTR(x)  (p,x)
-
-/*
- * Some macro machinery to get a MAP over the arguments of a variadic macro.
- * It uses a FOLD to apply a macro to every argument, and because there is
- * no recursion in the C preprocessor we must create a new macro for every
- * depth of FOLD's recursion.
- */
-
-/* FOLD macro */
-#define FE_1(WHAT, X) WHAT(X)
-#define FE_2(WHAT, X, ...) WHAT(X), FE_1(WHAT, __VA_ARGS__)
-#define FE_3(WHAT, X, ...) WHAT(X), FE_2(WHAT, __VA_ARGS__)
-#define FE_4(WHAT, X, ...) WHAT(X), FE_3(WHAT, __VA_ARGS__)
-#define FE_5(WHAT, X, ...) WHAT(X), FE_4(WHAT, __VA_ARGS__)
-/* NOTE: add as many FE_n as needed (maximum number of simcall arguments )*/
-
-/* Make a MAP macro usgin FOLD (will apply 'action' to the arguments.
- * GET_MACRO is a smart hack that counts the number of arguments passed to
- * the variadic macro, and it is used to invoke the right FOLD depth.
- */
-#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
-#define MAP(action,...) \
-  GET_MACRO(__VA_ARGS__,FE_5,FE_4,FE_3,FE_2,FE_1) (action, __VA_ARGS__)
-
-
-/* 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
-
-/* Project the second element of a tuple */
-#define SECOND_(x, y) y
-#define SECOND(t) SECOND_ t
-
-/*
- * \brief Simcall invocation macro
- * It calls a dummy function that uses the format attribute to ensure typesafety (see
- * gcc format attribute), then it invokes the real simcall function packing the
- * user provided arguments in an array.
- * \param id a simcall id (from the simcall enumeration ids)
- *
- */
-#define SIMIX_simcall(id, ...) \
-  SIMIX_simcall_typecheck(simcall_types[id], MAP(SECOND, __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);
-
-/*
- * \biref Dummy variadic function used to typecheck the arguments of a simcall
- * \param fmt A format string following printf style
- */
-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
+SG_END_DECL()
 
+#endif