Blame m4/extern-inline.m4

Packit 8f70b4
dnl 'extern inline' a la ISO C99.
Packit 8f70b4
Packit 8f70b4
dnl Copyright 2012-2018 Free Software Foundation, Inc.
Packit 8f70b4
dnl This file is free software; the Free Software Foundation
Packit 8f70b4
dnl gives unlimited permission to copy and/or distribute it,
Packit 8f70b4
dnl with or without modifications, as long as this notice is preserved.
Packit 8f70b4
Packit 8f70b4
AC_DEFUN([gl_EXTERN_INLINE],
Packit 8f70b4
[
Packit 8f70b4
  AH_VERBATIM([extern_inline],
Packit 8f70b4
[/* Please see the Gnulib manual for how to use these macros.
Packit 8f70b4
Packit 8f70b4
   Suppress extern inline with HP-UX cc, as it appears to be broken; see
Packit 8f70b4
   <https://lists.gnu.org/r/bug-texinfo/2013-02/msg00030.html>.
Packit 8f70b4
Packit 8f70b4
   Suppress extern inline with Sun C in standards-conformance mode, as it
Packit 8f70b4
   mishandles inline functions that call each other.  E.g., for 'inline void f
Packit 8f70b4
   (void) { } inline void g (void) { f (); }', c99 incorrectly complains
Packit 8f70b4
   'reference to static identifier "f" in extern inline function'.
Packit 8f70b4
   This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16.
Packit 8f70b4
Packit 8f70b4
   Suppress extern inline (with or without __attribute__ ((__gnu_inline__)))
Packit 8f70b4
   on configurations that mistakenly use 'static inline' to implement
Packit 8f70b4
   functions or macros in standard C headers like <ctype.h>.  For example,
Packit 8f70b4
   if isdigit is mistakenly implemented via a static inline function,
Packit 8f70b4
   a program containing an extern inline function that calls isdigit
Packit 8f70b4
   may not work since the C standard prohibits extern inline functions
Packit 8f70b4
   from calling static functions.  This bug is known to occur on:
Packit 8f70b4
Packit 8f70b4
     OS X 10.8 and earlier; see:
Packit 8f70b4
     https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html
Packit 8f70b4
Packit 8f70b4
     DragonFly; see
Packit 8f70b4
     http://muscles.dragonflybsd.org/bulk/bleeding-edge-potential/latest-per-pkg/ah-tty-0.3.12.log
Packit 8f70b4
Packit 8f70b4
     FreeBSD; see:
Packit 8f70b4
     https://lists.gnu.org/r/bug-gnulib/2014-07/msg00104.html
Packit 8f70b4
Packit 8f70b4
   OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
Packit 8f70b4
   for clang but remains for g++; see <https://trac.macports.org/ticket/41033>.
Packit 8f70b4
   Assume DragonFly and FreeBSD will be similar.  */
Packit 8f70b4
#if (((defined __APPLE__ && defined __MACH__) \
Packit 8f70b4
      || defined __DragonFly__ || defined __FreeBSD__) \
Packit 8f70b4
     && (defined __header_inline \
Packit 8f70b4
         ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
Packit 8f70b4
            && ! defined __clang__) \
Packit 8f70b4
         : ((! defined _DONT_USE_CTYPE_INLINE_ \
Packit 8f70b4
             && (defined __GNUC__ || defined __cplusplus)) \
Packit 8f70b4
            || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
Packit 8f70b4
                && defined __GNUC__ && ! defined __cplusplus))))
Packit 8f70b4
# define _GL_EXTERN_INLINE_STDHEADER_BUG
Packit 8f70b4
#endif
Packit 8f70b4
#if ((__GNUC__ \
Packit 8f70b4
      ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
Packit 8f70b4
      : (199901L <= __STDC_VERSION__ \
Packit 8f70b4
         && !defined __HP_cc \
Packit 8f70b4
         && !defined __PGI \
Packit 8f70b4
         && !(defined __SUNPRO_C && __STDC__))) \
Packit 8f70b4
     && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
Packit 8f70b4
# define _GL_INLINE inline
Packit 8f70b4
# define _GL_EXTERN_INLINE extern inline
Packit 8f70b4
# define _GL_EXTERN_INLINE_IN_USE
Packit 8f70b4
#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
Packit 8f70b4
       && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
Packit 8f70b4
# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
Packit 8f70b4
   /* __gnu_inline__ suppresses a GCC 4.2 diagnostic.  */
Packit 8f70b4
#  define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
Packit 8f70b4
# else
Packit 8f70b4
#  define _GL_INLINE extern inline
Packit 8f70b4
# endif
Packit 8f70b4
# define _GL_EXTERN_INLINE extern
Packit 8f70b4
# define _GL_EXTERN_INLINE_IN_USE
Packit 8f70b4
#else
Packit 8f70b4
# define _GL_INLINE static _GL_UNUSED
Packit 8f70b4
# define _GL_EXTERN_INLINE static _GL_UNUSED
Packit 8f70b4
#endif
Packit 8f70b4
Packit 8f70b4
/* In GCC 4.6 (inclusive) to 5.1 (exclusive),
Packit 8f70b4
   suppress bogus "no previous prototype for 'FOO'"
Packit 8f70b4
   and "no previous declaration for 'FOO'" diagnostics,
Packit 8f70b4
   when FOO is an inline function in the header; see
Packit 8f70b4
   <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113> and
Packit 8f70b4
   <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877>.  */
Packit 8f70b4
#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__
Packit 8f70b4
# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
Packit 8f70b4
#  define _GL_INLINE_HEADER_CONST_PRAGMA
Packit 8f70b4
# else
Packit 8f70b4
#  define _GL_INLINE_HEADER_CONST_PRAGMA \
Packit 8f70b4
     _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
Packit 8f70b4
# endif
Packit 8f70b4
# define _GL_INLINE_HEADER_BEGIN \
Packit 8f70b4
    _Pragma ("GCC diagnostic push") \
Packit 8f70b4
    _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
Packit 8f70b4
    _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \
Packit 8f70b4
    _GL_INLINE_HEADER_CONST_PRAGMA
Packit 8f70b4
# define _GL_INLINE_HEADER_END \
Packit 8f70b4
    _Pragma ("GCC diagnostic pop")
Packit 8f70b4
#else
Packit 8f70b4
# define _GL_INLINE_HEADER_BEGIN
Packit 8f70b4
# define _GL_INLINE_HEADER_END
Packit 8f70b4
#endif])
Packit 8f70b4
])