Skip to content

Commit dbb3d6f

Browse files
committed
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
1 parent 923e8de commit dbb3d6f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/include/c.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@
146146
#define pg_attribute_noreturn()
147147
#endif
148148

149+
/* GCC, Sunpro and XLC support always_inline via __attribute__ */
150+
#if defined(__GNUC__)
151+
#define pg_attribute_always_inline __attribute__((always_inline))
152+
/* msvc via a special keyword */
153+
#elif defined(_MSC_VER)
154+
#define pg_attribute_always_inline __forceinline
155+
#else
156+
#define pg_attribute_always_inline
157+
#endif
158+
149159
/*
150160
* Forcing a function not to be inlined can be useful if it's the slow path of
151161
* a performance-critical function, or should be visible in profiles to allow

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