annotate m4/extern-inline.m4 @ 17056:373b50f0c218

extern-inline: support old GCC 'inline' * m4/extern-inline.m4 (gl_EXTERN_INLINE): Use pre-C99 GCC 'inline' if available. This applies to GCC versions 2.7 through 4.2, or when newer GCC is using -fgnu89-inline. The goal is to address some of the performance issues mentioned by Bruno Haible in <http://lists.gnu.org/archive/html/bug-gnulib/2012-08/msg00097.html>.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 20 Aug 2012 17:01:18 -0700
parents 599464b0cbf8
children 03d96692c889
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17022
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
1 dnl 'extern inline' a la ISO C99.
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
2
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
3 dnl Copyright 2012 Free Software Foundation, Inc.
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
4 dnl This file is free software; the Free Software Foundation
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
5 dnl gives unlimited permission to copy and/or distribute it,
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
6 dnl with or without modifications, as long as this notice is preserved.
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
7
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
8 AC_DEFUN([gl_EXTERN_INLINE],
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
9 [
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
10 AC_REQUIRE([AC_C_INLINE])
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
11 AH_VERBATIM([extern_inline],
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
12 [/* _GL_INLINE is a portable alternative to ISO C99 plain 'inline'.
17029
a3c4b8128bde Fix typo: 'linline' -> 'inline' (thanks to Eric Blake).
Paul Eggert <eggert@cs.ucla.edu>
parents: 17027
diff changeset
13 _GL_EXTERN_INLINE is a portable alternative to 'extern inline'.
17027
c59debf0c042 Fix indenting.
Paul Eggert <eggert@cs.ucla.edu>
parents: 17022
diff changeset
14 _GL_INLINE_HEADER_BEGIN contains useful stuff to put
c59debf0c042 Fix indenting.
Paul Eggert <eggert@cs.ucla.edu>
parents: 17022
diff changeset
15 in an include file, before uses of _GL_INLINE.
c59debf0c042 Fix indenting.
Paul Eggert <eggert@cs.ucla.edu>
parents: 17022
diff changeset
16 It suppresses GCC's bogus "no previous prototype for 'FOO'" diagnostic,
c59debf0c042 Fix indenting.
Paul Eggert <eggert@cs.ucla.edu>
parents: 17022
diff changeset
17 when FOO is an inline function in the header; see
c59debf0c042 Fix indenting.
Paul Eggert <eggert@cs.ucla.edu>
parents: 17022
diff changeset
18 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>.
c59debf0c042 Fix indenting.
Paul Eggert <eggert@cs.ucla.edu>
parents: 17022
diff changeset
19 _GL_INLINE_HEADER_END contains useful stuff to put
c59debf0c042 Fix indenting.
Paul Eggert <eggert@cs.ucla.edu>
parents: 17022
diff changeset
20 in the same include file, after uses of _GL_INLINE. */
17022
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
21 #if __GNUC__ ? __GNUC_STDC_INLINE__ : 199901L <= __STDC_VERSION__
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
22 # define _GL_INLINE inline
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
23 # define _GL_EXTERN_INLINE extern inline
17056
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
24 #elif 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
25 # if __GNUC_GNU_INLINE__
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
26 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
27 # define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
28 # else
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
29 # define _GL_INLINE extern inline
17022
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
30 # endif
17056
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
31 # define _GL_EXTERN_INLINE extern
17022
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
32 #else
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
33 # define _GL_INLINE static inline
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
34 # define _GL_EXTERN_INLINE static inline
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
35 #endif
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
36
17056
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
37 #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
38 # if __GNUC_STDC_INLINE__
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
39 # define _GL_INLINE_HEADER_CONST_PRAGMA
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
40 # else
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
41 # define _GL_INLINE_HEADER_CONST_PRAGMA \
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
42 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
43 # endif
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
44 # define _GL_INLINE_HEADER_BEGIN \
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
45 _Pragma ("GCC diagnostic push") \
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
46 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
47 _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
48 _GL_INLINE_HEADER_CONST_PRAGMA
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
49 # define _GL_INLINE_HEADER_END \
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
50 _Pragma ("GCC diagnostic pop")
373b50f0c218 extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 17035
diff changeset
51 #else
17022
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
52 # define _GL_INLINE_HEADER_BEGIN
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
53 # define _GL_INLINE_HEADER_END
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
54 #endif])
23236de3f49d extern-inline: new module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
55 ])