diff options
Diffstat (limited to 'include/my_compiler.h')
-rw-r--r-- | include/my_compiler.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/my_compiler.h b/include/my_compiler.h index 833eedbf7c4..fbb4b959e8d 100644 --- a/include/my_compiler.h +++ b/include/my_compiler.h @@ -146,6 +146,29 @@ struct my_aligned_storage #define MY_ALIGNED(size) #endif +#ifdef __GNUC__ +# define ATTRIBUTE_NORETURN __attribute__((noreturn)) +# if MY_GNUC_PREREQ(4,3) +/** Starting with GCC 4.3, the "cold" attribute is used to inform the +compiler that a function is unlikely executed. The function is +optimized for size rather than speed and on many targets it is placed +into special subsection of the text section so all cold functions +appears close together improving code locality of non-cold parts of +program. The paths leading to call of cold functions within code are +marked as unlikely by the branch prediction mechanism. optimize a +rarely invoked function for size instead for speed. */ +# define ATTRIBUTE_COLD __attribute__((cold)) +# endif +#elif defined _WIN32 +# define ATTRIBUTE_NORETURN __declspec(noreturn) +#else +# define ATTRIBUTE_NORETURN /* empty */ +#endif + +#ifndef ATTRIBUTE_COLD +# define ATTRIBUTE_COLD /* empty */ +#endif + #include <my_attribute.h> #endif /* MY_COMPILER_INCLUDED */ |