diff options
| author | Paul Eggert | 2019-09-04 23:13:54 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-09-04 23:15:04 -0700 |
| commit | 365dad197bac5deec9244fd9c189d23c46c99b31 (patch) | |
| tree | b3e7f28e4935e6008c46a103152cd6590484146f /src | |
| parent | 507d5548349540dbde67d3e535a4607fd2207c49 (diff) | |
| download | emacs-365dad197bac5deec9244fd9c189d23c46c99b31.tar.gz emacs-365dad197bac5deec9244fd9c189d23c46c99b31.zip | |
Use plain ‘static’ for Emacs C inline functions
This improved performance of ‘make compile-always’ by 8.2%
on my platform (AMD Phenom II X4 910e, Fedora 30 x86-64).
* src/conf_post.h (INLINE, EXTERN_INLINE, INLINE_HEADER_BEGIN)
(INLINE_HEADER_END) [!EMACS_EXTERN_INLINE]: Use plain ‘static’.
Diffstat (limited to 'src')
| -rw-r--r-- | src/conf_post.h | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/src/conf_post.h b/src/conf_post.h index 4af1ba9331f..43f98620a4b 100644 --- a/src/conf_post.h +++ b/src/conf_post.h | |||
| @@ -373,8 +373,13 @@ extern int emacs_setenv_TZ (char const *); | |||
| 373 | #undef noinline | 373 | #undef noinline |
| 374 | #endif | 374 | #endif |
| 375 | 375 | ||
| 376 | /* Use Gnulib's extern-inline module for extern inline functions. | 376 | /* INLINE marks functions defined in Emacs-internal C headers. |
| 377 | An include file foo.h should prepend FOO_INLINE to function | 377 | INLINE is implemented via C99-style 'extern inline' if Emacs is built |
| 378 | with -DEMACS_EXTERN_INLINE; otherwise it is implemented via 'static'. | ||
| 379 | EMACS_EXTERN_INLINE is no longer the default, as 'static' seems to | ||
| 380 | have better performance with GCC. | ||
| 381 | |||
| 382 | An include file foo.h should prepend INLINE to function | ||
| 378 | definitions, with the following overall pattern: | 383 | definitions, with the following overall pattern: |
| 379 | 384 | ||
| 380 | [#include any other .h files first.] | 385 | [#include any other .h files first.] |
| @@ -399,20 +404,40 @@ extern int emacs_setenv_TZ (char const *); | |||
| 399 | For Emacs, this is done by having emacs.c first '#define INLINE | 404 | For Emacs, this is done by having emacs.c first '#define INLINE |
| 400 | EXTERN_INLINE' and then include every .h file that uses INLINE. | 405 | EXTERN_INLINE' and then include every .h file that uses INLINE. |
| 401 | 406 | ||
| 402 | The INLINE_HEADER_BEGIN and INLINE_HEADER_END suppress bogus | 407 | The INLINE_HEADER_BEGIN and INLINE_HEADER_END macros suppress bogus |
| 403 | warnings in some GCC versions; see ../m4/extern-inline.m4. | 408 | warnings in some GCC versions; see ../m4/extern-inline.m4. */ |
| 409 | |||
| 410 | #ifdef EMACS_EXTERN_INLINE | ||
| 411 | |||
| 412 | /* Use Gnulib's extern-inline module for extern inline functions. | ||
| 404 | 413 | ||
| 405 | C99 compilers compile functions like 'incr' as C99-style extern | 414 | C99 compilers compile functions like 'incr' as C99-style extern |
| 406 | inline functions. Buggy GCC implementations do something similar with | 415 | inline functions. Buggy GCC implementations do something similar with |
| 407 | GNU-specific keywords. Buggy non-GCC compilers use static | 416 | GNU-specific keywords. Buggy non-GCC compilers use static |
| 408 | functions, which bloats the code but is good enough. */ | 417 | functions, which bloats the code but is good enough. */ |
| 409 | 418 | ||
| 410 | #ifndef INLINE | 419 | # ifndef INLINE |
| 411 | # define INLINE _GL_INLINE | 420 | # define INLINE _GL_INLINE |
| 421 | # endif | ||
| 422 | # define EXTERN_INLINE _GL_EXTERN_INLINE | ||
| 423 | # define INLINE_HEADER_BEGIN _GL_INLINE_HEADER_BEGIN | ||
| 424 | # define INLINE_HEADER_END _GL_INLINE_HEADER_END | ||
| 425 | |||
| 426 | #else | ||
| 427 | |||
| 428 | /* Use 'static' instead of 'extern inline' because 'static' typically | ||
| 429 | has better performance for Emacs. Do not use the 'inline' keyword, | ||
| 430 | as modern compilers inline automatically. ATTRIBUTE_UNUSED | ||
| 431 | pacifies gcc -Wunused-function. */ | ||
| 432 | |||
| 433 | # ifndef INLINE | ||
| 434 | # define INLINE EXTERN_INLINE | ||
| 435 | # endif | ||
| 436 | # define EXTERN_INLINE static ATTRIBUTE_UNUSED | ||
| 437 | # define INLINE_HEADER_BEGIN | ||
| 438 | # define INLINE_HEADER_END | ||
| 439 | |||
| 412 | #endif | 440 | #endif |
| 413 | #define EXTERN_INLINE _GL_EXTERN_INLINE | ||
| 414 | #define INLINE_HEADER_BEGIN _GL_INLINE_HEADER_BEGIN | ||
| 415 | #define INLINE_HEADER_END _GL_INLINE_HEADER_END | ||
| 416 | 441 | ||
| 417 | /* 'int x UNINIT;' is equivalent to 'int x;', except it cajoles GCC | 442 | /* 'int x UNINIT;' is equivalent to 'int x;', except it cajoles GCC |
| 418 | into not warning incorrectly about use of an uninitialized variable. */ | 443 | into not warning incorrectly about use of an uninitialized variable. */ |