Debian Codegraph @

include/ruby/backward/2/attributes.h

raw
1 #ifndef RUBY_BACKWARD2_ATTRIBUTES_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RUBY_BACKWARD2_ATTRIBUTES_H
3 /**
4 * @author Ruby developers <[email protected]>
5 * @copyright This file is a part of the programming language Ruby.
6 * Permission is hereby granted, to either redistribute and/or
7 * modify this file, provided that the conditions mentioned in the
8 * file COPYING are met. Consult the file for details.
9 * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
10 * implementation details. Don't take them as canon. They could
11 * rapidly appear then vanish. The name (path) of this header file
12 * is also an implementation detail. Do not expect it to persist
13 * at the place it is now. Developers are free to move it anywhere
14 * anytime at will.
15 * @note To ruby-core: remember that this header can be possibly
16 * recursively included from extension libraries written in C++.
17 * Do not expect for instance `__VA_ARGS__` is always available.
18 * We assume C99 for ruby itself but we don't assume languages of
19 * extension libraries. They could be written in C++98.
20 * @brief Various attribute-related macros.
21 *
22 * ### Q&A ###
23 *
24 * - Q: Why are the macros defined in this header file so inconsistent in
25 * style?
26 *
27 * - A: Don't know. Don't blame me. Backward compatibility is the key here.
28 * I'm just preserving what they have been.
29 */
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 */