diff options
author | Andres Freund <andres@anarazel.de> | 2017-12-13 15:34:20 -0800 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2017-12-13 15:46:02 -0800 |
commit | dbb3d6f0102e0aca7575ff864450fca57ac85517 (patch) | |
tree | dcb394c503f8a0ac93e1b63d2eab1b7b99e66479 /src | |
parent | 923e8dee88ada071fe41541e83f121ead4baf7f8 (diff) | |
download | postgresql-dbb3d6f0102e0aca7575ff864450fca57ac85517.tar.gz postgresql-dbb3d6f0102e0aca7575ff864450fca57ac85517.zip |
Add pg_attribute_always_inline.
Sometimes it is useful to be able to insist that the compiler inline a
function that its normal cost analysis would not normally choose to inline.
This can be useful for instantiating different variants of a function that
remove branches of code by constant folding.
Author: Thomas Munro
Reviewed-By: Andres Freund
Discussion: https://postgr.es/m/CAEepm=09rr65VN+cAV5FgyM_z=D77Xy8Fuc9CDDDYbq3pQUezg@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r-- | src/include/c.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/include/c.h b/src/include/c.h index a61428843a8..11fcffbae39 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -146,6 +146,16 @@ #define pg_attribute_noreturn() #endif +/* GCC, Sunpro and XLC support always_inline via __attribute__ */ +#if defined(__GNUC__) +#define pg_attribute_always_inline __attribute__((always_inline)) +/* msvc via a special keyword */ +#elif defined(_MSC_VER) +#define pg_attribute_always_inline __forceinline +#else +#define pg_attribute_always_inline +#endif + /* * Forcing a function not to be inlined can be useful if it's the slow path of * a performance-critical function, or should be visible in profiles to allow |