util/macros: Add ATTRIBUTE_COLD

Reviewed-by: Mary Guillemard <mary@mary.zone>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37475>
This commit is contained in:
Mel Henning 2025-09-19 19:36:39 -04:00 committed by Marge Bot
parent 7790f98487
commit e7a62d5eff
2 changed files with 7 additions and 1 deletions

View file

@ -1033,7 +1033,7 @@ endforeach
_attributes = [ _attributes = [
'const', 'flatten', 'malloc', 'pure', 'unused', 'warn_unused_result', 'const', 'flatten', 'malloc', 'pure', 'unused', 'warn_unused_result',
'weak', 'format', 'packed', 'returns_nonnull', 'alias', 'noreturn', 'weak', 'format', 'packed', 'returns_nonnull', 'alias', 'noreturn',
'optimize', 'optimize', 'cold',
] ]
foreach a : cc.get_supported_function_attributes(_attributes) foreach a : cc.get_supported_function_attributes(_attributes)
pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper()) pre_args += '-DHAVE_FUNC_ATTRIBUTE_@0@'.format(a.to_upper())

View file

@ -173,6 +173,12 @@ do { \
#define ATTRIBUTE_CONST #define ATTRIBUTE_CONST
#endif #endif
#if defined(HAVE_FUNC_ATTRIBUTE_COLD)
#define ATTRIBUTE_COLD __attribute__((__cold__))
#else
#define ATTRIBUTE_COLD
#endif
#ifdef HAVE_FUNC_ATTRIBUTE_FLATTEN #ifdef HAVE_FUNC_ATTRIBUTE_FLATTEN
#define FLATTEN __attribute__((__flatten__)) #define FLATTEN __attribute__((__flatten__))
#else #else