DEENESPTFRRUARHIKOZHNL

Compiler Abstraction (Compiler)

ModulCompiler (Compiler Abstraction)
BSW-Modul-ID198
Standard-Header#include "Compiler.h"
SWS-SpezifikationAUTOSAR_SWS_CompilerAbstraction.pdf
Umfang35 Records · 0 Snippets
ClusterBasis- & Standardtypen

Compiler Abstraction (Compiler)

AUTOSAR Classic Special Files-Modul Compiler Abstraction (Compiler, Spezifikation: AUTOSAR_SWS_CompilerAbstraction.pdf).

Für Compiler liegen in den extrahierten Spezifikationsdaten keine C-API-Funktionen oder -Datentypen vor. Nachfolgend sind die 35 Anforderungs-Records der Spezifikation aufgeführt.

Anforderungen — Übersicht

Anforderungen — Detailansicht

requirement SWS_COMPILER_00001 [SWS_COMPILER_00001] 📄 PDF

Macro name: FUNC Syntax: #define FUNC(rettype, memclass) Parameters (in): r etype return type of the function m emclass classification of the function itself Parameters (out): N one -- Return value: N one -- Description: The compiler abstraction shall define the FUNC macro for the declaration and definition of functions that ensures correct syntax of function declarations as required by a specific compiler. Caveats: -- Configuration: --

requirement SWS_COMPILER_00003 [SWS_COMPILER_00003] 📄 PDF

For each compiler and platform an own compiler abstraction has to be provide d.

requirement SWS_COMPILER_00005 [SWS_COMPILER_00005] 📄 PDF

If a compiler does not require or support the usage of special keywords; the corresponding macros specified by this specification shall be provided as empty def initions or definitions without effect. Example: #define FUNC(type, memclass) type /* not required for DIABDATA */

requirement SWS_COMPILER_00006 [SWS_COMPILER_00006] 📄 PDF

Macro name: P2VAR Syntax: #define P2VAR(ptrtype, memclass, ptrclass) Parameters (in): ptrtype type of the referenced variable memclass classification of the pointer’s variable itself ptrclass defines the classification of the pointer’s distance Pa rameters (out): none -- Return value: none -- Description: The compiler abstraction shall define the P2VAR macro for the declaration and definition of pointers in RAM, pointing to variables. The pointer itself is modifiable (e.g. ExamplePtr++). The poin ter’s target is modifiable (e.g. *ExamplePtr = 5). Caveats: -- Configuration: --

requirement SWS_COMPILER_00010 [SWS_COMPILER_00010] 📄 PDF

The compiler abstraction shall define a symbol for the target compiler according to the following naming conventio n: _<COMPILERNAME>_C_<PLATFORMNAME>_ Note 1: In order to avoid incompatibilities and/ or inconsistencies , t he compiler symbol definitions are not allowed to contain any value behind the symbol. Note 2 : These defines can be used to switch between differ ent implementations for different compilers, e.g.  inline assembler fragments in drivers  special pragmas for memory alignment control  localization of function calls  adaptions to memory models

requirement SWS_COMPILER_00013 [SWS_COMPILER_00013] 📄 PDF

Macro name: P2CONST Syntax: #define P2CONST(ptrtype, memclass, ptrclass) Parameters (in): ptrtype type of the referenced constant memclass classification of the pointer’s va riable itself ptrclass defines the classification of the pointer’s distance Parameters (out): none -- Return value: none -- Description: The compiler abstraction shall define the P2CONST macro for the declaration and definition of pointers in RAM poin ting to constants The pointer itself is modifiable (e.g. ExamplePtr++). The pointer’s target is not modifiable (read only). Caveats: -- Configuration: --

requirement SWS_COMPILER_00023 [SWS_COMPILER_00023] 📄 PDF

Macro name: CONST Syntax: #define CONST(consttype, memclass) Parameters (in): consttype type of the constant memclass classif ication of the constant itself Parameters (out): none -- Return value: none -- Description: The compiler abstraction shall define the CONST macro for the declaration and definition of constants. Caveats: -- Configuration: --

requirement SWS_COMPILER_00026 [SWS_COMPILER_00026] 📄 PDF

