diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-05 04:58:00 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-05 04:58:00 +0000 |
commit | 1ccaa4756aff30afdaa4f9a565c69722a6f6ebe8 (patch) | |
tree | 135a45286d604bceaf6f8e7767e7234a5453e4b2 /internal.h | |
parent | 135bbdcdc704c6d6b3c86a0af188c4413fbd0640 (diff) | |
download | ruby-1ccaa4756aff30afdaa4f9a565c69722a6f6ebe8.tar.gz |
* 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
Diffstat (limited to 'internal.h')
-rw-r--r-- | internal.h | 21 |
1 files changed, 21 insertions, 0 deletions
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 <valgrind/memcheck.h> # ifndef VALGRIND_MAKE_MEM_DEFINED |