Logo AND Algorithmique Numérique Distribuée

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