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], [ 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 @@ #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 @@ #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 #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