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

ruby-changes:39340

From: nobu <ko1@a...>
Date: Wed, 29 Jul 2015 12:37:52 +0900 (JST)
Subject: [ruby-changes:39340] nobu:r51421 (trunk): internal.h: fix LIKELY

nobu	2015-07-29 12:37:24 +0900 (Wed, 29 Jul 2015)

  New Revision: 51421

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

  Log:
    internal.h: fix LIKELY
    
    * internal.h (LIKELY, UNLIKELY): inverted conditions generate
      wrong code.

  Modified files:
    trunk/internal.h
Index: internal.h
===================================================================
--- internal.h	(revision 51420)
+++ internal.h	(revision 51421)
@@ -25,8 +25,8 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/internal.h#L25
 
 /* likely */
 #if __GNUC__ >= 3
-#define LIKELY(x)   (__builtin_expect(!(x), 0))
-#define UNLIKELY(x) (__builtin_expect(!(x), 1))
+#define LIKELY(x)   (__builtin_expect(!!(x), 1))
+#define UNLIKELY(x) (__builtin_expect(!!(x), 0))
 #else /* __GNUC__ >= 3 */
 #define LIKELY(x)   (x)
 #define UNLIKELY(x) (x)

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

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