From c745df94a182b8a569cb833ecfbe8da33bf01f98 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 9 Nov 2023 14:34:21 -0500 Subject: config: New attr_noinline and attr_cold macros --- src/config.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/config.h') diff --git a/src/config.h b/src/config.h index 3100cec..b95abaa 100644 --- a/src/config.h +++ b/src/config.h @@ -184,6 +184,24 @@ # define fallthru ((void)0) #endif +/** + * Hint to avoid inlining a function. + */ +#if __has_attribute(noinline) +# define attr_noinline __attribute__((noinline)) +#else +# define attr_noinline +#endif + +/** + * Hint that a function is unlikely to be called. + */ +#if __has_attribute(cold) +# define attr_cold attr_noinline __attribute__((cold)) +#else +# define attr_cold attr_noinline +#endif + /** * Adds compiler warnings for bad printf()-style function calls, if supported. */ -- cgit v1.2.3