summaryrefslogtreecommitdiffstats
path: root/gl/m4/extern-inline.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/extern-inline.m4')
-rw-r--r--gl/m4/extern-inline.m479
1 files changed, 62 insertions, 17 deletions
diff --git a/gl/m4/extern-inline.m4 b/gl/m4/extern-inline.m4
index c4c5e7f..a4ac5ea 100644
--- a/gl/m4/extern-inline.m4
+++ b/gl/m4/extern-inline.m4
@@ -1,6 +1,6 @@
1dnl 'extern inline' a la ISO C99. 1dnl 'extern inline' a la ISO C99.
2 2
3dnl Copyright 2012-2013 Free Software Foundation, Inc. 3dnl Copyright 2012-2021 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
@@ -11,51 +11,96 @@ AC_DEFUN([gl_EXTERN_INLINE],
11[/* Please see the Gnulib manual for how to use these macros. 11[/* Please see the Gnulib manual for how to use these macros.
12 12
13 Suppress extern inline with HP-UX cc, as it appears to be broken; see 13 Suppress extern inline with HP-UX cc, as it appears to be broken; see
14 <http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>. 14 <https://lists.gnu.org/r/bug-texinfo/2013-02/msg00030.html>.
15 15
16 Suppress extern inline with Sun C in standards-conformance mode, as it 16 Suppress extern inline with Sun C in standards-conformance mode, as it
17 mishandles inline functions that call each other. E.g., for 'inline void f 17 mishandles inline functions that call each other. E.g., for 'inline void f
18 (void) { } inline void g (void) { f (); }', c99 incorrectly complains 18 (void) { } inline void g (void) { f (); }', c99 incorrectly complains
19 'reference to static identifier "f" in extern inline function'. 19 'reference to static identifier "f" in extern inline function'.
20 This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16. 20 This bug was observed with Oracle Developer Studio 12.6
21 (Sun C 5.15 SunOS_sparc 2017/05/30).
21 22
22 Suppress the use of extern inline on Apple's platforms, as Libc at least 23 Suppress extern inline (with or without __attribute__ ((__gnu_inline__)))
23 through Libc-825.26 (2013-04-09) is incompatible with it; see, e.g., 24 on configurations that mistakenly use 'static inline' to implement
24 <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>. 25 functions or macros in standard C headers like <ctype.h>. For example,
25 Perhaps Apple will fix this some day. */ 26 if isdigit is mistakenly implemented via a static inline function,
27 a program containing an extern inline function that calls isdigit
28 may not work since the C standard prohibits extern inline functions
29 from calling static functions (ISO C 99 section 6.7.4.(3).
30 This bug is known to occur on:
31
32 OS X 10.8 and earlier; see:
33 https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html
34
35 DragonFly; see
36 http://muscles.dragonflybsd.org/bulk/clang-master-potential/20141111_102002/logs/ah-tty-0.3.12.log
37
38 FreeBSD; see:
39 https://lists.gnu.org/r/bug-gnulib/2014-07/msg00104.html
40
41 OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
42 for clang but remains for g++; see <https://trac.macports.org/ticket/41033>.
43 Assume DragonFly and FreeBSD will be similar.
44
45 GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
46 inline semantics, unless -fgnu89-inline is used. It defines a macro
47 __GNUC_STDC_INLINE__ to indicate this situation or a macro
48 __GNUC_GNU_INLINE__ to indicate the opposite situation.
49 GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline
50 semantics but warns, unless -fgnu89-inline is used:
51 warning: C99 inline functions are not supported; using GNU89
52 warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute
53 It defines a macro __GNUC_GNU_INLINE__ to indicate this situation.
54 */
55#if (((defined __APPLE__ && defined __MACH__) \
56 || defined __DragonFly__ || defined __FreeBSD__) \
57 && (defined __header_inline \
58 ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
59 && ! defined __clang__) \
60 : ((! defined _DONT_USE_CTYPE_INLINE_ \
61 && (defined __GNUC__ || defined __cplusplus)) \
62 || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
63 && defined __GNUC__ && ! defined __cplusplus))))
64# define _GL_EXTERN_INLINE_STDHEADER_BUG
65#endif
26#if ((__GNUC__ \ 66#if ((__GNUC__ \
27 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ 67 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
28 : (199901L <= __STDC_VERSION__ \ 68 : (199901L <= __STDC_VERSION__ \
29 && !defined __HP_cc \ 69 && !defined __HP_cc \
70 && !defined __PGI \
30 && !(defined __SUNPRO_C && __STDC__))) \ 71 && !(defined __SUNPRO_C && __STDC__))) \
31 && !defined __APPLE__) 72 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
32# define _GL_INLINE inline 73# define _GL_INLINE inline
33# define _GL_EXTERN_INLINE extern inline 74# define _GL_EXTERN_INLINE extern inline
75# define _GL_EXTERN_INLINE_IN_USE
34#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ 76#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
35 && !defined __APPLE__) 77 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
36# if __GNUC_GNU_INLINE__ 78# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
37 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ 79 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
38# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) 80# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
39# else 81# else
40# define _GL_INLINE extern inline 82# define _GL_INLINE extern inline
41# endif 83# endif
42# define _GL_EXTERN_INLINE extern 84# define _GL_EXTERN_INLINE extern
85# define _GL_EXTERN_INLINE_IN_USE
43#else 86#else
44# define _GL_INLINE static _GL_UNUSED 87# define _GL_INLINE _GL_UNUSED static
45# define _GL_EXTERN_INLINE static _GL_UNUSED 88# define _GL_EXTERN_INLINE _GL_UNUSED static
46#endif 89#endif
47 90
48#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) 91/* In GCC 4.6 (inclusive) to 5.1 (exclusive),
92 suppress bogus "no previous prototype for 'FOO'"
93 and "no previous declaration for 'FOO'" diagnostics,
94 when FOO is an inline function in the header; see
95 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113> and
96 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877>. */
97#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__
49# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ 98# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
50# define _GL_INLINE_HEADER_CONST_PRAGMA 99# define _GL_INLINE_HEADER_CONST_PRAGMA
51# else 100# else
52# define _GL_INLINE_HEADER_CONST_PRAGMA \ 101# define _GL_INLINE_HEADER_CONST_PRAGMA \
53 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") 102 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
54# endif 103# endif
55 /* Suppress GCC's bogus "no previous prototype for 'FOO'"
56 and "no previous declaration for 'FOO'" diagnostics,
57 when FOO is an inline function in the header; see
58 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>. */
59# define _GL_INLINE_HEADER_BEGIN \ 104# define _GL_INLINE_HEADER_BEGIN \
60 _Pragma ("GCC diagnostic push") \ 105 _Pragma ("GCC diagnostic push") \
61 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \ 106 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \