Mercurial > hg > octave-lojdl > gnulib-hg
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 |
rev | line source |
---|---|
17022 | 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'. | |
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 | 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. */ | |
17022 | 21 #if __GNUC__ ? __GNUC_STDC_INLINE__ : 199901L <= __STDC_VERSION__ |
22 # define _GL_INLINE inline | |
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 | 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 | 32 #else |
33 # define _GL_INLINE static inline | |
34 # define _GL_EXTERN_INLINE static inline | |
35 #endif | |
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 | 52 # define _GL_INLINE_HEADER_BEGIN |
53 # define _GL_INLINE_HEADER_END | |
54 #endif]) | |
55 ]) |