Skip to content

Commit a0247e7

Browse files
committed
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
1 parent d133982 commit a0247e7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/include/c.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,22 @@ typedef NameData *Name;
642642
#define pg_attribute_noreturn()
643643
#endif
644644

645+
646+
/*
647+
* Forcing a function not to be inlined can be useful if it's the slow-path of
648+
* a performance critical function, or should be visible in profiles to allow
649+
* for proper cost attribution.
650+
*/
651+
/* GCC, Sunpro and XLC support noinline via __attribute */
652+
#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
653+
#define pg_noinline __attribute__((noinline))
654+
/* msvc via declspec */
655+
#elif defined(_MSC_VER)
656+
#define pg_noinline __declspec(noinline)
657+
#else
658+
#define pg_noinline
659+
#endif
660+
645661
/* ----------------------------------------------------------------
646662
* Section 6: assertions
647663
* ----------------------------------------------------------------

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy