diff --git a/meson.build b/meson.build index fb1dea3ab80..d7ed229b14a 100644 --- a/meson.build +++ b/meson.build @@ -1033,7 +1033,7 @@ endforeach _attributes = [ 'const', 'flatten', 'malloc', 'pure', 'unused', 'warn_unused_result', 'weak', 'format', 'packed', 'returns_nonnull', 'alias', 'noreturn', - 'optimize', + 'optimize', 'cold', ] foreach a : cc.get_supported_function_attributes(_attributes) pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper()) diff --git a/src/util/macros.h b/src/util/macros.h index e914fa2c6a7..d9487688900 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -173,6 +173,12 @@ do { \ #define ATTRIBUTE_CONST #endif +#if defined(HAVE_FUNC_ATTRIBUTE_COLD) +#define ATTRIBUTE_COLD __attribute__((__cold__)) +#else +#define ATTRIBUTE_COLD +#endif + #ifdef HAVE_FUNC_ATTRIBUTE_FLATTEN #define FLATTEN __attribute__((__flatten__)) #else