ruby-changes:35784
From: nobu <ko1@a...>
Date: Fri, 10 Oct 2014 21:45:32 +0900 (JST)
Subject: [ruby-changes:35784] nobu:r47866 (trunk): ruby/ruby.h: eliminate disabled function call
nobu 2014-10-10 21:45:21 +0900 (Fri, 10 Oct 2014) New Revision: 47866 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47866 Log: ruby/ruby.h: eliminate disabled function call * include/ruby/ruby.h (RUBY_SAFE_LEVEL_CHECK): eliminate function call for warning/error if not match to get rid of unconditional warning/error by a certain compiler option. Modified files: trunk/include/ruby/ruby.h trunk/thread.c Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 47865) +++ include/ruby/ruby.h (revision 47866) @@ -568,7 +568,7 @@ int ruby_safe_level_4_warning(void) __at https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L568 __extension__(__builtin_constant_p(level) && \ ((level) < 0 || RUBY_SAFE_LEVEL_MAX < (level))) #define RUBY_SAFE_LEVEL_CHECK(level, type) \ - (RUBY_SAFE_LEVEL_INVALID_P(level) ? ruby_safe_level_4_##type() : (level)) + __extension__(__builtin_choose_expr(RUBY_SAFE_LEVEL_INVALID_P(level), ruby_safe_level_4_##type(), (level))) #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 Index: thread.c =================================================================== --- thread.c (revision 47865) +++ thread.c (revision 47866) @@ -145,7 +145,11 @@ static inline void blocking_region_end(r https://github.com/ruby/ruby/blob/trunk/thread.c#L145 } while(0) #ifdef __GNUC__ +#ifdef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR +#define only_if_constant(expr, notconst) __builtin_choose_expr(__builtin_constant_p(expr), (expr), (notconst)) +#else #define only_if_constant(expr, notconst) (__builtin_constant_p(expr) ? (expr) : (notconst)) +#endif #else #define only_if_constant(expr, notconst) notconst #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/