summaryrefslogtreecommitdiff
path: root/util-internal.h
diff options
context:
space:
mode:
authorAzat Khuzhin <a3at.mail@gmail.com>2017-01-30 01:58:22 +0300
committerAzat Khuzhin <a3at.mail@gmail.com>2017-01-30 11:50:02 +0300
commitffbce578c40a06491ce6585ab2d82ebb69a52d30 (patch)
tree08148cc23c20ba7335dc61efa37b92377972488f /util-internal.h
parentd057c45e8f48aa90d8b340cac4c8ae4cc8b5d0ac (diff)
downloadlibevent-ffbce578c40a06491ce6585ab2d82ebb69a52d30.tar.gz
Fix clang 3 (some versions) misbehaviour for __has_attribute()
Refs: #447 Clang: https://reviews.llvm.org/rL223468 ("Modify __has_attribute so that it only looks for GNU-style attributes")
Diffstat (limited to 'util-internal.h')
-rw-r--r--util-internal.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/util-internal.h b/util-internal.h
index 54e9fa30..77e17ab0 100644
--- a/util-internal.h
+++ b/util-internal.h
@@ -50,8 +50,18 @@
extern "C" {
#endif
-#if !defined(__has_attribute)
-#define __has_attribute(x) 0
+/* __has_attribute() wrapper */
+#ifdef __has_attribute
+#define EVUTIL_HAS_ATTRIBUTE __has_attribute
+#endif
+/** clang 3 __has_attribute misbehaves in some versions */
+#if defined(__clang__) && \
+ __clang__ == 1 && __clang_major__ == 3 && \
+ (__clang_minor__ >= 2 && __clang_minor__ <= 5)
+#undef EVUTIL_HAS_ATTRIBUTE
+#endif
+#ifndef EVUTIL_HAS_ATTRIBUTE
+#define EVUTIL_HAS_ATTRIBUTE(x) 0
#endif
/* If we need magic to say "inline", get it for free internally. */
@@ -312,7 +322,7 @@ ev_int32_t evutil_weakrand_range_(struct evutil_weakrand_state *seed, ev_int32_t
#define EVUTIL_UNLIKELY(p) (p)
#endif
-#if __has_attribute(fallthrough)
+#if EVUTIL_HAS_ATTRIBUTE(fallthrough)
#define EVUTIL_FALLTHROUGH __attribute__((fallthrough))
#else
#define EVUTIL_FALLTHROUGH /* fallthrough */