Macro name: VAR Sy ntax: #define VAR(vartype, memclass) Parameters (in): v artype type of the variable m emclass classification of the variable itself Parameters (out): N one -- Return value: N one -- Description: The compiler abstraction shall define the VAR macro for the declaration and definition of variables. Caveats: -- Configuration: --

requirement SWS_COMPILER_00030 [SWS_COMPILER_00030] 📄 PDF

“Compiler.h” shall provide information of the supported compiler vendor and the applicable compiler version.

requirement SWS_COMPILER_00031 [SWS_COMPILER_00031] 📄 PDF

Macro name: CONSTP2VAR Syntax: #define CONSTP2VAR (ptrtype, memclass, ptrclass) Parameters (in): p trtype type of the referenced variable m emclass classification of the pointer’s constant itself p trclass defines the classification of the pointer’s d istance Parameters (out): N one -- Return value: N one -- Description: The compiler abstraction shall define the CONSTP2VAR macro for the declaration and definition of constant pointers accessing variables. The pointer itself is not modifiable (fix addre ss). The pointer’s target is modifiable (e.g. *ExamplePtr = 18). Caveats: -- Configuration: --

requirement SWS_COMPILER_00032 [SWS_COMPILER_00032] 📄 PDF

Macro name: CONSTP2CONST Syntax: #define CONSTP2CONST(ptrtype, me mclass, ptrclass) Parameters (in): ptrtype type of the referenced constant memclass classification of the pointer’s constant itself ptrclass defines the classification of the pointer’s distance Parameters (out): none -- Return value: none -- Descri ption: The compiler abstraction shall define the CONSTP2CONST macro for the declaration and definition of constant pointers accessing constants. The pointer itself is not modifiable (fix address). The pointer’s target is not modifiable (read only). Cavea ts: -- Configuration: --

requirement SWS_COMPILER_00036 [SWS_COMPILER_00036] 📄 PDF

C forbids the use of the far/near - keywords on function local variables (auto - variables). For thi s reason when using the macros below to allocate a pointer on stack, the memclass - parameter shall be set to AUTOMATIC.

requirement SWS_COMPILER_00039 [SWS_COMPILER_00039] 📄 PDF

Macro name: P2FUNC Syntax: #def ine P2FUNC(rettype, ptrclass, fctname) Parameters (in): rettype return type of the function ptrclass defines the classification of the pointer’s distance fctname function name respectively name of the defined type Parameters (out): N one -- Return v alue: N one -- Description: The compiler abstraction shall define the P2FUNC macro for the type definition of pointers to functions. Caveats: -- Configuration: --

requirement SWS_COMPILER_00040 [SWS_COMPILER_00040] 📄 PDF

Each AUTOSAR software module and application software component shall support the distinction of at least the following different memory classes and pointer classes.

requirement SWS_COMPILER_00041 [SWS_COMPILER_00041] 📄 PDF

Each AUTOSAR software module and application software component shall wrap declaration and definition of code, variables, constants an d pointer types using the following keyword macros:

requirement SWS_COMPILER_00042 [SWS_COMPILER_00042] 📄 PDF

The file Compiler.h is specific for each build scenario. Therefore there is no standardized configuration interface specified.

requirement SWS_COMPILER_00046 [SWS_COMPILER_00046] 📄 PDF

Define: AUTOMATIC Range: “empty” -- Description: The memory class AUTOMATIC shall be provided as empty definition, used for the declaration of local pointers. Caveats: SWS_COMPILER_00040

requirement SWS_COMPILER_00047 [SWS_COMPILER_00047] 📄 PDF

The Compiler.h header file shall protect itself against multiple inclusions. F or instance: #ifndef COMPILER_H #define COMPILER_H /* implementation of Compiler.h */ ... #endif /* COMPILER_H */ T here may be only comments outside of the ifndef - endif bracket.

requirement SWS_COMPILER_00048 [SWS_COMPILER_00048] 📄 PDF

