diff options
author | Andres Freund <andres@anarazel.de> | 2017-10-13 11:44:51 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2017-10-13 12:16:06 -0700 |
commit | a0247e7a11bb9f5fd55694b594a3906b7bd05881 (patch) | |
tree | bb517538405500988bdad171833e7804f2c8d52f /src | |
parent | d133982d598c7e6208d16cb4fc0b552151796603 (diff) | |
download | postgresql-a0247e7a11bb9f5fd55694b594a3906b7bd05881.tar.gz postgresql-a0247e7a11bb9f5fd55694b594a3906b7bd05881.zip |
Add pg_noinline macro to c.h.
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 for proper cost attribution.
Author: Andres Freund
Discussion: https://postgr.es/m/20170914061207.zxotvyopetm7lrrp@alap3.anarazel.de
Diffstat (limited to 'src')
-rw-r--r-- | src/include/c.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/include/c.h b/src/include/c.h index b6a969787ac..b39bbd7c713 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -642,6 +642,22 @@ typedef NameData *Name; #define pg_attribute_noreturn() #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 + * for proper cost attribution. + */ +/* GCC, Sunpro and XLC support noinline via __attribute */ +#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__) +#define pg_noinline __attribute__((noinline)) +/* msvc via declspec */ +#elif defined(_MSC_VER) +#define pg_noinline __declspec(noinline) +#else +#define pg_noinline +#endif + /* ---------------------------------------------------------------- * Section 6: assertions * ---------------------------------------------------------------- |