summaryrefslogtreecommitdiff
path: root/include/ruby/defines.h
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-12 18:12:47 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-12 18:12:47 +0000
commitb207e7cd1def68d729ef878dccac8974f0e5b753 (patch)
treeacabf7d5525dc45491be3a800aee5050b00a2e68 /include/ruby/defines.h
parent07dd6fcc96d4903ec6126b93004c3273dd2e28bf (diff)
downloadruby-b207e7cd1def68d729ef878dccac8974f0e5b753.tar.gz
include/ruby/defines.h (GCC_VERSION_SINCE): moved from internal.h
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby/defines.h')
-rw-r--r--include/ruby/defines.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/ruby/defines.h b/include/ruby/defines.h
index 74678c34ab..742017ebaf 100644
--- a/include/ruby/defines.h
+++ b/include/ruby/defines.h
@@ -46,6 +46,13 @@ extern "C" {
# define NOINLINE(x) x
#endif
+#define GCC_VERSION_SINCE(major, minor, patchlevel) \
+ (defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__) && \
+ ((__GNUC__ > (major)) || \
+ ((__GNUC__ == (major) && \
+ (__GNUC_MINOR__ > (minor)) || \
+ (__GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ >= (patchlevel))))))
+
/* likely */
#if __GNUC__ >= 3
#define RB_LIKELY(x) (__builtin_expect(!!(x), 1))
@@ -152,8 +159,8 @@ RUBY_SYMBOL_EXPORT_BEGIN
#define xrealloc2 ruby_xrealloc2
#define xfree ruby_xfree
-#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-# define RUBY_ATTR_ALLOC_SIZE(params) __attribute__ ((__alloc_size__ params))
+#if GCC_VERSION_SINCE(4,3,0)
+# deine RUBY_ATTR_ALLOC_SIZE(params) __attribute__ ((__alloc_size__ params))
#else
# define RUBY_ATTR_ALLOC_SIZE(params)
#endif