Use Gnulib ACL implementation, for benefit of Solaris etc.
[bpt/emacs.git] / m4 / extern-inline.m4
CommitLineData
a0d4efe9
PE
1dnl 'extern inline' a la ISO C99.
2
9ff99d22 3dnl Copyright 2012-2013 Free Software Foundation, Inc.
a0d4efe9
PE
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_EXTERN_INLINE],
9[
a0d4efe9
PE
10 AH_VERBATIM([extern_inline],
11[/* _GL_INLINE is a portable alternative to ISO C99 plain 'inline'.
12 _GL_EXTERN_INLINE is a portable alternative to 'extern inline'.
13 _GL_INLINE_HEADER_BEGIN contains useful stuff to put
14 in an include file, before uses of _GL_INLINE.
15 It suppresses GCC's bogus "no previous prototype for 'FOO'" diagnostic,
16 when FOO is an inline function in the header; see
17 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>.
18 _GL_INLINE_HEADER_END contains useful stuff to put
904dd565
PE
19 in the same include file, after uses of _GL_INLINE.
20
89bd9d36
PE
21 Suppress extern inline with HP-UX cc, as it appears to be broken; see
22 <http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>.
23
d9774ea4
PE
24 Suppress extern inline with Sun C in standards-conformance mode, as it
25 mishandles inline functions that call each other. E.g., for 'inline void f
26 (void) { } inline void g (void) { f (); }', c99 incorrectly complains
27 'reference to static identifier "f" in extern inline function'.
28 This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16.
29
30 Suppress the use of extern inline on Apple's platforms, as Libc at least
31 through Libc-825.26 (2013-04-09) is incompatible with it; see, e.g.,
904dd565
PE
32 <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
33 Perhaps Apple will fix this some day. */
34#if ((__GNUC__ \
35 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
d9774ea4
PE
36 : (199901L <= __STDC_VERSION__ \
37 && !defined __HP_cc \
38 && !(defined __SUNPRO_C && __STDC__))) \
904dd565 39 && !defined __APPLE__)
a0d4efe9
PE
40# define _GL_INLINE inline
41# define _GL_EXTERN_INLINE extern inline
904dd565 42#elif 2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __APPLE__
01b13eb7
PE
43# if __GNUC_GNU_INLINE__
44 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
45# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
46# else
47# define _GL_INLINE extern inline
a0d4efe9 48# endif
01b13eb7 49# define _GL_EXTERN_INLINE extern
a0d4efe9 50#else
904dd565
PE
51# define _GL_INLINE static _GL_UNUSED
52# define _GL_EXTERN_INLINE static _GL_UNUSED
a0d4efe9
PE
53#endif
54
01b13eb7 55#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
65788e2e 56# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
01b13eb7
PE
57# define _GL_INLINE_HEADER_CONST_PRAGMA
58# else
59# define _GL_INLINE_HEADER_CONST_PRAGMA \
60 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
61# endif
62# define _GL_INLINE_HEADER_BEGIN \
63 _Pragma ("GCC diagnostic push") \
64 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
65 _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \
66 _GL_INLINE_HEADER_CONST_PRAGMA
67# define _GL_INLINE_HEADER_END \
68 _Pragma ("GCC diagnostic pop")
69#else
a0d4efe9
PE
70# define _GL_INLINE_HEADER_BEGIN
71# define _GL_INLINE_HEADER_END
72#endif])
73])