aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2020-11-24 13:09:35 +1300
committerDavid Rowley <drowley@postgresql.org>2020-11-24 13:09:35 +1300
commit1fa22a43a56e1fe44c7bb3a3d5ef31be5bcac41d (patch)
treeb4a32ec58c0c685936267aae8d7efbfc8f54e16b
parent913ec71d682e99852cc188a7edbdccd02d42b4b3 (diff)
downloadpostgresql-1fa22a43a56e1fe44c7bb3a3d5ef31be5bcac41d.tar.gz
postgresql-1fa22a43a56e1fe44c7bb3a3d5ef31be5bcac41d.zip
Fix unportable usage of __has_attribute
This should fix the breakages caused by 697e1d02f, which seems to break the build for GCC version < 5. It seems, according to the GCC manual that __has_attribute is a "special operator" and must be tested without any other conditions in the preprocessor test. Per recommendation from the GCC manual via Greg Nancarrow Reported-by: Greg Nancarrow Discussion: https://postgr.es/m/CAJcOf-euSu8fhC10v476o9dqnjqKysVs1_vRms-_fvajpZ3kFw@mail.gmail.com
-rw-r--r--src/include/c.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/include/c.h b/src/include/c.h
index ff7c2eddcec..2c2451d11e1 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -195,18 +195,25 @@
* 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)
+#if defined(__has_attribute)
+
+#if __has_attribute (cold)
#define pg_attribute_cold __attribute__((cold))
#else
#define pg_attribute_cold
#endif
-#if defined(__has_attribute) && __has_attribute (hot)
+#if __has_attribute (hot)
#define pg_attribute_hot __attribute__((hot))
#else
#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.