[PATCH v2 01/15] cdefs: Add mechanism to add attributes to __always_inline functions
Christoph Müllner
christoph.muellner@vrull.eu
Mon May 27 11:18:46 GMT 2024
Contrary to LLVM, GCC does not propagate function attributes accross
inlined functions ("target specific option mismatch"). To overcome this
limiation, this patch introduces a __CODEGEN_ATTRIBUTE macro, which can
be used to add function attributes to __always_inline functions.
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
---
misc/sys/cdefs.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index ab9620bd0d..91dceab1f2 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -587,15 +587,19 @@
#endif
/* Forces a function to be always inlined. */
+# ifndef __CODEGEN_ATTRIBUTES
+# define __CODEGEN_ATTRIBUTES
+# endif
#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__)
/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
it conflicts with this definition. Therefore undefine it first to
allow either header to be included first. */
# undef __always_inline
-# define __always_inline __inline __attribute__ ((__always_inline__))
+# define __always_inline __inline __attribute__ ((__always_inline__)) \
+ __CODEGEN_ATTRIBUTES
#else
# undef __always_inline
-# define __always_inline __inline
+# define __always_inline __inline __CODEGEN_ATTRIBUTES
#endif
/* Associate error messages with the source location of the call site rather
--
2.45.1
More information about the Libc-alpha
mailing list