This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __MATH_INLINE - __extern_inline or __extern_always_inline?


On Thu, Apr 12, 2012 at 01:21:22PM -0700, Roland McGrath wrote:
> > commit cd205654 changed the definition of __MATH_INLINE from 
> > __extern_inline to __extern_always_inline - but only on x86-64.
> 
> As I mentioned earlier, the current definition of __extern_always_inline is
> inappropriate for pretty much any use except for _FORTIFY_SOURCE wrappers.
> Despite the name, it also includes __attribute__((artificial)), which
> affects error messages and DWARF generation.  I don't think we want that on
> normal miscellaneous inlines.
> 
> Given the nonobviousness of this, I think it would be appropriate to change
> the macros so that __extern_always_inline is just what it sounds like and
> we have a different macro for the _FORTIFY_SOURCE cases where we also want
> the artificial attribute.

Hmm, this was introduced here:
http://sources.redhat.com/ml/libc-hacker/2007-10/msg00001.html

Two approaches come to mind, the first one would be to define e.g.
__fortify_function macro, which would contain __extern_always_inline
and __attribute__((artificial), and then use that __fortify_function
macro where appropriate in place of __extern_always_inline.  Or, just
define __attribute_artificial__:

--- libc/misc/sys/cdefs.h.mp	2012-04-15 13:32:42.577179773 +0200
+++ libc/misc/sys/cdefs.h	2012-04-15 13:59:38.727694078 +0200
@@ -309,25 +309,24 @@
 # define __always_inline __inline
 #endif
 
+/* This tells the debugger to not step through the inlined instructions.  */
+#if __GNUC_PREREQ (4,3)
+# define __attribute_artificial__ __attribute__ ((__artificial__))
+#else
+# define __attribute_artificial__ /* Ignore */
+#endif
+
 /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
    inline semantics, unless -fgnu89-inline is used.  */
 #if !defined __cplusplus || __GNUC_PREREQ (4,3)
 # if defined __GNUC_STDC_INLINE__ || defined __cplusplus
 #  define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
-#  if __GNUC_PREREQ (4,3)
-#   define __extern_always_inline \
-  extern __always_inline __attribute__ ((__gnu_inline__, __artificial__))
-#  else
-#   define __extern_always_inline \
+#  define __extern_always_inline \
   extern __always_inline __attribute__ ((__gnu_inline__))
 #  endif
 # else
 #  define __extern_inline extern __inline
-#  if __GNUC_PREREQ (4,3)
-#   define __extern_always_inline \
-  extern __always_inline __attribute__ ((__artificial__))
-#  else
-#   define __extern_always_inline extern __always_inline
+#  define __extern_always_inline extern __always_inline
 #  endif
 # endif
 #endif

and then add the __attribute_artificial__ macro after __extern_always_inline
where it ought to be.  I probably like the second approach more.

	Marek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]