Blame gettext-runtime/m4/extern-inline.m4

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