Remove the use of memset in generated code
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jesus Alberto Calvo Portela
el 3 de Ag. de 2022
Respondida: Nicolas Schoonbroodt
el 5 de Sept. de 2022
Hello,
We need to remove the use of memset in the generated code because our platform does not suppor it (in fact, it does not support the lib string.h) and replace by another initialization.
We are generetanig code from an state machine (state flow) and memset is used only in the initialize service.
We are getting the following code:
void Mission_State_initialize(void)
{
rtmSetErrorStatus(Mission_State_M, (NULL));
{
Mission_State_B.Mission_State_Mode = Mission_State_Mode_Type_None;
}
(void) memset((void *)&Mission_State_DW, 0,
sizeof(DW_Mission_State_T));
Mission_State_DW.is_active_c1_Mission_State = 0U;
Mission_State_B.Mission_State_Mode = Mission_State_Mode_Type_None;
}
If it is not possible to replace memset by another code, we would like to keep the initializaiton for the rest of the variables.
NOTES:
- "Remove internal data zero initializiton" activalted lets the initialize servei empty (it ouwld be the last option).
- "Use memset to initialize floats and doubles to 0.0" has no impact in our generated code.
Do you have any idea how to do that?
Thanks in advacned.
Jesus.
3 comentarios
Bruno Luong
el 3 de Ag. de 2022
This is about how to make the same base code multi-platform compatible. There are many way to do it, including macro, have specific library/header, adapt make script, adapt build enviroment, etc...
The standard approach is NOT changing the base source code.
Respuestas (1)
Nicolas Schoonbroodt
el 5 de Sept. de 2022
Hi Jesus,
We discussed this with you on a call, but I'm also adding this here for reference, if anyone came here because they have the same question.
One way to replace the call to memset (and some other functions) in the generated code by a custom inhouse memset variation is to use Code Replacement Libraries. Please refer to https://www.mathworks.com/help/ecoder/ug/quick-start-library-development-sc.html for an example (not focusing on memset, but the idea is the same)
Nicolas
0 comentarios
Ver también
Categorías
Más información sobre Deployment, Integration, and Supported Hardware en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!