Skip to content

Commit 697e1d0

Browse files
committed
Define pg_attribute_cold and pg_attribute_hot macros
For compilers supporting __has_attribute and __has_attribute (hot/cold). __has_attribute is supported on gcc >= 5, clang >= 2.9 and icc >= 17. A followup commit will implement some usages of these macros. Author: David Rowley Reviewed-by: Andres Freund, Peter Eisentraut Discussion: https://postgr.es/m/CAApHDvrVpasrEzLL2er7p9iwZFZ%3DJj6WisePcFeunwfrV0js_A%40mail.gmail.com
1 parent 3b9b01f commit 697e1d0

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
@@ -191,6 +191,22 @@
191191
#define pg_noinline
192192
#endif
193193

194+
/*
195+
* Marking certain functions as "hot" or "cold" can be useful to assist the
196+
* compiler in arranging the assembly code in a more efficient way.
197+
*/
198+
#if defined(__has_attribute) && __has_attribute (cold)
199+
#define pg_attribute_cold __attribute__((cold))
200+
#else
201+
#define pg_attribute_cold
202+
#endif
203+
204+
#if defined(__has_attribute) && __has_attribute (hot)
205+
#define pg_attribute_hot __attribute__((hot))
206+
#else
207+
#define pg_attribute_hot
208+
#endif
209+
194210
/*
195211
* Mark a point as unreachable in a portable fashion. This should preferably
196212
* be something that the compiler understands, to aid code generation.

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