Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
This test do not seem to fail
[simgrid.git] / README.coding
1 **
2 ** Source tree organization
3 **
4 ******************************************************
5
6 There is at least 5 sub-projects in the tree:
7
8  - XBT: eXtended Bundle of Tools (low-level toolbox: logging, datatypes).
9  - SURF: a SimUlation aRtiFact. This is the simulation kernel.
10  - MSG:  originally MetaSimGrid, MSG is a simple distributed application
11          simulator.
12  - GRAS: Grid Reality And Simulation (message passing API with two
13          implementations allowing to compile programs on top of the
14          simulator or for the real life without code modification)
15  - AMOK: Advanced Metacomputing Overlay Kit (high level toolbox; Grid
16          application elements such as distributed database, topology
17          discovery service, and so on)
18
19 They are all in the same tree because they are complementary tools and
20 having all of them in the same package makes the installation easier
21 for end-users. Moreover, it enables to share the compilation chain and
22 eases the development.
23
24 The tree is not splited on projects, but on file finality:
25  include/            -> all *public* headers
26  include/xbt/*.h     -> one file per module
27  include/gras.h      -> file including all modules headers
28   (same for xbt instead of gras)
29   
30  src/Makefile.am     -> main makefile. All projects should fit in only one
31                         library (I mean 2, RL+SG), which is compiled here.
32                         
33                         Since all object.o files are placed here, you should
34                         choose the name of c files carfully to avoid
35                         conflict. 
36                         
37  src/gras/DataDesc                      -> typical project module
38  src/gras/DataDesc/datadesc_interface.h -> visible to any GRAS modules;
39                                            masked to the user and GROS/AMOK/SURF
40  src/gras/DataDesc/datadesc_private.h   -> visible only from this module                                           
41   
42    So, the modules have 3 levels of publicity for their interface. 
43    Private, internal to GRAS, public. Of course, I try to keep as much stuff
44    private as possible.
45
46  src/include -> another location for protected headers. Used by SURF, and
47                 other should be converted, since this is the Right Thing.
48
49  testsuite/ -> The more test the better. 
50                Same organization than src/ and include/
51                Tests are allowed to load some headers of the module they test.
52                All tests should be listed in run_test.in so that they get
53                   run on 'make check'. 
54                They are not listed directly in the check_PROGRAMS part of
55                   the makefile because run_test knows about the gras logging
56                   features and relaunch with full details the failed tests.
57                   
58  examples/ -> Supposed to be copy/pastable by the user, so keep it clear and
59                 avoid any kind of trick. In particular, do only include the
60                 public headers here.
61 **
62 ** Indentation standard
63 **
64 *****************************************************
65
66 Most files use the Kernighan & Ritchie coding style with 2 spaces of
67 indentation. The indent program can help you to stick to it:
68
69 indent -br -brs -ce -bbo -bad -bap --dont-break-procedure-type
70   --no-tabs --cuddle-do-while --cuddle-else --indent-level2
71   --leave-preprocessor-space --no-space-after-function-call-names
72   <myfile>
73
74 FIXME: this list of arguments is still to be discussed, maybe
75
76 **
77 ** Type naming standard
78 **
79 *****************************************************
80
81 It may sound strange, but the type naming convention was source of intense
82 discution between da GRAS posse members. The convention we came to may not
83 be the best solution, but it has the merit to exist and leave everyone work.
84 So please stick to it.
85
86   - ???_t is a valid type (builded with typedef)
87   - s_toto_t is a structure (access to fields with .)
88   - s_toto   is a structure needing 'struct' keyword to be used
89   - e_toto_t is an enum
90   - u_toto_t is an union
91   - u_toto   is an union needing 'union' keyword to be used
92   -   toto_t is an 'object' (struct*)
93   
94 Please to not call toto_t something else than an 'object' (ie, something you
95 have to call _new and _free on it).
96
97 Exemple:
98   typedef struct s_toto {} s_toto_t, *toto_t;
99   typedef enum {} e_toto_t;
100   
101 Moreover, only toto_t (and e_toto_t) are public. The rest (mainly s_toto_t)
102 is private.
103
104 If you see any part of the code not following this convention, this is a
105 bug. Please report it (or fix it yourself if you can).
106
107 **
108 ** Random bits about coding standards and portability
109 **
110 *****************************************************
111
112 MALLOC:
113  Don't use it, or you'll have to check the result (and do some dirty stuff
114  on AIX). Use xbt_malloc (or even better, xbt_new) instead.
115
116 SIZE_T
117  If possible, avoid size_t and use unsigned long instead. If not,
118  #include <sys/types.h> in all files manipulating size_t
119  do cast it to unsigned long before printing (and use %lu)
120  
121 PRINTF pointer difference
122  printf ("diff = %ld\n", (long) (pointer2 - pointer1));
123   
124
125 **              
126 ** Commenting the source: doxygen
127 **
128 ****************************************************
129
130 The global structure of the documentation is in doc/modules.doc 
131
132 The structure of each module (xbt, gras, etc) is in doc/module-<module>.doc
133
134 The structure of a module is in its public header. This way, you're sure to
135 see all the public interface (and only it). The different parts of the
136 interface are grouped using the @name construct, even if it's buggy. Since
137 parts often get reordered, it's better to add numbers to the parts (so that
138 users can see the intended order).
139
140 The documentation of each type and macro are also in the public header since
141 this is were they live.
142
143 The documentation of each function must be in the C file were it lives. 
144
145 Any public element (function, type and macro) must have a @brief part.
146
147 **
148 ** XBT virtualization mecanism
149 **
150 ****************************************************
151
152 There is some functionnalities that we want to virtualize in XBT. We
153 want xbt_time to give the simulated clock when running on top of the
154 simulator, and the host clock when running on a real system. This
155 could be placed in GRAS (and was, historically), but there is some
156 reason to lower it down to XBT. 
157
158 Here is the used naming scheme:
159
160   - xbt_<module>_<func>(): functions working both in SG and RL  
161   - xbt_os_<module>_<func>(): RL functions usable even in simulator
162     
163     That way, in libsimgrid, we still can use native functions if we
164     want to. It may for example be useful to get the real time when
165     implementing the simulator. Think of the SIGINT handler, which
166     wants to see if the user pressed the key twice in a 5 seconds
167     interval. This is of little use to check the simulated time here.
168
169 Here is the file layout:
170
171   - xbt_rl_<module>.c: native implementation (xbt_<module>_<func>()).
172     Simply call the corresponding xbt_os_<module>_<func>.     
173     Part only of libgras.so
174     
175   - xbt_sg_<module>.c: SIMIX implementation xbt_<module>_<func>()).
176     Simply call the corresponding SIMIX implementation. 
177     Part only of libsimgrid.so
178     
179   - xbt_os_<module>.c: body of the functions implementing natively the
180     stuff (xbt_os_<module>_<func>()).
181     Part of both libgras.so and libsimgrid.so
182     
183 Since there is almost nothing in xbt_rl_module.c and xbt_sg_module.c,
184 it'd be better to use symbol aliasing here (to declare in the object
185 code that the same function have two names), but I'm still
186 investigating the portability of the thing to windows.