From 1ccaa4756aff30afdaa4f9a565c69722a6f6ebe8 Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 5 Feb 2014 04:58:00 +0000 Subject: * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ common.mk | 2 +- internal.h | 21 +++++++++++++++++++++ string.c | 1 - vm_core.h | 21 --------------------- 5 files changed, 31 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 76b98f64ca..7812570335 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Feb 5 13:51:33 2014 Koichi Sasada + + * 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 * string.c (rb_str_free): use FL_TEST(str, STR_SHARED) directly diff --git a/common.mk b/common.mk index 0056fa30d6..8c097e374b 100644 --- a/common.mk +++ b/common.mk @@ -751,7 +751,7 @@ st.$(OBJEXT): {$(VPATH)}st.c $(RUBY_H_INCLUDES) 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) \ diff --git a/internal.h b/internal.h index ddb59d64b3..a057b20ab0 100644 --- a/internal.h +++ b/internal.h @@ -19,6 +19,27 @@ extern "C" { #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 # ifndef VALGRIND_MAKE_MEM_DEFINED diff --git a/string.c b/string.c index 0110c0a3a0..589c80088e 100644 --- a/string.c +++ b/string.c @@ -14,7 +14,6 @@ #include "ruby/ruby.h" #include "ruby/re.h" #include "ruby/encoding.h" -#include "vm_core.h" #include "internal.h" #include "probes.h" #include diff --git a/vm_core.h b/vm_core.h index fb0ff6ddb4..b1b9cadf98 100644 --- a/vm_core.h +++ b/vm_core.h @@ -100,27 +100,6 @@ #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 */ -- cgit v1.2.3