summaryrefslogtreecommitdiff
path: root/include/ruby/defines.h
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-05 17:23:32 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-05 17:23:32 +0000
commiteb79191f16dea9547ded38413b38f4de3fa78569 (patch)
tree180d91f941c8e4b7958bc7193bf1b12a7d63432e /include/ruby/defines.h
parent756914e57ed6c818155961e43d502132a401cc20 (diff)
Introduce "COLDFUNC" function attribute.
* include/ruby/defines.h: introduce "COLDFUNC" function attribute on several compilers for called unlikely functions. Apply to rb_memerror, rb_warn and rb_bug. A patch form methodmissing <lourens@bearmetal.eu>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby/defines.h')
-rw-r--r--include/ruby/defines.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/ruby/defines.h b/include/ruby/defines.h
index fb80813f05..cbf5537790 100644
--- a/include/ruby/defines.h
+++ b/include/ruby/defines.h
@@ -89,6 +89,16 @@ extern "C" {
#define RB_UNLIKELY(x) (x)
#endif /* __GNUC__ >= 3 */
+/*
+ cold attribute for code layout improvements
+ RUBY_FUNC_ATTRIBUTE not used because MSVC does not like nested func macros
+ */
+#if defined(__clang__) || GCC_VERSION_SINCE(4, 3, 0)
+#define COLDFUNC __attribute__((cold))
+#else
+#define COLDFUNC
+#endif
+
#ifdef __GNUC__
#if defined __MINGW_PRINTF_FORMAT
#define PRINTF_ARGS(decl, string_index, first_to_check) \