From a2b0ff98a0d44259cc5f6bd7d3a3676ae9f8996a Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Mon, 23 Dec 2024 05:11:58 +0800 Subject: include/sys/cdefs.h: Add __attribute_optimization_barrier__ Add __attribute_optimization_barrier__ to disable inlining and cloning on a function. For Clang, expand it to __attribute__ ((optnone)) Otherwise, expand it to __attribute__ ((noinline, clone)) Co-Authored-By: H.J. Lu Reviewed-by: Sam James --- include/sys/cdefs.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h index b84ad34a70..a676f75f62 100644 --- a/include/sys/cdefs.h +++ b/include/sys/cdefs.h @@ -56,4 +56,11 @@ rtld_hidden_proto (__chk_fail) #endif /* !defined _ISOMAC */ +/* Prevents a function from being considered for inlining and cloning. */ +#ifdef __clang__ +# define __attribute_optimization_barrier__ __attribute__ ((optnone)) +#else +# define __attribute_optimization_barrier__ __attribute__ ((noinline, noclone)) +#endif + #endif -- cgit v1.2.3