summaryrefslogtreecommitdiff
path: root/include/ruby/3/has
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-04-08 13:28:13 +0900
committerGitHub <noreply@github.com>2020-04-08 13:28:13 +0900
commit9e6e39c3512f7a962c44dc3729c98a0f8be90341 (patch)
tree901a22676d54d78240e450b64a8cd06eb1703910 /include/ruby/3/has
parent5ac4bf2cd87e1eb5779ca5ae7f96a1a22e8436d9 (diff)
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
Notes
Notes: Merged-By: shyouhei <shyouhei@ruby-lang.org>
Diffstat (limited to 'include/ruby/3/has')
-rw-r--r--include/ruby/3/has/attribute.h154
-rw-r--r--include/ruby/3/has/builtin.h90
-rw-r--r--include/ruby/3/has/c_attribute.h37
-rw-r--r--include/ruby/3/has/cpp_attribute.h82
-rw-r--r--include/ruby/3/has/declspec_attribute.h48
-rw-r--r--include/ruby/3/has/extension.h33
-rw-r--r--include/ruby/3/has/feature.h31
-rw-r--r--include/ruby/3/has/warning.h31
8 files changed, 506 insertions, 0 deletions
diff --git a/include/ruby/3/has/attribute.h b/include/ruby/3/has/attribute.h
new file mode 100644
index 0000000000..229e092b30
--- /dev/null
+++ b/include/ruby/3/has/attribute.h
@@ -0,0 +1,154 @@
+/** \noop-*-C++-*-vi:ft=cpp
+ * @file
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @warning Symbols prefixed with either `RUBY3` or `ruby3` are
+ * implementation details. Don't take them as canon. They could
+ * rapidly appear then vanish. The name (path) of this header file
+ * is also an implementation detail. Do not expect it to persist
+ * at the place it is now. Developers are free to move it anywhere
+ * anytime at will.
+ * @note To ruby-core: remember that this header can be possibly
+ * recursively included from extension libraries written in C++.
+ * Do not expect for instance `__VA_ARGS__` is always available.
+ * We assume C99 for ruby itself but we don't assume languages of
+ * extension libraries. They could be written in C++98.
+ * @brief Defines #RUBY3_HAS_ATTRIBUTE.
+ */
+#include "ruby/3/config.h"
+#include "ruby/3/compiler_since.h"
+#include "ruby/3/token_paste.h"
+
+/** Wraps (or simulates) `__has_attribute`. */
+#if defined(RUBY3_HAS_ATTRIBUTE)
+# /* Take that. */
+
+#elif defined(__has_attribute)
+# define RUBY3_HAS_ATTRIBUTE(_) __has_attribute(_)
+
+#elif RUBY3_COMPILER_IS(GCC)
+# /* GCC <= 4 lack __has_attribute predefined macro, while have attributes
+# * themselves. We can simulate the macro like the following: */
+# define RUBY3_HAS_ATTRIBUTE(_) RUBY3_TOKEN_PASTE(RUBY3_HAS_ATTRIBUTE_, _)
+# define RUBY3_HAS_ATTRIBUTE_aligned RUBY3_COMPILER_SINCE(GCC, 0, 0, 0)
+# define RUBY3_HAS_ATTRIBUTE_alloc_size RUBY3_COMPILER_SINCE(GCC, 4, 3, 0)
+# define RUBY3_HAS_ATTRIBUTE_artificial RUBY3_COMPILER_SINCE(GCC, 4, 3, 0)
+# define RUBY3_HAS_ATTRIBUTE_always_inline RUBY3_COMPILER_SINCE(GCC, 3, 1, 0)
+# define RUBY3_HAS_ATTRIBUTE_cdecl RUBY3_COMPILER_SINCE(GCC, 0, 0, 0)
+# define RUBY3_HAS_ATTRIBUTE_cold RUBY3_COMPILER_SINCE(GCC, 4, 3, 0)
+# define RUBY3_HAS_ATTRIBUTE_const RUBY3_COMPILER_SINCE(GCC, 2, 6, 0)
+# define RUBY3_HAS_ATTRIBUTE_deprecated RUBY3_COMPILER_SINCE(GCC, 3, 1, 0)
+# define RUBY3_HAS_ATTRIBUTE_dllexport RUBY3_COMPILER_SINCE(GCC, 0, 0, 0)
+# define RUBY3_HAS_ATTRIBUTE_dllimport RUBY3_COMPILER_SINCE(GCC, 0, 0, 0)
+# define RUBY3_HAS_ATTRIBUTE_error RUBY3_COMPILER_SINCE(GCC, 4, 3, 0)
+# define RUBY3_HAS_ATTRIBUTE_format RUBY3_COMPILER_SINCE(GCC, 0, 0, 0)
+# define RUBY3_HAS_ATTRIBUTE_hot RUBY3_COMPILER_SINCE(GCC, 4, 3, 0)
+# define RUBY3_HAS_ATTRIBUTE_leaf RUBY3_COMPILER_SINCE(GCC, 4, 6, 0)
+# define RUBY3_HAS_ATTRIBUTE_malloc RUBY3_COMPILER_SINCE(GCC, 3, 0, 0)
+# define RUBY3_HAS_ATTRIBUTE_no_address_safety_analysis RUBY3_COMPILER_SINCE(GCC, 4, 8, 0)
+# define RUBY3_HAS_ATTRIBUTE_no_sanitize_address RUBY3_COMPILER_SINCE(GCC, 4, 8, 0)
+# define RUBY3_HAS_ATTRIBUTE_no_sanitize_undefined RUBY3_COMPILER_SINCE(GCC, 4, 9, 0)
+# define RUBY3_HAS_ATTRIBUTE_noinline RUBY3_COMPILER_SINCE(GCC, 3, 1, 0)
+# define RUBY3_HAS_ATTRIBUTE_nonnull RUBY3_COMPILER_SINCE(GCC, 3, 3, 0)
+# define RUBY3_HAS_ATTRIBUTE_noreturn RUBY3_COMPILER_SINCE(GCC, 2, 5, 0)
+# define RUBY3_HAS_ATTRIBUTE_nothrow RUBY3_COMPILER_SINCE(GCC, 3, 3, 0)
+# define RUBY3_HAS_ATTRIBUTE_pure RUBY3_COMPILER_SINCE(GCC, 2,96, 0)
+# define RUBY3_HAS_ATTRIBUTE_returns_nonnull RUBY3_COMPILER_SINCE(GCC, 4, 9, 0)
+# define RUBY3_HAS_ATTRIBUTE_returns_twice RUBY3_COMPILER_SINCE(GCC, 4, 1, 0)
+# define RUBY3_HAS_ATTRIBUTE_stdcall RUBY3_COMPILER_SINCE(GCC, 0, 0, 0)
+# define RUBY3_HAS_ATTRIBUTE_unused RUBY3_COMPILER_SINCE(GCC, 0, 0, 0)
+# define RUBY3_HAS_ATTRIBUTE_visibility RUBY3_COMPILER_SINCE(GCC, 3, 3, 0)
+# define RUBY3_HAS_ATTRIBUTE_warn_unused_result RUBY3_COMPILER_SINCE(GCC, 3, 4, 0)
+# define RUBY3_HAS_ATTRIBUTE_warning RUBY3_COMPILER_SINCE(GCC, 4, 3, 0)
+# define RUBY3_HAS_ATTRIBUTE_weak RUBY3_COMPILER_SINCE(GCC, 0, 0, 0)
+# /* Note that "0, 0, 0" might be inaccurate. */
+
+#elif RUBY3_COMPILER_IS(SunPro)
+# /* Oracle Solaris Studio 12.4 (cc version 5.11) introduced __has_attribute.
+# * Before that, following attributes were available. */
+# /* See https://docs.oracle.com/cd/F24633_01/index.html */
+# define RUBY3_HAS_ATTRIBUTE(_) RUBY3_TOKEN_PASTE(RUBY3_HAS_ATTRIBUTE_, _)
+# define RUBY3_HAS_ATTRIBUTE_alias RUBY3_COMPILER_SINCE(SunPro, 5, 9, 0)
+# define RUBY3_HAS_ATTRIBUTE_aligned RUBY3_COMPILER_SINCE(SunPro, 5, 9, 0)
+# define RUBY3_HAS_ATTRIBUTE_always_inline RUBY3_COMPILER_SINCE(SunPro, 5, 10, 0)
+# define RUBY3_HAS_ATTRIBUTE_const RUBY3_COMPILER_SINCE(SunPro, 5, 9, 0)
+# define RUBY3_HAS_ATTRIBUTE_constructor RUBY3_COMPILER_SINCE(SunPro, 5, 9, 0)
+# define RUBY3_HAS_ATTRIBUTE_destructor RUBY3_COMPILER_SINCE(SunPro, 5, 9, 0)
+# define RUBY3_HAS_ATTRIBUTE_malloc RUBY3_COMPILER_SINCE(SunPro, 5, 9, 0)
+# define RUBY3_HAS_ATTRIBUTE_noinline RUBY3_COMPILER_SINCE(SunPro, 5, 9, 0)
+# define RUBY3_HAS_ATTRIBUTE_noreturn RUBY3_COMPILER_SINCE(SunPro, 5, 9, 0)
+# define RUBY3_HAS_ATTRIBUTE_packed RUBY3_COMPILER_SINCE(SunPro, 5, 9, 0)
+# define RUBY3_HAS_ATTRIBUTE_pure RUBY3_COMPILER_SINCE(SunPro, 5, 9, 0)
+# define RUBY3_HAS_ATTRIBUTE_returns_twice RUBY3_COMPILER_SINCE(SunPro, 5, 10, 0)
+# define RUBY3_HAS_ATTRIBUTE_vector_size RUBY3_COMPILER_SINCE(SunPro, 5, 10, 0)
+# define RUBY3_HAS_ATTRIBUTE_visibility RUBY3_COMPILER_SINCE(SunPro, 5, 9, 0)
+# define RUBY3_HAS_ATTRIBUTE_weak RUBY3_COMPILER_SINCE(SunPro, 5, 9, 0)
+
+#elif defined (_MSC_VER)
+# define RUBY3_HAS_ATTRIBUTE(_) 0
+# /* Fallback below doesn't work: see win32/Makefile.sub */
+
+#else
+# /* Take config.h definition when available. */
+# define RUBY3_HAS_ATTRIBUTE(_) RUBY3_TOKEN_PASTE(RUBY3_HAS_ATTRIBUTE_, _)
+# ifdef ALWAYS_INLINE
+# define RUBY3_HAS_ATTRIBUTE_always_inline
+# endif
+# ifdef FUNC_CDECL
+# define RUBY3_HAS_ATTRIBUTE_cdecl
+# endif
+# ifdef CONSTFUNC
+# define RUBY3_HAS_ATTRIBUTE_const
+# endif
+# ifdef DEPRECATED
+# define RUBY3_HAS_ATTRIBUTE_deprecated
+# endif
+# ifdef ERRORFUNC
+# define RUBY3_HAS_ATTRIBUTE_error
+# endif
+# ifdef FUNC_FASTCALL
+# define RUBY3_HAS_ATTRIBUTE_fastcall
+# endif
+# ifdef PUREFUNC
+# define RUBY3_HAS_ATTRIBUTE_pure
+# endif
+# ifdef NO_ADDRESS_SAFETY_ANALYSIS
+# define RUBY3_HAS_ATTRIBUTE_no_address_safety_analysis
+# endif
+# ifdef NO_SANITIZE
+# define RUBY3_HAS_ATTRIBUTE_no_sanitize
+# endif
+# ifdef NO_SANITIZE_ADDRESS
+# define RUBY3_HAS_ATTRIBUTE_no_sanitize_address
+# endif
+# ifdef NOINLINE
+# define RUBY3_HAS_ATTRIBUTE_noinline
+# endif
+# ifdef RUBY3_FUNC_NONNULL
+# define RUBY3_HAS_ATTRIBUTE_nonnull
+# endif
+# ifdef NORETURN
+# define RUBY3_HAS_ATTRIBUTE_noreturn
+# endif
+# ifdef FUNC_OPTIMIZED
+# define RUBY3_HAS_ATTRIBUTE_optimize
+# endif
+# ifdef FUNC_STDCALL
+# define RUBY3_HAS_ATTRIBUTE_stdcall
+# endif
+# ifdef MAYBE_UNUSED
+# define RUBY3_HAS_ATTRIBUTE_unused
+# endif
+# ifdef WARN_UNUSED_RESULT
+# define RUBY3_HAS_ATTRIBUTE_warn_unused_result
+# endif
+# ifdef WARNINGFUNC
+# define RUBY3_HAS_ATTRIBUTE_warning
+# endif
+# ifdef WEAK
+# define RUBY3_HAS_ATTRIBUTE_weak
+# endif
+#endif
diff --git a/include/ruby/3/has/builtin.h b/include/ruby/3/has/builtin.h
new file mode 100644
index 0000000000..51e1875b72
--- /dev/null
+++ b/include/ruby/3/has/builtin.h
@@ -0,0 +1,90 @@
+/** \noop-*-C++-*-vi:ft=cpp
+ * @file
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @warning Symbols prefixed with either `RUBY3` or `ruby3` are
+ * implementation details. Don't take them as canon. They could
+ * rapidly appear then vanish. The name (path) of this header file
+ * is also an implementation detail. Do not expect it to persist
+ * at the place it is now. Developers are free to move it anywhere
+ * anytime at will.
+ * @note To ruby-core: remember that this header can be possibly
+ * recursively included from extension libraries written in C++.
+ * Do not expect for instance `__VA_ARGS__` is always available.
+ * We assume C99 for ruby itself but we don't assume languages of
+ * extension libraries. They could be written in C++98.
+ * @brief Defines #RUBY3_HAS_BUILTIN.
+ */
+#include "ruby/3/config.h"
+#include "ruby/3/compiler_since.h"
+#include "ruby/3/token_paste.h"
+
+/** Wraps (or simulates) `__has_builtin`. */
+#if defined(RUBY3_HAS_BUILTIN)
+# /* Take that. */
+
+#elif defined(__has_builtin)
+# define RUBY3_HAS_BUILTIN(_) __has_builtin(_)
+
+#elif RUBY3_COMPILER_IS(GCC)
+# /* :FIXME: Historically GCC has had tons of builtins, but it implemented
+# * __has_builtin only since GCC 10. This section can be made more
+# * granular. */
+# /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66970 */
+# define RUBY3_HAS_BUILTIN(_) RUBY3_TOKEN_PASTE(RUBY3_HAS_BUILTIN_, _)
+# define RUBY3_HAS_BUILTIN___builtin_add_overflow RUBY3_COMPILER_SINCE(GCC, 5, 1, 0)
+# define RUBY3_HAS_BUILTIN___builtin_alloca RUBY3_COMPILER_SINCE(GCC, 0, 0, 0)
+# define RUBY3_HAS_BUILTIN___builtin_alloca_with_align RUBY3_COMPILER_SINCE(GCC, 6, 1, 0)
+# /* See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624 for bswap16. */
+# define RUBY3_HAS_BUILTIN___builtin_bswap16 RUBY3_COMPILER_SINCE(GCC, 4, 8, 0)
+# define RUBY3_HAS_BUILTIN___builtin_bswap32 RUBY3_COMPILER_SINCE(GCC, 3, 6, 0)
+# define RUBY3_HAS_BUILTIN___builtin_bswap64 RUBY3_COMPILER_SINCE(GCC, 3, 6, 0)
+# define RUBY3_HAS_BUILTIN___builtin_clz RUBY3_COMPILER_SINCE(GCC, 3, 6, 0)
+# define RUBY3_HAS_BUILTIN___builtin_clzl RUBY3_COMPILER_SINCE(GCC, 3, 6, 0)
+# define RUBY3_HAS_BUILTIN___builtin_clzll RUBY3_COMPILER_SINCE(GCC, 3, 6, 0)
+# define RUBY3_HAS_BUILTIN___builtin_constant_p RUBY3_COMPILER_SINCE(GCC, 2,95, 3)
+# define RUBY3_HAS_BUILTIN___builtin_ctz RUBY3_COMPILER_SINCE(GCC, 3, 6, 0)
+# define RUBY3_HAS_BUILTIN___builtin_ctzl RUBY3_COMPILER_SINCE(GCC, 3, 6, 0)
+# define RUBY3_HAS_BUILTIN___builtin_ctzll RUBY3_COMPILER_SINCE(GCC, 3, 6, 0)
+# define RUBY3_HAS_BUILTIN___builtin_expect RUBY3_COMPILER_SINCE(GCC, 3, 0, 0)
+# define RUBY3_HAS_BUILTIN___builtin_mul_overflow RUBY3_COMPILER_SINCE(GCC, 5, 1, 0)
+# define RUBY3_HAS_BUILTIN___builtin_mul_overflow_p RUBY3_COMPILER_SINCE(GCC, 7, 0, 0)
+# define RUBY3_HAS_BUILTIN___builtin_popcount RUBY3_COMPILER_SINCE(GCC, 3, 6, 0)
+# define RUBY3_HAS_BUILTIN___builtin_popcountl RUBY3_COMPILER_SINCE(GCC, 3, 6, 0)
+# define RUBY3_HAS_BUILTIN___builtin_popcountll RUBY3_COMPILER_SINCE(GCC, 3, 6, 0)
+# define RUBY3_HAS_BUILTIN___builtin_sub_overflow RUBY3_COMPILER_SINCE(GCC, 5, 1, 0)
+# define RUBY3_HAS_BUILTIN___builtin_unreachable RUBY3_COMPILER_SINCE(GCC, 4, 5, 0)
+# /* Note that "0, 0, 0" might be inaccurate. */
+
+#elif RUBY3_COMPILER_IS(MSVC)
+# /* MSVC has UNREACHABLE, but that is not __builtin_unreachable. */
+# define RUBY3_HAS_BUILTIN(_) 0
+
+#else
+# /* Take config.h definition when available */
+# define RUBY3_HAS_BUILTIN(_) RUBY3_TOKEN_PASTE(RUBY3_HAS_BUILTIN_, _)
+# define RUBY3_HAS_BUILTIN___builtin_add_overflow HAVE_BUILTIN___BUILTIN_ADD_OVERFLOW
+# define RUBY3_HAS_BUILTIN___builtin_alloca_with_align HAVE_BUILTIN___BUILTIN_ALLOCA_WITH_ALIGN
+# define RUBY3_HAS_BUILTIN___builtin_assume_aligned HAVE_BUILTIN___BUILTIN_ASSUME_ALIGNED
+# define RUBY3_HAS_BUILTIN___builtin_bswap16 HAVE_BUILTIN___BUILTIN_BSWAP16
+# define RUBY3_HAS_BUILTIN___builtin_bswap32 HAVE_BUILTIN___BUILTIN_BSWAP32
+# define RUBY3_HAS_BUILTIN___builtin_bswap64 HAVE_BUILTIN___BUILTIN_BSWAP64
+# define RUBY3_HAS_BUILTIN___builtin_clz HAVE_BUILTIN___BUILTIN_CLZ
+# define RUBY3_HAS_BUILTIN___builtin_clzl HAVE_BUILTIN___BUILTIN_CLZL
+# define RUBY3_HAS_BUILTIN___builtin_clzll HAVE_BUILTIN___BUILTIN_CLZLL
+# define RUBY3_HAS_BUILTIN___builtin_constant_p HAVE_BUILTIN___BUILTIN_CONSTANT_P
+# define RUBY3_HAS_BUILTIN___builtin_ctz HAVE_BUILTIN___BUILTIN_CTZ
+# define RUBY3_HAS_BUILTIN___builtin_ctzll HAVE_BUILTIN___BUILTIN_CTZLL
+# define RUBY3_HAS_BUILTIN___builtin_expect HAVE_BUILTIN___BUILTIN_EXPECT
+# define RUBY3_HAS_BUILTIN___builtin_mul_overflow HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW
+# define RUBY3_HAS_BUILTIN___builtin_mul_overflow_p HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW_P
+# define RUBY3_HAS_BUILTIN___builtin_popcount HAVE_BUILTIN___BUILTIN_POPCOUNT
+# define RUBY3_HAS_BUILTIN___builtin_popcountll HAVE_BUILTIN___BUILTIN_POPCOUNTLL
+# define RUBY3_HAS_BUILTIN___builtin_sub_overflow HAVE_BUILTIN___BUILTIN_SUB_OVERFLOW
+# if defined(UNREACHABLE)
+# define RUBY3_HAS_BUILTIN___builtin_unreachable
+# endif
+#endif
diff --git a/include/ruby/3/has/c_attribute.h b/include/ruby/3/has/c_attribute.h
new file mode 100644
index 0000000000..89186217d3
--- /dev/null
+++ b/include/ruby/3/has/c_attribute.h
@@ -0,0 +1,37 @@
+/** \noop-*-C++-*-vi:ft=cpp
+ * @file
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @warning Symbols prefixed with either `RUBY3` or `ruby3` are
+ * implementation details. Don't take them as canon. They could
+ * rapidly appear then vanish. The name (path) of this header file
+ * is also an implementation detail. Do not expect it to persist
+ * at the place it is now. Developers are free to move it anywhere
+ * anytime at will.
+ * @note To ruby-core: remember that this header can be possibly
+ * recursively included from extension libraries written in C++.
+ * Do not expect for instance `__VA_ARGS__` is always available.
+ * We assume C99 for ruby itself but we don't assume languages of
+ * extension libraries. They could be written in C++98.
+ * @brief Defines #RUBY3_HAS_C_ATTRIBUTE.
+ */
+
+/** Wraps (or simulates) `__has_c_attribute`. */
+#if defined(RUBY3_HAS_C_ATTRIBUTE)
+# /* Take that. */
+
+#elif defined(__cplusplus)
+# /* Makes no sense. */
+# define RUBY3_HAS_C_ATTRIBUTE(_) 0
+
+#elif defined(__has_c_attribute)
+# define RUBY3_HAS_C_ATTRIBUTE(_) __has_c_attribute(_)
+
+#else
+# /* As of writing everything that lacks __has_c_attribute also completely
+# * lacks C2x attributes as well. Might change in future? */
+# define RUBY3_HAS_C_ATTRIBUTE(_) 0
+#endif
diff --git a/include/ruby/3/has/cpp_attribute.h b/include/ruby/3/has/cpp_attribute.h
new file mode 100644
index 0000000000..83c5392200
--- /dev/null
+++ b/include/ruby/3/has/cpp_attribute.h
@@ -0,0 +1,82 @@
+/** \noop-*-C++-*-vi:ft=cpp
+ * @file
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @warning Symbols prefixed with either `RUBY3` or `ruby3` are
+ * implementation details. Don't take them as canon. They could
+ * rapidly appear then vanish. The name (path) of this header file
+ * is also an implementation detail. Do not expect it to persist
+ * at the place it is now. Developers are free to move it anywhere
+ * anytime at will.
+ * @note To ruby-core: remember that this header can be possibly
+ * recursively included from extension libraries written in C++.
+ * Do not expect for instance `__VA_ARGS__` is always available.
+ * We assume C99 for ruby itself but we don't assume languages of
+ * extension libraries. They could be written in C++98.
+ * @brief Defines #RUBY3_HAS_CPP_ATTRIBUTE.
+ */
+#include "ruby/3/compiler_is.h"
+#include "ruby/3/compiler_since.h"
+#include "ruby/3/token_paste.h"
+
+/** @cond INTERNAL_MACRO */
+#if defined(RUBY3_HAS_CPP_ATTRIBUTE0)
+# /* Take that. */
+
+#elif defined(__has_cpp_attribute)
+# define RUBY3_HAS_CPP_ATTRIBUTE0(_) __has_cpp_attribute(_)
+
+#elif RUBY3_COMPILER_IS(MSVC)
+# /* MSVC has never updated its __cplusplus since forever (unless specified
+# * explicitly by a compiler flag). They also lack __has_cpp_attribute until
+# * 2019. However, they do have attributes since 2015 or so. */
+# /* https://docs.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance */
+# define RUBY3_HAS_CPP_ATTRIBUTE0(_) RUBY3_TOKEN_PASTE(RUBY3_HAS_CPP_ATTRIBUTE_, _)
+# define RUBY3_HAS_CPP_ATTRIBUTE_noreturn 200809 * RUBY3_COMPILER_SINCE(MSVC, 19, 00, 0)
+# define RUBY3_HAS_CPP_ATTRIBUTE_carries_dependency 200809 * RUBY3_COMPILER_SINCE(MSVC, 19, 00, 0)
+# define RUBY3_HAS_CPP_ATTRIBUTE_deprecated 201309 * RUBY3_COMPILER_SINCE(MSVC, 19, 10, 0)
+# define RUBY3_HAS_CPP_ATTRIBUTE_fallthrough 201603 * RUBY3_COMPILER_SINCE(MSVC, 19, 10, 0)
+# define RUBY3_HAS_CPP_ATTRIBUTE_maybe_unused 201603 * RUBY3_COMPILER_SINCE(MSVC, 19, 11, 0)
+# define RUBY3_HAS_CPP_ATTRIBUTE_nodiscard 201603 * RUBY3_COMPILER_SINCE(MSVC, 19, 11, 0)
+
+#elif RUBY3_COMPILER_BEFORE(Clang, 3, 6, 0)
+# /* Clang 3.6.0 introduced __has_cpp_attribute. Prior to that following
+# * attributes were already there. */
+# /* https://clang.llvm.org/cxx_status.html */
+# define RUBY3_HAS_CPP_ATTRIBUTE0(_) RUBY3_TOKEN_PASTE(RUBY3_HAS_CPP_ATTRIBUTE_, _)
+# define RUBY3_HAS_CPP_ATTRIBUTE_noreturn 200809 * RUBY3_COMPILER_SINCE(Clang, 3, 3, 0)
+# define RUBY3_HAS_CPP_ATTRIBUTE_deprecated 201309 * RUBY3_COMPILER_SINCE(Clang, 3, 4, 0)
+
+#elif RUBY3_COMPILER_BEFORE(GCC, 5, 0, 0)
+# /* GCC 5+ have __has_cpp_attribute, while 4.x had following attributes. */
+# /* https://gcc.gnu.org/projects/cxx-status.html */
+# define RUBY3_HAS_CPP_ATTRIBUTE0(_) RUBY3_TOKEN_PASTE(RUBY3_HAS_CPP_ATTRIBUTE_, _)
+# define RUBY3_HAS_CPP_ATTRIBUTE_noreturn 200809 * RUBY3_COMPILER_SINCE(GCC, 4, 8, 0)
+# define RUBY3_HAS_CPP_ATTRIBUTE_deprecated 201309 * RUBY3_COMPILER_SINCE(GCC, 4, 9, 0)
+
+#else
+# /* :FIXME:
+# * Candidate compilers to list here:
+# * - icpc: They have __INTEL_CXX11_MODE__.
+# * - SunPro: Seems they support C++11.
+# */
+# define RUBY3_HAS_CPP_ATTRIBUTE0(_) 0
+#endif
+/** @endcond */
+
+/** Wraps (or simulates) `__has_cpp_attribute`. */
+#ifdef RUBY3_HAS_CPP_ATTRIBUTE
+# /* Take that. */
+
+#elif ! defined(__cplusplus)
+# /* Makes no sense. */
+# define RUBY3_HAS_CPP_ATTRIBUTE(_) 0
+
+#else
+# /* GCC needs workarounds. See https://gcc.godbolt.org/z/jdz3pa */
+# define RUBY3_HAS_CPP_ATTRIBUTE(_) \
+ ((RUBY3_HAS_CPP_ATTRIBUTE0(_) <= __cplusplus) ? RUBY3_HAS_CPP_ATTRIBUTE0(_) : 0)
+#endif
diff --git a/include/ruby/3/has/declspec_attribute.h b/include/ruby/3/has/declspec_attribute.h
new file mode 100644
index 0000000000..f902ef963c
--- /dev/null
+++ b/include/ruby/3/has/declspec_attribute.h
@@ -0,0 +1,48 @@
+/** \noop-*-C++-*-vi:ft=cpp
+ * @file
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @warning Symbols prefixed with either `RUBY3` or `ruby3` are
+ * implementation details. Don't take them as canon. They could
+ * rapidly appear then vanish. The name (path) of this header file
+ * is also an implementation detail. Do not expect it to persist
+ * at the place it is now. Developers are free to move it anywhere
+ * anytime at will.
+ * @note To ruby-core: remember that this header can be possibly
+ * recursively included from extension libraries written in C++.
+ * Do not expect for instance `__VA_ARGS__` is always available.
+ * We assume C99 for ruby itself but we don't assume languages of
+ * extension libraries. They could be written in C++98.
+ * @brief Defines #RUBY3_HAS_DECLSPEC_ATTRIBUTE.
+ */
+#include "ruby/3/compiler_since.h"
+#include "ruby/3/token_paste.h"
+
+/** Wraps (or simulates) `__has_declspec_attribute`. */
+#if defined(RUBY3_HAS_DECLSPEC_ATTRIBUTE)
+# /* Take that. */
+
+#elif defined(__has_declspec_attribute)
+# define RUBY3_HAS_DECLSPEC_ATTRIBUTE(_) __has_declspec_attribute(_)
+
+#else
+# define RUBY3_HAS_DECLSPEC_ATTRIBUTE(_) RUBY3_TOKEN_PASTE(RUBY3_HAS_DECLSPEC_ATTRIBUTE_, _)
+# define RUBY3_HAS_DECLSPEC_ATTRIBUTE_align RUBY3_COMPILER_SINCE(MSVC, 8, 0, 0)
+# define RUBY3_HAS_DECLSPEC_ATTRIBUTE_deprecated RUBY3_COMPILER_SINCE(MSVC,13, 0, 0)
+# define RUBY3_HAS_DECLSPEC_ATTRIBUTE_dllexport RUBY3_COMPILER_SINCE(MSVC, 8, 0, 0)
+# define RUBY3_HAS_DECLSPEC_ATTRIBUTE_dllimport RUBY3_COMPILER_SINCE(MSVC, 8, 0, 0)
+# define RUBY3_HAS_DECLSPEC_ATTRIBUTE_empty_bases RUBY3_COMPILER_SINCE(MSVC,19, 0, 23918)
+# define RUBY3_HAS_DECLSPEC_ATTRIBUTE_noalias RUBY3_COMPILER_SINCE(MSVC, 8, 0, 0)
+# define RUBY3_HAS_DECLSPEC_ATTRIBUTE_noinline RUBY3_COMPILER_SINCE(MSVC,13, 0, 0)
+# define RUBY3_HAS_DECLSPEC_ATTRIBUTE_noreturn RUBY3_COMPILER_SINCE(MSVC,11, 0, 0)
+# define RUBY3_HAS_DECLSPEC_ATTRIBUTE_nothrow RUBY3_COMPILER_SINCE(MSVC, 8, 0, 0)
+# define RUBY3_HAS_DECLSPEC_ATTRIBUTE_restrict RUBY3_COMPILER_SINCE(MSVC,14, 0, 0)
+# /* Note that "8, 0, 0" might be inaccurate. */
+# if ! defined(__cplusplus)
+# /* Clang has this in both C/C++, but MSVC has this in C++ only.*/
+# undef RUBY3_HAS_DECLSPEC_ATTRIBUTE_nothrow
+# endif
+#endif
diff --git a/include/ruby/3/has/extension.h b/include/ruby/3/has/extension.h
new file mode 100644
index 0000000000..ca3392a090
--- /dev/null
+++ b/include/ruby/3/has/extension.h
@@ -0,0 +1,33 @@
+/** \noop-*-C++-*-vi:ft=cpp
+ * @file
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @warning Symbols prefixed with either `RUBY3` or `ruby3` are
+ * implementation details. Don't take them as canon. They could
+ * rapidly appear then vanish. The name (path) of this header file
+ * is also an implementation detail. Do not expect it to persist
+ * at the place it is now. Developers are free to move it anywhere
+ * anytime at will.
+ * @note To ruby-core: remember that this header can be possibly
+ * recursively included from extension libraries written in C++.
+ * Do not expect for instance `__VA_ARGS__` is always available.
+ * We assume C99 for ruby itself but we don't assume languages of
+ * extension libraries. They could be written in C++98.
+ * @brief Defines #RUBY3_HAS_EXTENSION.
+ */
+#include "ruby/3/has/feature.h"
+
+/** Wraps (or simulates) `__has_extension`. */
+#if defined(RUBY3_HAS_EXTENSION)
+# /* Take that. */
+
+#elif defined(__has_extension)
+# define RUBY3_HAS_EXTENSION(_) __has_extension(_)
+
+#else
+# /* Pre-3.0 clang had __has_feature but not __has_extension. */
+# define RUBY3_HAS_EXTENSION(_) RUBY3_HAS_FEATURE(_)
+#endif
diff --git a/include/ruby/3/has/feature.h b/include/ruby/3/has/feature.h
new file mode 100644
index 0000000000..977b8150bb
--- /dev/null
+++ b/include/ruby/3/has/feature.h
@@ -0,0 +1,31 @@
+/** \noop-*-C++-*-vi:ft=cpp
+ * @file
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @warning Symbols prefixed with either `RUBY3` or `ruby3` are
+ * implementation details. Don't take them as canon. They could
+ * rapidly appear then vanish. The name (path) of this header file
+ * is also an implementation detail. Do not expect it to persist
+ * at the place it is now. Developers are free to move it anywhere
+ * anytime at will.
+ * @note To ruby-core: remember that this header can be possibly
+ * recursively included from extension libraries written in C++.
+ * Do not expect for instance `__VA_ARGS__` is always available.
+ * We assume C99 for ruby itself but we don't assume languages of
+ * extension libraries. They could be written in C++98.
+ * @brief Defines #RUBY3_HAS_FEATURE.
+ */
+
+/** Wraps (or simulates) `__has_feature`. */
+#if defined(RUBY3_HAS_FEATURE)
+# /* Take that. */
+
+#elif defined(__has_feature)
+# define RUBY3_HAS_FEATURE(_) __has_feature(_)
+
+#else
+# define RUBY3_HAS_FEATURE(_) 0
+#endif
diff --git a/include/ruby/3/has/warning.h b/include/ruby/3/has/warning.h
new file mode 100644
index 0000000000..a66d76dfa7
--- /dev/null
+++ b/include/ruby/3/has/warning.h
@@ -0,0 +1,31 @@
+/** \noop-*-C++-*-vi:ft=cpp
+ * @file
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @warning Symbols prefixed with either `RUBY3` or `ruby3` are
+ * implementation details. Don't take them as canon. They could
+ * rapidly appear then vanish. The name (path) of this header file
+ * is also an implementation detail. Do not expect it to persist
+ * at the place it is now. Developers are free to move it anywhere
+ * anytime at will.
+ * @note To ruby-core: remember that this header can be possibly
+ * recursively included from extension libraries written in C++.
+ * Do not expect for instance `__VA_ARGS__` is always available.
+ * We assume C99 for ruby itself but we don't assume languages of
+ * extension libraries. They could be written in C++98.
+ * @brief Defines #RUBY3_HAS_WARNING.
+ */
+
+/** Wraps (or simulates) `__has_warning`. */
+#if defined(RUBY3_HAS_WARNING)
+# /* Take that. */
+
+#elif defined(__has_warning)
+# define RUBY3_HAS_WARNING(_) __has_warning(_)
+
+#else
+# define RUBY3_HAS_WARNING(_) 0
+#endif