build_rtds_glue.c 16.6 KB
Newer Older
Maxime Perrotin's avatar
Maxime Perrotin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Buildsupport is (c) 2008-2015 European Space Agency
 * contact: maxime.perrotin@esa.int
 * License is LGPL, check LICENSE file */
/* 
 * build_rtds_glue.c
 * this program generates the glue to link Pragmadev'RTDS projects with ASSERT
 *
 * first version: 23/06/2009
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <assert.h>

#include "my_types.h"
#include "practical_functions.h"

static FILE *glue_c = NULL, *glue_h = NULL, *glue_macros = NULL, *sync_ri =
    NULL;

#define SIMPLETYPE(p) (integer==p->basic_type || boolean==p->basic_type || enumerated==p->basic_type || real==p->basic_type || string == p->basic_type)

/* Adds header to user_code.h and (if new) user_code.c */
void rtds_glue_preamble(FV * fv)
{
    int hasparam = 0;

    /* Check if any interface needs ASN.1 types */
    FOREACH(i, Interface, fv->interfaces, {
32
            if (NULL != i->in || NULL != i->out) hasparam = 1;}
Maxime Perrotin's avatar
Maxime Perrotin committed
33
34
35
36
    );

    /* a. glue_.h preamble */
    fprintf(glue_h,
37
            "/* This file was generated automatically: DO NOT MODIFY IT ! */\n\n");
Maxime Perrotin's avatar
Maxime Perrotin committed
38
    fprintf(glue_h,
39
            "/* Declaration of the provided and required interfaces */\n\n");
Maxime Perrotin's avatar
Maxime Perrotin committed
40
    fprintf(glue_h, "#ifndef __GLUE_H_%s__\n#define __GLUE_H_%s__\n\n",
41
            fv->name, fv->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
42
    if (hasparam) {
43
44
        fprintf(glue_h, "#include \"C_ASN1_Types.h\"\n\n");
        fprintf(glue_h, "#include \"RTDS_ASN1_Types.h\"\n\n");
Maxime Perrotin's avatar
Maxime Perrotin committed
45
46
47
48
49
50
    }

    /* fprintf(glue_h, "#include \"RTDS_OS.h\"\n"); */
    fprintf(glue_h, "#include \"RTDS_gen.h\"\n");
    fprintf(glue_h, "#include \"RTDS_Proc.h\"\n");
    fprintf(glue_h, "#include \"RTDS_%s_project_messages.h\"\n",
51
            fv->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
52
53
    fprintf(glue_h, "#include \"%s_p_decl.h\"\n\n", fv->name);

54
55
56
    fprintf(glue_h, "static RTDS_Proc %s_instanceDescriptor;\n", fv->name);     /* Declare the SDL instance descriptor */
    fprintf(glue_h, "static RTDS_GlobalProcessInfo %s_instanceContext;\n", fv->name);   /* Declare the SDL instance context */
    fprintf(glue_h, "static RTDS_MessageHeader currentMessage;\n\n");   /* Declare the RTDS message header */
Maxime Perrotin's avatar
Maxime Perrotin committed
57
58
59
60

    /* b. glue_.c preamble */

    fprintf(glue_c,
61
            "/* This file was generated automatically: DO NOT MODIFY IT ! */\n\n");
Maxime Perrotin's avatar
Maxime Perrotin committed
62
63
64
    fprintf(glue_c, "#include \"glue_%s.h\"\n\n", fv->name);

    fprintf(glue_c,
65
66
            "RTDS_Proc* %s_instanceDescriptor_ptr = NULL;\n",
            fv->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
67
68

    fprintf(glue_c,
69
70
            "char* %s_instanceDescriptor_locals_ptr = NULL;\n",
            fv->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
71
72
73
74

    fprintf(glue_c, "void %s_startup()\n{\n", fv->name);
    fprintf(glue_h, "void %s_startup();\n\n", fv->name);
    fprintf(glue_c,
75
76
            "\tRTDS_Proc_%s_p_createInstance(&%s_instanceDescriptor, NULL, &%s_instanceContext, NULL);\n",
            fv->name, fv->name, fv->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
77
78

    fprintf(glue_c,
79
80
            "\t%s_instanceDescriptor_ptr = &%s_instanceDescriptor;\n",
            fv->name, fv->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
81
82

    fprintf(glue_c,
83
84
            "\t%s_instanceDescriptor_locals_ptr = %s_instanceDescriptor.myLocals.%s_p.RTDS_myLocals;\n",
            fv->name, fv->name, fv->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
85
86

    fprintf(glue_c,
87
88
            "\tRTDS_%s_p_executeTransition(&%s_instanceDescriptor, NULL);\n}\n\n",
            fv->name, fv->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
89
90
91

    /* c. glue macros preamble */
    fprintf(glue_macros,
92
            "/* This file was generated automatically: DO NOT MODIFY IT ! */\n");
Maxime Perrotin's avatar
Maxime Perrotin committed
93
    fprintf(glue_macros,
94
            "/* Definition of the RI macros called by RTDS generated code */\n\n");
Maxime Perrotin's avatar
Maxime Perrotin committed
95
96
97
98
    fprintf(glue_macros, "#include \"glue_%s.h\"\n\n", fv->name);

    /* d. sync_RI preamble */
    fprintf(sync_ri,
99
            "/* This file was generated automatically: DO NOT MODIFY IT ! */\n\n");
Maxime Perrotin's avatar
Maxime Perrotin committed
100
    fprintf(sync_ri,
101
            "/* Definition of the synchronous required interfaces */\n\n");
Maxime Perrotin's avatar
Maxime Perrotin committed
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
    fprintf(sync_ri, "#include \"common.h\"\n\n");

}

/* Creates glue_<function>.h/c, common.h, and <function>_syncRI.c  */
int Init_RTDS_GLUE_Backend(FV * fv)
{
    char *path = NULL;
    char *filename = NULL;
    path = make_string("%s/%s", OUTPUT_PATH, fv->name);

    filename = make_string("glue_%s.c", fv->name);
    create_file(path, filename, &glue_c);

    /* change from .c to .h */
    filename[strlen(filename) - 1] = 'h';
    create_file(path, filename, &glue_h);
    free(filename);

    /*  Create the file used to store the definition of macros
     *  "called" by RTDS to send message to the environment of
     *  the SDL subsystem. It is called "common.h", and is
     *  #included by RTDS-generated code 
     */
    filename = make_string("common.h");
    create_file(path, filename, &glue_macros);
    free(filename);

    /* Create the file used to store the functions called by
     * RTDS to call synchronous RI (e.g. call to SCADE, Simulink).
     */
    filename = make_string("%s_syncRI.c", fv->name);
    create_file(path, filename, &sync_ri);

    free(path);
    free(filename);

    assert(NULL != glue_h && NULL != glue_c && NULL != glue_macros
140
           && NULL != sync_ri);
Maxime Perrotin's avatar
Maxime Perrotin committed
141
142
143
144
145
146
147
148
149
150
151
152
153
154

    rtds_glue_preamble(fv);

    return 0;
}

/* 
 * ForEachWithParam function : Call the function to convert a variable declared with an  ASN.1 type 
 * to a variable declared with an RTDS equivalent type
 * (the function making the conversion is provided by the B mapper from Semantix)
*/
void Convert_ASN1_to_RTDS(Parameter * p, FILE ** file)
{
    fprintf(*file,
155
156
157
158
            "\tConvert_%s_from_ASN1SCC_to_RTDS (&rtds_%s_%s, asn1_%s_%s);\n",
            p->type, (param_in == p->param_direction) ? "IN" : "OUT",
            p->name, (param_in == p->param_direction) ? "IN" : "OUT",
            p->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
159
160
161
162
163
164
165
166
167
168
169
}

/* 
 * ForEachWithParam function : Call the function to convert a variable declared with a ASN.1 type 
 * to a variable declared with an ASN.1 equivalent type
 * (the function making the conversion is provided by the B mapper from Semantix)
 * Macro version. Line finished with '\' and Asn.1 name passed by pointer
*/
void Convert_ASN1_to_RTDS_Macro(Parameter * p, FILE ** file)
{
    fprintf(*file,
170
171
172
173
            "\tConvert_%s_from_ASN1SCC_to_RTDS (rtds_%s_%s_%s, &asn1_%s_%s);\\\n",
            p->type, (param_in == p->param_direction) ? "IN" : "OUT",
            p->interface->name, p->name,
            (param_in == p->param_direction) ? "IN" : "OUT", p->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
174
175
176
177
178
179
180
181
182
183
}

/* 
 * ForEachWithParam function : Call the function to convert a variable declared with a RTDS type 
 * to a variable declared with an ASN.1 equivalent type
 * (the function making the conversion is provided by the B mapper from Semantix)
*/
void Convert_RTDS_to_ASN1(Parameter * p, FILE ** file, char *eol_separator)
{
    fprintf(*file,
184
185
186
187
188
189
190
            "\tConvert_%s_from_RTDS_to_ASN1SCC (&asn1_%s_%s_%s, %srtds_%s_%s);",
            p->type, (param_in == p->param_direction) ? "IN" : "OUT",
            p->interface->name, p->name, (SIMPLETYPE(p)
                                          || synch ==
                                          p->interface->
                                          synchronism) ? "" : "&",
            (param_in == p->param_direction) ? "IN" : "OUT", p->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
191
192
193
194
195
196
197
198
199
200
201
202
203
    fprintf(*file, "%s", eol_separator);
}

/*
 * ForEachWithParam function : Write to file the list of parameters, 
 * separated with commas (form "rtds_IN_PARAM1, ..., rtds_OUT_PARAMn")
*/
void List_RTDS_Params(Parameter * p, FILE ** file)
{
    unsigned int comma = 0;

    /* Determine if a comma is needed prior to the item to be put in the list.  */
    comma =
204
205
206
207
        ((p->param_direction == param_in && p != p->interface->in->value)
         || (p->param_direction == param_out
             && (NULL != p->interface->in
                 || p != p->interface->out->value)));
Maxime Perrotin's avatar
Maxime Perrotin committed
208
209

    fprintf(*file, "%srtds_%s_%s",
210
211
            comma ? ", " : "",
            (param_in == p->param_direction) ? "IN" : "OUT", p->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
212
213
214
215
216
217
218
219
220
}

/*
 * List RTDS types and params (RTDStype [*]IN_param1, ..., *OUT_param_i) 
 * Add pointer to IN params for complex types only (struct...)
*/
void List_RTDS_Types_And_Params(Parameter * p, FILE ** file)
{
    if ((param_in == p->param_direction && p != p->interface->in->value) ||
221
222
223
        (param_out == p->param_direction
         && (NULL != p->interface->in || p != p->interface->out->value))) {
        fprintf(*file, ", ");
Maxime Perrotin's avatar
Maxime Perrotin committed
224
225
    }
    fprintf(*file, "%s %srtds_%s_%s",
226
227
228
            p->type,
            (param_out == p->param_direction || !SIMPLETYPE(p)) ? "*" : "",
            (param_in == p->param_direction) ? "IN" : "OUT", p->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
229
230
231
232
233
234
235
236
237
238
239
240
}

/* 
 * ForEachWithParam function : Write to file the list of ASN.1 parameters, 
 * separated with commas (form "asn1_IN_PARAM1, ..., rtds_OUT_PARAMn")
*/
void List_ASN1_Params_With_Pointers(Parameter * p, FILE ** file)
{
    unsigned int comma = 0;

    /* Determine if a comma is needed prior to the item to be put in the list.  */
    comma =
241
242
243
244
        ((p->param_direction == param_in && p != p->interface->in->value)
         || (p->param_direction == param_out
             && (NULL != p->interface->in
                 || p != p->interface->out->value)));
Maxime Perrotin's avatar
Maxime Perrotin committed
245
246

    fprintf(*file, "%s&asn1_%s_%s_%s",
247
248
249
            comma ? ", " : "",
            (param_in == p->param_direction) ? "IN" : "OUT",
            p->interface->name, p->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
250
251
252
253
254
255
}

/* ForEachWithParam function : Make a declaration of static variable for a given parameter */
void Declare_static_ASN1_param(Parameter * p, FILE ** file)
{
    fprintf(*file, "static asn1Scc%s asn1_%s_%s_%s;\n",
256
257
258
            p->type,
            (param_in == p->param_direction) ? "IN" : "OUT",
            p->interface->name, p->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
}

/* 
 * Add a Provided interface. Can contain IN parameters and no OUT parameter (asynchronous SDL system)
 * Write in glue_<function>.h and in glue_<function>.c  the declaration of the functions
*/
void add_PI_to_RTDS_glue(Interface * i)
{
    Parameter_list *tmp;

    fprintf(glue_h, "void %s_PI_%s(", i->parent_fv->name, i->name);
    fprintf(glue_c, "void %s_PI_%s(", i->parent_fv->name, i->name);

    tmp = i->in;

    while (NULL != tmp) {
275
276
        fprintf(glue_h, "%sconst asn1Scc%s *",
                (tmp != i->in) ? ", " : "", tmp->value->type);
Maxime Perrotin's avatar
Maxime Perrotin committed
277

278
279
280
281
        fprintf(glue_c, "%sconst asn1Scc%s *asn1_IN_%s",
                (tmp != i->in) ? ", " : "",
                tmp->value->type, tmp->value->name);
        tmp = tmp->next;
Maxime Perrotin's avatar
Maxime Perrotin committed
282
283
284
285
286
287
    }

    fprintf(glue_h, ");\n\n");
    fprintf(glue_c, ")\n{\n");

    fprintf(glue_c,
288
            "\t/* 1) For each parameter, declare a RTDS variable */\n");
Maxime Perrotin's avatar
Maxime Perrotin committed
289
    FOREACH(p, Parameter, i->in, {
290
291
292
293
            fprintf(glue_c, "\t%s rtds_%s_%s;\n",
                    p->type,
                    (param_in == p->param_direction) ? "IN" : "OUT",
                    p->name);}
Maxime Perrotin's avatar
Maxime Perrotin committed
294
295
    )

296
        fprintf(glue_c, "\t/* 2) RTDS Macro to declare a message */\n");
Maxime Perrotin's avatar
Maxime Perrotin committed
297
298
299
    fprintf(glue_c, "\n\tRTDS_MSG_DATA_DECL\n");

    fprintf(glue_c,
300
            "\n\t/* 3) Convert each input parameter from ASN.1 to RTDS */\n");
Maxime Perrotin's avatar
Maxime Perrotin committed
301
302
    /*ForEachWithParam (i->in, Convert_ASN1_to_RTDS, &glue_c); */
    FOREACH(p, Parameter, i->in, {
303
304
            Convert_ASN1_to_RTDS(p, &glue_c);
            }
Maxime Perrotin's avatar
Maxime Perrotin committed
305
306
307
308
    );

    fprintf(glue_c, "\n\t/* 4) Set the message header */\n");
    fprintf(glue_c, "\tRTDS_%s_SET_MESSAGE(&currentMessage%s", i->name,
309
            (NULL != i->in) ? ", " : "");
Maxime Perrotin's avatar
Maxime Perrotin committed
310
311
    /*ForEachWithParam (i->in, List_RTDS_Params, &glue_c); */
    FOREACH(p, Parameter, i->in, {
312
313
            List_RTDS_Params(p, &glue_c);
            }
Maxime Perrotin's avatar
Maxime Perrotin committed
314
315
316
317
318
    );
    fprintf(glue_c, ");\n");

    fprintf(glue_c, "\n\t/* 5) Execute the SDL transition */\n");
    fprintf(glue_c,
319
320
            "\tRTDS_%s_p_executeTransition (&%s_instanceDescriptor, &currentMessage);\n",
            i->parent_fv->name, i->parent_fv->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337

    fprintf(glue_c, "}\n\n");
}

/* 
 * Declaration of the RI in glue_<function>.h 
 * (can contain several IN/OUT params -in case of local procedure call)
*/
void add_RI_to_RTDS_glue(Interface * i)
{
    Parameter_list *tmp;

    fprintf(glue_h, "extern void %s_RI_%s(", i->parent_fv->name, i->name);

    tmp = i->in;

    while (NULL != tmp) {
338
339
340
        fprintf(glue_h, "%sconst asn1Scc%s *",
                (tmp != i->in) ? ", " : "", tmp->value->type);
        tmp = tmp->next;
Maxime Perrotin's avatar
Maxime Perrotin committed
341
342
343
344
345
    }

    tmp = i->out;

    while (NULL != tmp) {
346
347
348
349
350
        fprintf(glue_h, "%sasn1Scc%s *",
                (tmp != i->out
                 || (tmp == i->out
                     && NULL != i->in)) ? ", " : "", tmp->value->type);
        tmp = tmp->next;
Maxime Perrotin's avatar
Maxime Perrotin committed
351
352
353
354
355
356
357
358
359
    }

    fprintf(glue_h, ");\n\n");
}

/* Add a synchronous RI function (syncRI_<InterfaceName> (in, out)) */
void add_sync_RI(Interface * i)
{
    fprintf(sync_ri, "\n/* SYNCHRONOUS REQUIRED INTERFACE %s */\n",
360
            i->name);
Maxime Perrotin's avatar
Maxime Perrotin committed
361
362
363
364
365
366
367

    /* 
     * function prototype : syncRI_<InterfaceName> (rtdstype [*]rtds_IN_param1,.., rtdstype *rtds_OUT_param1,...) 
     * for input parameters: there is a pointer for "complex" types only
     */
    fprintf(sync_ri, "void syncRI_%s (", i->name);
    FOREACH(p, Parameter, i->in, {
368
369
            List_RTDS_Types_And_Params(p, &sync_ri);
            });
Maxime Perrotin's avatar
Maxime Perrotin committed
370
    FOREACH(p, Parameter, i->out, {
371
372
            List_RTDS_Types_And_Params(p, &sync_ri);
            });
Maxime Perrotin's avatar
Maxime Perrotin committed
373
374
375
376
    fprintf(sync_ri, ")\n{\n");

    /* declare static data to put the Asn.1 encoded data */
    FOREACH(p, Parameter, i->in, {
377
378
            Declare_static_ASN1_param(p, &sync_ri);
            });
Maxime Perrotin's avatar
Maxime Perrotin committed
379
    FOREACH(p, Parameter, i->out, {
380
381
            Declare_static_ASN1_param(p, &sync_ri);
            });
Maxime Perrotin's avatar
Maxime Perrotin committed
382
383
384

    /* convert rtds input to asn.1 static data */
    FOREACH(p, Parameter, i->in, {
385
386
            Convert_RTDS_to_ASN1(p, &sync_ri, "\n");
            });
Maxime Perrotin's avatar
Maxime Perrotin committed
387
388
389
390
391
392

    fprintf(sync_ri, "\n");

    /* call RI function generated in invoke_ri.c by the C backend */
    fprintf(sync_ri, "\t%s_RI_%s(", i->parent_fv->name, i->name);
    FOREACH(p, Parameter, i->in, {
393
394
            List_ASN1_Params_With_Pointers(p, &sync_ri);
            });
Maxime Perrotin's avatar
Maxime Perrotin committed
395
    FOREACH(p, Parameter, i->out, {
396
397
            List_ASN1_Params_With_Pointers(p, &sync_ri);
            });
Maxime Perrotin's avatar
Maxime Perrotin committed
398
399
400
401
    fprintf(sync_ri, ");\n");

    /* convert result from asn1 to rtds and end function */
    FOREACH(p, Parameter, i->out, {
402
403
404
            fprintf(sync_ri,
                    "\tConvert_%s_from_ASN1SCC_to_RTDS (rtds_OUT_%s, &asn1_OUT_%s_%s);\n",
                    p->type, p->name, p->interface->name, p->name);});
Maxime Perrotin's avatar
Maxime Perrotin committed
405
406
407
408
409
410
411
412
413
414
415

    fprintf(sync_ri, "}\n");
}

void add_RI_to_Macro_Definitions(Interface * i)
{

    fprintf(glue_macros, "/* REQUIRED INTERFACE %s */\n", i->name);

    /* 1) declare static data to put the Asn.1 encoded data */
    FOREACH(p, Parameter, i->in, {
416
417
            Declare_static_ASN1_param(p, &glue_macros);
            });
Maxime Perrotin's avatar
Maxime Perrotin committed
418
    FOREACH(p, Parameter, i->out, {
419
420
            Declare_static_ASN1_param(p, &glue_macros);
            });
Maxime Perrotin's avatar
Maxime Perrotin committed
421
422
423
424
425
426
427
428
429
430
431
432
433

    /* 2) undef the possibly existing macro */
    fprintf(glue_macros, "\n#undef RTDS_MSG_SEND_%s\n", i->name);

    /* 
     * 3) define the macro:
     *      #define RTDS_MSG_SEND_<msg name>(PARAM1, ..., PARAMn)\
     *      { Convert_<type>_from_RTDS_to_ASN1SCC (PARAM1, &PARAM1_in_asn1); \  (for each IN param)
     *      message(PARAM1_in_asn1, ...);\
     *      Convert_<type>_from_ASN1_to_RTDS (&out_param_in_asn1, outPARAMi) \ (if applicable, for each OUT param)
     *      }
     */
    fprintf(glue_macros, "#define RTDS_MSG_SEND_%s%s", i->name,
434
            (NULL != i->in || NULL != i->out) ? "(" : "");
Maxime Perrotin's avatar
Maxime Perrotin committed
435
    FOREACH(p, Parameter, i->in, {
436
        List_RTDS_Params(p, &glue_macros);
Maxime Perrotin's avatar
Maxime Perrotin committed
437
438
439
440
441
442
    })
    FOREACH(p, Parameter, i->out, {
        List_RTDS_Params(p, &glue_macros);
    })

    fprintf(glue_macros, "%s\\\n{ ",
443
            (NULL != i->in || NULL != i->out) ? ")" : "");
Maxime Perrotin's avatar
Maxime Perrotin committed
444
    FOREACH(p, Parameter, i->in, {
445
446
            Convert_RTDS_to_ASN1(p, &glue_macros, "\\\n");
            });
Maxime Perrotin's avatar
Maxime Perrotin committed
447
448
    fprintf(glue_macros, "\t%s_RI_%s(", i->parent_fv->name, i->name);
    FOREACH(p, Parameter, i->in, {
449
        List_ASN1_Params_With_Pointers(p, &glue_macros);
Maxime Perrotin's avatar
Maxime Perrotin committed
450
451
452
453
454
455
456
    })
    FOREACH(p, Parameter, i->out, {
        List_ASN1_Params_With_Pointers(p, &glue_macros);
    })

    fprintf(glue_macros, ");\\\n");
    FOREACH(p, Parameter, i->out, {
457
        Convert_ASN1_to_RTDS_Macro(p, &glue_macros);
Maxime Perrotin's avatar
Maxime Perrotin committed
458
459
460
461
462
463
464
465
466
    })
    fprintf(glue_macros, "}\n\n");
}

/* Function to process one interface of the FV */
void GLUE_RTDS_Interface(Interface * i)
{
    switch (i->direction) {
    case PI:
467
468
        add_PI_to_RTDS_glue(i);
        break;
Maxime Perrotin's avatar
Maxime Perrotin committed
469
470

    case RI:
471
472
473
474
475
476
        add_RI_to_RTDS_glue(i);
        if (asynch == i->synchronism)
            add_RI_to_Macro_Definitions(i);
        if (synch == i->synchronism)
            add_sync_RI(i);
        break;
Maxime Perrotin's avatar
Maxime Perrotin committed
477
    default:
478
        break;
Maxime Perrotin's avatar
Maxime Perrotin committed
479
480
481
482
483
484
485
486
    }
}

/* External interface (the one and unique) */
void GLUE_RTDS_Backend(FV * fv)
{

    if (fv->system_ast->context->onlycv)
487
        return;
Maxime Perrotin's avatar
Maxime Perrotin committed
488
489
    if (rtds == fv->language) {

490
491
492
493
        Init_RTDS_GLUE_Backend(fv);
        FOREACH(i, Interface, fv->interfaces, {
            GLUE_RTDS_Interface(i);
        })
Maxime Perrotin's avatar
Maxime Perrotin committed
494

495
496
497
498
499
        fprintf(glue_h, "\n#endif\n");
        close_file(&glue_h);
        close_file(&glue_c);
        close_file(&glue_macros);
        close_file(&sync_ri);
Maxime Perrotin's avatar
Maxime Perrotin committed
500
501
    }
}