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

+16
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)