Blame m4/extern-inline.m4

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