summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYusuke Suzuki <utatane.tea@gmail.com>2014-10-02 03:38:02 +0900
committerIvan Maidanski <ivmai@mail.ru>2014-10-17 00:15:12 +0400
commitb725923951d77f5c6792c2797f89179267c58c9c (patch)
tree0beb6cebfd83e4ee7d1f97169a4ef13e71a15b5b
parent734827bf66d135fccd5193b5f9d880ba23b44646 (diff)
downloadbdwgc-b725923951d77f5c6792c2797f89179267c58c9c.tar.gz
Fix __alloc_size__ availability detection (Clang)
Since __clang_major__/__clang_minor__ etc. are vendor dependent values, we cannot implement the feature detection based on it. For example, Apple clang versioning is different from the FreeBSD clang. (At this time, Apple clang version is "6.0 (clang-600.0.51)" and __clang_major__ is 6.) Instead of this, we can use the clang feature detection macro, __has_attribute. * include/gc_config_macros.h (GC_ATTR_ALLOC_SIZE): Replace predefined __clang_major/minor__ testing with __has_attribute() one (in case of clang).
-rw-r--r--include/gc_config_macros.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h
index 13f7e77a..d6da7ca2 100644
--- a/include/gc_config_macros.h
+++ b/include/gc_config_macros.h
@@ -242,14 +242,17 @@
#ifndef GC_ATTR_ALLOC_SIZE
/* 'alloc_size' attribute improves __builtin_object_size correctness. */
/* Only single-argument form of 'alloc_size' attribute is used. */
-# if defined(__GNUC__) && (__GNUC__ > 4 \
- || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 && !defined(__ICC)) \
- || __clang_major__ > 3 \
- || (__clang_major__ == 3 && __clang_minor__ >= 2 \
- && (__clang_minor__ != 5 || __clang_patchlevel__ != 0)))
+# ifdef __clang__
+# if __has_attribute(__alloc_size__)
+# define GC_ATTR_ALLOC_SIZE(argnum) __attribute__((__alloc_size__(argnum)))
+# else
+# define GC_ATTR_ALLOC_SIZE(argnum) /* empty */
+# endif
+# elif __GNUC__ > 4 \
+ || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 && !defined(__ICC))
# define GC_ATTR_ALLOC_SIZE(argnum) __attribute__((__alloc_size__(argnum)))
# else
-# define GC_ATTR_ALLOC_SIZE(argnum)
+# define GC_ATTR_ALLOC_SIZE(argnum) /* empty */
# endif
#endif