In perl.git, the branch smoke-me/nicholas/likely-cBOOL has been updated <http://perl5.git.perl.org/perl.git/commitdiff/c0b8e78149fde4b5e8c0319f943946a178b3109e?hp=f615be485d8c90f01432a39e678e01c615e2c15e>
- Log ----------------------------------------------------------------- commit c0b8e78149fde4b5e8c0319f943946a178b3109e Author: Nicholas Clark <[email protected]> Date: Wed Mar 6 16:27:08 2013 +0100 Change LIKELY() and UNLIKELY() to cast their first argument to a bool. This avoids problems such as pointers being compared with the literal value 1. Suggested by Zefram. Note that this is technically a change of behaviour, as the macro EXPECT(), which they are both both wrappers for, returns its value, so they will now be returning TRUE or FALSE, rather than the actual value passed to them. However, all uses in the core and on CPAN are only within if() statements, so this should not make any difference in practice. ----------------------------------------------------------------------- Summary of changes: perl.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/perl.h b/perl.h index 4b020c7..a7b8251 100644 --- a/perl.h +++ b/perl.h @@ -3329,8 +3329,8 @@ typedef pthread_key_t perl_key; #else # define EXPECT(expr,val) (expr) #endif -#define LIKELY(cond) EXPECT(cond,1) -#define UNLIKELY(cond) EXPECT(cond,0) +#define LIKELY(cond) EXPECT(cBOOL(cond),TRUE) +#define UNLIKELY(cond) EXPECT(cBOOL(cond),FALSE) #ifdef HAS_BUILTIN_CHOOSE_EXPR /* placeholder */ #endif -- Perl5 Master Repository
