__attribute__((interrupt("type"))) function attribute
The GNU style
interrupt attribute instructs the compiler to generate a function in a manner that is suitable for use as an exception handler.
is one of the following:
interrupt attribute affects the code
generation of a function as follows:
- If the function is AAPCS, the stack is realigned to 8 bytes on entry.
For processors that are not based on the M-profile, preserves all processor registers, rather than only the registers that the AAPCS requires to be preserved. Floating-point registers are not preserved.
For processors that are not based on the M-profile, the function returns using an instruction that is architecturally defined as a return from exception.
- No arguments or return values can be used with the functions.
- The functions are incompatible with
In ARMv6-M, ARMv7-M, and ARMv8-M, the architectural exception handling
mechanism preserves all processor registers, and a standard function return can cause an
exception return. Therefore, specifying the
attribute does not affect the behavior of the compiled output. However, ARM recommends
interrupt attribute on exception handlers for
clarity and easier software porting.
For architectures that support A32 and T32 instructions, functions specified with the
interruptattribute compile to A32 or T32 code depending on whether the compile option specifies ARM or Thumb.
For Thumb only architectures, for example ARMv6-M, functions specified with the
interruptattribute compile to T32 code.
interruptattribute is not available for A64 code.