util: Add ATTRIBUTE_OPTIMIZE(flags)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30622>
(cherry picked from commit b3430a7bb8)
This commit is contained in:
Matt Turner 2024-08-12 11:45:44 -04:00 committed by Eric Engestrom
parent f6b2fe8455
commit 7335dbb895
3 changed files with 8 additions and 1 deletions

View file

@ -404,7 +404,7 @@
"description": "util: Add ATTRIBUTE_OPTIMIZE(flags)",
"nominated": false,
"nomination_type": 3,
"resolution": 4,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

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

View file

@ -240,6 +240,12 @@ do { \
# endif
#endif
#ifdef HAVE_FUNC_ATTRIBUTE_OPTIMIZE
#define ATTRIBUTE_OPTIMIZE(flags) __attribute__((__optimize__((flags))))
#else
#define ATTRIBUTE_OPTIMIZE(flags)
#endif
#ifdef __cplusplus
/**
* Macro function that evaluates to true if T is a trivially