Ruby  3.4.0dev (2024-11-22 revision 0989400a925cd201defdca9eb28eb87200b30785)
attribute.h
Go to the documentation of this file.
1 #ifndef RBIMPL_HAS_ATTRIBUTE_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RBIMPL_HAS_ATTRIBUTE_H
23 #include "ruby/internal/config.h"
25 
26 #if defined(__has_attribute)
27 # if __has_attribute(pure) || RBIMPL_COMPILER_IS(GCC)
28 # /* FreeBSD's <sys/cdefs.h> defines its own *broken* version of
29 # * __has_attribute. Cygwin copied that content to be a victim of the
30 # * broken-ness. We don't take them into account. */
31 # define RBIMPL_HAVE___HAS_ATTRIBUTE 1
32 # endif
33 #endif
34 
36 #if defined(RBIMPL_HAVE___HAS_ATTRIBUTE)
37 # define RBIMPL_HAS_ATTRIBUTE(_) __has_attribute(_)
38 
39 #elif RBIMPL_COMPILER_IS(GCC)
40 # /* GCC <= 4 lack __has_attribute predefined macro, while have attributes
41 # * themselves. We can simulate the macro like the following: */
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)
74 # /* Note that "0, 0, 0" might be inaccurate. */
75 
76 #elif RBIMPL_COMPILER_IS(SunPro)
77 # /* Oracle Solaris Studio 12.4 (cc version 5.11) introduced __has_attribute.
78 # * Before that, following attributes were available. */
79 # /* See https://docs.oracle.com/cd/F24633_01/index.html */
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)
96 
97 #elif defined (_MSC_VER)
98 # define RBIMPL_HAS_ATTRIBUTE(_) 0
99 # /* Fallback below doesn't work: see win32/Makefile.sub */
100 
101 #else
102 # /* Take config.h definition when available. */
103 # define RBIMPL_HAS_ATTRIBUTE(_) ((RBIMPL_HAS_ATTRIBUTE_ ## _)+0)
104 # ifdef ALWAYS_INLINE
105 # define RBIMPL_HAS_ATTRIBUTE_always_inline 1
106 # endif
107 # ifdef FUNC_CDECL
108 # define RBIMPL_HAS_ATTRIBUTE_cdecl 1
109 # endif
110 # ifdef CONSTFUNC
111 # define RBIMPL_HAS_ATTRIBUTE_const 1
112 # endif
113 # ifdef DEPRECATED
114 # define RBIMPL_HAS_ATTRIBUTE_deprecated 1
115 # endif
116 # ifdef ERRORFUNC
117 # define RBIMPL_HAS_ATTRIBUTE_error 1
118 # endif
119 # ifdef FUNC_FASTCALL
120 # define RBIMPL_HAS_ATTRIBUTE_fastcall 1
121 # endif
122 # ifdef PUREFUNC
123 # define RBIMPL_HAS_ATTRIBUTE_pure 1
124 # endif
125 # ifdef NO_ADDRESS_SAFETY_ANALYSIS
126 # define RBIMPL_HAS_ATTRIBUTE_no_address_safety_analysis 1
127 # endif
128 # ifdef NO_SANITIZE
129 # define RBIMPL_HAS_ATTRIBUTE_no_sanitize 1
130 # endif
131 # ifdef NO_SANITIZE_ADDRESS
132 # define RBIMPL_HAS_ATTRIBUTE_no_sanitize_address 1
133 # endif
134 # ifdef NOINLINE
135 # define RBIMPL_HAS_ATTRIBUTE_noinline 1
136 # endif
137 # ifdef RBIMPL_FUNC_NONNULL
138 # define RBIMPL_HAS_ATTRIBUTE_nonnull 1
139 # endif
140 # ifdef NORETURN
141 # define RBIMPL_HAS_ATTRIBUTE_noreturn 1
142 # endif
143 # ifdef FUNC_OPTIMIZED
144 # define RBIMPL_HAS_ATTRIBUTE_optimize 1
145 # endif
146 # ifdef FUNC_STDCALL
147 # define RBIMPL_HAS_ATTRIBUTE_stdcall 1
148 # endif
149 # ifdef MAYBE_UNUSED
150 # define RBIMPL_HAS_ATTRIBUTE_unused 1
151 # endif
152 # ifdef WARN_UNUSED_RESULT
153 # define RBIMPL_HAS_ATTRIBUTE_warn_unused_result 1
154 # endif
155 # ifdef WARNINGFUNC
156 # define RBIMPL_HAS_ATTRIBUTE_warning 1
157 # endif
158 # ifdef WEAK
159 # define RBIMPL_HAS_ATTRIBUTE_weak 1
160 # endif
161 #endif
162 
163 #endif /* RBIMPL_HAS_ATTRIBUTE_H */
Defines RBIMPL_COMPILER_SINCE.