The SWS Compiler Abstraction is applicable for each AUTOSAR basic software module and application software components. Therefore, the implementation of the memory class (memclass) and pointer class (ptrclass) macro parameters (see SWS_COMPILER_00040 ) shall fulfill the implementation and configuration specific needs of each software module in a specific build scenario.

requirement SWS_COMPILER_00050 [SWS_COMPILER_00050] 📄 PDF

It is allowed to extend the Compiler Abstraction header with vendor specific extensions. Vendor specific extended elements shall contain the AUTOSAR Vendor ID in the name.

requirement SWS_COMPILER_00051 [SWS_COMPILER_00051] 📄 PDF

Define: NULL_PTR Range: void pointer ((void *)0) Description: The compiler abstraction shall provide the NULL_PTR define with a void pointer to zero definition. Caveats: SWS_COMPILER_00040

requirement SWS_COMPILER_00053 [SWS_COMPILER_00053] 📄 PDF

The file Compiler.h shall contain the definitions and macros specified in chapter 7.1.5 . Those are fix for one specific compiler and platform.

requirement SWS_COMPILER_00054 [SWS_COMPILER_00054] 📄 PDF

Module specific extended elements shall contain the module abbreviation of the BSW module in the name. Application software component specific extended elements shall contain the Software Component Type ’s name.

requirement SWS_COMPILER_00055 [SWS_COMPILER_00055] 📄 PDF

The file Compiler_Cfg.h shall contain the module/component specific parameters ( ptrclass and memclass ) that are passed to the macros defined in Compiler.h. See SWS_COMPILER_00040 for memory types and required syntax.

requirement SWS_COMPILER_00057 [SWS_COMPILER_00057] 📄 PDF

Define: INLINE Range: inline/”empty” -- Description: The compiler abstraction shall provide the INLINE define for abstraction of the keyword inline. Caveats: SWS_ COMPILER_00040

requirement SWS_COMPILER_00058 [SWS_COMPILER_00058] 📄 PDF

In the parameter list of this macro no further Compiler Abstraction m acros shall be nested. Instead, use a previously defined type as return type or use FUNC_P2CONST/FUNC_P2VAR.

requirement SWS_COMPILER_00059 [SWS_COMPILER_00059] 📄 PDF

Define: TYPEDEF Range: “empty” -- Description: The memory class TYPEDEF shall be provided as empty definition. This memory class shall be used within type definitions, where no memory qualifier can be specified. Th is can be necessary for defining pointer types, with e.g. P2VAR, where the macros require two parameters. First parameter can be specified in the type definition (distance to the memory location referenced by the pointer), but the second one (memory alloca tion of the pointer itself) cannot be defined at this time. Hence, memory class TYPEDEF shall be applied. Caveats: SWS_COMPILER_00040

requirement SWS_COMPILER_00060 [SWS_COMPILER_00060] 📄 PDF

Define: LOCAL_INLINE Range: static inline/”empty” -- Description: The compiler abstraction shall provide the LOCAL_INLINE define for abstraction of the keyword inline in functions wi th “static” scope. Caveats: Different compilers may require a different sequence of the keywords “static” and “inline” if this is supported at all.

requirement SWS_COMPILER_00061 [SWS_COMPILER_00061] 📄 PDF

Macro name: FUNC_P2CONST Syntax: #define FUNC_P2CONST(rettype, ptrclass, memclass) Parameters (in): ret t ype return type of the function ptrclass defines the classification of the pointer’s distance memclas s classification of the function itself Parameters (out): none -- Return value: none -- Description: The compiler abstraction shall define the FUNC_P2CONST macro for the declaration and definition of functions returning a pointer to a constant. This sha ll ensure the correct syntax of function declarations as required by a specific compiler. Caveats: -- Configuration: --

requirement SWS_COMPILER_00062 [SWS_COMPILER_00062] 📄 PDF

In the parameter list of the FUNC_P2CONST, no further Compiler Abstraction macros shall be nested.

requirement SWS_COMPILER_00063 [SWS_COMPILER_00063] 📄 PDF

