Ruby 3.5.0dev (2025-01-10 revision 5fab31b15e32622c4b71d1d347a41937e9f9c212)
attributes.h
1#ifndef RUBY_BACKWARD2_ATTRIBUTES_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_BACKWARD2_ATTRIBUTES_H
30#include "ruby/internal/config.h"
48
49/* function attributes */
50#undef CONSTFUNC
51#define CONSTFUNC(x) RBIMPL_ATTR_CONST() x
52
53#undef PUREFUNC
54#define PUREFUNC(x) RBIMPL_ATTR_PURE() x
55
56#undef DEPRECATED
57#define DEPRECATED(x) RBIMPL_ATTR_DEPRECATED(("")) x
58
59#undef DEPRECATED_BY
60#define DEPRECATED_BY(n,x) RBIMPL_ATTR_DEPRECATED(("by: " # n)) x
61
62#undef DEPRECATED_TYPE
63#if defined(__GNUC__)
64# define DEPRECATED_TYPE(mesg, decl) \
65 _Pragma("message \"DEPRECATED_TYPE is deprecated\""); \
66 decl RBIMPL_ATTR_DEPRECATED(mseg)
67#elif defined(_MSC_VER)
68# pragma deprecated(DEPRECATED_TYPE)
69# define DEPRECATED_TYPE(mesg, decl) \
70 __pragma(message(__FILE__"("STRINGIZE(__LINE__)"): warning: " \
71 "DEPRECATED_TYPE is deprecated")) \
72 decl RBIMPL_ATTR_DEPRECATED(mseg)
73#else
74# define DEPRECATED_TYPE(mesg, decl) \
75 <-<-"DEPRECATED_TYPE is deprecated"->->
76#endif
77
78#undef RUBY_CXX_DEPRECATED
79#define RUBY_CXX_DEPRECATED(mseg) RBIMPL_ATTR_DEPRECATED((mseg))
80
81#undef NOINLINE
82#define NOINLINE(x) RBIMPL_ATTR_NOINLINE() x
83
84#undef ALWAYS_INLINE
85#define ALWAYS_INLINE(x) RBIMPL_ATTR_FORCEINLINE() x
86
87#undef ERRORFUNC
88#define ERRORFUNC(mesg, x) RBIMPL_ATTR_ERROR(mesg) x
89#if RBIMPL_HAS_ATTRIBUTE(error)
90# define HAVE_ATTRIBUTE_ERRORFUNC 1
91#endif
92
93#undef WARNINGFUNC
94#define WARNINGFUNC(mesg, x) RBIMPL_ATTR_WARNING(mesg) x
95#if RBIMPL_HAS_ATTRIBUTE(warning)
96# define HAVE_ATTRIBUTE_WARNINGFUNC 1
97#endif
98
99/*
100 cold attribute for code layout improvements
101 RUBY_FUNC_ATTRIBUTE not used because MSVC does not like nested func macros
102 */
103#undef COLDFUNC
104#define COLDFUNC RBIMPL_ATTR_COLD()
105
106#define PRINTF_ARGS(decl, string_index, first_to_check) \
107 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, (string_index), (first_to_check)) \
108 decl
109
110#undef RUBY_ATTR_ALLOC_SIZE
111#define RUBY_ATTR_ALLOC_SIZE RBIMPL_ATTR_ALLOC_SIZE
112
113#undef RUBY_ATTR_MALLOC
114#define RUBY_ATTR_MALLOC RBIMPL_ATTR_RESTRICT()
115
116#undef RUBY_ATTR_RETURNS_NONNULL
117#define RUBY_ATTR_RETURNS_NONNULL RBIMPL_ATTR_RETURNS_NONNULL()
118
119#ifndef FUNC_MINIMIZED
120#define FUNC_MINIMIZED(x) x
121#endif
122
123#ifndef FUNC_UNOPTIMIZED
124#define FUNC_UNOPTIMIZED(x) x
125#endif
126
127#ifndef RUBY_ALIAS_FUNCTION_TYPE
128#define RUBY_ALIAS_FUNCTION_TYPE(type, prot, name, args) \
129 FUNC_MINIMIZED(type prot) {return (type)name args;}
130#endif
131
132#ifndef RUBY_ALIAS_FUNCTION_VOID
133#define RUBY_ALIAS_FUNCTION_VOID(prot, name, args) \
134 FUNC_MINIMIZED(void prot) {name args;}
135#endif
136
137#ifndef RUBY_ALIAS_FUNCTION
138#define RUBY_ALIAS_FUNCTION(prot, name, args) \
139 RUBY_ALIAS_FUNCTION_TYPE(VALUE, prot, name, args)
140#endif
141
142#undef RUBY_FUNC_NONNULL
143#define RUBY_FUNC_NONNULL(n, x) RBIMPL_ATTR_NONNULL(n) x
144
145#undef NORETURN
146#define NORETURN(x) RBIMPL_ATTR_NORETURN() x
147#define NORETURN_STYLE_NEW
148
149#undef PACKED_STRUCT
150#define PACKED_STRUCT(x) \
151 RBIMPL_ATTR_PACKED_STRUCT_BEGIN() x RBIMPL_ATTR_PACKED_STRUCT_END()
152
153#undef PACKED_STRUCT_UNALIGNED
154#define PACKED_STRUCT_UNALIGNED(x) \
155 RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN() x \
156 RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END()
157
158#undef RB_UNUSED_VAR
159#define RB_UNUSED_VAR(x) x RBIMPL_ATTR_MAYBE_UNUSED()
160
161#endif /* RUBY_BACKWARD2_ATTRIBUTES_H */
Defines RBIMPL_ATTR_ALLOC_SIZE.
Defines RBIMPL_ATTR_WARNING.
Defines RBIMPL_HAS_ATTRIBUTE.
Defines RBIMPL_ATTR_COLD.
Defines RBIMPL_ATTR_CONST.
Defines RBIMPL_ATTR_DEPRECATED.
Defines RBIMPL_ATTR_FORCEINLINE.
Defines RBIMPL_ATTR_FORMAT.
Defines RBIMPL_ATTR_ERROR.
Defines RBIMPL_ATTR_MAYBE_UNUSED.
Defines RBIMPL_ATTR_NOINLINE.
Defines RBIMPL_ATTR_NONNULL.
Defines RBIMPL_ATTR_NORETURN.
Defines RBIMPL_ATTR_PACKED_STRUCT_BEGIN, RBIMPL_ATTR_PACKED_STRUCT_END, RBIMPL_ATTR_PACKED_STRUCT_UNA...
Defines RBIMPL_ATTR_PURE.
Defines RBIMPL_ATTR_RESTRICT.
Defines RBIMPL_ATTR_RETURNS_NONNULL.