Compiler Control

group NMSIS_Core_CompilerControl

Compiler agnostic #define symbols for generic c/c++ source code.

The NMSIS-Core provides the header file nmsis_compiler.h with consistent #define symbols for generate C or C++ source files that should be compiler agnostic. Each NMSIS compliant compiler should support the functionality described in this section.

The header file nmsis_compiler.h is also included by each Device Header File <device.h> so that these definitions are available.

Defines

__has_builtin(x) (0)
__ASM __asm

Pass information from the compiler to the assembler.

__INLINE inline

Recommend that function should be inlined by the compiler.

__STATIC_INLINE static inline

Define a static function that may be inlined by the compiler.

__STATIC_FORCEINLINE __attribute__((always_inline)) static inline

Define a static function that should be always inlined by the compiler.

__NO_RETURN __attribute__((__noreturn__))

Inform the compiler that a function does not return.

__USED __attribute__((used))

Inform that a variable shall be retained in executable image.

__WEAK __attribute__((weak))

restrict pointer qualifier to enable additional optimizations.

__VECTOR_SIZE(x) __attribute__((vector_size(x)))

specified the vector size of the variable, measured in bytes

__PACKED __attribute__((packed, aligned(1)))

Request smallest possible alignment.

__PACKED_STRUCT struct __attribute__((packed, aligned(1)))

Request smallest possible alignment for a structure.

__PACKED_UNION union __attribute__((packed, aligned(1)))

Request smallest possible alignment for a union.

__UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))

Pointer for unaligned write of a uint16_t variable.

__UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)

Pointer for unaligned read of a uint16_t variable.

__UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))

Pointer for unaligned write of a uint32_t variable.

__UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)

Pointer for unaligned read of a uint32_t variable.

__ALIGNED(x) __attribute__((aligned(x)))

Minimum x bytes alignment for a variable.

__RESTRICT __restrict

restrict pointer qualifier to enable additional optimizations.

__COMPILER_BARRIER() __ASM volatile("":::"memory")

Barrier to prevent compiler from reordering instructions.

__USUALLY(exp) __builtin_expect((exp), 1)

provide the compiler with branch prediction information, the branch is usually true

__RARELY(exp) __builtin_expect((exp), 0)

provide the compiler with branch prediction information, the branch is rarely true

__INTERRUPT __attribute__((interrupt))

Use this attribute to indicate that the specified function is an interrupt handler run in Machine Mode.

__MACHINE_INTERRUPT __attribute__ ((interrupt ("machine")))

Use this attribute to indicate that the specified function is an interrupt handler run in Machine Mode.

__SUPERVISOR_INTERRUPT __attribute__ ((interrupt ("supervisor")))

Use this attribute to indicate that the specified function is an interrupt handler run in Supervisor Mode.

__USER_INTERRUPT __attribute__ ((interrupt ("user")))

Use this attribute to indicate that the specified function is an interrupt handler run in User Mode.

Variables

__PACKED_STRUCT T_UINT16_WRITE

Packed struct for unaligned uint16_t write access.

__PACKED_STRUCT T_UINT16_READ

Packed struct for unaligned uint16_t read access.

__PACKED_STRUCT T_UINT32_WRITE

Packed struct for unaligned uint32_t write access.

__PACKED_STRUCT T_UINT32_READ

Packed struct for unaligned uint32_t read access.