ruby-changes:32752
From: ko1 <ko1@a...>
Date: Wed, 5 Feb 2014 13:58:05 +0900 (JST)
Subject: [ruby-changes:32752] ko1:r44831 (trunk): * internal.h, vm_core.h: move LIKELY/UNLIKELY/UNINITIALIZED_VAR()
ko1 2014-02-05 13:58:00 +0900 (Wed, 05 Feb 2014) New Revision: 44831 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44831 Log: * internal.h, vm_core.h: move LIKELY/UNLIKELY/UNINITIALIZED_VAR() macros from vm_core.h to internal.h. * string.c: remove dependency to "vm_core.h". * common.mk: ditto. Modified files: trunk/ChangeLog trunk/common.mk trunk/internal.h trunk/string.c trunk/vm_core.h Index: ChangeLog =================================================================== --- ChangeLog (revision 44830) +++ ChangeLog (revision 44831) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Feb 5 13:51:33 2014 Koichi Sasada <ko1@a...> + + * internal.h, vm_core.h: move LIKELY/UNLIKELY/UNINITIALIZED_VAR() + macros from vm_core.h to internal.h. + + * string.c: remove dependency to "vm_core.h". + + * common.mk: ditto. + Wed Feb 5 13:29:01 2014 Koichi Sasada <ko1@a...> * string.c (rb_str_free): use FL_TEST(str, STR_SHARED) directly Index: vm_core.h =================================================================== --- vm_core.h (revision 44830) +++ vm_core.h (revision 44831) @@ -100,27 +100,6 @@ https://github.com/ruby/ruby/blob/trunk/vm_core.h#L100 #endif /* OPT_STACK_CACHING */ #endif /* OPT_CALL_THREADED_CODE */ -/* likely */ -#if __GNUC__ >= 3 -#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) -#endif /* __GNUC__ >= 3 */ - -#ifndef __has_attribute -# define __has_attribute(x) 0 -#endif - -#if __has_attribute(unused) -#define UNINITIALIZED_VAR(x) x __attribute__((unused)) -#elif defined(__GNUC__) && __GNUC__ >= 3 -#define UNINITIALIZED_VAR(x) x = x -#else -#define UNINITIALIZED_VAR(x) x -#endif - typedef unsigned long rb_num_t; /* iseq data type */ Index: string.c =================================================================== --- string.c (revision 44830) +++ string.c (revision 44831) @@ -14,7 +14,6 @@ https://github.com/ruby/ruby/blob/trunk/string.c#L14 #include "ruby/ruby.h" #include "ruby/re.h" #include "ruby/encoding.h" -#include "vm_core.h" #include "internal.h" #include "probes.h" #include <assert.h> Index: common.mk =================================================================== --- common.mk (revision 44830) +++ common.mk (revision 44831) @@ -751,7 +751,7 @@ st.$(OBJEXT): {$(VPATH)}st.c $(RUBY_H_IN https://github.com/ruby/ruby/blob/trunk/common.mk#L751 strftime.$(OBJEXT): {$(VPATH)}strftime.c $(RUBY_H_INCLUDES) \ {$(VPATH)}timev.h $(ENCODING_H_INCLUDES) string.$(OBJEXT): {$(VPATH)}string.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \ - {$(VPATH)}regex.h $(ENCODING_H_INCLUDES) {$(VPATH)}internal.h $(PROBES_H_INCLUDES) {$(VPATH)}vm_opts.h {$(VPATH)}node.h {$(VPATH)}ruby_atomic.h {$(VPATH)}vm_core.h {$(VPATH)}vm_debug.h {$(VPATH)}id.h {$(VPATH)}method.h {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}thread_native.h + {$(VPATH)}regex.h $(ENCODING_H_INCLUDES) {$(VPATH)}internal.h $(PROBES_H_INCLUDES) struct.$(OBJEXT): {$(VPATH)}struct.c $(RUBY_H_INCLUDES) {$(VPATH)}internal.h thread.$(OBJEXT): {$(VPATH)}thread.c {$(VPATH)}eval_intern.h \ $(RUBY_H_INCLUDES) {$(VPATH)}gc.h $(VM_CORE_H_INCLUDES) \ Index: internal.h =================================================================== --- internal.h (revision 44830) +++ internal.h (revision 44831) @@ -19,6 +19,27 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/internal.h#L19 #endif #endif +/* likely */ +#if __GNUC__ >= 3 +#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) +#endif /* __GNUC__ >= 3 */ + +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif + +#if __has_attribute(unused) +#define UNINITIALIZED_VAR(x) x __attribute__((unused)) +#elif defined(__GNUC__) && __GNUC__ >= 3 +#define UNINITIALIZED_VAR(x) x = x +#else +#define UNINITIALIZED_VAR(x) x +#endif + #ifdef HAVE_VALGRIND_MEMCHECK_H # include <valgrind/memcheck.h> # ifndef VALGRIND_MAKE_MEM_DEFINED -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/