Blame gl/m4/extern-inline.m4

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