Remove the use of memset in generated code

20 ビュー (過去 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 Center および File ExchangeDeployment, 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