Commit acc2067b authored by Maxime Perrotin's avatar Maxime Perrotin

minor refactoring

parent e37d4b57
......@@ -2,6 +2,7 @@ GCCVERSION := $(shell gcc -v 2>&1 | grep ada | wc -l)
UNAME := $(shell uname)
VERSION=0.1
CC=gcc
exec = buildsupport
sources = $(wildcard ada/*.ad? c/*.c include/*.h)
......@@ -36,7 +37,7 @@ endif
# We have to compile in C99 to support "long long" integers, as imposed by the "aadlinteger" type
# -Wall -Werror -Wextra -Wconversion -Wno-deprecated -Winit-self -Wsign-conversion -Wredundant-decls -Wvla -Wshadow -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wlogical-op -Wmissing-include-dirs -Winit-self -Wpointer-arith -Wcast-qual -Wcast-align -Wold-style-cast -Wno-error=old-style-cast -Wsign-promo -Wundef
#clang -c -Wall -Werror -Iinclude c/*.c
gcc -c -W -g3 -g -Wall -Werror -Wextra -Werror=format-security -Wconversion -Wno-deprecated -Winit-self -Wsign-conversion -Wredundant-decls -Wvla -Wshadow -Wlogical-op -Wmissing-include-dirs -Winit-self -Wpointer-arith -Wcast-qual -Wcast-align -Wno-error=old-style-cast -Wundef -std=c99 -pedantic -Iinclude c/*.c
$(CC) -c -W -g3 -g -Wall -Werror -Wextra -Werror=format-security -Wconversion -Wno-deprecated -Winit-self -Wsign-conversion -Wredundant-decls -Wvla -Wshadow -Wlogical-op -Wmissing-include-dirs -Winit-self -Wpointer-arith -Wcast-qual -Wcast-align -Wno-error=old-style-cast -Wundef -std=c99 -pedantic -Iinclude c/*.c
mv *.o tmpBuild/
ADA_PROJECT_PATH=`ocarina-config --prefix`/lib/gnat:$$ADA_PROJECT_PATH $(gnatpath)gnatmake -x -g $(exec) -p -P buildsupport.gpr -XBUILD="debug"
# strip $(exec)
......
......@@ -1168,7 +1168,7 @@ FV_list *Find_All_Calling_FV(Interface * i)
APPEND_TO_LIST (FV, result, function);
}
})
if (get_context()->test) {
if (get_context()->test && NULL != result) {
printf("\n[Interface %s in FV %s] is called by:\n",
i->name,
i->parent_fv->name);
......
......@@ -150,7 +150,7 @@ void c_wrappers_preamble(FV * fv)
&& vhdl != fv->language) {
fprintf (cfile, "#include \"%s.h\"\n\n", fv->name);
}
else if (simulink == fv->language) {
else if (simulink == fv->language && NULL != fv->interfaces) {
Interface *simulink_entrypoint = fv->interfaces->value;
fprintf (cfile, "#include \"%s_Simulink.Simulink.h\"\n\n",
simulink_entrypoint->name);
......
......@@ -1054,15 +1054,17 @@ int CountActivePI(Interface_list *interfaces)
* IMPORTANT : it must be checked first that the number of IN and OUT
* parameters are the same (using CountParams)
*/
void CheckInOutParams(Parameter * p_in, Parameter_list * p_out)
bool CheckInOutParams(Parameter * p_in, Parameter_list * p_out)
{
if (NULL == p_out)
return;
return false;
if (0 == strcmp(p_in->type, p_out->value->type))
p_out = p_out->next;
else
p_out = NULL;
if (0 == strcmp(p_in->type, p_out->value->type)) {
return true;
}
else {
return false;
}
}
/*
......
......@@ -1253,7 +1253,7 @@ void Preprocessing_Backend (System *s)
/* If the caller is passive we must create one connection
* per calling thread */
if (passive_runtime == caller->runtime_nature) {
if (passive_runtime == caller->runtime_nature && NULL != callee) {
FOREACH (ct, FV, caller->calling_threads, {
New_Connection (
callee->name, strlen (callee->name),
......@@ -1266,7 +1266,7 @@ void Preprocessing_Backend (System *s)
});
APPEND_TO_LIST (Connection, connections_to_remove, cnt);
}
else if (strcmp (callee->name, cnt->src_system)) {
else if (NULL != callee && strcmp (callee->name, cnt->src_system)) {
New_Connection (
callee->name, strlen (callee->name),
cnt->src_port, strlen (cnt->src_port),
......
......@@ -610,17 +610,14 @@ int CheckTestMode(Interface * i)
(void) p;
count_out++;
})
if (count_in != count_out)
return -1; /* not the same number of input and output parameters */
return -1; /* not the same number of input and output parameters */
FOREACH(p, Parameter, i->in, {
CheckInOutParams(p, p_result);
FOREACH(p, Parameter, i->in, {
if (false == CheckInOutParams(p, p_result)) return -1;
})
if (NULL == p_result)
return -1;
return 0;
}
......
......@@ -930,22 +930,25 @@ void GenerateProcessRefinement(Process *p)
void GenerateProcessor(Process *p, Process_list *processes)
{
FOREACH(p2, Process, processes, {
if (p2 == p) {
break;
}
if ( (p->cpu != NULL) &&
(p2->cpu != NULL) &&
(p2->cpu->name != NULL) &&
(p->cpu->name != NULL) &&
strcmp (p2->cpu->name, p->cpu->name) == 0) {
return;
}
})
FOREACH(p2, Process, processes, {
if (p2 == p) {
break;
}
fprintf(process, "%s : processor %s;\n", p->cpu->name, p->cpu->classifier);
if ( (p->cpu != NULL) &&
(p2->cpu != NULL) &&
(p2->cpu->name != NULL) &&
(p->cpu->name != NULL) &&
strcmp (p2->cpu->name, p->cpu->name) == 0) {
return;
}
})
if (NULL != p->cpu) {
fprintf(process, "%s : processor %s;\n",
p->cpu->name,
p->cpu->classifier);
}
}
/* External interface: Create the PROCESS IMPLEMENTATION part */
......
......@@ -137,7 +137,7 @@ void Clear_Aplc_bindings_List (Aplc_binding_list *p);
void CheckForAsn1Params (Interface *i, int *result);
/* Check if a list of input parameters match a list of output parameters. */
void CheckInOutParams (Parameter *p_in, Parameter_list *p_out);
bool CheckInOutParams (Parameter *p_in, Parameter_list *p_out);
/* Check if a FV has context parameters (exclude Directives, Timers, etc.) */
bool has_context_param(FV *fv);
......
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