summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2015-05-15 19:51:05 +0000
committerpfg <pfg@FreeBSD.org>2015-05-15 19:51:05 +0000
commitdb0c7e7759b9b9c72247c978eee6b8d94c8bca42 (patch)
tree72762a657f142da2a7758a151654d17cafd2d2d7 /sys
parent7eb6de12d728194b90cfcb04fc365d9e50c65ac0 (diff)
downloadFreeBSD-src-db0c7e7759b9b9c72247c978eee6b8d94c8bca42.zip
FreeBSD-src-db0c7e7759b9b9c72247c978eee6b8d94c8bca42.tar.gz
Break apart the gnu_inline attribute and use "artificial" if available.
In general it is bad practice to use the gnu_inline attribute but we will need it in special cases like FORTIFY_SOURCE. In this specific case it is also useful to have the "artificial" attribute: "This attribute is useful for small inline wrappers which if possible should appear during debugging as a unit, depending on the debug info format it will either mean marking the function as artificial or using the caller location for all instructions within the inlined body." This attribute appears to be currently implemented only in GCC. Use it only in conjuntion with gnu_inline in the cases where it is available, which is similar in spirit in how it's used in glibc.
Diffstat (limited to 'sys')
-rw-r--r--sys/sys/cdefs.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index f46efcc..c7a7e4b 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -375,10 +375,8 @@
#endif
#if __GNUC_PREREQ__(4, 1)
-#define __gnu_inline __attribute__((__gnu_inline__))
#define __returns_twice __attribute__((__returns_twice__))
#else
-#define __gnu_inline
#define __returns_twice
#endif
@@ -538,6 +536,21 @@
__attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
#endif
+/*
+ * FORTIFY_SOURCE, and perhaps other compiler-specific features, require
+ * the use of non-standard inlining. In general we should try to avoid
+ * using these but GCC-compatible compilers tend to support the extensions
+ * well enough to use them in limited cases.
+ */
+#if __GNUC_PREREQ__(4, 1)
+#if __has_attribute(artificial) || __GNUC_PREREQ__(4, 3)
+#define __gnu_inline __attribute__((__gnu_inline__, __artificial__))
+#else
+#define __gnu_inline __attribute__((__gnu_inline__))
+#else
+#define __gnu_inline
+#endif
+
/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \
defined(__GNUC__) && !defined(__INTEL_COMPILER)
OpenPOWER on IntegriCloud