Ruby: include/ruby/backward/2/attributes.h Source File

Ruby 4.0.5p0 (2026-05-20 revision 64336ffd0ee9e1f4c05891695a3d7b49cb709721)

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"
31#include "ruby/internal/attr/alloc_size.h"
32#include "ruby/internal/attr/cold.h"
33#include "ruby/internal/attr/const.h"
34#include "ruby/internal/attr/deprecated.h"
35#include "ruby/internal/attr/error.h"
36#include "ruby/internal/attr/forceinline.h"
37#include "ruby/internal/attr/format.h"
38#include "ruby/internal/attr/maybe_unused.h"
39#include "ruby/internal/attr/noinline.h"
40#include "ruby/internal/attr/nonnull.h"
41#include "ruby/internal/attr/noreturn.h"
42#include "ruby/internal/attr/packed_struct.h"
43#include "ruby/internal/attr/pure.h"
44#include "ruby/internal/attr/restrict.h"
45#include "ruby/internal/attr/returns_nonnull.h"
46#include "ruby/internal/attr/warning.h"
47#include "ruby/internal/has/attribute.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 */
alloc_size.h
Defines RBIMPL_ATTR_ALLOC_SIZE.
warning.h
Defines RBIMPL_ATTR_WARNING.
attribute.h
Defines RBIMPL_HAS_ATTRIBUTE.
cold.h
Defines RBIMPL_ATTR_COLD.
const.h
Defines RBIMPL_ATTR_CONST.
deprecated.h
Defines RBIMPL_ATTR_DEPRECATED.
forceinline.h
Defines RBIMPL_ATTR_FORCEINLINE.
format.h
Defines RBIMPL_ATTR_FORMAT.
error.h
Defines RBIMPL_ATTR_ERROR.
maybe_unused.h
Defines RBIMPL_ATTR_MAYBE_UNUSED.
noinline.h
Defines RBIMPL_ATTR_NOINLINE.
nonnull.h
Defines RBIMPL_ATTR_NONNULL.
noreturn.h
Defines RBIMPL_ATTR_NORETURN.
packed_struct.h
Defines RBIMPL_ATTR_PACKED_STRUCT_BEGIN, RBIMPL_ATTR_PACKED_STRUCT_END, RBIMPL_ATTR_PACKED_STRUCT_UNA...
pure.h
Defines RBIMPL_ATTR_PURE.
restrict.h
Defines RBIMPL_ATTR_RESTRICT.
returns_nonnull.h
Defines RBIMPL_ATTR_RETURNS_NONNULL.