Macro name: FUNC_P2 VAR Syntax: #define FUNC_P2VAR(rettype, ptrclass, memclass) Parameters (in): ret t ype return type of the function ptrclass defines the classification of the pointer’s distance memclass classification of the function itself Parameters (out): none -- Return value: none -- Description: The compiler abstraction shall define the FUNC_P2VAR macro for the declaration and definition of functions returning a pointer to a variable. This shall ensure the correct syntax of function declarations as required by a specific compiler. Caveats: -- Configuration: --

requirement SWS_COMPILER_00064 [SWS_COMPILER_00064] 📄 PDF

In the parameter list of the macro FUNC_P2VAR, no further Compiler Abstraction macros shall be nested.

requirement SWS_COMPILER_00065 [SWS_COMPILER_00065] 📄 PDF

Macro name: CONSTP2FUNC Syntax: #define CONSTP2FUNC(rettype, ptrclass, fctname) Parameters (in): rettype return type of the function ptrclass defines t he classification of the pointer’s distance fctname function name respectively name of the defined type Parameters (out): N one -- Return value: N one -- Description: The compiler abstraction shall define the CONSTP2FUNC macro for the type definition o f constant pointers to functions. Caveats: -- Configuration: --

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/CP_MOD_Compiler
Status
unspecified
Version
AUTOSAR/AP/record/CP_MOD_Compiler@rel:R20-11#63e3e222
Content hash
63e3e222
Source
https://www.autosar.org/fileadmin/standards/R20-11/CP/AUTOSAR_SWS_CompilerAbstraction.pdf#nameddest=SWS_COMPILER_00001

Anforderungen

SWS_COMPILER_00001 requirement

Macro name: FUNC Syntax: #define FUNC(rettype, memclass) Parameters (in): r etype return type of the function m emclass classification of the function itself Parameters (out): N one -- Return value: N one -- Description: The compiler abstraction shall define the FUNC macro for the declaration and definition of functions that ensures correct syntax of function declarations as required by a specific compiler. Caveats: -- Configuration: --

SWS_COMPILER_00003 requirement

For each compiler and platform an own compiler abstraction has to be provide d.

SWS_COMPILER_00004 requirement

The file name of the compiler abstraction shall be ‘Compiler.h’.

SWS_COMPILER_00005 requirement

If a compiler does not require or support the usage of special keywords; the corresponding macros specified by this specification shall be provided as empty def initions or definitions without effect. Example: #define FUNC(type, memclass) type /* not required for DIABDATA */

SWS_COMPILER_00006 requirement

Macro name: P2VAR Syntax: #define P2VAR(ptrtype, memclass, ptrclass) Parameters (in): ptrtype type of the referenced variable memclass classification of the pointer’s variable itself ptrclass defines the classification of the pointer’s distance Pa rameters (out): none -- Return value: none -- Description: The compiler abstraction shall define the P2VAR macro for the declaration and definition of pointers in RAM, pointing to variables. The pointer itself is modifiable (e.g. ExamplePtr++). The poin ter’s target is modifiable (e.g. *ExamplePtr = 5). Caveats: -- Configuration: --

SWS_COMPILER_00010 requirement

The compiler abstraction shall define a symbol for the target compiler according to the following naming conventio n: _<COMPILERNAME>_C_<PLATFORMNAME>_ Note 1: In order to avoid incompatibilities and/ or inconsistencies , t he compiler symbol definitions are not allowed to contain any value behind the symbol. Note 2 : These defines can be used to switch between differ ent implementations for different compilers, e.g.  inline assembler fragments in drivers  special pragmas for memory alignment control  localization of function calls  adaptions to memory models

SWS_COMPILER_00013 requirement

Macro name: P2CONST Syntax: #define P2CONST(ptrtype, memclass, ptrclass) Parameters (in): ptrtype type of the referenced constant memclass classification of the pointer’s va riable itself ptrclass defines the classification of the pointer’s distance Parameters (out): none -- Return value: none -- Description: The compiler abstraction shall define the P2CONST macro for the declaration and definition of pointers in RAM poin ting to constants The pointer itself is modifiable (e.g. ExamplePtr++). The pointer’s target is not modifiable (read only). Caveats: -- Configuration: --

SWS_COMPILER_00023 requirement

