diff options
Diffstat (limited to 'gl/arpa')
-rw-r--r-- | gl/arpa/inet.h | 657 |
1 files changed, 657 insertions, 0 deletions
diff --git a/gl/arpa/inet.h b/gl/arpa/inet.h new file mode 100644 index 00000000..ec1c725a --- /dev/null +++ b/gl/arpa/inet.h | |||
@@ -0,0 +1,657 @@ | |||
1 | /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ | ||
2 | /* A GNU-like <arpa/inet.h>. | ||
3 | |||
4 | Copyright (C) 2005-2006, 2008-2022 Free Software Foundation, Inc. | ||
5 | |||
6 | This file is free software: you can redistribute it and/or modify | ||
7 | it under the terms of the GNU Lesser General Public License as | ||
8 | published by the Free Software Foundation; either version 2.1 of the | ||
9 | License, or (at your option) any later version. | ||
10 | |||
11 | This file is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU Lesser General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU Lesser General Public License | ||
17 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ | ||
18 | |||
19 | #ifndef _GL_ARPA_INET_H | ||
20 | |||
21 | #if __GNUC__ >= 3 | ||
22 | #pragma GCC system_header | ||
23 | #endif | ||
24 | |||
25 | |||
26 | #if 1 | ||
27 | # include <features.h> /* for __GLIBC__ */ | ||
28 | #endif | ||
29 | |||
30 | /* Gnulib's sys/socket.h is responsible for defining socklen_t (used below) and | ||
31 | for pulling in winsock2.h etc. under MinGW. | ||
32 | But avoid namespace pollution on glibc systems. */ | ||
33 | #ifndef __GLIBC__ | ||
34 | # include <sys/socket.h> | ||
35 | #endif | ||
36 | |||
37 | /* On NonStop Kernel, inet_ntop and inet_pton are declared in <netdb.h>. | ||
38 | But avoid namespace pollution on glibc systems. */ | ||
39 | #if defined __TANDEM && !defined __GLIBC__ | ||
40 | # include <netdb.h> | ||
41 | #endif | ||
42 | |||
43 | #if 1 | ||
44 | |||
45 | /* The include_next requires a split double-inclusion guard. */ | ||
46 | # include_next <arpa/inet.h> | ||
47 | |||
48 | #endif | ||
49 | |||
50 | #ifndef _GL_ARPA_INET_H | ||
51 | #define _GL_ARPA_INET_H | ||
52 | |||
53 | /* Get all possible declarations of inet_ntop() and inet_pton(). */ | ||
54 | #if (1 || 0 || defined GNULIB_POSIXCHECK) \ | ||
55 | && 0 | ||
56 | # include <ws2tcpip.h> | ||
57 | #endif | ||
58 | |||
59 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | ||
60 | /* C++ compatible function declaration macros. | ||
61 | Copyright (C) 2010-2022 Free Software Foundation, Inc. | ||
62 | |||
63 | This program is free software: you can redistribute it and/or modify it | ||
64 | under the terms of the GNU Lesser General Public License as published | ||
65 | by the Free Software Foundation; either version 2 of the License, or | ||
66 | (at your option) any later version. | ||
67 | |||
68 | This program is distributed in the hope that it will be useful, | ||
69 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
70 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
71 | Lesser General Public License for more details. | ||
72 | |||
73 | You should have received a copy of the GNU Lesser General Public License | ||
74 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ | ||
75 | |||
76 | #ifndef _GL_CXXDEFS_H | ||
77 | #define _GL_CXXDEFS_H | ||
78 | |||
79 | /* Begin/end the GNULIB_NAMESPACE namespace. */ | ||
80 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
81 | # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { | ||
82 | # define _GL_END_NAMESPACE } | ||
83 | #else | ||
84 | # define _GL_BEGIN_NAMESPACE | ||
85 | # define _GL_END_NAMESPACE | ||
86 | #endif | ||
87 | |||
88 | /* The three most frequent use cases of these macros are: | ||
89 | |||
90 | * For providing a substitute for a function that is missing on some | ||
91 | platforms, but is declared and works fine on the platforms on which | ||
92 | it exists: | ||
93 | |||
94 | #if @GNULIB_FOO@ | ||
95 | # if !@HAVE_FOO@ | ||
96 | _GL_FUNCDECL_SYS (foo, ...); | ||
97 | # endif | ||
98 | _GL_CXXALIAS_SYS (foo, ...); | ||
99 | _GL_CXXALIASWARN (foo); | ||
100 | #elif defined GNULIB_POSIXCHECK | ||
101 | ... | ||
102 | #endif | ||
103 | |||
104 | * For providing a replacement for a function that exists on all platforms, | ||
105 | but is broken/insufficient and needs to be replaced on some platforms: | ||
106 | |||
107 | #if @GNULIB_FOO@ | ||
108 | # if @REPLACE_FOO@ | ||
109 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
110 | # undef foo | ||
111 | # define foo rpl_foo | ||
112 | # endif | ||
113 | _GL_FUNCDECL_RPL (foo, ...); | ||
114 | _GL_CXXALIAS_RPL (foo, ...); | ||
115 | # else | ||
116 | _GL_CXXALIAS_SYS (foo, ...); | ||
117 | # endif | ||
118 | _GL_CXXALIASWARN (foo); | ||
119 | #elif defined GNULIB_POSIXCHECK | ||
120 | ... | ||
121 | #endif | ||
122 | |||
123 | * For providing a replacement for a function that exists on some platforms | ||
124 | but is broken/insufficient and needs to be replaced on some of them and | ||
125 | is additionally either missing or undeclared on some other platforms: | ||
126 | |||
127 | #if @GNULIB_FOO@ | ||
128 | # if @REPLACE_FOO@ | ||
129 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
130 | # undef foo | ||
131 | # define foo rpl_foo | ||
132 | # endif | ||
133 | _GL_FUNCDECL_RPL (foo, ...); | ||
134 | _GL_CXXALIAS_RPL (foo, ...); | ||
135 | # else | ||
136 | # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ | ||
137 | _GL_FUNCDECL_SYS (foo, ...); | ||
138 | # endif | ||
139 | _GL_CXXALIAS_SYS (foo, ...); | ||
140 | # endif | ||
141 | _GL_CXXALIASWARN (foo); | ||
142 | #elif defined GNULIB_POSIXCHECK | ||
143 | ... | ||
144 | #endif | ||
145 | */ | ||
146 | |||
147 | /* _GL_EXTERN_C declaration; | ||
148 | performs the declaration with C linkage. */ | ||
149 | #if defined __cplusplus | ||
150 | # define _GL_EXTERN_C extern "C" | ||
151 | #else | ||
152 | # define _GL_EXTERN_C extern | ||
153 | #endif | ||
154 | |||
155 | /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); | ||
156 | declares a replacement function, named rpl_func, with the given prototype, | ||
157 | consisting of return type, parameters, and attributes. | ||
158 | Example: | ||
159 | _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) | ||
160 | _GL_ARG_NONNULL ((1))); | ||
161 | */ | ||
162 | #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ | ||
163 | _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) | ||
164 | #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ | ||
165 | _GL_EXTERN_C rettype rpl_func parameters_and_attributes | ||
166 | |||
167 | /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); | ||
168 | declares the system function, named func, with the given prototype, | ||
169 | consisting of return type, parameters, and attributes. | ||
170 | Example: | ||
171 | _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) | ||
172 | _GL_ARG_NONNULL ((1))); | ||
173 | */ | ||
174 | #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ | ||
175 | _GL_EXTERN_C rettype func parameters_and_attributes | ||
176 | |||
177 | /* _GL_CXXALIAS_RPL (func, rettype, parameters); | ||
178 | declares a C++ alias called GNULIB_NAMESPACE::func | ||
179 | that redirects to rpl_func, if GNULIB_NAMESPACE is defined. | ||
180 | Example: | ||
181 | _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); | ||
182 | |||
183 | Wrapping rpl_func in an object with an inline conversion operator | ||
184 | avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is | ||
185 | actually used in the program. */ | ||
186 | #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ | ||
187 | _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) | ||
188 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
189 | # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ | ||
190 | namespace GNULIB_NAMESPACE \ | ||
191 | { \ | ||
192 | static const struct _gl_ ## func ## _wrapper \ | ||
193 | { \ | ||
194 | typedef rettype (*type) parameters; \ | ||
195 | \ | ||
196 | inline operator type () const \ | ||
197 | { \ | ||
198 | return ::rpl_func; \ | ||
199 | } \ | ||
200 | } func = {}; \ | ||
201 | } \ | ||
202 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
203 | #else | ||
204 | # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ | ||
205 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
206 | #endif | ||
207 | |||
208 | /* _GL_CXXALIAS_MDA (func, rettype, parameters); | ||
209 | is to be used when func is a Microsoft deprecated alias, on native Windows. | ||
210 | It declares a C++ alias called GNULIB_NAMESPACE::func | ||
211 | that redirects to _func, if GNULIB_NAMESPACE is defined. | ||
212 | Example: | ||
213 | _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); | ||
214 | */ | ||
215 | #define _GL_CXXALIAS_MDA(func,rettype,parameters) \ | ||
216 | _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters) | ||
217 | |||
218 | /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); | ||
219 | is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); | ||
220 | except that the C function rpl_func may have a slightly different | ||
221 | declaration. A cast is used to silence the "invalid conversion" error | ||
222 | that would otherwise occur. */ | ||
223 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
224 | # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ | ||
225 | namespace GNULIB_NAMESPACE \ | ||
226 | { \ | ||
227 | static const struct _gl_ ## func ## _wrapper \ | ||
228 | { \ | ||
229 | typedef rettype (*type) parameters; \ | ||
230 | \ | ||
231 | inline operator type () const \ | ||
232 | { \ | ||
233 | return reinterpret_cast<type>(::rpl_func); \ | ||
234 | } \ | ||
235 | } func = {}; \ | ||
236 | } \ | ||
237 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
238 | #else | ||
239 | # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ | ||
240 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
241 | #endif | ||
242 | |||
243 | /* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters); | ||
244 | is like _GL_CXXALIAS_MDA (func, rettype, parameters); | ||
245 | except that the C function func may have a slightly different declaration. | ||
246 | A cast is used to silence the "invalid conversion" error that would | ||
247 | otherwise occur. */ | ||
248 | #define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \ | ||
249 | _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters) | ||
250 | |||
251 | /* _GL_CXXALIAS_SYS (func, rettype, parameters); | ||
252 | declares a C++ alias called GNULIB_NAMESPACE::func | ||
253 | that redirects to the system provided function func, if GNULIB_NAMESPACE | ||
254 | is defined. | ||
255 | Example: | ||
256 | _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); | ||
257 | |||
258 | Wrapping func in an object with an inline conversion operator | ||
259 | avoids a reference to func unless GNULIB_NAMESPACE::func is | ||
260 | actually used in the program. */ | ||
261 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
262 | # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ | ||
263 | namespace GNULIB_NAMESPACE \ | ||
264 | { \ | ||
265 | static const struct _gl_ ## func ## _wrapper \ | ||
266 | { \ | ||
267 | typedef rettype (*type) parameters; \ | ||
268 | \ | ||
269 | inline operator type () const \ | ||
270 | { \ | ||
271 | return ::func; \ | ||
272 | } \ | ||
273 | } func = {}; \ | ||
274 | } \ | ||
275 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
276 | #else | ||
277 | # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ | ||
278 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
279 | #endif | ||
280 | |||
281 | /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); | ||
282 | is like _GL_CXXALIAS_SYS (func, rettype, parameters); | ||
283 | except that the C function func may have a slightly different declaration. | ||
284 | A cast is used to silence the "invalid conversion" error that would | ||
285 | otherwise occur. */ | ||
286 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
287 | # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ | ||
288 | namespace GNULIB_NAMESPACE \ | ||
289 | { \ | ||
290 | static const struct _gl_ ## func ## _wrapper \ | ||
291 | { \ | ||
292 | typedef rettype (*type) parameters; \ | ||
293 | \ | ||
294 | inline operator type () const \ | ||
295 | { \ | ||
296 | return reinterpret_cast<type>(::func); \ | ||
297 | } \ | ||
298 | } func = {}; \ | ||
299 | } \ | ||
300 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
301 | #else | ||
302 | # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ | ||
303 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
304 | #endif | ||
305 | |||
306 | /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); | ||
307 | is like _GL_CXXALIAS_SYS (func, rettype, parameters); | ||
308 | except that the C function is picked among a set of overloaded functions, | ||
309 | namely the one with rettype2 and parameters2. Two consecutive casts | ||
310 | are used to silence the "cannot find a match" and "invalid conversion" | ||
311 | errors that would otherwise occur. */ | ||
312 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
313 | /* The outer cast must be a reinterpret_cast. | ||
314 | The inner cast: When the function is defined as a set of overloaded | ||
315 | functions, it works as a static_cast<>, choosing the designated variant. | ||
316 | When the function is defined as a single variant, it works as a | ||
317 | reinterpret_cast<>. The parenthesized cast syntax works both ways. */ | ||
318 | # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ | ||
319 | namespace GNULIB_NAMESPACE \ | ||
320 | { \ | ||
321 | static const struct _gl_ ## func ## _wrapper \ | ||
322 | { \ | ||
323 | typedef rettype (*type) parameters; \ | ||
324 | \ | ||
325 | inline operator type () const \ | ||
326 | { \ | ||
327 | return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ | ||
328 | } \ | ||
329 | } func = {}; \ | ||
330 | } \ | ||
331 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
332 | #else | ||
333 | # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ | ||
334 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
335 | #endif | ||
336 | |||
337 | /* _GL_CXXALIASWARN (func); | ||
338 | causes a warning to be emitted when ::func is used but not when | ||
339 | GNULIB_NAMESPACE::func is used. func must be defined without overloaded | ||
340 | variants. */ | ||
341 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
342 | # define _GL_CXXALIASWARN(func) \ | ||
343 | _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) | ||
344 | # define _GL_CXXALIASWARN_1(func,namespace) \ | ||
345 | _GL_CXXALIASWARN_2 (func, namespace) | ||
346 | /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, | ||
347 | we enable the warning only when not optimizing. */ | ||
348 | # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) | ||
349 | # define _GL_CXXALIASWARN_2(func,namespace) \ | ||
350 | _GL_WARN_ON_USE (func, \ | ||
351 | "The symbol ::" #func " refers to the system function. " \ | ||
352 | "Use " #namespace "::" #func " instead.") | ||
353 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||
354 | # define _GL_CXXALIASWARN_2(func,namespace) \ | ||
355 | extern __typeof__ (func) func | ||
356 | # else | ||
357 | # define _GL_CXXALIASWARN_2(func,namespace) \ | ||
358 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
359 | # endif | ||
360 | #else | ||
361 | # define _GL_CXXALIASWARN(func) \ | ||
362 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
363 | #endif | ||
364 | |||
365 | /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); | ||
366 | causes a warning to be emitted when the given overloaded variant of ::func | ||
367 | is used but not when GNULIB_NAMESPACE::func is used. */ | ||
368 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
369 | # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ | ||
370 | _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ | ||
371 | GNULIB_NAMESPACE) | ||
372 | # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ | ||
373 | _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) | ||
374 | /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, | ||
375 | we enable the warning only when not optimizing. */ | ||
376 | # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) | ||
377 | # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ | ||
378 | _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \ | ||
379 | "The symbol ::" #func " refers to the system function. " \ | ||
380 | "Use " #namespace "::" #func " instead.") | ||
381 | # else | ||
382 | # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ | ||
383 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
384 | # endif | ||
385 | #else | ||
386 | # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ | ||
387 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
388 | #endif | ||
389 | |||
390 | #endif /* _GL_CXXDEFS_H */ | ||
391 | |||
392 | /* The definition of _GL_ARG_NONNULL is copied here. */ | ||
393 | /* A C macro for declaring that specific arguments must not be NULL. | ||
394 | Copyright (C) 2009-2022 Free Software Foundation, Inc. | ||
395 | |||
396 | This program is free software: you can redistribute it and/or modify it | ||
397 | under the terms of the GNU Lesser General Public License as published | ||
398 | by the Free Software Foundation; either version 2 of the License, or | ||
399 | (at your option) any later version. | ||
400 | |||
401 | This program is distributed in the hope that it will be useful, | ||
402 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
403 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
404 | Lesser General Public License for more details. | ||
405 | |||
406 | You should have received a copy of the GNU Lesser General Public License | ||
407 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ | ||
408 | |||
409 | /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools | ||
410 | that the values passed as arguments n, ..., m must be non-NULL pointers. | ||
411 | n = 1 stands for the first argument, n = 2 for the second argument etc. */ | ||
412 | #ifndef _GL_ARG_NONNULL | ||
413 | # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__ | ||
414 | # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) | ||
415 | # else | ||
416 | # define _GL_ARG_NONNULL(params) | ||
417 | # endif | ||
418 | #endif | ||
419 | |||
420 | /* The definition of _GL_WARN_ON_USE is copied here. */ | ||
421 | /* A C macro for emitting warnings if a function is used. | ||
422 | Copyright (C) 2010-2022 Free Software Foundation, Inc. | ||
423 | |||
424 | This program is free software: you can redistribute it and/or modify it | ||
425 | under the terms of the GNU Lesser General Public License as published | ||
426 | by the Free Software Foundation; either version 2 of the License, or | ||
427 | (at your option) any later version. | ||
428 | |||
429 | This program is distributed in the hope that it will be useful, | ||
430 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
431 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
432 | Lesser General Public License for more details. | ||
433 | |||
434 | You should have received a copy of the GNU Lesser General Public License | ||
435 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ | ||
436 | |||
437 | /* _GL_WARN_ON_USE (function, "literal string") issues a declaration | ||
438 | for FUNCTION which will then trigger a compiler warning containing | ||
439 | the text of "literal string" anywhere that function is called, if | ||
440 | supported by the compiler. If the compiler does not support this | ||
441 | feature, the macro expands to an unused extern declaration. | ||
442 | |||
443 | _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the | ||
444 | attribute used in _GL_WARN_ON_USE. If the compiler does not support | ||
445 | this feature, it expands to empty. | ||
446 | |||
447 | These macros are useful for marking a function as a potential | ||
448 | portability trap, with the intent that "literal string" include | ||
449 | instructions on the replacement function that should be used | ||
450 | instead. | ||
451 | _GL_WARN_ON_USE is for functions with 'extern' linkage. | ||
452 | _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' | ||
453 | linkage. | ||
454 | |||
455 | However, one of the reasons that a function is a portability trap is | ||
456 | if it has the wrong signature. Declaring FUNCTION with a different | ||
457 | signature in C is a compilation error, so this macro must use the | ||
458 | same type as any existing declaration so that programs that avoid | ||
459 | the problematic FUNCTION do not fail to compile merely because they | ||
460 | included a header that poisoned the function. But this implies that | ||
461 | _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already | ||
462 | have a declaration. Use of this macro implies that there must not | ||
463 | be any other macro hiding the declaration of FUNCTION; but | ||
464 | undefining FUNCTION first is part of the poisoning process anyway | ||
465 | (although for symbols that are provided only via a macro, the result | ||
466 | is a compilation error rather than a warning containing | ||
467 | "literal string"). Also note that in C++, it is only safe to use if | ||
468 | FUNCTION has no overloads. | ||
469 | |||
470 | For an example, it is possible to poison 'getline' by: | ||
471 | - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], | ||
472 | [getline]) in configure.ac, which potentially defines | ||
473 | HAVE_RAW_DECL_GETLINE | ||
474 | - adding this code to a header that wraps the system <stdio.h>: | ||
475 | #undef getline | ||
476 | #if HAVE_RAW_DECL_GETLINE | ||
477 | _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" | ||
478 | "not universally present; use the gnulib module getline"); | ||
479 | #endif | ||
480 | |||
481 | It is not possible to directly poison global variables. But it is | ||
482 | possible to write a wrapper accessor function, and poison that | ||
483 | (less common usage, like &environ, will cause a compilation error | ||
484 | rather than issue the nice warning, but the end result of informing | ||
485 | the developer about their portability problem is still achieved): | ||
486 | #if HAVE_RAW_DECL_ENVIRON | ||
487 | static char *** | ||
488 | rpl_environ (void) { return &environ; } | ||
489 | _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); | ||
490 | # undef environ | ||
491 | # define environ (*rpl_environ ()) | ||
492 | #endif | ||
493 | or better (avoiding contradictory use of 'static' and 'extern'): | ||
494 | #if HAVE_RAW_DECL_ENVIRON | ||
495 | static char *** | ||
496 | _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") | ||
497 | rpl_environ (void) { return &environ; } | ||
498 | # undef environ | ||
499 | # define environ (*rpl_environ ()) | ||
500 | #endif | ||
501 | */ | ||
502 | #ifndef _GL_WARN_ON_USE | ||
503 | |||
504 | # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) | ||
505 | /* A compiler attribute is available in gcc versions 4.3.0 and later. */ | ||
506 | # define _GL_WARN_ON_USE(function, message) \ | ||
507 | _GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message))) | ||
508 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ | ||
509 | __attribute__ ((__warning__ (message))) | ||
510 | # elif __clang_major__ >= 4 | ||
511 | /* Another compiler attribute is available in clang. */ | ||
512 | # define _GL_WARN_ON_USE(function, message) \ | ||
513 | _GL_WARN_EXTERN_C __typeof__ (function) function \ | ||
514 | __attribute__ ((__diagnose_if__ (1, message, "warning"))) | ||
515 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ | ||
516 | __attribute__ ((__diagnose_if__ (1, message, "warning"))) | ||
517 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||
518 | /* Verify the existence of the function. */ | ||
519 | # define _GL_WARN_ON_USE(function, message) \ | ||
520 | _GL_WARN_EXTERN_C __typeof__ (function) function | ||
521 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) | ||
522 | # else /* Unsupported. */ | ||
523 | # define _GL_WARN_ON_USE(function, message) \ | ||
524 | _GL_WARN_EXTERN_C int _gl_warn_on_use | ||
525 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) | ||
526 | # endif | ||
527 | #endif | ||
528 | |||
529 | /* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message") | ||
530 | is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the | ||
531 | function is declared with the given prototype, consisting of return type, | ||
532 | parameters, and attributes. | ||
533 | This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does | ||
534 | not work in this case. */ | ||
535 | #ifndef _GL_WARN_ON_USE_CXX | ||
536 | # if !defined __cplusplus | ||
537 | # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ | ||
538 | _GL_WARN_ON_USE (function, msg) | ||
539 | # else | ||
540 | # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) | ||
541 | /* A compiler attribute is available in gcc versions 4.3.0 and later. */ | ||
542 | # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ | ||
543 | extern rettype_gcc function parameters_and_attributes \ | ||
544 | __attribute__ ((__warning__ (msg))) | ||
545 | # elif __clang_major__ >= 4 | ||
546 | /* Another compiler attribute is available in clang. */ | ||
547 | # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ | ||
548 | extern rettype_clang function parameters_and_attributes \ | ||
549 | __attribute__ ((__diagnose_if__ (1, msg, "warning"))) | ||
550 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||
551 | /* Verify the existence of the function. */ | ||
552 | # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ | ||
553 | extern rettype_gcc function parameters_and_attributes | ||
554 | # else /* Unsupported. */ | ||
555 | # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ | ||
556 | _GL_WARN_EXTERN_C int _gl_warn_on_use | ||
557 | # endif | ||
558 | # endif | ||
559 | #endif | ||
560 | |||
561 | /* _GL_WARN_EXTERN_C declaration; | ||
562 | performs the declaration with C linkage. */ | ||
563 | #ifndef _GL_WARN_EXTERN_C | ||
564 | # if defined __cplusplus | ||
565 | # define _GL_WARN_EXTERN_C extern "C" | ||
566 | # else | ||
567 | # define _GL_WARN_EXTERN_C extern | ||
568 | # endif | ||
569 | #endif | ||
570 | |||
571 | |||
572 | #if 1 | ||
573 | /* Converts an internet address from internal format to a printable, | ||
574 | presentable format. | ||
575 | AF is an internet address family, such as AF_INET or AF_INET6. | ||
576 | SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr' | ||
577 | (for AF_INET6). | ||
578 | DST points to a buffer having room for CNT bytes. | ||
579 | The printable representation of the address (in numeric form, not | ||
580 | surrounded by [...], no reverse DNS is done) is placed in DST, and | ||
581 | DST is returned. If an error occurs, the return value is NULL and | ||
582 | errno is set. If CNT bytes are not sufficient to hold the result, | ||
583 | the return value is NULL and errno is set to ENOSPC. A good value | ||
584 | for CNT is 46. | ||
585 | |||
586 | For more details, see the POSIX:2008 specification | ||
587 | <https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntop.html>. */ | ||
588 | # if 0 | ||
589 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
590 | # undef inet_ntop | ||
591 | # define inet_ntop rpl_inet_ntop | ||
592 | # endif | ||
593 | _GL_FUNCDECL_RPL (inet_ntop, const char *, | ||
594 | (int af, const void *restrict src, | ||
595 | char *restrict dst, socklen_t cnt) | ||
596 | _GL_ARG_NONNULL ((2, 3))); | ||
597 | _GL_CXXALIAS_RPL (inet_ntop, const char *, | ||
598 | (int af, const void *restrict src, | ||
599 | char *restrict dst, socklen_t cnt)); | ||
600 | # else | ||
601 | # if !1 | ||
602 | _GL_FUNCDECL_SYS (inet_ntop, const char *, | ||
603 | (int af, const void *restrict src, | ||
604 | char *restrict dst, socklen_t cnt) | ||
605 | _GL_ARG_NONNULL ((2, 3))); | ||
606 | # endif | ||
607 | /* Need to cast, because on NonStop Kernel, the fourth parameter is | ||
608 | size_t cnt. */ | ||
609 | _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *, | ||
610 | (int af, const void *restrict src, | ||
611 | char *restrict dst, socklen_t cnt)); | ||
612 | # endif | ||
613 | # if __GLIBC__ >= 2 | ||
614 | _GL_CXXALIASWARN (inet_ntop); | ||
615 | # endif | ||
616 | #elif defined GNULIB_POSIXCHECK | ||
617 | # undef inet_ntop | ||
618 | # if HAVE_RAW_DECL_INET_NTOP | ||
619 | _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - " | ||
620 | "use gnulib module inet_ntop for portability"); | ||
621 | # endif | ||
622 | #endif | ||
623 | |||
624 | #if 0 | ||
625 | # if 0 | ||
626 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
627 | # undef inet_pton | ||
628 | # define inet_pton rpl_inet_pton | ||
629 | # endif | ||
630 | _GL_FUNCDECL_RPL (inet_pton, int, | ||
631 | (int af, const char *restrict src, void *restrict dst) | ||
632 | _GL_ARG_NONNULL ((2, 3))); | ||
633 | _GL_CXXALIAS_RPL (inet_pton, int, | ||
634 | (int af, const char *restrict src, void *restrict dst)); | ||
635 | # else | ||
636 | # if !1 | ||
637 | _GL_FUNCDECL_SYS (inet_pton, int, | ||
638 | (int af, const char *restrict src, void *restrict dst) | ||
639 | _GL_ARG_NONNULL ((2, 3))); | ||
640 | # endif | ||
641 | _GL_CXXALIAS_SYS (inet_pton, int, | ||
642 | (int af, const char *restrict src, void *restrict dst)); | ||
643 | # endif | ||
644 | # if __GLIBC__ >= 2 | ||
645 | _GL_CXXALIASWARN (inet_pton); | ||
646 | # endif | ||
647 | #elif defined GNULIB_POSIXCHECK | ||
648 | # undef inet_pton | ||
649 | # if HAVE_RAW_DECL_INET_PTON | ||
650 | _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - " | ||
651 | "use gnulib module inet_pton for portability"); | ||
652 | # endif | ||
653 | #endif | ||
654 | |||
655 | |||
656 | #endif /* _GL_ARPA_INET_H */ | ||
657 | #endif /* _GL_ARPA_INET_H */ | ||