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

ruby-changes:71226

From: Nobuyoshi <ko1@a...>
Date: Sat, 19 Feb 2022 23:33:05 +0900 (JST)
Subject: [ruby-changes:71226] 131154f878 (master): Define `HAVE___BUILTIN_UNREACHABLE` instead of `UNREACHABLE`

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

From 131154f878b7f63277bd97520500414047a814fa Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 19 Feb 2022 16:02:29 +0900
Subject: Define `HAVE___BUILTIN_UNREACHABLE` instead of `UNREACHABLE`

`UNREACHABLE` in ruby/internal/has/builtin.h is only used as just
a flag now, and redefined in ruby/backward/2/assume.h then.
---
 configure.ac                        | 2 +-
 include/ruby/backward/2/assume.h    | 1 -
 include/ruby/internal/has/builtin.h | 6 +-----
 win32/Makefile.sub                  | 1 -
 4 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4b8dce1a2f..916e9a4e98 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1677,7 +1677,7 @@ AS_IF([test "$GCC" = yes], [ https://github.com/ruby/ruby/blob/trunk/configure.ac#L1677
     ])
     ])
     AS_IF([test "$rb_cv_func___builtin_unreachable" = yes], [
-	AC_DEFINE_UNQUOTED(UNREACHABLE, [__builtin_unreachable()])
+	AC_DEFINE(HAVE___BUILTIN_UNREACHABLE)
     ])
 }
 
diff --git a/include/ruby/backward/2/assume.h b/include/ruby/backward/2/assume.h
index 265421df79..10d2f826f6 100644
--- a/include/ruby/backward/2/assume.h
+++ b/include/ruby/backward/2/assume.h
@@ -25,7 +25,6 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/backward/2/assume.h#L25
 #include "ruby/internal/has/builtin.h"
 
 #undef  ASSUME             /* Kill config.h definition */
-#undef  UNREACHABLE        /* 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/has/builtin.h b/include/ruby/internal/has/builtin.h
index c7b1ba44a7..243ba2a34c 100644
--- a/include/ruby/internal/has/builtin.h
+++ b/include/ruby/internal/has/builtin.h
@@ -78,10 +78,6 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/has/builtin.h#L78
 # define RBIMPL_HAS_BUILTIN___builtin_unreachable       RBIMPL_COMPILER_SINCE(GCC, 4, 5, 0)
 # /* Note that "0, 0, 0" might be inaccurate. */
 
-#elif RBIMPL_COMPILER_IS(MSVC)
-# /* MSVC has UNREACHABLE, but that is not __builtin_unreachable. */
-# define RBIMPL_HAS_BUILTIN(_) 0
-
 #else
 # /* Take config.h definition when available */
 # define RBIMPL_HAS_BUILTIN(_) ((RBIMPL_HAS_BUILTIN_ ## _)+0)
@@ -111,7 +107,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/has/builtin.h#L107
 # define RBIMPL_HAS_BUILTIN___builtin_rotateright64     0
 # define RBIMPL_HAS_BUILTIN___builtin_popcountll        HAVE_BUILTIN___BUILTIN_POPCOUNTLL
 # define RBIMPL_HAS_BUILTIN___builtin_sub_overflow      HAVE_BUILTIN___BUILTIN_SUB_OVERFLOW
-# if defined(UNREACHABLE)
+# if defined(HAVE___BUILTIN_UNREACHABLE)
 #  define RBIMPL_HAS_BUILTIN___builtin_unreachable 1
 # else
 #  define RBIMPL_HAS_BUILTIN___builtin_unreachable 0
diff --git a/win32/Makefile.sub b/win32/Makefile.sub
index a339061459..06d12099bb 100644
--- a/win32/Makefile.sub
+++ b/win32/Makefile.sub
@@ -702,7 +702,6 @@ $(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 UNREACHABLE __assume(0)
 #define ASSUME(x) __assume(!!(x))
 #define FUNC_STDCALL(x) __stdcall x
 #define FUNC_CDECL(x) __cdecl x
-- 
cgit v1.2.1


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

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