33#ifndef _AVR_INTERRUPT_H_
34#define _AVR_INTERRUPT_H_
38#if !defined(__DOXYGEN__) && !defined(__STRINGIFY)
40#define __STRINGIFY(x) #x
74# define sei() __asm__ __volatile__ ("sei" ::: "memory")
88# define cli() __asm__ __volatile__ ("cli" ::: "memory")
94#if defined(__DOXYGEN__)
118# define ISR(vector, [attributes])
121#if defined (__clang__)
122# define __INTR_ATTRS __used__
123#elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
124# define __INTR_ATTRS __used__, __externally_visible__
126# define __INTR_ATTRS __used__
130# define ISR(vector, ...) \
131 extern "C" void vector (void) __attribute__ ((__signal__,__INTR_ATTRS)) __VA_ARGS__; \
134# define ISR(vector, ...) \
135 void vector (void) __attribute__ ((__signal__,__INTR_ATTRS)) __VA_ARGS__; \
141#if defined(__DOXYGEN__)
177# define ISR_N(vector_num, [attributes])
180#if defined __HAVE_SIGNAL_N__
183#define ISR_N(N, ...) \
184 __attribute__((__signal__(N))) __VA_ARGS__
188#define __ISR_N_error2(L) \
189 __attribute__((__used__,__error__( \
190 "ISR_N not supported by this version of the compiler"))) \
191 int AVR_LibC_show_error##L (int x) \
193 __asm (".error \"ISR_N not supported by this version of the compiler\"");\
194 return x ? 1 : x * AVR_LibC_show_error##L (x - 1); \
196#define __ISR_N_error1(L) __ISR_N_error2(L)
197#define ISR_N(...) __ISR_N_error1(__LINE__)
201#if defined(__DOXYGEN__)
211# define SIGNAL(vector)
215# define SIGNAL(vector) \
216 extern "C" void vector(void) __attribute__ ((__signal__, __INTR_ATTRS)); \
219# define SIGNAL(vector) \
220 void vector (void) __attribute__ ((__signal__, __INTR_ATTRS)); \
226#if defined(__DOXYGEN__)
235# define EMPTY_INTERRUPT(vector)
239# define EMPTY_INTERRUPT(vector) \
240 extern "C" void vector(void) __attribute__ ((__signal__,__naked__,__INTR_ATTRS)); \
241 void vector (void) { __asm__ __volatile__ ("reti" ::: "memory"); }
243# define EMPTY_INTERRUPT(vector) \
244 void vector (void) __attribute__ ((__signal__,__naked__,__INTR_ATTRS)); \
245 void vector (void) { __asm__ __volatile__ ("reti" ::: "memory"); }
250#if defined(__DOXYGEN__)
297# define ISR_ALIAS(vector, target_vector)
301# define ISR_ALIAS(vector, tgt) extern "C" void vector (void) \
302 __attribute__((__signal__, __naked__, __INTR_ATTRS)); \
303 void vector (void) { __asm__ __volatile__ ("%~jmp " __STRINGIFY(tgt) ::); }
305# define ISR_ALIAS(vector, tgt) void vector (void) \
306 __attribute__((__signal__, __naked__, __INTR_ATTRS)); \
307 void vector (void) { __asm__ __volatile__ ("%~jmp " __STRINGIFY(tgt) ::); }
325# define reti() __asm__ __volatile__ ("reti" ::: "memory")
327#if defined(__DOXYGEN__)
340# define BADISR_vect __vector_default
345#if defined(__DOXYGEN__)
451# define ISR_ALIASOF(target_vector)
456# ifdef __HAVE_SIGNAL_N__
460# define ISR_NOBLOCK __attribute__((__noblock__))
462# define ISR_NOBLOCK __attribute__((__interrupt__))
465# define ISR_NAKED __attribute__((__naked__))
467#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || (__GNUC__ >= 5)
468# define ISR_FLATTEN __attribute__((__flatten__))
473#if defined (__has_attribute)
474#if __has_attribute (__no_icf__)
475# define ISR_NOICF __attribute__((__no_icf__))
480#if __has_attribute (__no_gccisr__)
481# define ISR_NOGCCISR __attribute__((__no_gccisr__))
487# define ISR_ALIASOF(v) __attribute__((__alias__(__STRINGIFY(v))))