[前][次][番号順一覧][スレッド一覧]

ruby-changes:42914

From: naruse <ko1@a...>
Date: Fri, 13 May 2016 03:19:18 +0900 (JST)
Subject: [ruby-changes:42914] naruse:r54988 (trunk): include/ruby/defines.h (GCC_VERSION_SINCE): moved from internal.h

naruse	2016-05-13 03:12:47 +0900 (Fri, 13 May 2016)

  New Revision: 54988

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54988

  Log:
    include/ruby/defines.h (GCC_VERSION_SINCE): moved from internal.h

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
    trunk/include/ruby/defines.h
    trunk/include/ruby/ruby.h
    trunk/internal.h
Index: include/ruby/defines.h
===================================================================
--- include/ruby/defines.h	(revision 54987)
+++ include/ruby/defines.h	(revision 54988)
@@ -46,6 +46,13 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/include/ruby/defines.h#L46
 # 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 https://github.com/ruby/ruby/blob/trunk/include/ruby/defines.h#L159
 #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
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 54987)
+++ include/ruby/ruby.h	(revision 54988)
@@ -565,7 +565,7 @@ void rb_check_safe_obj(VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L565
     StringValue(v);\
     rb_check_safe_obj(v);\
 } while (0)
-#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+#if GCC_VERSION_SINCE(4,4,0)
 void rb_check_safe_str(VALUE) __attribute__((error("rb_check_safe_str() and Check_SafeStr() are obsolete; use SafeStringValue() instead")));
 # define Check_SafeStr(v) rb_check_safe_str((VALUE)(v))
 #else
@@ -590,32 +590,32 @@ VALUE rb_get_path_no_checksafe(VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L590
 void rb_secure(int);
 int rb_safe_level(void);
 void rb_set_safe_level(int);
-#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+#if GCC_VERSION_SINCE(4,4,0)
 int ruby_safe_level_2_error(void) __attribute__((error("$SAFE=2 to 4 are obsolete")));
 int ruby_safe_level_2_warning(void) __attribute__((const,warning("$SAFE=2 to 4 are obsolete")));
 # ifdef RUBY_EXPORT
 #   define ruby_safe_level_2_warning() ruby_safe_level_2_error()
 # endif
-#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
-# define RUBY_SAFE_LEVEL_INVALID_P(level) \
+# if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
+#  define RUBY_SAFE_LEVEL_INVALID_P(level) \
     __extension__(\
 	__builtin_choose_expr(\
 	    __builtin_constant_p(level), \
 	    ((level) < 0 || RUBY_SAFE_LEVEL_MAX < (level)), 0))
-# define RUBY_SAFE_LEVEL_CHECK(level, type) \
+#  define RUBY_SAFE_LEVEL_CHECK(level, type) \
     __extension__(__builtin_choose_expr(RUBY_SAFE_LEVEL_INVALID_P(level), ruby_safe_level_2_##type(), (level)))
-#else
+# else
 /* in gcc 4.8 or earlier, __builtin_choose_expr() does not consider
  * __builtin_constant_p(variable) a constant expression.
  */
-# define RUBY_SAFE_LEVEL_INVALID_P(level) \
+#  define RUBY_SAFE_LEVEL_INVALID_P(level) \
     __extension__(__builtin_constant_p(level) && \
 		  ((level) < 0 || RUBY_SAFE_LEVEL_MAX < (level)))
-# define RUBY_SAFE_LEVEL_CHECK(level, type) \
+#  define RUBY_SAFE_LEVEL_CHECK(level, type) \
     (RUBY_SAFE_LEVEL_INVALID_P(level) ? ruby_safe_level_2_##type() : (level))
-#endif
-#define rb_secure(level) rb_secure(RUBY_SAFE_LEVEL_CHECK(level, warning))
-#define rb_set_safe_level(level) rb_set_safe_level(RUBY_SAFE_LEVEL_CHECK(level, error))
+# endif
+# define rb_secure(level) rb_secure(RUBY_SAFE_LEVEL_CHECK(level, warning))
+# define rb_set_safe_level(level) rb_set_safe_level(RUBY_SAFE_LEVEL_CHECK(level, error))
 #endif
 void rb_set_safe_level_force(int);
 CONSTFUNC(void rb_secure_update(VALUE));
@@ -1335,7 +1335,7 @@ rb_obj_freeze_inline(VALUE x) https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1335
     }
 }
 
-#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+#if GCC_VERSION_SINCE(4,4,0)
 # define RUBY_UNTYPED_DATA_FUNC(func) func __attribute__((warning("untyped Data is unsafe; use TypedData instead")))
 #else
 # define RUBY_UNTYPED_DATA_FUNC(func) DEPRECATED(func)
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54987)
+++ ChangeLog	(revision 54988)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri May 13 03:12:09 2016  NARUSE, Yui  <naruse@r...>
+
+	* include/ruby/defines.h (GCC_VERSION_SINCE): moved from internal.h.
+
 Fri May 13 03:11:20 2016  NARUSE, Yui  <naruse@r...>
 
 	* configure.in (__builtin_constant_p): check.
Index: gc.c
===================================================================
--- gc.c	(revision 54987)
+++ gc.c	(revision 54988)
@@ -947,8 +947,7 @@ tick(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L947
     return ((unsigned long long)lo)|( ((unsigned long long)hi)<<32);
 }
 
-#elif defined(__powerpc64__) && \
-    (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
+#elif defined(__powerpc64__) && GCC_VERSION_SINCE(4,8,0)
 typedef unsigned long long tick_t;
 #define PRItick "llu"
 
Index: internal.h
===================================================================
--- internal.h	(revision 54987)
+++ internal.h	(revision 54988)
@@ -40,7 +40,7 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/internal.h#L40
 
 #if __has_attribute(__warn_unused_result__)
 #define WARN_UNUSED_RESULT(x) x __attribute__((__warn_unused_result__))
-#elif defined(__GNUC__) && (__GNUC__ * 1000 + __GNUC_MINOR__) >= 3004
+#elif GCC_VERSION_SINCE(3,4,0)
 #define WARN_UNUSED_RESULT(x) x __attribute__((__warn_unused_result__))
 #else
 #define WARN_UNUSED_RESULT(x) x
@@ -61,12 +61,6 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/internal.h#L61
 
 #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
 
-#define GCC_VERSION_SINCE(major, minor, patchlevel) \
-  (defined(__GNUC__) && !defined(__INTEL_COMPILER) && \
-   ((__GNUC__ > (major)) ||  \
-    (__GNUC__ == (major) && __GNUC_MINOR__ > (minor)) || \
-    (__GNUC__ == (major) && __GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ >= (patchlevel))))
-
 #ifndef __has_feature
 # define __has_feature(x) 0
 #endif

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]