ruby-changes:39261
From: nobu <ko1@a...>
Date: Wed, 22 Jul 2015 20:27:57 +0900 (JST)
Subject: [ruby-changes:39261] nobu:r51342 (trunk): ruby.h: ASSUME
nobu 2015-07-22 20:27:46 +0900 (Wed, 22 Jul 2015) New Revision: 51342 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51342 Log: ruby.h: ASSUME * include/ruby/ruby.h (ASSUME): hint for optimization, the expression is assumed to be true always. Modified files: trunk/include/ruby/ruby.h trunk/win32/Makefile.sub Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 51341) +++ include/ruby/ruby.h (revision 51342) @@ -41,8 +41,15 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L41 #ifndef NOINLINE # define NOINLINE(x) x #endif +#ifndef ASSUME +# ifdef UNREACHABLE +# define ASSUME(x) (LIKELY(!!(x)) ? (void)0 : UNREACHABLE) +# else +# define ASSUME(x) ((void)0) +# endif +#endif #ifndef UNREACHABLE -# define UNREACHABLE /* unreachable */ +# define UNREACHABLE ((void)0) /* unreachable */ #endif #ifdef __GNUC__ Index: win32/Makefile.sub =================================================================== --- win32/Makefile.sub (revision 51341) +++ win32/Makefile.sub (revision 51342) @@ -587,6 +587,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/ https://github.com/ruby/ruby/blob/trunk/win32/Makefile.sub#L587 #define NOINLINE(x) __declspec(noinline) x !endif #define UNREACHABLE __assume(0) +#define ASSUME(x) __assume(!!(x)) #define FUNC_STDCALL(x) __stdcall x #define FUNC_CDECL(x) __cdecl x #define FUNC_FASTCALL(x) __fastcall x -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/