Macro name: CONST Syntax: #define CONST(consttype, memclass) Parameters (in): consttype type of the constant memclass classif ication of the constant itself Parameters (out): none -- Return value: none -- Description: The compiler abstraction shall define the CONST macro for the declaration and definition of constants. Caveats: -- Configuration: --

SWS_COMPILER_00026 requirement

Macro name: VAR Sy ntax: #define VAR(vartype, memclass) Parameters (in): v artype type of the variable m emclass classification of the variable itself Parameters (out): N one -- Return value: N one -- Description: The compiler abstraction shall define the VAR macro for the declaration and definition of variables. Caveats: -- Configuration: --

SWS_COMPILER_00030 requirement

“Compiler.h” shall provide information of the supported compiler vendor and the applicable compiler version.

SWS_COMPILER_00031 requirement

Macro name: CONSTP2VAR Syntax: #define CONSTP2VAR (ptrtype, memclass, ptrclass) Parameters (in): p trtype type of the referenced variable m emclass classification of the pointer’s constant itself p trclass defines the classification of the pointer’s d istance Parameters (out): N one -- Return value: N one -- Description: The compiler abstraction shall define the CONSTP2VAR macro for the declaration and definition of constant pointers accessing variables. The pointer itself is not modifiable (fix addre ss). The pointer’s target is modifiable (e.g. *ExamplePtr = 18). Caveats: -- Configuration: --

SWS_COMPILER_00032 requirement

Macro name: CONSTP2CONST Syntax: #define CONSTP2CONST(ptrtype, me mclass, ptrclass) Parameters (in): ptrtype type of the referenced constant memclass classification of the pointer’s constant itself ptrclass defines the classification of the pointer’s distance Parameters (out): none -- Return value: none -- Descri ption: The compiler abstraction shall define the CONSTP2CONST macro for the declaration and definition of constant pointers accessing constants. The pointer itself is not modifiable (fix address). The pointer’s target is not modifiable (read only). Cavea ts: -- Configuration: --

SWS_COMPILER_00036 requirement

C forbids the use of the far/near - keywords on function local variables (auto - variables). For thi s reason when using the macros below to allocate a pointer on stack, the memclass - parameter shall be set to AUTOMATIC.

SWS_COMPILER_00039 requirement

Macro name: P2FUNC Syntax: #def ine P2FUNC(rettype, ptrclass, fctname) Parameters (in): rettype return type of the function ptrclass defines the classification of the pointer’s distance fctname function name respectively name of the defined type Parameters (out): N one -- Return v alue: N one -- Description: The compiler abstraction shall define the P2FUNC macro for the type definition of pointers to functions. Caveats: -- Configuration: --

SWS_COMPILER_00040 requirement

Each AUTOSAR software module and application software component shall support the distinction of at least the following different memory classes and pointer classes.

SWS_COMPILER_00041 requirement

Each AUTOSAR software module and application software component shall wrap declaration and definition of code, variables, constants an d pointer types using the following keyword macros:

SWS_COMPILER_00042 requirement

The file Compiler.h is specific for each build scenario. Therefore there is no standardized configuration interface specified.

SWS_COMPILER_00046 requirement

Define: AUTOMATIC Range: “empty” -- Description: The memory class AUTOMATIC shall be provided as empty definition, used for the declaration of local pointers. Caveats: SWS_COMPILER_00040

SWS_COMPILER_00047 requirement

The Compiler.h header file shall protect itself against multiple inclusions. F or instance: #ifndef COMPILER_H #define COMPILER_H /* implementation of Compiler.h */ ... #endif /* COMPILER_H */ T here may be only comments outside of the ifndef - endif bracket.

SWS_COMPILER_00048 requirement

The SWS Compiler Abstraction is applicable for each AUTOSAR basic software module and application software components. Therefore, the implementation of the memory class (memclass) and pointer class (ptrclass) macro parameters (see SWS_COMPILER_00040 ) shall fulfill the implementation and configuration specific needs of each software module in a specific build scenario.

SWS_COMPILER_00050 requirement

It is allowed to extend the Compiler Abstraction header with vendor specific extensions. Vendor specific extended elements shall contain the AUTOSAR Vendor ID in the name.

