Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ee9131a899b6762d4a846588b6c286c3ca9d0a04
[simgrid.git] / src / simix / smx_smurf_private.h
1 /* Copyright (c) 2007-2010, 2012-2014. 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 SG_BEGIN_DECL()
11
12 /********************************* Simcalls *********************************/
13
14 /* we want to build the e_smx_simcall_t enumeration, the table of the
15  * corresponding simcalls string names, and the simcall handlers table
16  * automatically, using macros.
17  * To add a new simcall follow the following syntax:
18  *
19  * */
20
21 /**
22  * \brief All possible simcalls.
23  */
24 typedef enum {
25 SIMCALL_NONE,
26 #include "simcalls_generated_enum.h"
27 SIMCALL_NEW_API_INIT,
28 NUM_SIMCALLS
29 } e_smx_simcall_t;
30
31 typedef int (*simix_match_func_t)(void *, void *, smx_action_t);
32 typedef void (*simix_copy_data_func_t)(smx_action_t, void*, size_t);
33 typedef void (*simix_clean_func_t)(void *);
34 typedef void (*FPtr)(void); // Hide the ugliness
35
36 /* Pack all possible scalar types in an union */
37 union u_smx_scalar {
38   char            c;
39   const char*     cc;
40   short           s;
41   int             i;
42   long            l;
43   unsigned char   uc;
44   unsigned short  us;
45   unsigned int    ui;
46   unsigned long   ul;
47   float           f;
48   double          d;
49   size_t          sz;
50   sg_size_t       sgsz;
51   void*           dp;
52   FPtr            fp;
53   const void*     cp;
54 };
55
56 /**
57  * \brief Represents a simcall to the kernel.
58  */
59 typedef struct s_smx_simcall {
60   e_smx_simcall_t call;
61   smx_process_t issuer;
62 #ifdef HAVE_MC
63   int mc_value;
64 #endif
65   union u_smx_scalar args[10];
66   union u_smx_scalar result;
67   //FIXME: union u_smx_scalar retval;
68   union {
69     struct {
70       const char* param1;
71       double param2;
72       int result;
73     } new_api;
74
75   };
76 } s_smx_simcall_t, *smx_simcall_t;
77
78 #if HAVE_MC
79 #define SIMCALL_SET_MC_VALUE(simcall, value) ((simcall)->mc_value = (value))
80 #define SIMCALL_GET_MC_VALUE(simcall) ((simcall)->mc_value)
81 #else
82 #define SIMCALL_SET_MC_VALUE(simcall, value) ((void)0)
83 #define SIMCALL_GET_MC_VALUE(simcall) 0
84 #endif
85
86 #include "simcalls_generated_res_getter_setter.h"
87 #include "simcalls_generated_args_getter_setter.h"
88
89 /******************************** General *************************************/
90
91 void SIMIX_simcall_push(smx_process_t self);
92 void SIMIX_simcall_answer(smx_simcall_t);
93 void SIMIX_simcall_pre(smx_simcall_t, int);
94 void SIMIX_simcall_post(smx_action_t);
95 smx_simcall_t SIMIX_simcall_mine(void);
96 const char *SIMIX_simcall_name(e_smx_simcall_t kind);
97 //TOFIX put it in a better place
98 xbt_dict_t SIMIX_pre_asr_get_properties(smx_simcall_t simcall, const char *name);
99
100 /*************************** New simcall interface ****************************/
101
102 typedef smx_action_t (*simcall_handler_t)(u_smx_scalar_t *);
103
104 extern const char *simcall_types[];
105 extern simcall_handler_t simcall_table[];
106
107 SG_END_DECL()
108
109 #endif