Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move SIMCALL_HOST_EXECUTE to the new simcall architecture for initial testing.
[simgrid.git] / src / simix / smx_smurf_private.h
1 /* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef _SIMIX_SMURF_PRIVATE_H
8 #define _SIMIX_SMURF_PRIVATE_H
9
10 /********************************* Simcalls *********************************/
11
12 /* we want to build the e_smx_simcall_t enumeration and the table of the
13  * corresponding strings automatically, using macros */
14
15 #define SIMCALL_LIST1 \
16 SIMCALL_ENUM_ELEMENT(SIMCALL_NONE),\
17 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_BY_NAME),\
18 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_NAME),\
19 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_PROPERTIES),\
20 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_SPEED),\
21 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_AVAILABLE_SPEED),\
22 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_STATE),\
23 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_DATA),\
24 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_SET_DATA),\
25 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTE),\
26 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_PARALLEL_EXECUTE),\
27 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_DESTROY),\
28 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_CANCEL),\
29 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_GET_REMAINS),\
30 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_GET_STATE),\
31 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_SET_PRIORITY),\
32 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_WAIT),\
33 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CREATE),\
34 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_KILL),\
35 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_KILLALL),\
36 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CLEANUP),\
37 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CHANGE_HOST),\
38 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SUSPEND),\
39 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_RESUME),\
40 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_COUNT),\
41 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_DATA),\
42 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SET_DATA),\
43 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_HOST),\
44 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_NAME),\
45 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_IS_SUSPENDED),\
46 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_PROPERTIES),\
47 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SLEEP),\
48 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_ON_EXIT),\
49 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_AUTO_RESTART_SET),\
50 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_RESTART),\
51 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_CREATE),\
52 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_DESTROY),\
53 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GEY_BY_NAME),\
54 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_COMM_COUNT_BY_HOST),\
55 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GET_HEAD),\
56 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_SET_RECV),\
57 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GET_RECV),\
58 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_SEND),\
59 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_ISEND),\
60 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_RECV),\
61 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IRECV),\
62 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_DESTROY),\
63 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_CANCEL),\
64 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAITANY),\
65 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAIT),\
66 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TEST),\
67 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TESTANY),\
68 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IPROBE),\
69 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_REMAINS),\
70 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_STATE),\
71 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_SRC_DATA),\
72 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_DST_DATA),\
73 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_SRC_PROC),\
74 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_DST_PROC),\
75 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_INIT),\
76 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_DESTROY),\
77 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_LOCK),\
78 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_TRYLOCK),\
79 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_UNLOCK),\
80 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_INIT),\
81 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_DESTROY),\
82 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_SIGNAL),\
83 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_WAIT),\
84 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_WAIT_TIMEOUT),\
85 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_BROADCAST),\
86 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_INIT),\
87 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_DESTROY),\
88 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_RELEASE),\
89 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_WOULD_BLOCK),\
90 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE),\
91 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE_TIMEOUT),\
92 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_GET_CAPACITY),\
93 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_READ),\
94 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_WRITE),\
95 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_OPEN),\
96 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_CLOSE),\
97 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_STAT), \
98 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_UNLINK),\
99 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_LS),\
100 SIMCALL_ENUM_ELEMENT(SIMCALL_ASR_GET_PROPERTIES), \
101 /* ****************************************************************************************** */ \
102 /* TUTORIAL: New API                                                                        */ \
103 /* ****************************************************************************************** */ \
104 SIMCALL_ENUM_ELEMENT(SIMCALL_NEW_API_INIT)
105
106 /* SIMCALL_COMM_IS_LATENCY_BOUNDED and SIMCALL_SET_CATEGORY make things complicated
107  * because they are not always present */
108 #ifdef HAVE_LATENCY_BOUND_TRACKING
109 #define SIMCALL_LIST2 \
110 ,SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IS_LATENCY_BOUNDED)
111 #else
112 #define SIMCALL_LIST2
113 #endif
114
115 #ifdef HAVE_TRACING
116 #define SIMCALL_LIST3 \
117 ,SIMCALL_ENUM_ELEMENT(SIMCALL_SET_CATEGORY)
118 #else
119 #define SIMCALL_LIST3
120 #endif
121
122 #ifdef HAVE_MC
123 #define SIMCALL_LIST4                                        \
124   ,SIMCALL_ENUM_ELEMENT(SIMCALL_MC_SNAPSHOT)                 \
125   ,SIMCALL_ENUM_ELEMENT(SIMCALL_MC_COMPARE_SNAPSHOTS)
126 #else
127 #define SIMCALL_LIST4
128 #endif
129
130 /* SIMCALL_LIST is the final macro to use */
131 #define SIMCALL_LIST SIMCALL_LIST1 SIMCALL_LIST2 SIMCALL_LIST3 SIMCALL_LIST4
132
133 /* you can redefine the following macro differently to generate something else
134  * with the list of enumeration values (e.g. a table of strings or a table of function pointers) */
135 #define SIMCALL_ENUM_ELEMENT(x) x
136
137 /**
138  * \brief All possible simcalls.
139  */
140 typedef enum {
141 SIMCALL_LIST
142 } e_smx_simcall_t;
143
144 /**
145  * \brief Represents a simcall to the kernel.
146  */
147 typedef struct s_smx_simcall {
148   e_smx_simcall_t call;
149   smx_process_t issuer;
150   union u_smx_scalar *args;
151   //FIXME: union u_smx_scalar retval;
152
153   union {
154
155     struct {
156       const char *name;
157       smx_host_t result;
158     } host_get_by_name;
159
160     struct {
161       smx_host_t host;
162       const char* result;
163     } host_get_name;
164
165     struct {
166       smx_host_t host;
167       xbt_dict_t result;
168     } host_get_properties;
169
170     struct {
171       smx_host_t host;
172       double result;
173     } host_get_speed;
174
175     struct {
176       smx_host_t host;
177       double result;
178     } host_get_available_speed;
179
180     struct {
181       smx_host_t host;
182       int result;
183     } host_get_state;
184
185     struct {
186       smx_host_t host;
187       void* result;
188     } host_get_data;
189
190     struct {
191       smx_host_t host;
192       void* data;
193     } host_set_data;
194
195     struct {
196       const char* name;
197       smx_host_t host;
198       double computation_amount;
199       double priority;
200       smx_action_t result;
201     } host_execute;
202
203     struct {
204       const char *name;
205       int host_nb;
206       smx_host_t *host_list;
207       double *computation_amount;
208       double *communication_amount;
209       double amount;
210       double rate;
211       smx_action_t result;
212     } host_parallel_execute;
213
214     struct {
215       smx_action_t execution;
216     } host_execution_destroy;
217
218     struct {
219       smx_action_t execution;
220     } host_execution_cancel;
221
222     struct {
223       smx_action_t execution;
224       double result;
225     } host_execution_get_remains;
226
227     struct {
228       smx_action_t execution;
229       e_smx_state_t result;
230     } host_execution_get_state;
231
232     struct {
233       smx_action_t execution;
234       double priority;
235     } host_execution_set_priority;
236
237     struct {
238       smx_action_t execution;
239       e_smx_state_t result;
240     } host_execution_wait;
241
242     struct {
243       smx_process_t *process;
244       const char *name;
245       xbt_main_func_t code;
246       void *data;
247       const char *hostname;
248       double kill_time;
249       int argc;
250       char **argv;
251       xbt_dict_t properties;
252       int auto_restart;
253     } process_create;
254
255     struct {
256       smx_process_t process;
257     } process_kill;
258
259     struct {
260       smx_process_t process;
261     } process_cleanup;
262
263     struct {
264       smx_process_t process;
265       smx_host_t dest;
266     } process_change_host;
267
268     struct {
269       smx_process_t process;
270     } process_suspend;
271
272     struct {
273       smx_process_t process;
274     } process_resume;
275
276     struct {
277       int result;
278     } process_count;
279
280     struct {
281       smx_process_t process;
282       void* result;
283     } process_get_data;
284
285     struct {
286       smx_process_t process;
287       void* data;
288     } process_set_data;
289
290     struct {
291       smx_process_t process;
292       smx_host_t result;
293     } process_get_host;
294
295     struct {
296       smx_process_t process;
297       const char *result;
298     } process_get_name;
299
300     struct {
301       smx_process_t process;
302       int result;
303     } process_is_suspended;
304
305     struct {
306       smx_process_t process;
307       xbt_dict_t result;
308     } process_get_properties;
309
310     struct {
311       double duration;
312       e_smx_state_t result;
313     } process_sleep;
314
315     struct {
316       smx_process_t process;
317       int_f_pvoid_t fun;
318       void *data;
319     } process_on_exit;
320
321     struct {
322       smx_process_t process;
323       int auto_restart;
324     } process_auto_restart;
325
326     struct {
327       smx_process_t process;
328       smx_process_t result;
329     } process_restart;
330
331     struct {
332       const char *name;
333       smx_rdv_t result;
334     } rdv_create;
335
336     struct {
337       smx_rdv_t rdv;
338     } rdv_destroy;
339
340     struct {
341       const char* name;
342       smx_rdv_t result;
343     } rdv_get_by_name;
344
345     struct {
346       smx_rdv_t rdv;
347       smx_host_t host;
348       unsigned int result; 
349     } rdv_comm_count_by_host;
350
351     struct {
352       smx_rdv_t rdv;
353       smx_action_t result;
354     } rdv_get_head;
355
356     struct {
357       smx_rdv_t rdv;
358       smx_process_t receiver;
359     } rdv_set_rcv_proc;
360
361     struct {
362       smx_rdv_t rdv;
363       smx_process_t result;
364     } rdv_get_rcv_proc;
365
366     struct {
367       smx_rdv_t rdv;
368       double task_size;
369       double rate;
370       void *src_buff;
371       size_t src_buff_size;
372       int (*match_fun)(void *, void *, smx_action_t);
373       void *data;
374       double timeout;
375     } comm_send;
376
377     struct {
378       smx_rdv_t rdv;
379       double task_size;
380       double rate;
381       void *src_buff;
382       size_t src_buff_size;
383       int (*match_fun)(void *, void *, smx_action_t);
384       void (*clean_fun)(void *);
385       void *data;
386       int detached;
387       smx_action_t result;
388     } comm_isend;
389
390     struct {
391       smx_rdv_t rdv;
392       void *dst_buff;
393       size_t *dst_buff_size;
394       int (*match_fun)(void *, void *, smx_action_t);
395       void *data;
396       double timeout;
397     } comm_recv;
398
399     struct {
400       smx_rdv_t rdv;
401       void *dst_buff;
402       size_t *dst_buff_size;
403       int (*match_fun)(void *, void *, smx_action_t);
404       void *data;
405       smx_action_t result;
406     } comm_irecv;
407
408     struct {
409       smx_rdv_t rdv;
410       int src;
411       int tag;
412       int (*match_fun)(void *, void *, smx_action_t);
413       void *data;
414       smx_action_t result;
415     } comm_iprobe;
416
417     struct {
418       smx_action_t comm;
419     } comm_destroy;
420
421     struct {
422       smx_action_t comm;
423     } comm_cancel;
424
425     struct {
426       xbt_dynar_t comms;
427       unsigned int result;
428     } comm_waitany;
429
430     struct {
431       smx_action_t comm;
432       double timeout;
433     } comm_wait;
434
435     struct {
436       smx_action_t comm;
437       int result;
438     } comm_test;
439
440     struct {
441       xbt_dynar_t comms;
442       int result;
443     } comm_testany;
444
445     struct {
446       smx_action_t comm;
447       double result;
448     } comm_get_remains;
449
450     struct {
451       smx_action_t comm;
452       e_smx_state_t result;
453     } comm_get_state;
454
455     struct {
456       smx_action_t comm;
457       void *result;
458     } comm_get_src_data;
459
460     struct {
461       smx_action_t comm;
462       void *result;
463     } comm_get_dst_data;
464
465     struct {
466       smx_action_t comm;
467       smx_process_t result;
468     } comm_get_src_proc;
469
470     struct {
471       smx_action_t comm;
472       smx_process_t result;
473     } comm_get_dst_proc;
474
475 #ifdef HAVE_LATENCY_BOUND_TRACKING
476     struct {
477       smx_action_t comm;
478       int result;
479     } comm_is_latency_bounded;
480 #endif
481
482 #ifdef HAVE_TRACING
483     struct {
484       smx_action_t action;
485       const char *category;
486     } set_category;
487 #endif
488
489     struct {
490       smx_mutex_t result;
491     } mutex_init;
492
493     struct {
494       smx_mutex_t mutex;
495     } mutex_lock;
496
497     struct {
498       smx_mutex_t mutex;
499       int result;
500     } mutex_trylock;
501
502     struct {
503       smx_mutex_t mutex;
504     } mutex_unlock;
505
506     struct {
507       smx_mutex_t mutex;
508     } mutex_destroy;
509
510     struct {
511       smx_cond_t result;
512     } cond_init;
513
514     struct {
515       smx_cond_t cond;
516     } cond_destroy;
517
518     struct {
519       smx_cond_t cond;
520     } cond_signal;
521
522     struct {
523       smx_cond_t cond;
524       smx_mutex_t mutex;
525     } cond_wait;
526
527     struct {
528       smx_cond_t cond;
529       smx_mutex_t mutex;
530       double timeout;
531     } cond_wait_timeout;
532
533     struct {
534       smx_cond_t cond;
535     } cond_broadcast;
536
537     struct {
538       int capacity;
539       smx_sem_t result;
540     } sem_init;
541
542     struct {
543       smx_sem_t sem;
544     } sem_destroy;
545
546     struct {
547       smx_sem_t sem;
548     } sem_release;
549
550     struct {
551       smx_sem_t sem;
552       int result;
553     } sem_would_block;
554
555     struct {
556       smx_sem_t sem;
557     } sem_acquire;
558
559     struct {
560       smx_sem_t sem;
561       double timeout;
562     } sem_acquire_timeout;
563
564     struct {
565       smx_sem_t sem;
566       int result;
567     } sem_get_capacity;
568
569     struct {
570       void *ptr;
571       size_t size;
572       size_t nmemb;
573       smx_file_t stream;
574       double result;
575     } file_read;
576
577     struct {
578       const void *ptr;
579       size_t size;
580       size_t nmemb;
581       smx_file_t stream;
582       size_t result;
583     } file_write;
584
585     struct {
586       const char* mount;
587       const char* path;
588       const char* mode;
589       smx_file_t result;
590     } file_open;
591
592     struct {
593       smx_file_t fp;
594       int result;
595     } file_close;
596
597     struct {
598       smx_file_t fd;
599       s_file_stat_t buf;
600       int result;
601     } file_stat;
602
603     struct {
604       smx_file_t fd;
605       int result;
606     } file_unlink;
607
608     struct {
609       const char *mount;
610       const char *path;
611       xbt_dict_t result;
612     } file_ls;
613
614     struct {
615       const char* name;
616       xbt_dict_t result;
617     } asr_get_properties;
618
619     struct{
620       void *s;
621     } mc_snapshot;
622
623     struct{
624       void *snapshot1;
625       void *snapshot2;
626       int result;
627     } mc_compare_snapshots;
628
629     /* ****************************************************************************************** */
630     /* TUTORIAL: New API                                                                        */
631     /* ****************************************************************************************** */
632     struct {
633       const char* param1;
634       double param2;
635       int result;
636     } new_api;
637
638   };
639 } s_smx_simcall_t, *smx_simcall_t;
640
641 /******************************** General *************************************/
642
643 void SIMIX_simcall_push(smx_process_t self);
644 void SIMIX_simcall_answer(smx_simcall_t);
645 void SIMIX_simcall_pre(smx_simcall_t, int);
646 void SIMIX_simcall_post(smx_action_t);
647 smx_simcall_t SIMIX_simcall_mine(void);
648 const char *SIMIX_simcall_name(e_smx_simcall_t kind);
649
650 /*************************** New simcall interface ****************************/
651
652 /* Pack all possible scalar types in an union */
653 typedef union u_smx_scalar {
654   char            c;
655   short           s;
656   int             i;
657   long            l;
658   unsigned char   uc;
659   unsigned short  us;
660   unsigned int    ui;
661   unsigned long   ul;
662   float           f;
663   double          d;
664   void            *p;
665 } u_smx_scalar_t;
666
667 /*
668  * Define scalar type wrappers to ease the use of simcalls.
669  * These are used to wrap the arguments in SIMIX_simcall macro.
670  */
671 #define CHAR(x) (c,x)
672 #define SHORT(x) (s,x)
673 #define INT(x) (i,x)
674 #define LONG(x) (l,x)
675 #define UCHAR(x) (uc,x)
676 #define USHORT(x) (us,x)
677 #define UINT(x) (ui,x)
678 #define ULONG(x) (ul,x)
679 #define FLOAT(x) (f,x)
680 #define DOUBLE(x) (d,x)
681 #define PTR(x)  (p,x)
682
683 #define MYMACRO(...)
684
685 /*
686  * Some macro machinery to get a MAP over the arguments of a variadic macro.
687  * It uses a FOLD to apply a macro to every argument, and because there is
688  * no recursion in the C preprocessor we must create a new macro for every
689  * depth of FOLD's recursion.
690  */
691
692 /* FOLD macro */
693 #define FE_1(WHAT, X) WHAT(X)
694 #define FE_2(WHAT, X, ...) WHAT(X), FE_1(WHAT, __VA_ARGS__)
695 #define FE_3(WHAT, X, ...) WHAT(X), FE_2(WHAT, __VA_ARGS__)
696 #define FE_4(WHAT, X, ...) WHAT(X), FE_3(WHAT, __VA_ARGS__)
697 #define FE_5(WHAT, X, ...) WHAT(X), FE_4(WHAT, __VA_ARGS__)
698 /* NOTE: add as many FE_n as needed (maximum number of simcall arguments )*/
699
700 /* Make a MAP macro usgin FOLD (will apply 'action' to the arguments.
701  * GET_MACRO is a smart hack that counts the number of arguments passed to
702  * the variadic macro, and it is used to invoke the right FOLD depth.
703  */
704 #define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
705 #define MAP(action,...) \
706   GET_MACRO(__VA_ARGS__,FE_5,FE_4,FE_3,FE_2,FE_1) (action, __VA_ARGS__)
707
708
709 /* Generate code to initialize the field 'x' with value 'y' of an structure or union */
710 #define INIT_FIELD_(x,y) {.x = y}
711 #define INIT_FIELD(t) INIT_FIELD_ t
712
713 /* Project the second element of a tuple */
714 #define SECOND_(x, y) y
715 #define SECOND(t) SECOND_ t
716
717 /*
718  * \brief Simcall invocation macro
719  * It calls a dummy function that uses the format attribute to ensure typesafety (see
720  * gcc format attribute), then it invokes the real simcall function packing the
721  * user provided arguments in an array.
722  * \param id a simcall id (from the simcall enumeration ids)
723  *
724  */
725 #define SIMIX_simcall(id, ...) \
726   SIMIX_simcall_typecheck(simcall_types[id], MAP(SECOND, __VA_ARGS__)); \
727   __SIMIX_simcall(id, (u_smx_scalar_t[]){MAP(INIT_FIELD, __VA_ARGS__)})
728
729 void __SIMIX_simcall(e_smx_simcall_t simcall_id, u_smx_scalar_t *args);
730
731 /*
732  * \biref Dummy variadic function used to typecheck the arguments of a simcall
733  * \param fmt A format string following printf style
734  */
735 void SIMIX_simcall_typecheck(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
736
737 typedef smx_action_t (*simcall_handler_t)(u_smx_scalar_t *);
738
739 extern const char *simcall_types[];
740 extern simcall_handler_t simcall_table[];
741
742 #endif
743