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