SWS_COMPILER_00051 requirement

Define: NULL_PTR Range: void pointer ((void *)0) Description: The compiler abstraction shall provide the NULL_PTR define with a void pointer to zero definition. Caveats: SWS_COMPILER_00040

SWS_COMPILER_00053 requirement

The file Compiler.h shall contain the definitions and macros specified in chapter 7.1.5 . Those are fix for one specific compiler and platform.

SWS_COMPILER_00054 requirement

Module specific extended elements shall contain the module abbreviation of the BSW module in the name. Application software component specific extended elements shall contain the Software Component Type ’s name.

SWS_COMPILER_00055 requirement

The file Compiler_Cfg.h shall contain the module/component specific parameters ( ptrclass and memclass ) that are passed to the macros defined in Compiler.h. See SWS_COMPILER_00040 for memory types and required syntax.

SWS_COMPILER_00057 requirement

Define: INLINE Range: inline/”empty” -- Description: The compiler abstraction shall provide the INLINE define for abstraction of the keyword inline. Caveats: SWS_ COMPILER_00040

SWS_COMPILER_00058 requirement

In the parameter list of this macro no further Compiler Abstraction m acros shall be nested. Instead, use a previously defined type as return type or use FUNC_P2CONST/FUNC_P2VAR.

SWS_COMPILER_00059 requirement

Define: TYPEDEF Range: “empty” -- Description: The memory class TYPEDEF shall be provided as empty definition. This memory class shall be used within type definitions, where no memory qualifier can be specified. Th is can be necessary for defining pointer types, with e.g. P2VAR, where the macros require two parameters. First parameter can be specified in the type definition (distance to the memory location referenced by the pointer), but the second one (memory alloca tion of the pointer itself) cannot be defined at this time. Hence, memory class TYPEDEF shall be applied. Caveats: SWS_COMPILER_00040

SWS_COMPILER_00060 requirement

Define: LOCAL_INLINE Range: static inline/”empty” -- Description: The compiler abstraction shall provide the LOCAL_INLINE define for abstraction of the keyword inline in functions wi th “static” scope. Caveats: Different compilers may require a different sequence of the keywords “static” and “inline” if this is supported at all.

SWS_COMPILER_00061 requirement

Macro name: FUNC_P2CONST Syntax: #define FUNC_P2CONST(rettype, ptrclass, memclass) Parameters (in): ret t ype return type of the function ptrclass defines the classification of the pointer’s distance memclas s classification of the function itself Parameters (out): none -- Return value: none -- Description: The compiler abstraction shall define the FUNC_P2CONST macro for the declaration and definition of functions returning a pointer to a constant. This sha ll ensure the correct syntax of function declarations as required by a specific compiler. Caveats: -- Configuration: --

SWS_COMPILER_00062 requirement

In the parameter list of the FUNC_P2CONST, no further Compiler Abstraction macros shall be nested.

SWS_COMPILER_00063 requirement

Macro name: FUNC_P2 VAR Syntax: #define FUNC_P2VAR(rettype, ptrclass, memclass) Parameters (in): ret t ype return type of the function ptrclass defines the classification of the pointer’s distance memclass classification of the function itself Parameters (out): none -- Return value: none -- Description: The compiler abstraction shall define the FUNC_P2VAR macro for the declaration and definition of functions returning a pointer to a variable. This shall ensure the correct syntax of function declarations as required by a specific compiler. Caveats: -- Configuration: --

SWS_COMPILER_00064 requirement

In the parameter list of the macro FUNC_P2VAR, no further Compiler Abstraction macros shall be nested.

SWS_COMPILER_00065 requirement

Macro name: CONSTP2FUNC Syntax: #define CONSTP2FUNC(rettype, ptrclass, fctname) Parameters (in): rettype return type of the function ptrclass defines t he classification of the pointer’s distance fctname function name respectively name of the defined type Parameters (out): N one -- Return value: N one -- Description: The compiler abstraction shall define the CONSTP2FUNC macro for the type definition o f constant pointers to functions. Caveats: -- Configuration: --

SWS_COMPILER_00999 requirement

Thes e requirements are not applicable to this specification.