[前][次][番号順一覧][スレッド一覧]

ruby-changes:71225

From: Nobuyoshi <ko1@a...>
Date: Sat, 19 Feb 2022 23:33:05 +0900 (JST)
Subject: [ruby-changes:71225] 7470780058 (master): Check if `__assume` is supported

https://git.ruby-lang.org/ruby.git/commit/?id=7470780058

From 74707800588dc452d5a64e786b5c98d0e7586e74 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 19 Feb 2022 21:22:13 +0900
Subject: Check if `__assume` is supported

---
 configure.ac                     | 12 ++++++++++++
 include/ruby/backward/2/assume.h |  1 -
 include/ruby/internal/assume.h   |  5 +----
 win32/Makefile.sub               |  2 +-
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 916e9a4e98..b63e395091 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1679,6 +1679,18 @@ AS_IF([test "$GCC" = yes], [ https://github.com/ruby/ruby/blob/trunk/configure.ac#L1679
     AS_IF([test "$rb_cv_func___builtin_unreachable" = yes], [
 	AC_DEFINE(HAVE___BUILTIN_UNREACHABLE)
     ])
+
+    AC_CACHE_CHECK(for __assume, rb_cv_func___assume,
+    [RUBY_WERROR_FLAG([
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
+            [[__assume(1);]])],
+            [rb_cv_func___assume=yes],
+            [rb_cv_func___assume=no])
+    ])
+    ])
+    AS_IF([test "$rb_cv_func___assume" = yes], [
+	AC_DEFINE(HAVE___ASSUME)
+    ])
 }
 
 AC_CACHE_CHECK(for exported function attribute, rb_cv_func_exported, [
diff --git a/include/ruby/backward/2/assume.h b/include/ruby/backward/2/assume.h
index 10d2f826f6..d148710127 100644
--- a/include/ruby/backward/2/assume.h
+++ b/include/ruby/backward/2/assume.h
@@ -24,7 +24,6 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/backward/2/assume.h#L24
 #include "ruby/internal/assume.h"
 #include "ruby/internal/has/builtin.h"
 
-#undef  ASSUME             /* Kill config.h definition */
 #define ASSUME             RBIMPL_ASSUME             /**< @old{RBIMPL_ASSUME} */
 #define UNREACHABLE        RBIMPL_UNREACHABLE()      /**< @old{RBIMPL_UNREACHABLE} */
 #define UNREACHABLE_RETURN RBIMPL_UNREACHABLE_RETURN /**< @old{RBIMPL_UNREACHABLE_RETURN} */
diff --git a/include/ruby/internal/assume.h b/include/ruby/internal/assume.h
index 65d34d4ac8..4c183e8af9 100644
--- a/include/ruby/internal/assume.h
+++ b/include/ruby/internal/assume.h
@@ -32,10 +32,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/assume.h#L32
 #include "ruby/internal/warning_push.h"
 
 /** @cond INTERNAL_MACRO */
-#if RBIMPL_COMPILER_SINCE(MSVC, 13, 10, 0)
-# define RBIMPL_HAVE___ASSUME
-
-#elif RBIMPL_COMPILER_SINCE(Intel, 13, 0, 0)
+#if defined(HAVE___ASSUME)
 # define RBIMPL_HAVE___ASSUME
 #endif
 /** @endcond */
diff --git a/win32/Makefile.sub b/win32/Makefile.sub
index 06d12099bb..2b4bebac48 100644
--- a/win32/Makefile.sub
+++ b/win32/Makefile.sub
@@ -702,7 +702,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub https://github.com/ruby/ruby/blob/trunk/win32/Makefile.sub#L702
 #define ALWAYS_INLINE(x) __forceinline x
 #define WARN_UNUSED_RESULT(x) x
 #define MAYBE_UNUSED(x) x
-#define ASSUME(x) __assume(!!(x))
+#define HAVE___ASSUME 1
 #define FUNC_STDCALL(x) __stdcall x
 #define FUNC_CDECL(x) __cdecl x
 #define FUNC_FASTCALL(x) __fastcall x
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]