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

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

attributes.h
Go to the documentation of this file.
1#ifndef RUBY_BACKWARD2_ATTRIBUTES_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_BACKWARD2_ATTRIBUTES_H
31#include "ruby/internal/config.h"
32#include "ruby/internal/attr/alloc_size.h"
33#include "ruby/internal/attr/cold.h"
34#include "ruby/internal/attr/const.h"
35#include "ruby/internal/attr/deprecated.h"
36#include "ruby/internal/attr/error.h"
37#include "ruby/internal/attr/forceinline.h"
38#include "ruby/internal/attr/format.h"
39#include "ruby/internal/attr/maybe_unused.h"
40#include "ruby/internal/attr/noinline.h"
41#include "ruby/internal/attr/nonnull.h"
42#include "ruby/internal/attr/noreturn.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#ifndef MJIT_HEADER
85# undef ALWAYS_INLINE
86# define ALWAYS_INLINE(x) RBIMPL_ATTR_FORCEINLINE() x
87#endif
88
89#undef ERRORFUNC
90#define ERRORFUNC(mesg, x) RBIMPL_ATTR_ERROR(mesg) x
91#if RBIMPL_HAS_ATTRIBUTE(error)
92# define HAVE_ATTRIBUTE_ERRORFUNC 1
93#else
94# define HAVE_ATTRIBUTE_ERRORFUNC 0
95#endif
96
97#undef WARNINGFUNC
98#define WARNINGFUNC(mesg, x) RBIMPL_ATTR_WARNING(mesg) x
99#if RBIMPL_HAS_ATTRIBUTE(warning)
100# define HAVE_ATTRIBUTE_WARNINGFUNC 1
101#else
102# define HAVE_ATTRIBUTE_WARNINGFUNC 0
103#endif
104
105/*
106 cold attribute for code layout improvements
107 RUBY_FUNC_ATTRIBUTE not used because MSVC does not like nested func macros
108 */
109#undef COLDFUNC
110#define COLDFUNC RBIMPL_ATTR_COLD()
111
112#define PRINTF_ARGS(decl, string_index, first_to_check) \
113 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, (string_index), (first_to_check)) \
114 decl
115
116#undef RUBY_ATTR_ALLOC_SIZE
117#define RUBY_ATTR_ALLOC_SIZE RBIMPL_ATTR_ALLOC_SIZE
118
119#undef RUBY_ATTR_MALLOC
120#define RUBY_ATTR_MALLOC RBIMPL_ATTR_RESTRICT()
121
122#undef RUBY_ATTR_RETURNS_NONNULL
123#define RUBY_ATTR_RETURNS_NONNULL RBIMPL_ATTR_RETURNS_NONNULL()
124
125#ifndef FUNC_MINIMIZED
126#define FUNC_MINIMIZED(x) x
127#endif
128
129#ifndef FUNC_UNOPTIMIZED
130#define FUNC_UNOPTIMIZED(x) x
131#endif
132
133#ifndef RUBY_ALIAS_FUNCTION_TYPE
134#define RUBY_ALIAS_FUNCTION_TYPE(type, prot, name, args) \
135 FUNC_MINIMIZED(type prot) {return (type)name args;}
136#endif
137
138#ifndef RUBY_ALIAS_FUNCTION_VOID
139#define RUBY_ALIAS_FUNCTION_VOID(prot, name, args) \
140 FUNC_MINIMIZED(void prot) {name args;}
141#endif
142
143#ifndef RUBY_ALIAS_FUNCTION
144#define RUBY_ALIAS_FUNCTION(prot, name, args) \
145 RUBY_ALIAS_FUNCTION_TYPE(VALUE, prot, name, args)
146#endif
147
148#undef RUBY_FUNC_NONNULL
149#define RUBY_FUNC_NONNULL(n, x) RBIMPL_ATTR_NONNULL(n) x
150
151#undef NORETURN
152#define NORETURN(x) RBIMPL_ATTR_NORETURN() x
153#define NORETURN_STYLE_NEW
154
155#ifndef PACKED_STRUCT
156# define PACKED_STRUCT(x) x
157#endif
158
159#ifndef PACKED_STRUCT_UNALIGNED
160# if UNALIGNED_WORD_ACCESS
161# define PACKED_STRUCT_UNALIGNED(x) PACKED_STRUCT(x)
162# else
163# define PACKED_STRUCT_UNALIGNED(x) x
164# endif
165#endif
166
167#undef RB_UNUSED_VAR
168#define RB_UNUSED_VAR(x) x RBIMPL_ATTR_MAYBE_UNUSED()
169
170#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.
config.h
Thin wrapper to ruby/config.h.
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.
pure.h
Defines RBIMPL_ATTR_PURE.
restrict.h
Defines RBIMPL_ATTR_RESTRICT.
returns_nonnull.h
Defines RBIMPL_ATTR_RETURNS_NONNULL.