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

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

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