33#ifndef _AVR_INTERRUPT_H_
34#define _AVR_INTERRUPT_H_
38#if !defined(__DOXYGEN__) && !defined(__STRINGIFY)
40#define __STRINGIFY(x) #x
75# define sei() __asm__ __volatile__ ("sei" ::: "memory")
77# define sei() __asm__ __volatile__ ("sei ; [[len=1]]" ::: "memory")
93# define cli() __asm__ __volatile__ ("cli" ::: "memory")
95# define cli() __asm__ __volatile__ ("cli ; [[len=1]]" ::: "memory")
102#if defined(__DOXYGEN__)
126# define ISR(vector, [attributes])
129#if defined (__clang__)
130# define __INTR_ATTRS __used__
131#elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
132# define __INTR_ATTRS __used__, __externally_visible__
134# define __INTR_ATTRS __used__
138# define ISR(vector, ...) \
139 extern "C" void vector (void) __attribute__ ((__signal__,__INTR_ATTRS)) __VA_ARGS__; \
142# define ISR(vector, ...) \
143 void vector (void) __attribute__ ((__signal__,__INTR_ATTRS)) __VA_ARGS__; \
149#if defined(__DOXYGEN__)
185# define ISR_N(vector_num, [attributes])
188#if defined __HAVE_SIGNAL_N__
191#define ISR_N(N, ...) \
192 __attribute__((__signal__(N))) __VA_ARGS__
196#define __ISR_N_error2(L) \
197 __attribute__((__used__,__error__( \
198 "ISR_N not supported by this version of the compiler"))) \
199 int AVR_LibC_show_error##L (int x) \
201 __asm (".error \"ISR_N not supported by this version of the compiler\"");\
202 return x ? 1 : x * AVR_LibC_show_error##L (x - 1); \
204#define __ISR_N_error1(L) __ISR_N_error2(L)
205#define ISR_N(...) __ISR_N_error1(__LINE__)
209#if defined(__DOXYGEN__)
219# define SIGNAL(vector)
223# define SIGNAL(vector) \
224 extern "C" void vector(void) __attribute__ ((__signal__, __INTR_ATTRS)); \
227# define SIGNAL(vector) \
228 void vector (void) __attribute__ ((__signal__, __INTR_ATTRS)); \
234#if defined(__DOXYGEN__)
243# define EMPTY_INTERRUPT(vector)
247# define EMPTY_INTERRUPT(vector) \
248 extern "C" void vector(void) __attribute__ ((__signal__,__naked__,__INTR_ATTRS)); \
249 void vector (void) { __asm__ __volatile__ ("reti" ::: "memory"); }
251# define EMPTY_INTERRUPT(vector) \
252 void vector (void) __attribute__ ((__signal__,__naked__,__INTR_ATTRS)); \
253 void vector (void) { __asm__ __volatile__ ("reti" ::: "memory"); }
258#if defined(__DOXYGEN__)
303# define ISR_ALIAS(vector, target_vector)
307# define ISR_ALIAS(vector, tgt) extern "C" void vector (void) \
308 __attribute__((__signal__, __naked__, __INTR_ATTRS)); \
309 void vector (void) { __asm__ __volatile__ ("%~jmp " __STRINGIFY(tgt) ::); }
311# define ISR_ALIAS(vector, tgt) void vector (void) \
312 __attribute__((__signal__, __naked__, __INTR_ATTRS)); \
313 void vector (void) { __asm__ __volatile__ ("%~jmp " __STRINGIFY(tgt) ::); }
331# define reti() __asm__ __volatile__ ("reti" ::: "memory")
333#if defined(__DOXYGEN__)
346# define BADISR_vect __vector_default
351#if defined(__DOXYGEN__)
455# define ISR_ALIASOF(target_vector)
460# ifdef __HAVE_SIGNAL_N__
464# define ISR_NOBLOCK __attribute__((__noblock__))
466# define ISR_NOBLOCK __attribute__((__interrupt__))
469# define ISR_NAKED __attribute__((__naked__))
471#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || (__GNUC__ >= 5)
472# define ISR_FLATTEN __attribute__((__flatten__))
477#if defined (__has_attribute)
478#if __has_attribute (__no_icf__)
479# define ISR_NOICF __attribute__((__no_icf__))
484#if __has_attribute (__no_gccisr__)
485# define ISR_NOGCCISR __attribute__((__no_gccisr__))
491# define ISR_ALIASOF(v) __attribute__((__alias__(__STRINGIFY(v))))