Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b33c06c55788ffe8b615a8bfffb0ecaf85bff6b9
[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   sg_offset_t     sgoff;
52   void*           dp;
53   FPtr            fp;
54   const void*     cp;
55 };
56
57 /**
58  * \brief Represents a simcall to the kernel.
59  */
60 typedef struct s_smx_simcall {
61   e_smx_simcall_t call;
62   smx_process_t issuer;
63 #ifdef HAVE_MC
64   int mc_value;
65 #endif
66   union u_smx_scalar args[10];
67   union u_smx_scalar result;
68   //FIXME: union u_smx_scalar retval;
69   union {
70     struct {
71       const char* param1;
72       double param2;
73       int result;
74     } new_api;
75
76   };
77 } s_smx_simcall_t, *smx_simcall_t;
78
79 #if HAVE_MC
80 #define SIMCALL_SET_MC_VALUE(simcall, value) ((simcall)->mc_value = (value))
81 #define SIMCALL_GET_MC_VALUE(simcall) ((simcall)->mc_value)
82 #else
83 #define SIMCALL_SET_MC_VALUE(simcall, value) ((void)0)
84 #define SIMCALL_GET_MC_VALUE(simcall) 0
85 #endif
86
87 #include "simcalls_generated_res_getter_setter.h"
88 #include "simcalls_generated_args_getter_setter.h"
89
90 /******************************** General *************************************/
91
92 void SIMIX_simcall_push(smx_process_t self);
93 void SIMIX_simcall_answer(smx_simcall_t);
94 void SIMIX_simcall_pre(smx_simcall_t, int);
95 void SIMIX_simcall_post(smx_action_t);
96 smx_simcall_t SIMIX_simcall_mine(void);
97 const char *SIMIX_simcall_name(e_smx_simcall_t kind);
98 //TOFIX put it in a better place
99 xbt_dict_t SIMIX_pre_asr_get_properties(smx_simcall_t simcall, const char *name);
100
101 /*************************** New simcall interface ****************************/
102
103 typedef smx_action_t (*simcall_handler_t)(u_smx_scalar_t *);
104
105 extern const char *simcall_types[];
106 extern simcall_handler_t simcall_table[];
107
108 SG_END_DECL()
109
110 #endif