필터 지우기
필터 지우기

Remove the use of memset in generated code

조회 수: 5 (최근 30일)
Jesus Alberto Calvo Portela
Jesus Alberto Calvo Portela 2022년 8월 3일
답변: Nicolas Schoonbroodt 2022년 9월 5일
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
Jesus Alberto Calvo Portela
Jesus Alberto Calvo Portela 2022년 8월 3일
Hello Bruno.
Thanks for your answer.
We have already another memset for the platform.
The issue is that we run the same code (more or less) on windows also (non-regression tests) and for that memset is fine (we have to differnt compilation chains).
So, in fact, in that case we would need to include a macro in the generated code for the include and the calls.
Jesus.
P.S.: Making a "overwrite" of the platform memset for windows won't be trivial ...
Bruno Luong
Bruno Luong 2022년 8월 3일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Nicolas Schoonbroodt
Nicolas Schoonbroodt 2022년 9월 5일
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

카테고리

Help CenterFile Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by