Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill dead code
[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 #include "simcalls_generated_enum.h" /* All possible simcalls (generated) */
22
23 typedef int (*simix_match_func_t)(void *, void *, smx_action_t);
24 typedef void (*simix_copy_data_func_t)(smx_action_t, void*, size_t);
25 typedef void (*simix_clean_func_t)(void *);
26 typedef void (*FPtr)(void); // Hide the ugliness
27
28 /* Pack all possible scalar types in an union */
29 union u_smx_scalar {
30   char            c;
31   const char*     cc;
32   short           s;
33   int             i;
34   long            l;
35   unsigned char   uc;
36   unsigned short  us;
37   unsigned int    ui;
38   unsigned long   ul;
39   float           f;
40   double          d;
41   size_t          sz;
42   sg_size_t       sgsz;
43   sg_offset_t     sgoff;
44   void*           dp;
45   FPtr            fp;
46   const void*     cp;
47 };
48
49 /**
50  * \brief Represents a simcall to the kernel.
51  */
52 typedef struct s_smx_simcall {
53   e_smx_simcall_t call;
54   smx_process_t issuer;
55 #ifdef HAVE_MC
56   int mc_value;
57 #endif
58   union u_smx_scalar args[11];
59   union u_smx_scalar result;
60   //FIXME: union u_smx_scalar retval;
61   union {
62     struct {
63       const char* param1;
64       double param2;
65       int result;
66     } new_api;
67
68   };
69 } s_smx_simcall_t, *smx_simcall_t;
70
71 #if HAVE_MC
72 #define SIMCALL_SET_MC_VALUE(simcall, value) ((simcall)->mc_value = (value))
73 #define SIMCALL_GET_MC_VALUE(simcall) ((simcall)->mc_value)
74 #else
75 #define SIMCALL_SET_MC_VALUE(simcall, value) ((void)0)
76 #define SIMCALL_GET_MC_VALUE(simcall) 0
77 #endif
78
79 #include "simcalls_generated_res_getter_setter.h"
80 #include "simcalls_generated_args_getter_setter.h"
81
82 /******************************** General *************************************/
83
84 void SIMIX_simcall_push(smx_process_t self);
85 void SIMIX_simcall_answer(smx_simcall_t);
86 void SIMIX_simcall_enter(smx_simcall_t, int);
87 void SIMIX_simcall_exit(smx_action_t);
88 smx_simcall_t SIMIX_simcall_mine(void);
89 const char *SIMIX_simcall_name(e_smx_simcall_t kind);
90 //TOFIX put it in a better place
91 xbt_dict_t SIMIX_pre_asr_get_properties(smx_simcall_t simcall, const char *name);
92
93 /*************************** New simcall interface ****************************/
94
95 typedef smx_action_t (*simcall_handler_t)(u_smx_scalar_t *);
96
97 extern const char *simcall_types[];
98 extern simcall_handler_t simcall_table[];
99
100 SG_END_DECL()
101
102 #endif