ruby-changes:42653
From: naruse <ko1@a...>
Date: Sat, 23 Apr 2016 15:18:50 +0900 (JST)
Subject: [ruby-changes:42653] naruse:r54726 (trunk): * include/ruby/ruby.h (RB_LIKELY): use prefix in ruby.h.
naruse 2016-04-23 16:15:25 +0900 (Sat, 23 Apr 2016) New Revision: 54726 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54726 Log: * include/ruby/ruby.h (RB_LIKELY): use prefix in ruby.h. * intern.h (LIKELY): define with RB_LIKELY. Modified files: trunk/ChangeLog trunk/include/ruby/ruby.h trunk/internal.h Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 54725) +++ include/ruby/ruby.h (revision 54726) @@ -53,7 +53,7 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L53 #endif #ifndef ASSUME # ifdef UNREACHABLE -# define ASSUME(x) (LIKELY(!!(x)) ? (void)0 : UNREACHABLE) +# define ASSUME(x) (RB_LIKELY(!!(x)) ? (void)0 : UNREACHABLE) # else # define ASSUME(x) ((void)(x)) # endif @@ -64,11 +64,11 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L64 /* likely */ #if __GNUC__ >= 3 -#define LIKELY(x) (__builtin_expect(!!(x), 1)) -#define UNLIKELY(x) (__builtin_expect(!!(x), 0)) +#define RB_LIKELY(x) (__builtin_expect(!!(x), 1)) +#define RB_UNLIKELY(x) (__builtin_expect(!!(x), 0)) #else /* __GNUC__ >= 3 */ -#define LIKELY(x) (x) -#define UNLIKELY(x) (x) +#define RB_LIKELY(x) (x) +#define RB_UNLIKELY(x) (x) #endif /* __GNUC__ >= 3 */ #ifdef __GNUC__ @@ -1628,10 +1628,10 @@ rb_mul_size_overflow(size_t a, size_t b, https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1628 { #ifdef DSIZE_T DSIZE_T c2 = (DSIZE_T)a * (DSIZE_T)b; - if (UNLIKELY(c2 > max)) return 1; + if (RB_UNLIKELY(c2 > max)) return 1; *c = (size_t)c2; #else - if (b != 0 && UNLIKELY(a > max / b)) return 1; + if (b != 0 && RB_UNLIKELY(a > max / b)) return 1; *c = a * b; #endif return 0; @@ -1641,13 +1641,13 @@ rb_alloc_tmp_buffer2(volatile VALUE *sto https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1641 { size_t cnt = (size_t)count; if (elsize % sizeof(VALUE) == 0) { - if (UNLIKELY(cnt > LONG_MAX / sizeof(VALUE))) { + if (RB_UNLIKELY(cnt > LONG_MAX / sizeof(VALUE))) { ruby_malloc_size_overflow(cnt, elsize); } } else { size_t size, max = LONG_MAX - sizeof(VALUE) + 1; - if (UNLIKELY(rb_mul_size_overflow(count, elsize, max, &size))) { + if (RB_UNLIKELY(rb_mul_size_overflow(count, elsize, max, &size))) { ruby_malloc_size_overflow(cnt, elsize); } cnt = (size + sizeof(VALUE) - 1) / sizeof(VALUE); Index: ChangeLog =================================================================== --- ChangeLog (revision 54725) +++ ChangeLog (revision 54726) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Apr 23 16:10:02 2016 NARUSE, Yui <naruse@r...> + + * include/ruby/ruby.h (RB_LIKELY): use prefix in ruby.h. + + * intern.h (LIKELY): define with RB_LIKELY. + Sat Apr 23 13:27:25 2016 Yuichiro Kaneko <yui-knk@r...> * NEWS: Add descriptions for Time#to_time updates. Index: internal.h =================================================================== --- internal.h (revision 54725) +++ internal.h (revision 54726) @@ -23,6 +23,9 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/internal.h#L23 #endif #endif +#define LIKELY(x) RB_LIKELY(x) +#define UNLIKELY(x) RB_UNLIKELY(x) + #ifndef __has_attribute # define __has_attribute(x) 0 #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/