• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2002-2004, 2006-2018 Free Software Foundation, Inc.
2# This file is free software; the Free Software Foundation
3# gives unlimited permission to copy and/or distribute it,
4# with or without modifications, as long as this notice is preserved.
5
6# Copyright 2012-2018 Free Software Foundation, Inc.
7# This file is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11gl_extern_inline = '''
12/* Please see the Gnulib manual for how to use these macros.
13
14   Suppress extern inline with HP-UX cc, as it appears to be broken; see
15   <https://lists.gnu.org/r/bug-texinfo/2013-02/msg00030.html>.
16
17   Suppress extern inline with Sun C in standards-conformance mode, as it
18   mishandles inline functions that call each other.  E.g., for 'inline void f
19   (void) { } inline void g (void) { f (); }', c99 incorrectly complains
20   'reference to static identifier "f" in extern inline function'.
21   This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16.
22
23   Suppress extern inline (with or without __attribute__ ((__gnu_inline__)))
24   on configurations that mistakenly use 'static inline' to implement
25   functions or macros in standard C headers like <ctype.h>.  For example,
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.  This bug is known to occur on:
30
31     OS X 10.8 and earlier; see:
32     https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html
33
34     DragonFly; see
35     http://muscles.dragonflybsd.org/bulk/bleeding-edge-potential/latest-per-pkg/ah-tty-0.3.12.log
36
37     FreeBSD; see:
38     https://lists.gnu.org/r/bug-gnulib/2014-07/msg00104.html
39
40   OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
41   for clang but remains for g++; see <https://trac.macports.org/ticket/41033>.
42   Assume DragonFly and FreeBSD will be similar.  */
43#if (((defined __APPLE__ && defined __MACH__) \
44      || defined __DragonFly__ || defined __FreeBSD__) \
45     && (defined __header_inline \
46         ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
47            && ! defined __clang__) \
48         : ((! defined _DONT_USE_CTYPE_INLINE_ \
49             && (defined __GNUC__ || defined __cplusplus)) \
50            || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
51                && defined __GNUC__ && ! defined __cplusplus))))
52# define _GL_EXTERN_INLINE_STDHEADER_BUG
53#endif
54#if ((__GNUC__ \
55      ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
56      : (199901L <= __STDC_VERSION__ \
57         && !defined __HP_cc \
58         && !defined __PGI \
59         && !(defined __SUNPRO_C && __STDC__))) \
60     && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
61# define _GL_INLINE inline
62# define _GL_EXTERN_INLINE extern inline
63# define _GL_EXTERN_INLINE_IN_USE
64#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
65       && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
66# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
67   /* __gnu_inline__ suppresses a GCC 4.2 diagnostic.  */
68#  define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) __attribute__ ((always_inline))
69# else
70#  define _GL_INLINE extern inline
71# endif
72# define _GL_EXTERN_INLINE extern
73# define _GL_EXTERN_INLINE_IN_USE
74#else
75# define _GL_INLINE static _GL_UNUSED
76# define _GL_EXTERN_INLINE static _GL_UNUSED
77#endif
78
79/* In GCC 4.6 (inclusive) to 5.1 (exclusive),
80   suppress bogus "no previous prototype for 'FOO'"
81   and "no previous declaration for 'FOO'" diagnostics,
82   when FOO is an inline function in the header; see
83   <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113> and
84   <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877>.  */
85#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__
86# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
87#  define _GL_INLINE_HEADER_CONST_PRAGMA
88# else
89#  define _GL_INLINE_HEADER_CONST_PRAGMA \
90     _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
91# endif
92# define _GL_INLINE_HEADER_BEGIN \
93    _Pragma ("GCC diagnostic push") \
94    _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
95    _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \
96    _GL_INLINE_HEADER_CONST_PRAGMA
97# define _GL_INLINE_HEADER_END \
98    _Pragma ("GCC diagnostic pop")
99#else
100# define _GL_INLINE_HEADER_BEGIN
101# define _GL_INLINE_HEADER_END
102#endif
103'''
104