W3cubDocs

/GCC 9

6.33.26 RISC-V Function Attributes

These function attributes are supported by the RISC-V back end:

naked

This attribute allows the compiler to construct the requisite function declaration, while allowing the body of the function to be assembly code. The specified function will not have prologue/epilogue sequences generated by the compiler. Only basic asm statements can safely be included in naked functions (see Basic Asm). While using extended asm or a mixture of basic asm and C code may appear to work, they cannot be depended upon to work reliably and are not supported.

interrupt

Use this attribute to indicate that the specified function is an interrupt handler. The compiler generates function entry and exit sequences suitable for use in an interrupt handler when this attribute is present.

You can specify the kind of interrupt to be handled by adding an optional parameter to the interrupt attribute like this:

void f (void) __attribute__ ((interrupt ("user")));

Permissible values for this parameter are user, supervisor, and machine. If there is no parameter, then it defaults to machine.

© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/RISC_002dV-Function-Attributes.html