diff options
Diffstat (limited to 'gl/sys/socket.h')
-rw-r--r-- | gl/sys/socket.h | 1241 |
1 files changed, 1241 insertions, 0 deletions
diff --git a/gl/sys/socket.h b/gl/sys/socket.h new file mode 100644 index 00000000..0519ccb1 --- /dev/null +++ b/gl/sys/socket.h | |||
@@ -0,0 +1,1241 @@ | |||
1 | /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ | ||
2 | /* Provide a sys/socket header file for systems lacking it (read: MinGW) | ||
3 | and for systems where it is incomplete. | ||
4 | Copyright (C) 2005-2022 Free Software Foundation, Inc. | ||
5 | Written by Simon Josefsson. | ||
6 | |||
7 | This file is free software: you can redistribute it and/or modify | ||
8 | it under the terms of the GNU Lesser General Public License as | ||
9 | published by the Free Software Foundation; either version 2.1 of the | ||
10 | License, or (at your option) any later version. | ||
11 | |||
12 | This file is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU Lesser General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU Lesser General Public License | ||
18 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ | ||
19 | |||
20 | /* This file is supposed to be used on platforms that lack <sys/socket.h>, | ||
21 | on platforms where <sys/socket.h> cannot be included standalone, and on | ||
22 | platforms where <sys/socket.h> does not provide all necessary definitions. | ||
23 | It is intended to provide definitions and prototypes needed by an | ||
24 | application. */ | ||
25 | |||
26 | #if __GNUC__ >= 3 | ||
27 | #pragma GCC system_header | ||
28 | #endif | ||
29 | |||
30 | |||
31 | #if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H | ||
32 | /* Special invocation convention: | ||
33 | - On Cygwin 1.5.x we have a sequence of nested includes | ||
34 | <sys/socket.h> -> <cygwin/socket.h> -> <asm/socket.h> -> <cygwin/if.h>, | ||
35 | and the latter includes <sys/socket.h>. In this situation, the functions | ||
36 | are not yet declared, therefore we cannot provide the C++ aliases. */ | ||
37 | |||
38 | #include_next <sys/socket.h> | ||
39 | |||
40 | #else | ||
41 | /* Normal invocation convention. */ | ||
42 | |||
43 | #ifndef _GL_SYS_SOCKET_H | ||
44 | |||
45 | #if 1 | ||
46 | |||
47 | # define _GL_ALREADY_INCLUDING_SYS_SOCKET_H | ||
48 | |||
49 | /* On many platforms, <sys/socket.h> assumes prior inclusion of | ||
50 | <sys/types.h>. */ | ||
51 | # include <sys/types.h> | ||
52 | |||
53 | /* On FreeBSD 6.4, <sys/socket.h> defines some macros that assume that NULL | ||
54 | is defined. */ | ||
55 | # include <stddef.h> | ||
56 | |||
57 | /* The include_next requires a split double-inclusion guard. */ | ||
58 | # include_next <sys/socket.h> | ||
59 | |||
60 | # undef _GL_ALREADY_INCLUDING_SYS_SOCKET_H | ||
61 | |||
62 | #endif | ||
63 | |||
64 | #ifndef _GL_SYS_SOCKET_H | ||
65 | #define _GL_SYS_SOCKET_H | ||
66 | |||
67 | #ifndef _GL_INLINE_HEADER_BEGIN | ||
68 | #error "Please include config.h first." | ||
69 | #endif | ||
70 | _GL_INLINE_HEADER_BEGIN | ||
71 | #ifndef _GL_SYS_SOCKET_INLINE | ||
72 | # define _GL_SYS_SOCKET_INLINE _GL_INLINE | ||
73 | #endif | ||
74 | |||
75 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | ||
76 | /* C++ compatible function declaration macros. | ||
77 | Copyright (C) 2010-2022 Free Software Foundation, Inc. | ||
78 | |||
79 | This program is free software: you can redistribute it and/or modify it | ||
80 | under the terms of the GNU Lesser General Public License as published | ||
81 | by the Free Software Foundation; either version 2 of the License, or | ||
82 | (at your option) any later version. | ||
83 | |||
84 | This program is distributed in the hope that it will be useful, | ||
85 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
86 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
87 | Lesser General Public License for more details. | ||
88 | |||
89 | You should have received a copy of the GNU Lesser General Public License | ||
90 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ | ||
91 | |||
92 | #ifndef _GL_CXXDEFS_H | ||
93 | #define _GL_CXXDEFS_H | ||
94 | |||
95 | /* Begin/end the GNULIB_NAMESPACE namespace. */ | ||
96 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
97 | # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { | ||
98 | # define _GL_END_NAMESPACE } | ||
99 | #else | ||
100 | # define _GL_BEGIN_NAMESPACE | ||
101 | # define _GL_END_NAMESPACE | ||
102 | #endif | ||
103 | |||
104 | /* The three most frequent use cases of these macros are: | ||
105 | |||
106 | * For providing a substitute for a function that is missing on some | ||
107 | platforms, but is declared and works fine on the platforms on which | ||
108 | it exists: | ||
109 | |||
110 | #if @GNULIB_FOO@ | ||
111 | # if !@HAVE_FOO@ | ||
112 | _GL_FUNCDECL_SYS (foo, ...); | ||
113 | # endif | ||
114 | _GL_CXXALIAS_SYS (foo, ...); | ||
115 | _GL_CXXALIASWARN (foo); | ||
116 | #elif defined GNULIB_POSIXCHECK | ||
117 | ... | ||
118 | #endif | ||
119 | |||
120 | * For providing a replacement for a function that exists on all platforms, | ||
121 | but is broken/insufficient and needs to be replaced on some platforms: | ||
122 | |||
123 | #if @GNULIB_FOO@ | ||
124 | # if @REPLACE_FOO@ | ||
125 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
126 | # undef foo | ||
127 | # define foo rpl_foo | ||
128 | # endif | ||
129 | _GL_FUNCDECL_RPL (foo, ...); | ||
130 | _GL_CXXALIAS_RPL (foo, ...); | ||
131 | # else | ||
132 | _GL_CXXALIAS_SYS (foo, ...); | ||
133 | # endif | ||
134 | _GL_CXXALIASWARN (foo); | ||
135 | #elif defined GNULIB_POSIXCHECK | ||
136 | ... | ||
137 | #endif | ||
138 | |||
139 | * For providing a replacement for a function that exists on some platforms | ||
140 | but is broken/insufficient and needs to be replaced on some of them and | ||
141 | is additionally either missing or undeclared on some other platforms: | ||
142 | |||
143 | #if @GNULIB_FOO@ | ||
144 | # if @REPLACE_FOO@ | ||
145 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
146 | # undef foo | ||
147 | # define foo rpl_foo | ||
148 | # endif | ||
149 | _GL_FUNCDECL_RPL (foo, ...); | ||
150 | _GL_CXXALIAS_RPL (foo, ...); | ||
151 | # else | ||
152 | # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ | ||
153 | _GL_FUNCDECL_SYS (foo, ...); | ||
154 | # endif | ||
155 | _GL_CXXALIAS_SYS (foo, ...); | ||
156 | # endif | ||
157 | _GL_CXXALIASWARN (foo); | ||
158 | #elif defined GNULIB_POSIXCHECK | ||
159 | ... | ||
160 | #endif | ||
161 | */ | ||
162 | |||
163 | /* _GL_EXTERN_C declaration; | ||
164 | performs the declaration with C linkage. */ | ||
165 | #if defined __cplusplus | ||
166 | # define _GL_EXTERN_C extern "C" | ||
167 | #else | ||
168 | # define _GL_EXTERN_C extern | ||
169 | #endif | ||
170 | |||
171 | /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); | ||
172 | declares a replacement function, named rpl_func, with the given prototype, | ||
173 | consisting of return type, parameters, and attributes. | ||
174 | Example: | ||
175 | _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) | ||
176 | _GL_ARG_NONNULL ((1))); | ||
177 | */ | ||
178 | #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ | ||
179 | _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) | ||
180 | #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ | ||
181 | _GL_EXTERN_C rettype rpl_func parameters_and_attributes | ||
182 | |||
183 | /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); | ||
184 | declares the system function, named func, with the given prototype, | ||
185 | consisting of return type, parameters, and attributes. | ||
186 | Example: | ||
187 | _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) | ||
188 | _GL_ARG_NONNULL ((1))); | ||
189 | */ | ||
190 | #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ | ||
191 | _GL_EXTERN_C rettype func parameters_and_attributes | ||
192 | |||
193 | /* _GL_CXXALIAS_RPL (func, rettype, parameters); | ||
194 | declares a C++ alias called GNULIB_NAMESPACE::func | ||
195 | that redirects to rpl_func, if GNULIB_NAMESPACE is defined. | ||
196 | Example: | ||
197 | _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); | ||
198 | |||
199 | Wrapping rpl_func in an object with an inline conversion operator | ||
200 | avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is | ||
201 | actually used in the program. */ | ||
202 | #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ | ||
203 | _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) | ||
204 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
205 | # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ | ||
206 | namespace GNULIB_NAMESPACE \ | ||
207 | { \ | ||
208 | static const struct _gl_ ## func ## _wrapper \ | ||
209 | { \ | ||
210 | typedef rettype (*type) parameters; \ | ||
211 | \ | ||
212 | inline operator type () const \ | ||
213 | { \ | ||
214 | return ::rpl_func; \ | ||
215 | } \ | ||
216 | } func = {}; \ | ||
217 | } \ | ||
218 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
219 | #else | ||
220 | # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ | ||
221 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
222 | #endif | ||
223 | |||
224 | /* _GL_CXXALIAS_MDA (func, rettype, parameters); | ||
225 | is to be used when func is a Microsoft deprecated alias, on native Windows. | ||
226 | It declares a C++ alias called GNULIB_NAMESPACE::func | ||
227 | that redirects to _func, if GNULIB_NAMESPACE is defined. | ||
228 | Example: | ||
229 | _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); | ||
230 | */ | ||
231 | #define _GL_CXXALIAS_MDA(func,rettype,parameters) \ | ||
232 | _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters) | ||
233 | |||
234 | /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); | ||
235 | is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); | ||
236 | except that the C function rpl_func may have a slightly different | ||
237 | declaration. A cast is used to silence the "invalid conversion" error | ||
238 | that would otherwise occur. */ | ||
239 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
240 | # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ | ||
241 | namespace GNULIB_NAMESPACE \ | ||
242 | { \ | ||
243 | static const struct _gl_ ## func ## _wrapper \ | ||
244 | { \ | ||
245 | typedef rettype (*type) parameters; \ | ||
246 | \ | ||
247 | inline operator type () const \ | ||
248 | { \ | ||
249 | return reinterpret_cast<type>(::rpl_func); \ | ||
250 | } \ | ||
251 | } func = {}; \ | ||
252 | } \ | ||
253 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
254 | #else | ||
255 | # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ | ||
256 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
257 | #endif | ||
258 | |||
259 | /* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters); | ||
260 | is like _GL_CXXALIAS_MDA (func, rettype, parameters); | ||
261 | except that the C function func may have a slightly different declaration. | ||
262 | A cast is used to silence the "invalid conversion" error that would | ||
263 | otherwise occur. */ | ||
264 | #define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \ | ||
265 | _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters) | ||
266 | |||
267 | /* _GL_CXXALIAS_SYS (func, rettype, parameters); | ||
268 | declares a C++ alias called GNULIB_NAMESPACE::func | ||
269 | that redirects to the system provided function func, if GNULIB_NAMESPACE | ||
270 | is defined. | ||
271 | Example: | ||
272 | _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); | ||
273 | |||
274 | Wrapping func in an object with an inline conversion operator | ||
275 | avoids a reference to func unless GNULIB_NAMESPACE::func is | ||
276 | actually used in the program. */ | ||
277 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
278 | # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ | ||
279 | namespace GNULIB_NAMESPACE \ | ||
280 | { \ | ||
281 | static const struct _gl_ ## func ## _wrapper \ | ||
282 | { \ | ||
283 | typedef rettype (*type) parameters; \ | ||
284 | \ | ||
285 | inline operator type () const \ | ||
286 | { \ | ||
287 | return ::func; \ | ||
288 | } \ | ||
289 | } func = {}; \ | ||
290 | } \ | ||
291 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
292 | #else | ||
293 | # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ | ||
294 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
295 | #endif | ||
296 | |||
297 | /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); | ||
298 | is like _GL_CXXALIAS_SYS (func, rettype, parameters); | ||
299 | except that the C function func may have a slightly different declaration. | ||
300 | A cast is used to silence the "invalid conversion" error that would | ||
301 | otherwise occur. */ | ||
302 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
303 | # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ | ||
304 | namespace GNULIB_NAMESPACE \ | ||
305 | { \ | ||
306 | static const struct _gl_ ## func ## _wrapper \ | ||
307 | { \ | ||
308 | typedef rettype (*type) parameters; \ | ||
309 | \ | ||
310 | inline operator type () const \ | ||
311 | { \ | ||
312 | return reinterpret_cast<type>(::func); \ | ||
313 | } \ | ||
314 | } func = {}; \ | ||
315 | } \ | ||
316 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
317 | #else | ||
318 | # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ | ||
319 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
320 | #endif | ||
321 | |||
322 | /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); | ||
323 | is like _GL_CXXALIAS_SYS (func, rettype, parameters); | ||
324 | except that the C function is picked among a set of overloaded functions, | ||
325 | namely the one with rettype2 and parameters2. Two consecutive casts | ||
326 | are used to silence the "cannot find a match" and "invalid conversion" | ||
327 | errors that would otherwise occur. */ | ||
328 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
329 | /* The outer cast must be a reinterpret_cast. | ||
330 | The inner cast: When the function is defined as a set of overloaded | ||
331 | functions, it works as a static_cast<>, choosing the designated variant. | ||
332 | When the function is defined as a single variant, it works as a | ||
333 | reinterpret_cast<>. The parenthesized cast syntax works both ways. */ | ||
334 | # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ | ||
335 | namespace GNULIB_NAMESPACE \ | ||
336 | { \ | ||
337 | static const struct _gl_ ## func ## _wrapper \ | ||
338 | { \ | ||
339 | typedef rettype (*type) parameters; \ | ||
340 | \ | ||
341 | inline operator type () const \ | ||
342 | { \ | ||
343 | return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ | ||
344 | } \ | ||
345 | } func = {}; \ | ||
346 | } \ | ||
347 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
348 | #else | ||
349 | # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ | ||
350 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
351 | #endif | ||
352 | |||
353 | /* _GL_CXXALIASWARN (func); | ||
354 | causes a warning to be emitted when ::func is used but not when | ||
355 | GNULIB_NAMESPACE::func is used. func must be defined without overloaded | ||
356 | variants. */ | ||
357 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
358 | # define _GL_CXXALIASWARN(func) \ | ||
359 | _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) | ||
360 | # define _GL_CXXALIASWARN_1(func,namespace) \ | ||
361 | _GL_CXXALIASWARN_2 (func, namespace) | ||
362 | /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, | ||
363 | we enable the warning only when not optimizing. */ | ||
364 | # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) | ||
365 | # define _GL_CXXALIASWARN_2(func,namespace) \ | ||
366 | _GL_WARN_ON_USE (func, \ | ||
367 | "The symbol ::" #func " refers to the system function. " \ | ||
368 | "Use " #namespace "::" #func " instead.") | ||
369 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||
370 | # define _GL_CXXALIASWARN_2(func,namespace) \ | ||
371 | extern __typeof__ (func) func | ||
372 | # else | ||
373 | # define _GL_CXXALIASWARN_2(func,namespace) \ | ||
374 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
375 | # endif | ||
376 | #else | ||
377 | # define _GL_CXXALIASWARN(func) \ | ||
378 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
379 | #endif | ||
380 | |||
381 | /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); | ||
382 | causes a warning to be emitted when the given overloaded variant of ::func | ||
383 | is used but not when GNULIB_NAMESPACE::func is used. */ | ||
384 | #if defined __cplusplus && defined GNULIB_NAMESPACE | ||
385 | # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ | ||
386 | _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ | ||
387 | GNULIB_NAMESPACE) | ||
388 | # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ | ||
389 | _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) | ||
390 | /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, | ||
391 | we enable the warning only when not optimizing. */ | ||
392 | # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) | ||
393 | # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ | ||
394 | _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \ | ||
395 | "The symbol ::" #func " refers to the system function. " \ | ||
396 | "Use " #namespace "::" #func " instead.") | ||
397 | # else | ||
398 | # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ | ||
399 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
400 | # endif | ||
401 | #else | ||
402 | # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ | ||
403 | _GL_EXTERN_C int _gl_cxxalias_dummy | ||
404 | #endif | ||
405 | |||
406 | #endif /* _GL_CXXDEFS_H */ | ||
407 | |||
408 | /* The definition of _GL_ARG_NONNULL is copied here. */ | ||
409 | /* A C macro for declaring that specific arguments must not be NULL. | ||
410 | Copyright (C) 2009-2022 Free Software Foundation, Inc. | ||
411 | |||
412 | This program is free software: you can redistribute it and/or modify it | ||
413 | under the terms of the GNU Lesser General Public License as published | ||
414 | by the Free Software Foundation; either version 2 of the License, or | ||
415 | (at your option) any later version. | ||
416 | |||
417 | This program is distributed in the hope that it will be useful, | ||
418 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
419 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
420 | Lesser General Public License for more details. | ||
421 | |||
422 | You should have received a copy of the GNU Lesser General Public License | ||
423 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ | ||
424 | |||
425 | /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools | ||
426 | that the values passed as arguments n, ..., m must be non-NULL pointers. | ||
427 | n = 1 stands for the first argument, n = 2 for the second argument etc. */ | ||
428 | #ifndef _GL_ARG_NONNULL | ||
429 | # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__ | ||
430 | # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) | ||
431 | # else | ||
432 | # define _GL_ARG_NONNULL(params) | ||
433 | # endif | ||
434 | #endif | ||
435 | |||
436 | /* The definition of _GL_WARN_ON_USE is copied here. */ | ||
437 | /* A C macro for emitting warnings if a function is used. | ||
438 | Copyright (C) 2010-2022 Free Software Foundation, Inc. | ||
439 | |||
440 | This program is free software: you can redistribute it and/or modify it | ||
441 | under the terms of the GNU Lesser General Public License as published | ||
442 | by the Free Software Foundation; either version 2 of the License, or | ||
443 | (at your option) any later version. | ||
444 | |||
445 | This program is distributed in the hope that it will be useful, | ||
446 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
447 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
448 | Lesser General Public License for more details. | ||
449 | |||
450 | You should have received a copy of the GNU Lesser General Public License | ||
451 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ | ||
452 | |||
453 | /* _GL_WARN_ON_USE (function, "literal string") issues a declaration | ||
454 | for FUNCTION which will then trigger a compiler warning containing | ||
455 | the text of "literal string" anywhere that function is called, if | ||
456 | supported by the compiler. If the compiler does not support this | ||
457 | feature, the macro expands to an unused extern declaration. | ||
458 | |||
459 | _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the | ||
460 | attribute used in _GL_WARN_ON_USE. If the compiler does not support | ||
461 | this feature, it expands to empty. | ||
462 | |||
463 | These macros are useful for marking a function as a potential | ||
464 | portability trap, with the intent that "literal string" include | ||
465 | instructions on the replacement function that should be used | ||
466 | instead. | ||
467 | _GL_WARN_ON_USE is for functions with 'extern' linkage. | ||
468 | _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' | ||
469 | linkage. | ||
470 | |||
471 | However, one of the reasons that a function is a portability trap is | ||
472 | if it has the wrong signature. Declaring FUNCTION with a different | ||
473 | signature in C is a compilation error, so this macro must use the | ||
474 | same type as any existing declaration so that programs that avoid | ||
475 | the problematic FUNCTION do not fail to compile merely because they | ||
476 | included a header that poisoned the function. But this implies that | ||
477 | _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already | ||
478 | have a declaration. Use of this macro implies that there must not | ||
479 | be any other macro hiding the declaration of FUNCTION; but | ||
480 | undefining FUNCTION first is part of the poisoning process anyway | ||
481 | (although for symbols that are provided only via a macro, the result | ||
482 | is a compilation error rather than a warning containing | ||
483 | "literal string"). Also note that in C++, it is only safe to use if | ||
484 | FUNCTION has no overloads. | ||
485 | |||
486 | For an example, it is possible to poison 'getline' by: | ||
487 | - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], | ||
488 | [getline]) in configure.ac, which potentially defines | ||
489 | HAVE_RAW_DECL_GETLINE | ||
490 | - adding this code to a header that wraps the system <stdio.h>: | ||
491 | #undef getline | ||
492 | #if HAVE_RAW_DECL_GETLINE | ||
493 | _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" | ||
494 | "not universally present; use the gnulib module getline"); | ||
495 | #endif | ||
496 | |||
497 | It is not possible to directly poison global variables. But it is | ||
498 | possible to write a wrapper accessor function, and poison that | ||
499 | (less common usage, like &environ, will cause a compilation error | ||
500 | rather than issue the nice warning, but the end result of informing | ||
501 | the developer about their portability problem is still achieved): | ||
502 | #if HAVE_RAW_DECL_ENVIRON | ||
503 | static char *** | ||
504 | rpl_environ (void) { return &environ; } | ||
505 | _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); | ||
506 | # undef environ | ||
507 | # define environ (*rpl_environ ()) | ||
508 | #endif | ||
509 | or better (avoiding contradictory use of 'static' and 'extern'): | ||
510 | #if HAVE_RAW_DECL_ENVIRON | ||
511 | static char *** | ||
512 | _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") | ||
513 | rpl_environ (void) { return &environ; } | ||
514 | # undef environ | ||
515 | # define environ (*rpl_environ ()) | ||
516 | #endif | ||
517 | */ | ||
518 | #ifndef _GL_WARN_ON_USE | ||
519 | |||
520 | # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) | ||
521 | /* A compiler attribute is available in gcc versions 4.3.0 and later. */ | ||
522 | # define _GL_WARN_ON_USE(function, message) \ | ||
523 | _GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message))) | ||
524 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ | ||
525 | __attribute__ ((__warning__ (message))) | ||
526 | # elif __clang_major__ >= 4 | ||
527 | /* Another compiler attribute is available in clang. */ | ||
528 | # define _GL_WARN_ON_USE(function, message) \ | ||
529 | _GL_WARN_EXTERN_C __typeof__ (function) function \ | ||
530 | __attribute__ ((__diagnose_if__ (1, message, "warning"))) | ||
531 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ | ||
532 | __attribute__ ((__diagnose_if__ (1, message, "warning"))) | ||
533 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||
534 | /* Verify the existence of the function. */ | ||
535 | # define _GL_WARN_ON_USE(function, message) \ | ||
536 | _GL_WARN_EXTERN_C __typeof__ (function) function | ||
537 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) | ||
538 | # else /* Unsupported. */ | ||
539 | # define _GL_WARN_ON_USE(function, message) \ | ||
540 | _GL_WARN_EXTERN_C int _gl_warn_on_use | ||
541 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) | ||
542 | # endif | ||
543 | #endif | ||
544 | |||
545 | /* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message") | ||
546 | is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the | ||
547 | function is declared with the given prototype, consisting of return type, | ||
548 | parameters, and attributes. | ||
549 | This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does | ||
550 | not work in this case. */ | ||
551 | #ifndef _GL_WARN_ON_USE_CXX | ||
552 | # if !defined __cplusplus | ||
553 | # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ | ||
554 | _GL_WARN_ON_USE (function, msg) | ||
555 | # else | ||
556 | # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) | ||
557 | /* A compiler attribute is available in gcc versions 4.3.0 and later. */ | ||
558 | # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ | ||
559 | extern rettype_gcc function parameters_and_attributes \ | ||
560 | __attribute__ ((__warning__ (msg))) | ||
561 | # elif __clang_major__ >= 4 | ||
562 | /* Another compiler attribute is available in clang. */ | ||
563 | # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ | ||
564 | extern rettype_clang function parameters_and_attributes \ | ||
565 | __attribute__ ((__diagnose_if__ (1, msg, "warning"))) | ||
566 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||
567 | /* Verify the existence of the function. */ | ||
568 | # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ | ||
569 | extern rettype_gcc function parameters_and_attributes | ||
570 | # else /* Unsupported. */ | ||
571 | # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ | ||
572 | _GL_WARN_EXTERN_C int _gl_warn_on_use | ||
573 | # endif | ||
574 | # endif | ||
575 | #endif | ||
576 | |||
577 | /* _GL_WARN_EXTERN_C declaration; | ||
578 | performs the declaration with C linkage. */ | ||
579 | #ifndef _GL_WARN_EXTERN_C | ||
580 | # if defined __cplusplus | ||
581 | # define _GL_WARN_EXTERN_C extern "C" | ||
582 | # else | ||
583 | # define _GL_WARN_EXTERN_C extern | ||
584 | # endif | ||
585 | #endif | ||
586 | |||
587 | #if !1 | ||
588 | # if !GNULIB_defined_sa_family_t | ||
589 | /* On OS/2 kLIBC, sa_family_t is unsigned char unless TCPV40HDRS is defined. */ | ||
590 | # if !defined __KLIBC__ || defined TCPV40HDRS | ||
591 | typedef unsigned short sa_family_t; | ||
592 | # else | ||
593 | typedef unsigned char sa_family_t; | ||
594 | # endif | ||
595 | # define GNULIB_defined_sa_family_t 1 | ||
596 | # endif | ||
597 | #endif | ||
598 | |||
599 | #if 1 | ||
600 | /* Make the 'struct sockaddr_storage' field 'ss_family' visible on AIX 7.1. */ | ||
601 | # if !1 | ||
602 | # ifndef ss_family | ||
603 | # define ss_family __ss_family | ||
604 | # endif | ||
605 | # endif | ||
606 | #else | ||
607 | # include <stdalign.h> | ||
608 | /* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on | ||
609 | 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */ | ||
610 | # define __ss_aligntype unsigned long int | ||
611 | # define _SS_SIZE 256 | ||
612 | # define _SS_PADSIZE \ | ||
613 | (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \ | ||
614 | ? sizeof (sa_family_t) \ | ||
615 | : alignof (__ss_aligntype)) \ | ||
616 | + sizeof (__ss_aligntype))) | ||
617 | |||
618 | # if !GNULIB_defined_struct_sockaddr_storage | ||
619 | struct sockaddr_storage | ||
620 | { | ||
621 | sa_family_t ss_family; /* Address family, etc. */ | ||
622 | __ss_aligntype __ss_align; /* Force desired alignment. */ | ||
623 | char __ss_padding[_SS_PADSIZE]; | ||
624 | }; | ||
625 | # define GNULIB_defined_struct_sockaddr_storage 1 | ||
626 | # endif | ||
627 | |||
628 | #endif | ||
629 | |||
630 | /* Get struct iovec. */ | ||
631 | /* But avoid namespace pollution on glibc systems. */ | ||
632 | #if ! defined __GLIBC__ | ||
633 | # include <sys/uio.h> | ||
634 | #endif | ||
635 | |||
636 | #if 1 | ||
637 | |||
638 | /* A platform that has <sys/socket.h>. */ | ||
639 | |||
640 | /* For shutdown(). */ | ||
641 | # if !defined SHUT_RD | ||
642 | # define SHUT_RD 0 | ||
643 | # endif | ||
644 | # if !defined SHUT_WR | ||
645 | # define SHUT_WR 1 | ||
646 | # endif | ||
647 | # if !defined SHUT_RDWR | ||
648 | # define SHUT_RDWR 2 | ||
649 | # endif | ||
650 | |||
651 | # ifdef __VMS /* OpenVMS */ | ||
652 | # ifndef CMSG_SPACE | ||
653 | # define CMSG_SPACE(length) _CMSG_SPACE(length) | ||
654 | # endif | ||
655 | # ifndef CMSG_LEN | ||
656 | # define CMSG_LEN(length) _CMSG_LEN(length) | ||
657 | # endif | ||
658 | # endif | ||
659 | |||
660 | #else | ||
661 | |||
662 | # ifdef __CYGWIN__ | ||
663 | # error "Cygwin does have a sys/socket.h, doesn't it?!?" | ||
664 | # endif | ||
665 | |||
666 | /* A platform that lacks <sys/socket.h>. | ||
667 | |||
668 | Currently only MinGW is supported. See the gnulib manual regarding | ||
669 | Windows sockets. MinGW has the header files winsock2.h and | ||
670 | ws2tcpip.h that declare the sys/socket.h definitions we need. Note | ||
671 | that you can influence which definitions you get by setting the | ||
672 | WINVER symbol before including these two files. For example, | ||
673 | getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that | ||
674 | symbol is set indirectly through WINVER). You can set this by | ||
675 | adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your | ||
676 | code may not run on older Windows releases then. My Windows 2000 | ||
677 | box was not able to run the code, for example. The situation is | ||
678 | slightly confusing because | ||
679 | <https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-getaddrinfo> | ||
680 | suggests that getaddrinfo should be available on all Windows | ||
681 | releases. */ | ||
682 | |||
683 | # if 0 | ||
684 | # include <winsock2.h> | ||
685 | # endif | ||
686 | # if 0 | ||
687 | # include <ws2tcpip.h> | ||
688 | # endif | ||
689 | |||
690 | /* For shutdown(). */ | ||
691 | # if !defined SHUT_RD && defined SD_RECEIVE | ||
692 | # define SHUT_RD SD_RECEIVE | ||
693 | # endif | ||
694 | # if !defined SHUT_WR && defined SD_SEND | ||
695 | # define SHUT_WR SD_SEND | ||
696 | # endif | ||
697 | # if !defined SHUT_RDWR && defined SD_BOTH | ||
698 | # define SHUT_RDWR SD_BOTH | ||
699 | # endif | ||
700 | |||
701 | # if 0 | ||
702 | /* Include headers needed by the emulation code. */ | ||
703 | # include <sys/types.h> | ||
704 | # include <io.h> | ||
705 | /* If these headers don't define socklen_t, <config.h> does. */ | ||
706 | # endif | ||
707 | |||
708 | /* Rudimentary 'struct msghdr'; this works as long as you don't try to | ||
709 | access msg_control or msg_controllen. */ | ||
710 | struct msghdr { | ||
711 | void *msg_name; | ||
712 | socklen_t msg_namelen; | ||
713 | struct iovec *msg_iov; | ||
714 | int msg_iovlen; | ||
715 | int msg_flags; | ||
716 | }; | ||
717 | |||
718 | #endif | ||
719 | |||
720 | /* Ensure SO_REUSEPORT is defined. */ | ||
721 | /* For the subtle differences between SO_REUSEPORT and SO_REUSEADDR, see | ||
722 | https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t | ||
723 | and https://lwn.net/Articles/542629/ | ||
724 | */ | ||
725 | #ifndef SO_REUSEPORT | ||
726 | # define SO_REUSEPORT SO_REUSEADDR | ||
727 | #endif | ||
728 | |||
729 | /* Fix some definitions from <winsock2.h>. */ | ||
730 | |||
731 | #if 0 | ||
732 | |||
733 | # if !GNULIB_defined_rpl_fd_isset | ||
734 | |||
735 | /* Re-define FD_ISSET to avoid a WSA call while we are not using | ||
736 | network sockets. */ | ||
737 | _GL_SYS_SOCKET_INLINE int | ||
738 | rpl_fd_isset (SOCKET fd, fd_set * set) | ||
739 | { | ||
740 | u_int i; | ||
741 | if (set == NULL) | ||
742 | return 0; | ||
743 | |||
744 | for (i = 0; i < set->fd_count; i++) | ||
745 | if (set->fd_array[i] == fd) | ||
746 | return 1; | ||
747 | |||
748 | return 0; | ||
749 | } | ||
750 | |||
751 | # define GNULIB_defined_rpl_fd_isset 1 | ||
752 | # endif | ||
753 | |||
754 | # undef FD_ISSET | ||
755 | # define FD_ISSET(fd, set) rpl_fd_isset(fd, set) | ||
756 | |||
757 | #endif | ||
758 | |||
759 | /* Hide some function declarations from <winsock2.h>. */ | ||
760 | |||
761 | #if 0 | ||
762 | # if !defined _GL_UNISTD_H | ||
763 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
764 | # undef close | ||
765 | # define close close_used_without_including_unistd_h | ||
766 | # elif !defined __clang__ | ||
767 | _GL_WARN_ON_USE (close, | ||
768 | "close() used without including <unistd.h>"); | ||
769 | # endif | ||
770 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
771 | # undef gethostname | ||
772 | # define gethostname gethostname_used_without_including_unistd_h | ||
773 | # else | ||
774 | _GL_WARN_ON_USE (gethostname, | ||
775 | "gethostname() used without including <unistd.h>"); | ||
776 | # endif | ||
777 | # endif | ||
778 | # if !defined _GL_SYS_SELECT_H | ||
779 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
780 | # undef select | ||
781 | # define select select_used_without_including_sys_select_h | ||
782 | # else | ||
783 | _GL_WARN_ON_USE (select, | ||
784 | "select() used without including <sys/select.h>"); | ||
785 | # endif | ||
786 | # endif | ||
787 | #endif | ||
788 | |||
789 | /* Wrap everything else to use libc file descriptors for sockets. */ | ||
790 | |||
791 | #if 0 | ||
792 | # if 0 | ||
793 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
794 | # undef socket | ||
795 | # define socket rpl_socket | ||
796 | # endif | ||
797 | _GL_FUNCDECL_RPL (socket, int, (int domain, int type, int protocol)); | ||
798 | _GL_CXXALIAS_RPL (socket, int, (int domain, int type, int protocol)); | ||
799 | # else | ||
800 | _GL_CXXALIAS_SYS (socket, int, (int domain, int type, int protocol)); | ||
801 | # endif | ||
802 | _GL_CXXALIASWARN (socket); | ||
803 | #elif 0 | ||
804 | # undef socket | ||
805 | # define socket socket_used_without_requesting_gnulib_module_socket | ||
806 | #elif defined GNULIB_POSIXCHECK | ||
807 | # undef socket | ||
808 | # if HAVE_RAW_DECL_SOCKET | ||
809 | _GL_WARN_ON_USE (socket, "socket is not always POSIX compliant - " | ||
810 | "use gnulib module socket for portability"); | ||
811 | # endif | ||
812 | #endif | ||
813 | |||
814 | #if 0 | ||
815 | # if 0 | ||
816 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
817 | # undef connect | ||
818 | # define connect rpl_connect | ||
819 | # endif | ||
820 | _GL_FUNCDECL_RPL (connect, int, | ||
821 | (int fd, const struct sockaddr *addr, socklen_t addrlen) | ||
822 | _GL_ARG_NONNULL ((2))); | ||
823 | _GL_CXXALIAS_RPL (connect, int, | ||
824 | (int fd, const struct sockaddr *addr, socklen_t addrlen)); | ||
825 | # else | ||
826 | /* Need to cast, because on NonStop Kernel, the third parameter is | ||
827 | size_t addrlen. */ | ||
828 | _GL_CXXALIAS_SYS_CAST (connect, int, | ||
829 | (int fd, | ||
830 | const struct sockaddr *addr, socklen_t addrlen)); | ||
831 | # endif | ||
832 | _GL_CXXALIASWARN (connect); | ||
833 | #elif 0 | ||
834 | # undef connect | ||
835 | # define connect socket_used_without_requesting_gnulib_module_connect | ||
836 | #elif defined GNULIB_POSIXCHECK | ||
837 | # undef connect | ||
838 | # if HAVE_RAW_DECL_CONNECT | ||
839 | _GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - " | ||
840 | "use gnulib module connect for portability"); | ||
841 | # endif | ||
842 | #endif | ||
843 | |||
844 | #if 0 | ||
845 | # if 0 | ||
846 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
847 | # undef accept | ||
848 | # define accept rpl_accept | ||
849 | # endif | ||
850 | _GL_FUNCDECL_RPL (accept, int, | ||
851 | (int fd, | ||
852 | struct sockaddr *restrict addr, | ||
853 | socklen_t *restrict addrlen)); | ||
854 | _GL_CXXALIAS_RPL (accept, int, | ||
855 | (int fd, | ||
856 | struct sockaddr *restrict addr, | ||
857 | socklen_t *restrict addrlen)); | ||
858 | # else | ||
859 | /* Need to cast, because on Solaris 10 systems, the third parameter is | ||
860 | void *addrlen. */ | ||
861 | _GL_CXXALIAS_SYS_CAST (accept, int, | ||
862 | (int fd, | ||
863 | struct sockaddr *restrict addr, | ||
864 | socklen_t *restrict addrlen)); | ||
865 | # endif | ||
866 | _GL_CXXALIASWARN (accept); | ||
867 | #elif 0 | ||
868 | # undef accept | ||
869 | # define accept accept_used_without_requesting_gnulib_module_accept | ||
870 | #elif defined GNULIB_POSIXCHECK | ||
871 | # undef accept | ||
872 | # if HAVE_RAW_DECL_ACCEPT | ||
873 | _GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - " | ||
874 | "use gnulib module accept for portability"); | ||
875 | # endif | ||
876 | #endif | ||
877 | |||
878 | #if 0 | ||
879 | # if 0 | ||
880 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
881 | # undef bind | ||
882 | # define bind rpl_bind | ||
883 | # endif | ||
884 | _GL_FUNCDECL_RPL (bind, int, | ||
885 | (int fd, const struct sockaddr *addr, socklen_t addrlen) | ||
886 | _GL_ARG_NONNULL ((2))); | ||
887 | _GL_CXXALIAS_RPL (bind, int, | ||
888 | (int fd, const struct sockaddr *addr, socklen_t addrlen)); | ||
889 | # else | ||
890 | /* Need to cast, because on NonStop Kernel, the third parameter is | ||
891 | size_t addrlen. */ | ||
892 | _GL_CXXALIAS_SYS_CAST (bind, int, | ||
893 | (int fd, | ||
894 | const struct sockaddr *addr, socklen_t addrlen)); | ||
895 | # endif | ||
896 | _GL_CXXALIASWARN (bind); | ||
897 | #elif 0 | ||
898 | # undef bind | ||
899 | # define bind bind_used_without_requesting_gnulib_module_bind | ||
900 | #elif defined GNULIB_POSIXCHECK | ||
901 | # undef bind | ||
902 | # if HAVE_RAW_DECL_BIND | ||
903 | _GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - " | ||
904 | "use gnulib module bind for portability"); | ||
905 | # endif | ||
906 | #endif | ||
907 | |||
908 | #if 0 | ||
909 | # if 0 | ||
910 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
911 | # undef getpeername | ||
912 | # define getpeername rpl_getpeername | ||
913 | # endif | ||
914 | _GL_FUNCDECL_RPL (getpeername, int, | ||
915 | (int fd, struct sockaddr *restrict addr, | ||
916 | socklen_t *restrict addrlen) | ||
917 | _GL_ARG_NONNULL ((2, 3))); | ||
918 | _GL_CXXALIAS_RPL (getpeername, int, | ||
919 | (int fd, struct sockaddr *restrict addr, | ||
920 | socklen_t *restrict addrlen)); | ||
921 | # else | ||
922 | /* Need to cast, because on Solaris 10 systems, the third parameter is | ||
923 | void *addrlen. */ | ||
924 | _GL_CXXALIAS_SYS_CAST (getpeername, int, | ||
925 | (int fd, struct sockaddr *restrict addr, | ||
926 | socklen_t *restrict addrlen)); | ||
927 | # endif | ||
928 | _GL_CXXALIASWARN (getpeername); | ||
929 | #elif 0 | ||
930 | # undef getpeername | ||
931 | # define getpeername getpeername_used_without_requesting_gnulib_module_getpeername | ||
932 | #elif defined GNULIB_POSIXCHECK | ||
933 | # undef getpeername | ||
934 | # if HAVE_RAW_DECL_GETPEERNAME | ||
935 | _GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - " | ||
936 | "use gnulib module getpeername for portability"); | ||
937 | # endif | ||
938 | #endif | ||
939 | |||
940 | #if 0 | ||
941 | # if 0 | ||
942 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
943 | # undef getsockname | ||
944 | # define getsockname rpl_getsockname | ||
945 | # endif | ||
946 | _GL_FUNCDECL_RPL (getsockname, int, | ||
947 | (int fd, struct sockaddr *restrict addr, | ||
948 | socklen_t *restrict addrlen) | ||
949 | _GL_ARG_NONNULL ((2, 3))); | ||
950 | _GL_CXXALIAS_RPL (getsockname, int, | ||
951 | (int fd, struct sockaddr *restrict addr, | ||
952 | socklen_t *restrict addrlen)); | ||
953 | # else | ||
954 | /* Need to cast, because on Solaris 10 systems, the third parameter is | ||
955 | void *addrlen. */ | ||
956 | _GL_CXXALIAS_SYS_CAST (getsockname, int, | ||
957 | (int fd, struct sockaddr *restrict addr, | ||
958 | socklen_t *restrict addrlen)); | ||
959 | # endif | ||
960 | _GL_CXXALIASWARN (getsockname); | ||
961 | #elif 0 | ||
962 | # undef getsockname | ||
963 | # define getsockname getsockname_used_without_requesting_gnulib_module_getsockname | ||
964 | #elif defined GNULIB_POSIXCHECK | ||
965 | # undef getsockname | ||
966 | # if HAVE_RAW_DECL_GETSOCKNAME | ||
967 | _GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - " | ||
968 | "use gnulib module getsockname for portability"); | ||
969 | # endif | ||
970 | #endif | ||
971 | |||
972 | #if 0 | ||
973 | # if 0 | ||
974 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
975 | # undef getsockopt | ||
976 | # define getsockopt rpl_getsockopt | ||
977 | # endif | ||
978 | _GL_FUNCDECL_RPL (getsockopt, int, | ||
979 | (int fd, int level, int optname, | ||
980 | void *restrict optval, socklen_t *restrict optlen) | ||
981 | _GL_ARG_NONNULL ((4, 5))); | ||
982 | _GL_CXXALIAS_RPL (getsockopt, int, | ||
983 | (int fd, int level, int optname, | ||
984 | void *restrict optval, socklen_t *restrict optlen)); | ||
985 | # else | ||
986 | /* Need to cast, because on Solaris 10 systems, the fifth parameter is | ||
987 | void *optlen. */ | ||
988 | _GL_CXXALIAS_SYS_CAST (getsockopt, int, | ||
989 | (int fd, int level, int optname, | ||
990 | void *restrict optval, socklen_t *restrict optlen)); | ||
991 | # endif | ||
992 | _GL_CXXALIASWARN (getsockopt); | ||
993 | #elif 0 | ||
994 | # undef getsockopt | ||
995 | # define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt | ||
996 | #elif defined GNULIB_POSIXCHECK | ||
997 | # undef getsockopt | ||
998 | # if HAVE_RAW_DECL_GETSOCKOPT | ||
999 | _GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - " | ||
1000 | "use gnulib module getsockopt for portability"); | ||
1001 | # endif | ||
1002 | #endif | ||
1003 | |||
1004 | #if 0 | ||
1005 | # if 0 | ||
1006 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
1007 | # undef listen | ||
1008 | # define listen rpl_listen | ||
1009 | # endif | ||
1010 | _GL_FUNCDECL_RPL (listen, int, (int fd, int backlog)); | ||
1011 | _GL_CXXALIAS_RPL (listen, int, (int fd, int backlog)); | ||
1012 | # else | ||
1013 | _GL_CXXALIAS_SYS (listen, int, (int fd, int backlog)); | ||
1014 | # endif | ||
1015 | _GL_CXXALIASWARN (listen); | ||
1016 | #elif 0 | ||
1017 | # undef listen | ||
1018 | # define listen listen_used_without_requesting_gnulib_module_listen | ||
1019 | #elif defined GNULIB_POSIXCHECK | ||
1020 | # undef listen | ||
1021 | # if HAVE_RAW_DECL_LISTEN | ||
1022 | _GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - " | ||
1023 | "use gnulib module listen for portability"); | ||
1024 | # endif | ||
1025 | #endif | ||
1026 | |||
1027 | #if 0 | ||
1028 | # if 0 | ||
1029 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
1030 | # undef recv | ||
1031 | # define recv rpl_recv | ||
1032 | # endif | ||
1033 | _GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags) | ||
1034 | _GL_ARG_NONNULL ((2))); | ||
1035 | _GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); | ||
1036 | # else | ||
1037 | /* Need to cast, because on HP-UX 11.31 the return type may be | ||
1038 | int, | ||
1039 | depending on compiler options. */ | ||
1040 | _GL_CXXALIAS_SYS_CAST (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); | ||
1041 | # endif | ||
1042 | _GL_CXXALIASWARN (recv); | ||
1043 | #elif 0 | ||
1044 | # undef recv | ||
1045 | # define recv recv_used_without_requesting_gnulib_module_recv | ||
1046 | #elif defined GNULIB_POSIXCHECK | ||
1047 | # undef recv | ||
1048 | # if HAVE_RAW_DECL_RECV | ||
1049 | _GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - " | ||
1050 | "use gnulib module recv for portability"); | ||
1051 | # endif | ||
1052 | #endif | ||
1053 | |||
1054 | #if 0 | ||
1055 | # if 0 | ||
1056 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
1057 | # undef send | ||
1058 | # define send rpl_send | ||
1059 | # endif | ||
1060 | _GL_FUNCDECL_RPL (send, ssize_t, | ||
1061 | (int fd, const void *buf, size_t len, int flags) | ||
1062 | _GL_ARG_NONNULL ((2))); | ||
1063 | _GL_CXXALIAS_RPL (send, ssize_t, | ||
1064 | (int fd, const void *buf, size_t len, int flags)); | ||
1065 | # else | ||
1066 | /* Need to cast, because on HP-UX 11.31 the return type may be | ||
1067 | int, | ||
1068 | depending on compiler options. */ | ||
1069 | _GL_CXXALIAS_SYS_CAST (send, ssize_t, | ||
1070 | (int fd, const void *buf, size_t len, int flags)); | ||
1071 | # endif | ||
1072 | _GL_CXXALIASWARN (send); | ||
1073 | #elif 0 | ||
1074 | # undef send | ||
1075 | # define send send_used_without_requesting_gnulib_module_send | ||
1076 | #elif defined GNULIB_POSIXCHECK | ||
1077 | # undef send | ||
1078 | # if HAVE_RAW_DECL_SEND | ||
1079 | _GL_WARN_ON_USE (send, "send is not always POSIX compliant - " | ||
1080 | "use gnulib module send for portability"); | ||
1081 | # endif | ||
1082 | #endif | ||
1083 | |||
1084 | #if 0 | ||
1085 | # if 0 | ||
1086 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
1087 | # undef recvfrom | ||
1088 | # define recvfrom rpl_recvfrom | ||
1089 | # endif | ||
1090 | _GL_FUNCDECL_RPL (recvfrom, ssize_t, | ||
1091 | (int fd, void *restrict buf, size_t len, int flags, | ||
1092 | struct sockaddr *restrict from, | ||
1093 | socklen_t *restrict fromlen) | ||
1094 | _GL_ARG_NONNULL ((2))); | ||
1095 | _GL_CXXALIAS_RPL (recvfrom, ssize_t, | ||
1096 | (int fd, void *restrict buf, size_t len, int flags, | ||
1097 | struct sockaddr *restrict from, | ||
1098 | socklen_t *restrict fromlen)); | ||
1099 | # else | ||
1100 | /* Need to cast, because on Solaris 10 systems, the sixth parameter is | ||
1101 | void *fromlen. */ | ||
1102 | _GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t, | ||
1103 | (int fd, void *restrict buf, size_t len, int flags, | ||
1104 | struct sockaddr *restrict from, | ||
1105 | socklen_t *restrict fromlen)); | ||
1106 | # endif | ||
1107 | _GL_CXXALIASWARN (recvfrom); | ||
1108 | #elif 0 | ||
1109 | # undef recvfrom | ||
1110 | # define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom | ||
1111 | #elif defined GNULIB_POSIXCHECK | ||
1112 | # undef recvfrom | ||
1113 | # if HAVE_RAW_DECL_RECVFROM | ||
1114 | _GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - " | ||
1115 | "use gnulib module recvfrom for portability"); | ||
1116 | # endif | ||
1117 | #endif | ||
1118 | |||
1119 | #if 0 | ||
1120 | # if 0 | ||
1121 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
1122 | # undef sendto | ||
1123 | # define sendto rpl_sendto | ||
1124 | # endif | ||
1125 | _GL_FUNCDECL_RPL (sendto, ssize_t, | ||
1126 | (int fd, const void *buf, size_t len, int flags, | ||
1127 | const struct sockaddr *to, socklen_t tolen) | ||
1128 | _GL_ARG_NONNULL ((2))); | ||
1129 | _GL_CXXALIAS_RPL (sendto, ssize_t, | ||
1130 | (int fd, const void *buf, size_t len, int flags, | ||
1131 | const struct sockaddr *to, socklen_t tolen)); | ||
1132 | # else | ||
1133 | /* Need to cast, because on NonStop Kernel, the sixth parameter is | ||
1134 | size_t tolen. */ | ||
1135 | _GL_CXXALIAS_SYS_CAST (sendto, ssize_t, | ||
1136 | (int fd, const void *buf, size_t len, int flags, | ||
1137 | const struct sockaddr *to, socklen_t tolen)); | ||
1138 | # endif | ||
1139 | _GL_CXXALIASWARN (sendto); | ||
1140 | #elif 0 | ||
1141 | # undef sendto | ||
1142 | # define sendto sendto_used_without_requesting_gnulib_module_sendto | ||
1143 | #elif defined GNULIB_POSIXCHECK | ||
1144 | # undef sendto | ||
1145 | # if HAVE_RAW_DECL_SENDTO | ||
1146 | _GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - " | ||
1147 | "use gnulib module sendto for portability"); | ||
1148 | # endif | ||
1149 | #endif | ||
1150 | |||
1151 | #if 0 | ||
1152 | # if 0 | ||
1153 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
1154 | # undef setsockopt | ||
1155 | # define setsockopt rpl_setsockopt | ||
1156 | # endif | ||
1157 | _GL_FUNCDECL_RPL (setsockopt, int, (int fd, int level, int optname, | ||
1158 | const void * optval, socklen_t optlen) | ||
1159 | _GL_ARG_NONNULL ((4))); | ||
1160 | _GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname, | ||
1161 | const void * optval, socklen_t optlen)); | ||
1162 | # else | ||
1163 | /* Need to cast, because on NonStop Kernel, the fifth parameter is | ||
1164 | size_t optlen. */ | ||
1165 | _GL_CXXALIAS_SYS_CAST (setsockopt, int, | ||
1166 | (int fd, int level, int optname, | ||
1167 | const void * optval, socklen_t optlen)); | ||
1168 | # endif | ||
1169 | _GL_CXXALIASWARN (setsockopt); | ||
1170 | #elif 0 | ||
1171 | # undef setsockopt | ||
1172 | # define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt | ||
1173 | #elif defined GNULIB_POSIXCHECK | ||
1174 | # undef setsockopt | ||
1175 | # if HAVE_RAW_DECL_SETSOCKOPT | ||
1176 | _GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - " | ||
1177 | "use gnulib module setsockopt for portability"); | ||
1178 | # endif | ||
1179 | #endif | ||
1180 | |||
1181 | #if 0 | ||
1182 | # if 0 | ||
1183 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
1184 | # undef shutdown | ||
1185 | # define shutdown rpl_shutdown | ||
1186 | # endif | ||
1187 | _GL_FUNCDECL_RPL (shutdown, int, (int fd, int how)); | ||
1188 | _GL_CXXALIAS_RPL (shutdown, int, (int fd, int how)); | ||
1189 | # else | ||
1190 | _GL_CXXALIAS_SYS (shutdown, int, (int fd, int how)); | ||
1191 | # endif | ||
1192 | _GL_CXXALIASWARN (shutdown); | ||
1193 | #elif 0 | ||
1194 | # undef shutdown | ||
1195 | # define shutdown shutdown_used_without_requesting_gnulib_module_shutdown | ||
1196 | #elif defined GNULIB_POSIXCHECK | ||
1197 | # undef shutdown | ||
1198 | # if HAVE_RAW_DECL_SHUTDOWN | ||
1199 | _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - " | ||
1200 | "use gnulib module shutdown for portability"); | ||
1201 | # endif | ||
1202 | #endif | ||
1203 | |||
1204 | #if 0 | ||
1205 | /* Accept a connection on a socket, with specific opening flags. | ||
1206 | The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | ||
1207 | and O_TEXT, O_BINARY (defined in "binary-io.h"). | ||
1208 | See also the Linux man page at | ||
1209 | <https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */ | ||
1210 | # if 1 | ||
1211 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
1212 | # define accept4 rpl_accept4 | ||
1213 | # endif | ||
1214 | _GL_FUNCDECL_RPL (accept4, int, | ||
1215 | (int sockfd, struct sockaddr *addr, socklen_t *addrlen, | ||
1216 | int flags)); | ||
1217 | _GL_CXXALIAS_RPL (accept4, int, | ||
1218 | (int sockfd, struct sockaddr *addr, socklen_t *addrlen, | ||
1219 | int flags)); | ||
1220 | # else | ||
1221 | _GL_FUNCDECL_SYS (accept4, int, | ||
1222 | (int sockfd, struct sockaddr *addr, socklen_t *addrlen, | ||
1223 | int flags)); | ||
1224 | _GL_CXXALIAS_SYS (accept4, int, | ||
1225 | (int sockfd, struct sockaddr *addr, socklen_t *addrlen, | ||
1226 | int flags)); | ||
1227 | # endif | ||
1228 | _GL_CXXALIASWARN (accept4); | ||
1229 | #elif defined GNULIB_POSIXCHECK | ||
1230 | # undef accept4 | ||
1231 | # if HAVE_RAW_DECL_ACCEPT4 | ||
1232 | _GL_WARN_ON_USE (accept4, "accept4 is unportable - " | ||
1233 | "use gnulib module accept4 for portability"); | ||
1234 | # endif | ||
1235 | #endif | ||
1236 | |||
1237 | _GL_INLINE_HEADER_END | ||
1238 | |||
1239 | #endif /* _GL_SYS_SOCKET_H */ | ||
1240 | #endif /* _GL_SYS_SOCKET_H */ | ||
1241 | #endif | ||