summaryrefslogtreecommitdiff
path: root/src/include/c.h
diff options
context:
space:
mode:
authorDavid Rowley2020-11-24 21:52:50 +0000
committerDavid Rowley2020-11-24 21:52:50 +0000
commitb0727ae99b7056ca88e9708c014a86f6e611d938 (patch)
treee9ef75375ca08f70dadae97944e72983b6b025ed /src/include/c.h
parentec05bafdbbf474bf0a1416772da31f9f1f27fa1e (diff)
Tidy up definitions of pg_attribute_hot and pg_attribute_cold
1fa22a43a was a quick fix for portability problem I introduced in 697e1d02f. 1fa22a43a adds a few more cases to the preprocessor logic than I'd have liked. Andres Freund and Dagfinn Ilmari MannsÃ¥ker suggested a better way to do this. In passing, also adjust the only current usage of these macros so that the macro comes before the function's return type in the declaration of the function. This now matches what the definition of the function does. Discussion: https://postgr.es/m/[email protected] Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/include/c.h')
-rw-r--r--src/include/c.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/include/c.h b/src/include/c.h
index 2c2451d11e1..3d047490078 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -104,6 +104,15 @@
* XLC: https://www.ibm.com/support/knowledgecenter/SSGH2K_13.1.2/com.ibm.xlc131.aix.doc/language_ref/type_attrib.html
*/
+/*
+ * For compilers which don't support __has_attribute, we just define
+ * __has_attribute(x) to 0 so that we can define macros for various
+ * __attribute__s more easily below.
+ */
+#ifndef __has_attribute
+#define __has_attribute(attribute) 0
+#endif
+
/* only GCC supports the unused attribute */
#ifdef __GNUC__
#define pg_attribute_unused() __attribute__((unused))
@@ -195,8 +204,6 @@
* 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)
-
#if __has_attribute (cold)
#define pg_attribute_cold __attribute__((cold))
#else
@@ -209,11 +216,6 @@
#define pg_attribute_hot
#endif
-#else
-#define pg_attribute_hot
-#define pg_attribute_cold
-#endif
-
/*
* Mark a point as unreachable in a portable fashion. This should preferably
* be something that the compiler understands, to aid code generation.