1 #ifndef RBIMPL_HAS_ATTRIBUTE_H
2 #define RBIMPL_HAS_ATTRIBUTE_H
23 #include "ruby/internal/config.h"
26 #if defined(__has_attribute)
27 # if __has_attribute(pure) || RBIMPL_COMPILER_IS(GCC)
31 # define RBIMPL_HAVE___HAS_ATTRIBUTE 1
36 #if defined(RBIMPL_HAVE___HAS_ATTRIBUTE)
37 # define RBIMPL_HAS_ATTRIBUTE(_) __has_attribute(_)
39 #elif RBIMPL_COMPILER_IS(GCC)
42 # define RBIMPL_HAS_ATTRIBUTE(_) (RBIMPL_HAS_ATTRIBUTE_ ## _)
43 # define RBIMPL_HAS_ATTRIBUTE_aligned RBIMPL_COMPILER_SINCE(GCC, 0, 0, 0)
44 # define RBIMPL_HAS_ATTRIBUTE_alloc_size RBIMPL_COMPILER_SINCE(GCC, 4, 3, 0)
45 # define RBIMPL_HAS_ATTRIBUTE_artificial RBIMPL_COMPILER_SINCE(GCC, 4, 3, 0)
46 # define RBIMPL_HAS_ATTRIBUTE_always_inline RBIMPL_COMPILER_SINCE(GCC, 3, 1, 0)
47 # define RBIMPL_HAS_ATTRIBUTE_cdecl RBIMPL_COMPILER_SINCE(GCC, 0, 0, 0)
48 # define RBIMPL_HAS_ATTRIBUTE_cold RBIMPL_COMPILER_SINCE(GCC, 4, 3, 0)
49 # define RBIMPL_HAS_ATTRIBUTE_const RBIMPL_COMPILER_SINCE(GCC, 2, 6, 0)
50 # define RBIMPL_HAS_ATTRIBUTE_deprecated RBIMPL_COMPILER_SINCE(GCC, 3, 1, 0)
51 # define RBIMPL_HAS_ATTRIBUTE_dllexport RBIMPL_COMPILER_SINCE(GCC, 0, 0, 0)
52 # define RBIMPL_HAS_ATTRIBUTE_dllimport RBIMPL_COMPILER_SINCE(GCC, 0, 0, 0)
53 # define RBIMPL_HAS_ATTRIBUTE_error RBIMPL_COMPILER_SINCE(GCC, 4, 3, 0)
54 # define RBIMPL_HAS_ATTRIBUTE_format RBIMPL_COMPILER_SINCE(GCC, 0, 0, 0)
55 # define RBIMPL_HAS_ATTRIBUTE_hot RBIMPL_COMPILER_SINCE(GCC, 4, 3, 0)
56 # define RBIMPL_HAS_ATTRIBUTE_leaf RBIMPL_COMPILER_SINCE(GCC, 4, 6, 0)
57 # define RBIMPL_HAS_ATTRIBUTE_malloc RBIMPL_COMPILER_SINCE(GCC, 3, 0, 0)
58 # define RBIMPL_HAS_ATTRIBUTE_no_address_safety_analysis RBIMPL_COMPILER_SINCE(GCC, 4, 8, 0)
59 # define RBIMPL_HAS_ATTRIBUTE_no_sanitize_address RBIMPL_COMPILER_SINCE(GCC, 4, 8, 0)
60 # define RBIMPL_HAS_ATTRIBUTE_no_sanitize_undefined RBIMPL_COMPILER_SINCE(GCC, 4, 9, 0)
61 # define RBIMPL_HAS_ATTRIBUTE_noinline RBIMPL_COMPILER_SINCE(GCC, 3, 1, 0)
62 # define RBIMPL_HAS_ATTRIBUTE_nonnull RBIMPL_COMPILER_SINCE(GCC, 3, 3, 0)
63 # define RBIMPL_HAS_ATTRIBUTE_noreturn RBIMPL_COMPILER_SINCE(GCC, 2, 5, 0)
64 # define RBIMPL_HAS_ATTRIBUTE_nothrow RBIMPL_COMPILER_SINCE(GCC, 3, 3, 0)
65 # define RBIMPL_HAS_ATTRIBUTE_pure RBIMPL_COMPILER_SINCE(GCC, 2,96, 0)
66 # define RBIMPL_HAS_ATTRIBUTE_returns_nonnull RBIMPL_COMPILER_SINCE(GCC, 4, 9, 0)
67 # define RBIMPL_HAS_ATTRIBUTE_returns_twice RBIMPL_COMPILER_SINCE(GCC, 4, 1, 0)
68 # define RBIMPL_HAS_ATTRIBUTE_stdcall RBIMPL_COMPILER_SINCE(GCC, 0, 0, 0)
69 # define RBIMPL_HAS_ATTRIBUTE_unused RBIMPL_COMPILER_SINCE(GCC, 0, 0, 0)
70 # define RBIMPL_HAS_ATTRIBUTE_visibility RBIMPL_COMPILER_SINCE(GCC, 3, 3, 0)
71 # define RBIMPL_HAS_ATTRIBUTE_warn_unused_result RBIMPL_COMPILER_SINCE(GCC, 3, 4, 0)
72 # define RBIMPL_HAS_ATTRIBUTE_warning RBIMPL_COMPILER_SINCE(GCC, 4, 3, 0)
73 # define RBIMPL_HAS_ATTRIBUTE_weak RBIMPL_COMPILER_SINCE(GCC, 0, 0, 0)
76 #elif RBIMPL_COMPILER_IS(SunPro)
80 # define RBIMPL_HAS_ATTRIBUTE(_) (RBIMPL_HAS_ATTRIBUTE_ ## _)
81 # define RBIMPL_HAS_ATTRIBUTE_alias RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
82 # define RBIMPL_HAS_ATTRIBUTE_aligned RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
83 # define RBIMPL_HAS_ATTRIBUTE_always_inline RBIMPL_COMPILER_SINCE(SunPro, 5, 10, 0)
84 # define RBIMPL_HAS_ATTRIBUTE_const RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
85 # define RBIMPL_HAS_ATTRIBUTE_constructor RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
86 # define RBIMPL_HAS_ATTRIBUTE_destructor RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
87 # define RBIMPL_HAS_ATTRIBUTE_malloc RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
88 # define RBIMPL_HAS_ATTRIBUTE_noinline RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
89 # define RBIMPL_HAS_ATTRIBUTE_noreturn RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
90 # define RBIMPL_HAS_ATTRIBUTE_packed RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
91 # define RBIMPL_HAS_ATTRIBUTE_pure RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
92 # define RBIMPL_HAS_ATTRIBUTE_returns_twice RBIMPL_COMPILER_SINCE(SunPro, 5, 10, 0)
93 # define RBIMPL_HAS_ATTRIBUTE_vector_size RBIMPL_COMPILER_SINCE(SunPro, 5, 10, 0)
94 # define RBIMPL_HAS_ATTRIBUTE_visibility RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
95 # define RBIMPL_HAS_ATTRIBUTE_weak RBIMPL_COMPILER_SINCE(SunPro, 5, 9, 0)
97 #elif defined (_MSC_VER)
98 # define RBIMPL_HAS_ATTRIBUTE(_) 0
103 # define RBIMPL_HAS_ATTRIBUTE(_) ((RBIMPL_HAS_ATTRIBUTE_ ## _)+0)
104 # ifdef ALWAYS_INLINE
105 # define RBIMPL_HAS_ATTRIBUTE_always_inline 1
108 # define RBIMPL_HAS_ATTRIBUTE_cdecl 1
111 # define RBIMPL_HAS_ATTRIBUTE_const 1
114 # define RBIMPL_HAS_ATTRIBUTE_deprecated 1
117 # define RBIMPL_HAS_ATTRIBUTE_error 1
119 # ifdef FUNC_FASTCALL
120 # define RBIMPL_HAS_ATTRIBUTE_fastcall 1
123 # define RBIMPL_HAS_ATTRIBUTE_pure 1
125 # ifdef NO_ADDRESS_SAFETY_ANALYSIS
126 # define RBIMPL_HAS_ATTRIBUTE_no_address_safety_analysis 1
129 # define RBIMPL_HAS_ATTRIBUTE_no_sanitize 1
131 # ifdef NO_SANITIZE_ADDRESS
132 # define RBIMPL_HAS_ATTRIBUTE_no_sanitize_address 1
135 # define RBIMPL_HAS_ATTRIBUTE_noinline 1
137 # ifdef RBIMPL_FUNC_NONNULL
138 # define RBIMPL_HAS_ATTRIBUTE_nonnull 1
141 # define RBIMPL_HAS_ATTRIBUTE_noreturn 1
143 # ifdef FUNC_OPTIMIZED
144 # define RBIMPL_HAS_ATTRIBUTE_optimize 1
147 # define RBIMPL_HAS_ATTRIBUTE_stdcall 1
150 # define RBIMPL_HAS_ATTRIBUTE_unused 1
152 # ifdef WARN_UNUSED_RESULT
153 # define RBIMPL_HAS_ATTRIBUTE_warn_unused_result 1
156 # define RBIMPL_HAS_ATTRIBUTE_warning 1
159 # define RBIMPL_HAS_ATTRIBUTE_weak 1
Defines RBIMPL_COMPILER_SINCE.