aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-23 07:15:25 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-23 07:15:25 +0000
commit5587badf241777493d833d258dc31c4d70b7ea8b (patch)
tree3476d507f7554ac16d2ebbb931166eccb0de7a31
parent3f7cce9f189a06a9321ad084ae632058b2422fe1 (diff)
downloadruby-5587badf241777493d833d258dc31c4d70b7ea8b.tar.gz
* include/ruby/ruby.h (RB_LIKELY): use prefix in ruby.h.
* intern.h (LIKELY): define with RB_LIKELY. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--include/ruby/ruby.h18
-rw-r--r--internal.h3
3 files changed, 18 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 0124ea40c9..8b666883cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Apr 23 16:10:02 2016 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* NEWS: Add descriptions for Time#to_time updates.
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 71e61721d2..b12beff9b1 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -53,7 +53,7 @@ extern "C" {
#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" {
/* 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, size_t max, size_t *c)
{
#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 *store, long count, size_t elsize)
{
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);
diff --git a/internal.h b/internal.h
index 371cb1b83a..a9f50a5cdc 100644
--- a/internal.h
+++ b/internal.h
@@ -23,6 +23,9 @@ extern "C" {
#endif
#endif
+#define LIKELY(x) RB_LIKELY(x)
+#define UNLIKELY(x) RB_UNLIKELY(x)
+
#ifndef __has_attribute
# define __has_attribute(x) 0
#endif