Commit 5c56e8f6 authored by Maxime Perrotin's avatar Maxime Perrotin

Refactor Ada-C Interface

use char_array from Interfaces.C when sending a string to C
this avoids issues on 64 bits architectures when passing an Ada 'Length
attribute (32 bits) to a size_t (64 bits) recipient in C
parent 12862c5f
This diff is collapsed.
......@@ -3,153 +3,100 @@
-- LGPL license, see LICENSE file
with Ocarina.Types; use Ocarina.Types;
with Interfaces.C; use Interfaces.C;
-- with Types; use Types;
package Imported_Routines is
procedure C_Set_OutDir (Dir : String; Len : Integer);
procedure C_Set_Stack (Val : String; Len : Integer);
procedure C_Set_Timer_Resolution (Val : String; Len : Integer);
procedure C_New_APLC (Arg : String; Len : Integer);
procedure C_New_FV (Arg : String; Len : Integer; CS : String);
procedure C_Set_OutDir (Dir : char_array);
procedure C_Set_Stack (Val : char_array);
procedure C_Set_Timer_Resolution (Val : char_array);
procedure C_New_APLC (Arg : char_array);
procedure C_New_FV (Arg : char_array; CS : char_array);
procedure C_Set_PolyORBHI_C;
procedure C_Add_PI (Arg : String;
Len : Integer);
procedure C_Add_PI (Arg : char_array);
procedure C_Add_RI (Arg : String;
Len : Integer;
DistFV : String;
DLen : Integer;
DistName : String;
DistNameLen : Integer);
procedure C_Add_RI (Arg : char_array;
DistFV : char_array;
DistName : char_array);
procedure C_Set_Property (Name : String;
Len : Integer;
Val : String;
Val_Len : Integer);
procedure C_Set_Property (Name : char_array;
Val : char_array);
procedure C_Set_Distant_APLC (Arg : String; Len : Integer);
procedure C_Set_Distant_APLC (Arg : char_array);
procedure C_End_IF;
procedure C_End_FV;
procedure C_Set_Root_Node (Arg : String; Len : Integer);
procedure C_Set_Root_Node (Arg : char_array);
procedure C_New_Process (Arg : String;
Len : Integer;
Id : String;
LenId : Integer;
Node_Name : String;
Len_Node : Integer;
procedure C_New_Process (Arg : char_array;
Id : char_array;
Node_Name : char_array;
Coverage : Integer);
procedure C_New_Processor (Name : String;
Name_Len : Integer;
Classifier : String;
Classifier_Len : Integer;
Platform : String;
Platform_Len : Integer;
EnvVars : String;
EnvVars_Len : Integer;
CFflags : String;
CFlags_Len : Integer;
LdFlags : String;
LdFlags_Len : Integer);
procedure C_New_Processor (Name : char_array;
Classifier : char_array;
Platform : char_array;
EnvVars : char_array;
CFflags : char_array;
LdFlags : char_array);
procedure C_New_Bus (Name : String;
Name_Len : Integer;
Classifier : String;
Classifier_Len : Integer);
procedure C_New_Bus (Name : char_array;
Classifier : char_array);
procedure C_New_Device (Name : String;
Name_Len : Integer;
Classifier : String;
Classifier_Len : Integer;
Associated_Processor : String;
Associated_Processor_Len : Integer;
Configuration : String;
Configuration_Len : Integer;
Accessed_Bus : String;
Accessed_Bus_Len : Integer;
Access_Port : String;
Access_Port_Len : Integer;
Asn1_Filename : String;
Asn1_Filename_Len : Integer;
Asn1_Typename : String;
Asn1_Typename_Len : Integer;
Asn1_Modulename : String;
Asn1_Modulename_Len : Integer);
procedure C_New_Device (Name : char_array;
Classifier : char_array;
Associated_Processor : char_array;
Configuration : char_array;
Accessed_Bus : char_array;
Access_Port : char_array;
Asn1_Filename : char_array;
Asn1_Typename : char_array;
Asn1_Modulename : char_array);
procedure C_New_Connection (Src_System : String;
Src_System_Length : Integer;
Src_Port : String;
Src_Port_Length : Integer;
Bus : String;
Bus_Length : Integer;
Dst_System : String;
Dst_System_Length : Integer;
Dst_Port : String;
Dst_Port_Length : Integer);
procedure C_New_Connection (Src_System : char_array;
Src_Port : char_array;
Bus : char_array;
Dst_System : char_array;
Dst_Port : char_array);
procedure C_Add_Binding (Arg : String; Len : Integer);
procedure C_Add_Binding (Arg : char_array);
procedure C_End_Process;
procedure C_End_Bus;
procedure C_End_Device;
procedure C_End_Connection;
procedure C_Add_In_Param
(name : String;
Len1 : Integer;
partype : String;
Len2 : Integer;
module : String;
Len3 : Integer;
filename : String;
Len4 : Integer);
(name : char_array;
partype : char_array;
module : char_array;
filename : char_array);
procedure C_Add_Out_Param
(name : String;
Len1 : Integer;
partype : String;
Len2 : Integer;
module : String;
Len3 : Integer;
filename : String;
Len4 : Integer);
procedure C_Add_Package
(Name : String;
Len : Integer);
(name : char_array;
partype : char_array;
module : char_array;
filename : char_array);
procedure C_Add_Package (Name : char_array);
procedure C_Set_Compute_Time
(Lower_Bound : Unsigned_Long_Long;
Lower_Unit : String;
Len2 : Integer;
Lower_Unit : char_array;
Upper_Bound : Unsigned_Long_Long;
Upper_Unit : String;
Len4 : Integer);
Upper_Unit : char_array);
procedure C_Set_Context_Variable
(varName : String;
nameLen : Integer;
varType : String;
typeLen : Integer;
varVal : String;
valLen : Integer;
varMod : String;
modLen : Integer;
varFile : String;
fileLen : Integer;
fullName : String);
(varName : char_array;
varType : char_array;
varVal : char_array;
varMod : char_array;
varFile : char_array;
fullName : char_array);
procedure C_Set_Period (Period : Unsigned_Long_Long);
procedure C_Set_Interface_Queue_Size (Size : Unsigned_Long_Long);
procedure C_Set_Glue;
procedure C_Set_SMP2;
procedure C_Set_Interfaceview
(name : String;
len : Integer);
procedure C_Set_Dataview
(name : String;
len : Integer);
procedure C_Set_Zipfile
(name : String;
len : Integer);
procedure C_Set_Interfaceview (Name : char_array);
procedure C_Set_Dataview (Name : char_array);
procedure C_Set_Zipfile (Name : char_array);
procedure C_Set_Gateway;
procedure C_Keep_case;
procedure C_Set_Test;
......@@ -204,9 +151,7 @@ package Imported_Routines is
procedure C_Set_Debug_Messages;
procedure C_New_Drivers_Section;
procedure C_End_Drivers_Section;
procedure C_Set_Instance_Of
(component : String;
len : Integer);
procedure C_Set_Instance_Of (Component : char_array);
procedure C_Set_Is_Component_Type;
private
......
This diff is collapsed.
......@@ -209,22 +209,17 @@ char *build_string(char **str, char *text_to_add, size_t length)
char *old_string = NULL;
if (NULL == *str) {
fflush(stdout);
*str = (char *) malloc(length + 1);
if (NULL == *str) {
return NULL;
}
assert (NULL != *str);
memcpy(*str, text_to_add, length);
(*str)[length] = '\0';
} else {
old_string = (char *) malloc(strlen(*str) + 1);
if (NULL == old_string) {
return NULL;
}
assert (NULL != old_string);
strcpy(old_string, *str);
*str = (char *) realloc(*str, strlen(*str) + length + 1);
if (NULL == *str) {
return NULL;
}
assert (NULL != *str);
strcpy(*str, old_string);
strncat(*str, text_to_add, length);
(*str)[strlen(old_string) + length] = '\0';
......
......@@ -50,7 +50,7 @@ FV *Add_timer_manager(Process *node, FV_list *fv_with_timer)
name = make_string ("%s_timer_manager", node->name);
fv = (FV *) New_FV (name, strlen(name), name);
fv = (FV *) New_FV (name, name);
Set_Language_To_C();
......@@ -79,7 +79,7 @@ FV *Add_timer_manager(Process *node, FV_list *fv_with_timer)
/* Add the new FV to the binding list of the Process */
Set_Current_Process (node);
Add_Binding(name, strlen(name));
Add_Binding(name);
/* Create a file called "_hook" to add this function
* to the orchestrator work */
......@@ -341,7 +341,7 @@ void Add_Artificial_Function (Interface *duplicate_pi,
/* 1) Create a new FV called fv_name (argument of the function)
* and set 2 interfaces to it (PI and RI) */
new_fv = (FV *) New_FV (fv_name, strlen(fv_name), fv_name);
new_fv = (FV *) New_FV (fv_name, fv_name);
/*
Setting the language to blackbox_device allows to avoid generating
unnecessary code for VT-created threads (vm_if, invoke_ri, dataview glue)
......@@ -384,7 +384,7 @@ void Add_Artificial_Function (Interface *duplicate_pi,
}
Set_Current_Process (fv->process);
Add_Binding(fv_name, strlen(fv_name));
Add_Binding(fv_name);
/* 3) Create a file called "_hook" to add this function
* to the orchestrator work */
......@@ -839,7 +839,7 @@ void Add_api(Process *node, FV_list *all_fv)
name = make_string("%s_taste_api", node->name);
fv = New_FV(name, strlen(name), name);
fv = New_FV(name, name);
assert (NULL != fv);
if(get_context()->polyorb_hi_c) {
......@@ -899,7 +899,7 @@ void Add_api(Process *node, FV_list *all_fv)
/* Add the new FV to the binding list of the Process */
Set_Current_Process (node);
Add_Binding(name, strlen(name));
Add_Binding(name);
/* Create a file called "_hook" to add this function
* to the orchestrator work */
......@@ -1157,7 +1157,7 @@ void Preprocess_coverage (Process *node)
name = make_string ("%s_coverage_collector", node->name);
fv = (FV *) New_FV (name, strlen(name), name);
fv = (FV *) New_FV (name, name);
Set_Language_To_C();
......@@ -1187,7 +1187,7 @@ void Preprocess_coverage (Process *node)
/* Add the new FV to the binding list of the Process */
Set_Current_Process (node);
Add_Binding(name, strlen(name));
Add_Binding(name);
/* 3) Create a file called "_hook" to add this function
* to the orchestrator work */
......@@ -1363,7 +1363,6 @@ void Preprocessing_Backend (System *s)
FV *caller = NULL;
FV *callee = NULL;
Interface *ri = NULL;
/* Find the FV of the caller */
FOREACH (fv, FV, get_system_ast()->functions, {
if (!strcmp (fv->name, cnt->dst_system) && (true != fv->is_component_type)) caller = fv;
......@@ -1386,23 +1385,24 @@ void Preprocessing_Backend (System *s)
if (passive_runtime == caller->runtime_nature && NULL != callee) {
FOREACH (ct, FV, caller->calling_threads, {
New_Connection (
callee->name, strlen (callee->name),
cnt->src_port, strlen (cnt->src_port),
cnt->bus, strlen (cnt->bus),
ct->name, strlen (ct->name),
cnt->dst_port, strlen (cnt->dst_port)
callee->name,
cnt->src_port,
cnt->bus,
ct->name,
cnt->dst_port
);
APPEND_TO_LIST (Connection, new_connections, Get_Connection());
});
APPEND_TO_LIST (Connection, connections_to_remove, cnt);
}
else if (NULL != callee && strcmp (callee->name, cnt->src_system)) {
printf("5b\n");
New_Connection (
callee->name, strlen (callee->name),
cnt->src_port, strlen (cnt->src_port),
cnt->bus, strlen (cnt->bus),
caller->name, strlen (caller->name),
cnt->dst_port, strlen (cnt->dst_port)
callee->name,
cnt->src_port,
cnt->bus,
caller->name,
cnt->dst_port
);
APPEND_TO_LIST (Connection, new_connections, Get_Connection());
APPEND_TO_LIST (Connection, connections_to_remove, cnt);
......
......@@ -223,8 +223,8 @@ void write_thread_implementation(FV *fv)
FOREACH(p, Process, get_system_ast()->processes, {
FOREACH(b, Aplc_binding, p->bindings, {
if (b->fv == fv &&
((!strcmp(p->cpu->platform_name, "PLATFORM_NATIVE"))
|| (!strcmp(p->cpu->platform_name, "PLATFORM_LINUX_DLL")))) {
((!strcmp(p->cpu->platform_name, "PLATFORM_NATIVE"))
|| (!strcmp(p->cpu->platform_name, "PLATFORM_LINUX_DLL")))) {
stack_size = 100;
}
});
......@@ -1001,7 +1001,7 @@ void Generate_Full_ConcurrencyView(Process_list *processes, char *root_node)
FOREACH (p, Process, processes, {
GenerateProcessRefinement(p);
FOREACH(b, Device, p->drivers, {
FOREACH(b, Device, p->drivers, {
char *driver_no_underscore =
underscore_to_dash (b->name, strlen (b->name));
fprintf(process,
......
......@@ -14,36 +14,36 @@ void CompareFVname(FV *fv_local,FV **result);
void SetSearchName(char *name);
void End_FV();
void End_IF();
void Add_Out_Param(char *name, size_t l1,
char *type, size_t l2,
char *module, size_t l3,
char *filename, size_t l4);
void Add_Out_Param(char *name,
char *type,
char *module,
char *filename);
void Add_In_Param(char *,size_t l1,char *,size_t, char *, size_t, char*, size_t);
void Add_RI(char *ri,size_t length,char *dist_fv,size_t distant_length, char *dist_name, size_t dist_name_length);
void Add_PI(char *pi, size_t length);
void New_Interface(char *name, size_t length,char *dist_fv,size_t distant_length, char *dist_name, size_t dist_name_length, IF_type direction);
FV *New_FV(char *fv_name, size_t length, char *caseSensitive);
void Add_In_Param(char *, char *, char *, char*);
void Add_RI(char *ri, char *dist_fv, char *dist_name);
void Add_PI(char *pi);
void New_Interface(char *name,char *dist_fv, char *dist_name, IF_type direction);
FV *New_FV(char *fv_name, char *caseSensitive);
FV *FindFV(char *fv_name);
void LookForRI(Interface *i, Interface **check);
FV_list *Find_All_Calling_FV(Interface *i);
void Add_Binding(char *b, size_t length);
void Add_Binding(char *b);
void Set_Current_Process(Process *p);
void End_Process();
void New_Drivers_Section();
void End_Drivers_Section();
void New_Processor (char *name, size_t name_length,
char *classifier, size_t classifier_length,
char* platform, size_t platform_length,
char *envvars, size_t envvars_length,
char *cflags, size_t cflags_length,
char *ldflags, size_t ldflags_length);
void New_Process(char *, size_t, char *,size_t, char *, size_t, bool);
void Set_OutDir(char *o,size_t len);
void Set_Interfaceview (char *name, size_t len);
void Set_Dataview (char *name, size_t len);
void New_Processor (char *name,
char *classifier,
char* platform,
char *envvars,
char *cflags,
char *ldflags);
void New_Process(char *, char *, char *, bool);
void Set_OutDir(char *o);
void Set_Interfaceview (char *name);
void Set_Dataview (char *name);
void Set_Test();
void Set_Timer_Resolution(char *val, size_t len);
void Set_Timer_Resolution(char *val);
void Set_Future();
void Set_OnlyCV();
void Set_AADLV2();
......@@ -51,10 +51,10 @@ void Set_Gateway();
void Set_keep_case();
void Set_Glue();
Context *get_context();
void Set_Compute_Time (uint64_t lower, char *unitlower, size_t len2,
uint64_t upper, char *unitupper, size_t len4);
void Set_Context_Variable (char *name, size_t len1, char *type, size_t len2,
char *def, size_t len3, char *mod, size_t len4, char *file, size_t len5, char *nameWithCase);
void Set_Compute_Time (uint64_t lower, char *unitlower,
uint64_t upper, char *unitupper);
void Set_Context_Variable (char *name, char *type,
char *def, char *mod, char *file, char *nameWithCase);
void Set_Period(long long p);
void Set_UndefinedKind_PI();
......@@ -66,7 +66,7 @@ void Set_Cyclic_IF();
void Set_Unknown_IF();
void Set_ASync_IF();
void Set_Sync_IF();
void Set_Property (char *name, size_t name_len, char *val, size_t val_len);
void Set_Property (char *name, char *val);
void Set_Language_To_GUI();
void Set_Language_To_CPP();
void Set_Language_To_VDM();
......@@ -97,19 +97,19 @@ void Set_ASN1_BasicType_SequenceOf();
void Set_ASN1_BasicType_Sequence();
void Set_UPER_Encoding();
void Set_Native_Encoding();
void Set_Zipfile (char *file, size_t len);
void Set_Root_Node(char *name,size_t len);
void Set_Zipfile (char *file);
void Set_Root_Node(char *name);
void Set_PolyorbHI_C();
void Set_Instance_Of(char *component, size_t len);
void Set_Instance_Of(char *component);
void Set_Is_Component_Type();
System *get_system_ast();
void Delete_System_AST();
void C_Init();
void New_Connection(char *src_system, size_t src_system_length,
char *src_port, size_t src_port_length,
char *bus, size_t bus_length,
char *dst_system, size_t dst_system_length,
char *dst_port, size_t dst_port_length);
void New_Connection(char *src_system,
char *src_port,
char *bus,
char *dst_system,
char *dst_port);
void End_Connection();
Connection *Get_Connection();
char *getASN1DataView();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment