Merge from emacs-24; up to 2012-05-05T02:50:20Z!monnier@iro.umontreal.ca
[bpt/emacs.git] / m4 / extern-inline.m4
1 dnl 'extern inline' a la ISO C99.
2
3 dnl Copyright 2012 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 AC_DEFUN([gl_EXTERN_INLINE],
9 [
10 AC_REQUIRE([AC_C_INLINE])
11 AH_VERBATIM([extern_inline],
12 [/* _GL_INLINE is a portable alternative to ISO C99 plain 'inline'.
13 _GL_EXTERN_INLINE is a portable alternative to 'extern inline'.
14 _GL_INLINE_HEADER_BEGIN contains useful stuff to put
15 in an include file, before uses of _GL_INLINE.
16 It suppresses GCC's bogus "no previous prototype for 'FOO'" diagnostic,
17 when FOO is an inline function in the header; see
18 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>.
19 _GL_INLINE_HEADER_END contains useful stuff to put
20 in the same include file, after uses of _GL_INLINE. */
21 #if __GNUC__ ? __GNUC_STDC_INLINE__ : 199901L <= __STDC_VERSION__
22 # define _GL_INLINE inline
23 # define _GL_EXTERN_INLINE extern inline
24 #elif 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
25 # if __GNUC_GNU_INLINE__
26 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
27 # define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
28 # else
29 # define _GL_INLINE extern inline
30 # endif
31 # define _GL_EXTERN_INLINE extern
32 #else
33 # define _GL_INLINE static inline
34 # define _GL_EXTERN_INLINE static inline
35 #endif
36
37 #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
38 # if __GNUC_STDC_INLINE__
39 # define _GL_INLINE_HEADER_CONST_PRAGMA
40 # else
41 # define _GL_INLINE_HEADER_CONST_PRAGMA \
42 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
43 # endif
44 # define _GL_INLINE_HEADER_BEGIN \
45 _Pragma ("GCC diagnostic push") \
46 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
47 _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \
48 _GL_INLINE_HEADER_CONST_PRAGMA
49 # define _GL_INLINE_HEADER_END \
50 _Pragma ("GCC diagnostic pop")
51 #else
52 # define _GL_INLINE_HEADER_BEGIN
53 # define _GL_INLINE_HEADER_END
54 #endif])
55 ])