1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
naruse 2016-05-12 18:12:47 +00:00
parent 07dd6fcc96
commit b207e7cd1d
5 changed files with 27 additions and 23 deletions

View file

@ -1,3 +1,7 @@
Fri May 13 03:12:09 2016 NARUSE, Yui <naruse@ruby-lang.org>
* include/ruby/defines.h (GCC_VERSION_SINCE): moved from internal.h.
Fri May 13 03:11:20 2016 NARUSE, Yui <naruse@ruby-lang.org>
* configure.in (__builtin_constant_p): check.

3
gc.c
View file

@ -947,8 +947,7 @@ tick(void)
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"

View file

@ -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

View file

@ -565,7 +565,7 @@ void rb_check_safe_obj(VALUE);
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);
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)
}
}
#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)

View file

@ -40,7 +40,7 @@ extern "C" {
#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" {
#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