/*!
* @file     Compiler.h
*
* @version  1.0.0
*
* @brief    This file contains the macros for compiler abstraction
*
* @attention
*
* Project Name      : AUTOSAR MCAL
*
* Platform          : Arm
*
* Autosar Standard  : Classic Platform 4.4.0
*
* Compiled Version  : G32A10xx_MCAL_1_0_0_01-Otc-25
*
* Copyright (C) 2026 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (Geehy Semiconductor Software License Agreement).
*
* The program is only for reference, which is distributed in the hope
* that it will be usefull and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the Geehy Semiconductor Software License Agreement for the governing permissions
* and limitations under the License.
*/

#ifndef COMPILER_H
#define COMPILER_H

#ifdef __cplusplus
extern "C"{
#endif

#include "Compiler_Cfg.h"
#include "CompilerDefinition.h"

/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

/** @defgroup PLATFORM_Driver
  * @brief PLATFORM driver modules
  @{
*/

/** @defgroup PLATFORM_Macros
  @{
*/
/*******************************************************************************
                    VENDOR ID & AUTOSAR VERSION INFO
*******************************************************************************/
/** Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define COMPILER_H_VENDOR_ID                     0x00C1U
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define COMPILER_H_AR_RELEASE_MAJOR_VERSION      0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define COMPILER_H_AR_RELEASE_MINOR_VERSION      0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define COMPILER_H_AR_RELEASE_REVISION_VERSION   0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define COMPILER_H_SW_MAJOR_VERSION              0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define COMPILER_H_SW_MINOR_VERSION              0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define COMPILER_H_SW_PATCH_VERSION              0x00U

/**************************************************************************
                    MACRO DEFINITION
**************************************************************************/
/** The memory class AUTOMATIC is provided as empty definition. Used for the declaration of local pointers. */
#define AUTOMATIC

/**
* The memory class TYPEDEF is provided as empty definition.
* This memory class shall be used within type definitions, where no memory
* qualifier can be specified. This is necessary for defining pointer types
* 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 allocation of the pointer itself) cannot be defined
* at this time. Hence memory class TYPEDEF shall be applied.
*/
#define TYPEDEF

/** Definition for null pointer */
#define NULL_PTR ((void *)0)

/** The VAR macro is used for the declaration and definition of variables. */
#define VAR(vartype, memclass) vartype

/** The CONST macro is used for the declaration and definition of constants. */
#define CONST(consttype, memclass) const consttype

/** The FUNC macro is used for the declaration and definition of functions. */
#define FUNC(rettype, memclass) rettype

/** The P2VAR macro is used for the declaration and definition of pointers in RAM which pointing to variables. */
#define P2VAR(ptrtype, memclass, ptrclass) ptrtype *

/** The P2CONST macro is used for the declaration and definition of pointers in RAM which pointing to constants. */
#define P2CONST(ptrtype, memclass, ptrclass) const ptrtype *

/** The CONSTP2VAR macro is used for the declaration and definition of constant pointers which accessing variables. */
#define CONSTP2VAR(ptrtype, memclass, ptrclass) ptrtype * const

/** The CONSTP2CONST macro is used for the declaration and definition of constant pointers which accessing constants. */
#define CONSTP2CONST(ptrtype, memclass, ptrclass) const ptrtype * const

/** The P2FUNC macro is used for the declaration of pointers to functions. */
#define P2FUNC(rettype, ptrclass, fctname) rettype (*fctname)

/** The CONSTP2FUNC is used for the declaration of const pointers to functions. */
#define CONSTP2FUNC(rettype, ptrclass, fctname) rettype (* const fctname)

/** The FUNC_P2CONST macro is used for the declaration and definition of functions which returning a pointer to a constant. */ 
#define FUNC_P2CONST(rettype, ptrclass, memclass) const ptrclass rettype * memclass

/** The FUNC_P2VAR macro is used for the declaration and definition of functions returning a pointer to a variable. */
#define FUNC_P2VAR(rettype, ptrclass, memclass) ptrclass rettype * memclass

/*******************************************************************************
                            DS5 COMPILER
*******************************************************************************/
#ifdef G32A_C_DS5
    #define INLINE              __inline
    #define LOCAL_INLINE        static __inline
    #define INTERRUPT_FUNC
#endif

/*******************************************************************************
                            HITECH COMPILER
*******************************************************************************/
#ifdef _G32A_C_HITECH_
    #define INLINE              __inline
    #define LOCAL_INLINE        static __inline
    #define INTERRUPT_FUNC      __attribute__((interrupt));
#endif

/*******************************************************************************
                            LINARO COMPILER
*******************************************************************************/
#ifdef G32A_C_LINARO
   #define INLINE              inline __attribute__((always_inline))
   #define LOCAL_INLINE        static inline __attribute__((always_inline))
   #define INTERRUPT_FUNC
#endif

/*******************************************************************************
                            DIAB COMPILER
*******************************************************************************/
#ifdef G32A_C_DIAB
    #define INLINE              __inline__
    #define LOCAL_INLINE        static __inline__
    #define INTERRUPT_FUNC      __interrupt__
#endif

/*******************************************************************************
                            CODEWARRIOR COMPILER
*******************************************************************************/
#ifdef G32A_C_CODEWARRIOR
    #define INLINE              inline
    #define LOCAL_INLINE        static inline
    #define INTERRUPT_FUNC      __declspec(interrupt nowarn)
#endif

/*******************************************************************************
                            GREENHILLS COMPILER
*******************************************************************************/
#ifdef G32A_C_GREENHILLS
    #define INLINE              __inline
    #define LOCAL_INLINE        static __inline
    #define INTERRUPT_FUNC      __interrupt
#endif

/*******************************************************************************
                            IAR COMPILER
*******************************************************************************/
#ifdef G32A_C_IAR
    #define INLINE              inline
    #define LOCAL_INLINE        static inline
    #define INTERRUPT_FUNC
#endif

/*******************************************************************************
                            COSMIC COMPILER
*******************************************************************************/
#ifdef G32A_C_COSMIC
    #define INLINE              @inline
    #define LOCAL_INLINE        static @inline
    #define INTERRUPT_FUNC      @interrupt
#endif

/**@} end of group PLATFORM_Macros */

#ifdef __cplusplus
}
#endif

#endif

/**@} end of group PLATFORM_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */
