1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #ifndef _GL_CXXDEFS_H
18 #define _GL_CXXDEFS_H
19
20
21 #if defined __cplusplus && defined GNULIB_NAMESPACE
22 # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
23 # define _GL_END_NAMESPACE }
24 #else
25 # define _GL_BEGIN_NAMESPACE
26 # define _GL_END_NAMESPACE
27 #endif
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90 #if defined __cplusplus
91 # define _GL_EXTERN_C extern "C"
92 #else
93 # define _GL_EXTERN_C extern
94 #endif
95
96
97
98
99
100
101
102
103 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
104 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
105 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
106 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
107
108
109
110
111
112
113
114
115 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
116 _GL_EXTERN_C rettype func parameters_and_attributes
117
118
119
120
121
122
123
124
125
126
127 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
128 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
129 #if defined __cplusplus && defined GNULIB_NAMESPACE
130 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
131 namespace GNULIB_NAMESPACE \
132 { \
133 static const struct _gl_ ## func ## _wrapper \
134 { \
135 typedef rettype (*type) parameters; \
136 \
137 inline operator type () const \
138 { \
139 return ::rpl_func; \
140 } \
141 } func = {}; \
142 } \
143 _GL_EXTERN_C int _gl_cxxalias_dummy
144 #else
145 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
146 _GL_EXTERN_C int _gl_cxxalias_dummy
147 #endif
148
149
150
151
152
153
154
155
156 #define _GL_CXXALIAS_MDA(func,rettype,parameters) \
157 _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
158
159
160
161
162
163
164 #if defined __cplusplus && defined GNULIB_NAMESPACE
165 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
166 namespace GNULIB_NAMESPACE \
167 { \
168 static const struct _gl_ ## func ## _wrapper \
169 { \
170 typedef rettype (*type) parameters; \
171 \
172 inline operator type () const \
173 { \
174 return reinterpret_cast<type>(::rpl_func); \
175 } \
176 } func = {}; \
177 } \
178 _GL_EXTERN_C int _gl_cxxalias_dummy
179 #else
180 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
181 _GL_EXTERN_C int _gl_cxxalias_dummy
182 #endif
183
184
185
186
187
188
189 #define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
190 _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
191
192
193
194
195
196
197
198
199
200
201
202 #if defined __cplusplus && defined GNULIB_NAMESPACE
203 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
204 namespace GNULIB_NAMESPACE \
205 { \
206 static const struct _gl_ ## func ## _wrapper \
207 { \
208 typedef rettype (*type) parameters; \
209 \
210 inline operator type () const \
211 { \
212 return ::func; \
213 } \
214 } func = {}; \
215 } \
216 _GL_EXTERN_C int _gl_cxxalias_dummy
217 #else
218 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
219 _GL_EXTERN_C int _gl_cxxalias_dummy
220 #endif
221
222
223
224
225
226
227 #if defined __cplusplus && defined GNULIB_NAMESPACE
228 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
229 namespace GNULIB_NAMESPACE \
230 { \
231 static const struct _gl_ ## func ## _wrapper \
232 { \
233 typedef rettype (*type) parameters; \
234 \
235 inline operator type () const \
236 { \
237 return reinterpret_cast<type>(::func); \
238 } \
239 } func = {}; \
240 } \
241 _GL_EXTERN_C int _gl_cxxalias_dummy
242 #else
243 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
244 _GL_EXTERN_C int _gl_cxxalias_dummy
245 #endif
246
247
248
249
250
251
252
253 #if defined __cplusplus && defined GNULIB_NAMESPACE
254
255
256
257
258
259 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
260 namespace GNULIB_NAMESPACE \
261 { \
262 static const struct _gl_ ## func ## _wrapper \
263 { \
264 typedef rettype (*type) parameters; \
265 \
266 inline operator type () const \
267 { \
268 return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
269 } \
270 } func = {}; \
271 } \
272 _GL_EXTERN_C int _gl_cxxalias_dummy
273 #else
274 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
275 _GL_EXTERN_C int _gl_cxxalias_dummy
276 #endif
277
278
279
280
281
282 #if defined __cplusplus && defined GNULIB_NAMESPACE
283 # define _GL_CXXALIASWARN(func) \
284 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
285 # define _GL_CXXALIASWARN_1(func,namespace) \
286 _GL_CXXALIASWARN_2 (func, namespace)
287
288
289 # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
290 # define _GL_CXXALIASWARN_2(func,namespace) \
291 _GL_WARN_ON_USE (func, \
292 "The symbol ::" #func " refers to the system function. " \
293 "Use " #namespace "::" #func " instead.")
294 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
295 # define _GL_CXXALIASWARN_2(func,namespace) \
296 extern __typeof__ (func) func
297 # else
298 # define _GL_CXXALIASWARN_2(func,namespace) \
299 _GL_EXTERN_C int _gl_cxxalias_dummy
300 # endif
301 #else
302 # define _GL_CXXALIASWARN(func) \
303 _GL_EXTERN_C int _gl_cxxalias_dummy
304 #endif
305
306
307
308
309 #if defined __cplusplus && defined GNULIB_NAMESPACE
310 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
311 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
312 GNULIB_NAMESPACE)
313 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
314 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
315
316
317 # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
318 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
319 _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
320 "The symbol ::" #func " refers to the system function. " \
321 "Use " #namespace "::" #func " instead.")
322 # else
323 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
324 _GL_EXTERN_C int _gl_cxxalias_dummy
325 # endif
326 #else
327 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
328 _GL_EXTERN_C int _gl_cxxalias_dummy
329 #endif
330
331 #endif