Skip to content

Commit 1fa22a4

Browse files
committed
Fix unportable usage of __has_attribute
This should fix the breakages caused by 697e1d0, 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
1 parent 913ec71 commit 1fa22a4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/include/c.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -195,18 +195,25 @@
195195
* Marking certain functions as "hot" or "cold" can be useful to assist the
196196
* compiler in arranging the assembly code in a more efficient way.
197197
*/
198-
#if defined(__has_attribute) && __has_attribute (cold)
198+
#if defined(__has_attribute)
199+
200+
#if __has_attribute (cold)
199201
#define pg_attribute_cold __attribute__((cold))
200202
#else
201203
#define pg_attribute_cold
202204
#endif
203205

204-
#if defined(__has_attribute) && __has_attribute (hot)
206+
#if __has_attribute (hot)
205207
#define pg_attribute_hot __attribute__((hot))
206208
#else
207209
#define pg_attribute_hot
208210
#endif
209211

212+
#else
213+
#define pg_attribute_hot
214+
#define pg_attribute_cold
215+
#endif
216+
210217
/*
211218
* Mark a point as unreachable in a portable fashion. This should preferably
212219
* be something that the compiler understands, to aid code generation.

0 commit comments

Comments
 (0)