diff options
author | David Rowley <drowley@postgresql.org> | 2020-11-24 11:29:28 +1300 |
---|---|---|
committer | David Rowley <drowley@postgresql.org> | 2020-11-24 11:29:28 +1300 |
commit | 697e1d02f53f985992a4f479b0b08fca5c272c6c (patch) | |
tree | 4e5cf5d43395338179f36c790c6137a8e9e34c75 | |
parent | 3b9b01f75d6e2d7bf9e0bf8ec958ce420aa037c2 (diff) | |
download | postgresql-697e1d02f53f985992a4f479b0b08fca5c272c6c.tar.gz postgresql-697e1d02f53f985992a4f479b0b08fca5c272c6c.zip |
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
-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 d5dc3632f74..ff7c2eddcec 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -192,6 +192,22 @@ #endif /* + * Marking certain functions as "hot" or "cold" can be useful to assist the + * compiler in arranging the assembly code in a more efficient way. + */ +#if defined(__has_attribute) && __has_attribute (cold) +#define pg_attribute_cold __attribute__((cold)) +#else +#define pg_attribute_cold +#endif + +#if defined(__has_attribute) && __has_attribute (hot) +#define pg_attribute_hot __attribute__((hot)) +#else +#define pg_attribute_hot +#endif + +/* * Mark a point as unreachable in a portable fashion. This should preferably * be something that the compiler understands, to aid code generation. * In assert-enabled builds, we prefer abort() for debugging reasons. |