List:Commits« Previous MessageNext Message »
From:Guilhem Bichot Date:May 10 2010 12:41pm
Subject:bzr commit into mysql-next-mr-bugfixing branch (guilhem:3159)
View as plain text  
#At file:///home/mysql_src/bzrrepos/mysql-next-mr-opt-backporting2/ based on revid:epotemkin@stripped

 3159 Guilhem Bichot	2010-05-10
      Backport of a little bit of guilhem@stripped:
      likely() had an implicit cast to long, which loses bits when likely(ulonglong)
      or likely(pointer) and has proved to cause bugs.

    modified:
      include/my_global.h
=== modified file 'include/my_global.h'
--- a/include/my_global.h	2010-02-25 12:23:43 +0000
+++ b/include/my_global.h	2010-05-10 09:10:42 +0000
@@ -227,9 +227,14 @@
 #define __builtin_expect(x, expected_value) (x)
 #endif
 
-#define likely(x)	__builtin_expect((x),1)
-#define unlikely(x)	__builtin_expect((x),0)
-
+/**
+  The semantics of builtin_expect() are that
+  1) its two arguments are long
+  2) it's likely that they are ==
+  Those of our likely(x) are that x can be bool/int/longlong/pointer.
+*/
+#define likely(x)	__builtin_expect(((x) != 0),1)
+#define unlikely(x)	__builtin_expect(((x) != 0),0)
 
 /*
   The macros below are useful in optimising places where it has been


Attachment: [text/bzr-bundle] bzr/guilhem@mysql.com-20100510091042-9o7uk4cjesepob5y.bundle
Thread
bzr commit into mysql-next-mr-bugfixing branch (guilhem:3159) Guilhem Bichot14 May