Set specified parameters for semaphore entry in code replacement table
This example shows how to use the
setTflCSemaphoreEntryParameters
function to set specified
parameters for a code replacement table entry for a semaphore initialization
replacement.
sem_entry = RTW.TflCSemaphoreEntry; sem_entry.setTflCSemaphoreEntryParameters( ... 'Key', 'RTW_SEM_INIT', ... 'Priority', 100, ... 'ImplementationName', 'mySemCreate', ... 'ImplementationHeaderFile', 'mySem.h', ... 'ImplementationSourceFile', 'mySem.c', ... 'GenCallback', 'RTW.copyFileToBuildDir', ... 'SideEffects', true);
hEntry
— Handle to semaphore entryThe hEntry
is a handle to a code replacement
library semaphore entry previously returned by
.hEntry
=
RTW.TflCSemaphoreEntry;
Example: sem_entry
varargin
— Name-value pairs of arguments for function entryExample: 'Key','RTW_SEM_INIT'
Specify optional
comma-separated pairs of Name,Value
arguments. Name
is
the argument name and Value
is the corresponding value.
Name
must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN
.
'Key','RTW_SEM_INIT'
'AcceptExprInput'
— Specifies whether implementation function accepts expression inputstrue
| false
The AcceptExprInput
value flags the code
generator that the implementation function described by this entry
accepts expression inputs. The default value is true
if ImplType
equals FCN_IMPL_FUNCT
and false
if ImplType
equals
FCN_IMPL_MACRO
.
If the value is true
, expression inputs are
integrated into the generated code in a form similar to this
form:
rtY.Out1 = mySin(rtU.In1 + rtU.In2);
If the value is false
, a temporary variable is
generated for the expression input:
real_T rtb_Sum; rtb_Sum = rtU.In1 + rtU.In2; rtY.Out1 = mySin(rtb_Sum);
Example: 'AcceptExprInput',true
'AdditionalHeaderFiles'
— Specifies additional header files for table entry{}
(default) | array of character vectors | string arrayThe AdditionalHeaderFiles
value specifies
additional header files for a code replacement table entry. The
character vectors or string array can include tokens. For example, in
the token $mytoken$
, mytoken
is a
variable defined as a character vector or string scalar in the
MATLAB® workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'AdditionalHeaderFiles',{}
'AdditionalIncludePaths'
— Specifies additional include paths for table entry{}
(default) | array of character vectors | string arrayThe AdditionalIncludePaths
value specifies
the full path of additional include paths for a code replacement entry.
The character vectors or string array can include tokens. For example,
in the token $mytoken$
, mytoken
is
a variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'AdditionalIncludePaths',{}
'AdditionalLinkObjs'
— Specifies additional link objects for table entry{}
(default) | array of character vectors | string arrayThe AdditionalLinkObjs
value specifies
additional link objects for a code replacement table entry. The
character vectors or string array can include tokens. For example, in
the token $mytoken$
, mytoken
is a
variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'AdditionalLinkObjs',{}
'AdditionalLinkObjsPaths'
— Specifies additional link object paths for table entry{}
(default) | array of character vectors | string arrayThe AdditionalLinkObjsPaths
value specifies
the full path of additional link object paths for a code replacement
entry. The character vectors or string array can include tokens. For
example, in the token $mytoken$
,
mytoken
is a variable defined as a character
vector or string scalar in the MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'AdditionalLinkObjsPaths',{}
'AdditionalSourceFiles'
— specifies additional source files for table entry{}
(default) | array of character vectors | string arrayThe AdditionalSourceFiles
value specifies
additional source files for a code replacement table entry. The
character vectors or string array can include tokens. For example, in
the token $mytoken$
, mytoken
is a
variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'AdditionalSourceFiles',{}
'AdditionalSourcePaths'
— Specifies additional source paths for table entry{}
(default) | array of character vectors | string arrayThe AdditionalSourcePaths
value specifies
the full path of additional source paths for a code replacement entry.
The character vectors or string array can include tokens. For example,
in the token $mytoken$
, mytoken
is
a variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector. The default is {}
.
Example: 'AdditionalSourcePaths',{}
'AdditionalCompileFlags'
— Specifies additional compiler flags for table entry{}
(default) | array of character vectors | string arrayThe AdditionalCompileFlags
value specifies
additional flags required to compile the source files defined for a code
replacement table entry.
Example: 'AdditionalCompileFlags',{}
'AdditionalLinkFlags'
— Specifies additional linker flags for table entry{}
(default) | array of character vectors | string arrayThe AdditionalLinkFlags
value specifies
additional flags required to link the compiled files for a code
replacement table entry.
Example: 'AdditionalLinkFlags',{}
'GenCallback'
— Specifies callback that follows code generation''
(default) | 'RTW.copyFileToBuildDir'
The GenCallback
specifies a callback that
follows code generation. If you specify
'RTW.copyFileToBuildDir'
, and if this function
entry is matched and used, the function
RTW.copyFileToBuildDir
is called after code
generation. This callback function copies additional header, source, or
object files that you have specified for this function entry to the
build folder.
Example: 'GenCallback',''
'ImplementationHeaderFile'
— Specifies name of header file that declares implementation function''
(default) | character vector | string scalarThe ImplementationHeaderFile
value
specifies the name of the header file that declares the implementation
function. The character vector or string scalar can include tokens. For
example, in the token $mytoken$
,
mytoken
is a variable defined as a character
vector or string scalar in the MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'ImplementationHeaderFile','<math.h>'
'ImplementationHeaderPath'
— Specifies path to implementation header file''
(default) | character vector | string scalarThe ImplementationHeaderPath
value
specifies the full path to the implementation header file. The character
vector or string scalar can include tokens. For example, in the token
$mytoken$
, mytoken
is a
variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'ImplementationHeaderPath',''
'ImplementationName'
— Specifies name of implementation function''
(default) | character vector | string scalarThe ImplementationName
value specifies the
name of the implementation function, which can match or differ from the
Key
name.
Example: 'ImplementationName','sqrt'
'ImplementationSourceFile'
— specifies name of implementation source file''
(default) | character vector | string scalarThe ImplementationSourceFile
value
specifies the name of the implementation source file. The character
vector or string scalar can include tokens. For example, in the token
$mytoken$
, mytoken
is a
variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'ImplementationSourceFile',''
'ImplementationSourcePath'
— Specifies path to implementation source file''
(default) | character vector | string scalarThe ImplementationSourcePath
value
specifies the full path to the implementation source file. The character
vector or string scalar can include tokens. For example, in the token
$mytoken$
, mytoken
is a
variable defined as a character vector or string scalar in the
MATLAB workspace or as a MATLAB function in the search path that returns a character
vector.
Example: 'ImplementationSourcePath',''
'ImplType'
— Specifies the type of table entry'FCN_IMPL_FUNCT'
(default) | 'FCN_IMPL_MACRO'
The ImplType
value specifies the type of
table entry. Use FCN_IMPL_FUNCT
for function or
FCN_IMPL_MACRO
for macro.
Example: 'ImplType','FCN_IMPL_FUNCT'
'Key'
— Specifies key for operator to replaceThe Key
value specifies the key for the
operator to replace. The name must match a function name listed in Code You Can Replace from MATLAB Code or Code You Can Replace From Simulink Models.
Example: 'Key','RTW_OP_ADD'
'Priority'
— Specifies the search priority of the function entry100
(default) | integer value 0..100The Priority
value specifies the search
priority of the function entry, relative to other entries of the same
function name and conceptual argument list within this table. Highest
priority is 0, and lowest priority is 100. The default is 100. If the
table provides two implementations for a function, the implementation
with the higher priority shadows the one with the lower priority.
Example: 'Priority',100
'RoundingModes'
— Specifies rounding modes supported by implementation function'RTW_ROUND_UNSPECIFIED'
(default) | 'RTW_ROUND_FLOOR'
| 'RTW_ROUND_CEILING'
| 'RTW_ROUND_ZERO'
| 'RTW_ROUND_NEAREST'
| 'RTW_ROUND_NEAREST_ML'
| 'RTW_ROUND_CONV'
| 'RTW_ROUND_SIMPLEST'
| array of character vectors | string arrayThe RoundingModes
value specifies one or
more rounding modes supported by the implementation function.
Example: 'RoundingModes',{'RTW_ROUND_UNSPECIFIED'}
'SaturationMode'
— specifies saturation mode supported by implementation function'RTW_SATURATE_UNSPECIFIED'
(default) | 'RTW_SATURATE_ON_OVERFLOW'
| 'RTW_WRAP_ON_OVERFLOW'
| character vector | string scalarThe SaturationMode
value specifies the
saturation mode supported by the implementation function.
Example: 'SaturationMode','RTW_SATURATE_UNSPECIFIED'
'SideEffects'
— Specifies whether to attempt to optimize away the implementation functionfalse
(default) | true
The SideEffects
value flags the code
generator not to optimize away the implementation function described by this
entry. This parameter applies to implementation functions that return
void
but are not to be optimized away, such as a
memcpy
implementation or an implementation function
that accesses global memory values. For those implementation functions only,
you must include this parameter and specify the value
true
.
Example: 'SideEffects',false
'StoreFcnReturnInLocalVar'
— Specifies whether to store the implementation function regardless expression folding settingsfalse
(default) | true
The StoreFcnReturnInLocalVar
value flags
the code generator that the return value of the implementation function
described by this entry must be stored in a local variable regardless of
other expression folding settings. If the value is
false
, other expression folding settings
determine whether the return value is folded. Storing function returns
in a local variable can increase the clarity of generated code. This
example shows code generated with expression folding:
void sw_step(void) { if (ssub(sadd(sw_U.In1, sw_U.In2), sw_U.In3) <= smul(ssub(sw_U.In4, sw_U.In5),sw_U.In6)) { sw_Y.Out1 = sw_U.In7; } else { sw_Y.Out1 = sw_U.In8; } }
With StoreFcnReturnInLocalVar
set to
true
, the generated code is potentially easier to
understand and debug:
void sw_step(void) { real32_T rtb_Switch; real32_T hoistedExpr; ...... rtb_Switch = sadd(sw_U.In1, sw_U.In2); rtb_Switch = ssub(rtb_Switch, sw_U.In3); hoistedExpr = ssub(sw_U.In4, sw_U.In5); hoistedExpr = smul(hoistedExpr, sw_U.In6); if (rtb_Switch <= hoistedExpr) { sw_Y.Out1 = sw_U.In7; } else { sw_Y.Out1 = sw_U.In8; } }
Example: 'StoreFcnReturnInLocalVar',false
addAdditionalHeaderFile
| addAdditionalIncludePath
| addAdditionalLinkObj
| addAdditionalLinkObjPath
| addAdditionalSourceFile
| addAdditionalSourcepath