About Social Code
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMel Henning <mhenning@darkrefraction.com>2025-09-19 19:36:39 -0400
committerMarge Bot <marge-bot@fdo.invalid>2025-09-26 19:40:45 +0000
commite7a62d5effd3fb5012800bb98874537ab75c9c0c (patch)
tree794ec7872f21ef586f207fc6b36622a731aa14c1
parent7790f98487c626181ddabe036b4e35aaf3bfc7e2 (diff)
util/macros: Add ATTRIBUTE_COLD
Reviewed-by: Mary Guillemard <mary@mary.zone> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37475>
-rw-r--r--meson.build2
-rw-r--r--src/util/macros.h6
2 files changed, 7 insertions, 1 deletions
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