diff options
author | Andres Freund <andres@anarazel.de> | 2015-08-05 18:19:52 +0200 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2015-08-05 18:19:52 +0200 |
commit | de6fd1c898f6eca82c2130a9dbb42d00da68d79e (patch) | |
tree | 2387db94ee7d19f19ec45dbfc31c3a6c3494a62c /src/include/c.h | |
parent | a855118be3f0682a2061448db5a87dec50717af4 (diff) | |
download | postgresql-de6fd1c898f6eca82c2130a9dbb42d00da68d79e.tar.gz postgresql-de6fd1c898f6eca82c2130a9dbb42d00da68d79e.zip |
Rely on inline functions even if that causes warnings in older compilers.
So far we have worked around the fact that some very old compilers do
not support 'inline' functions by only using inline functions
conditionally (or not at all). Since such compilers are very rare by
now, we have decided to rely on inline functions from 9.6 onwards.
To avoid breaking these old compilers inline is defined away when not
supported. That'll cause "function x defined but not used" type of
warnings, but since nobody develops on such compilers anymore that's
ok.
This change in policy will allow us to more easily employ inline
functions.
I chose to remove code previously conditional on PG_USE_INLINE as it
seemed confusing to have code dependent on a define that's always
defined.
Blacklisting of compilers, like in c53f73879f, now has to be done
differently. A platform template can define PG_FORCE_DISABLE_INLINE to
force inline to be defined empty.
Discussion: 20150701161447.GB30708@awork2.anarazel.de
Diffstat (limited to 'src/include/c.h')
-rw-r--r-- | src/include/c.h | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/src/include/c.h b/src/include/c.h index 92c52021ffa..e84c77460c0 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -54,6 +54,20 @@ #include "pg_config_manual.h" /* must be after pg_config.h */ /* + * Force disable inlining if PG_FORCE_DISABLE_INLINE is defined. This is used + * to work around compiler bugs and might also be useful for investigatory + * purposes. + * + * This is done early (in slightly the wrong section) for two reasons: a) we + * don't want to include headers with different settings of this b) + * functionality later in this file might want to rely on inline functions. + */ +#ifdef PG_FORCE_DISABLE_INLINE +#undef inline +#define inline +#endif + +/* * We always rely on the WIN32 macro being set by our build system, * but _WIN32 is the compiler pre-defined macro. So make sure we define * WIN32 whenever _WIN32 is set, to facilitate standalone building. @@ -920,34 +934,6 @@ typedef NameData *Name; #endif -/* - * Function inlining support -- Allow modules to define functions that may be - * inlined, if the compiler supports it. - * - * The function bodies must be defined in the module header prefixed by - * STATIC_IF_INLINE, protected by a cpp symbol that the module's .c file must - * define. If the compiler doesn't support inline functions, the function - * definitions are pulled in by the .c file as regular (not inline) symbols. - * - * The header must also declare the functions' prototypes, protected by - * !PG_USE_INLINE. - */ - -/* declarations which are only visible when not inlining and in the .c file */ -#ifdef PG_USE_INLINE -#define STATIC_IF_INLINE static inline -#else -#define STATIC_IF_INLINE -#endif /* PG_USE_INLINE */ - -/* declarations which are marked inline when inlining, extern otherwise */ -#ifdef PG_USE_INLINE -#define STATIC_IF_INLINE_DECLARE static inline -#else -#define STATIC_IF_INLINE_DECLARE extern -#endif /* PG_USE_INLINE */ - - /* ---------------------------------------------------------------- * Section 8: random stuff * ---------------------------------------------------------------- |