Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Constellation authored and ivmai committed Oct 16, 2014
1 parent 734827b commit b725923
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions include/gc_config_macros.h
Expand Up @@ -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

Expand Down

0 comments on commit b725923

Please sign in to comment.