1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* Substitute for and wrapper around <unistd.h>.
3 Copyright (C) 2003-2020 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <https://www.gnu.org/licenses/>. */
17
18 #ifndef _GL_UNISTD_H
19
20 #if __GNUC__ >= 3
21 #pragma GCC system_header
22 #endif
23
24
25 #if 1 && defined _GL_INCLUDING_UNISTD_H
26 /* Special invocation convention:
27 - On Mac OS X 10.3.9 we have a sequence of nested includes
28 <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>
29 In this situation, the functions are not yet declared, therefore we cannot
30 provide the C++ aliases. */
31
32 #include_next <unistd.h>
33
34 #else
35 /* Normal invocation convention. */
36
37 /* The include_next requires a split double-inclusion guard. */
38 #if 1
39 # define _GL_INCLUDING_UNISTD_H
40 # include_next <unistd.h>
41 # undef _GL_INCLUDING_UNISTD_H
42 #endif
43
44 /* Get all possible declarations of gethostname(). */
45 #if 0 && 0 \
46 && !defined _GL_INCLUDING_WINSOCK2_H
47 # define _GL_INCLUDING_WINSOCK2_H
48 # include <winsock2.h>
49 # undef _GL_INCLUDING_WINSOCK2_H
50 #endif
51
52 #if !defined _GL_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
53 #define _GL_UNISTD_H
54
55 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
56 /* But avoid namespace pollution on glibc systems. */
57 #ifndef __GLIBC__
58 # include <stddef.h>
59 #endif
60
61 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
62 /* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>. We must include
63 it before we #define unlink rpl_unlink. */
64 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
65 /* But avoid namespace pollution on glibc systems. */
66 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
67 || ((0 || defined GNULIB_POSIXCHECK) \
68 && (defined _WIN32 && ! defined __CYGWIN__)) \
69 || ((0 || defined GNULIB_POSIXCHECK) \
70 && defined __CYGWIN__)) \
71 && ! defined __GLIBC__
72 # include <stdio.h>
73 #endif
74
75 /* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
76 <unistd.h>. */
77 /* But avoid namespace pollution on glibc systems. */
78 #if (0 || defined GNULIB_POSIXCHECK) \
79 && (defined __CYGWIN__ || defined __ANDROID__) \
80 && ! defined __GLIBC__
81 # include <fcntl.h>
82 #endif
83
84 /* mingw fails to declare _exit in <unistd.h>. */
85 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
86 <unistd.h>. */
87 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
88 /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
89 included here. */
90 /* But avoid namespace pollution on glibc systems. */
91 #if !defined __GLIBC__ && !defined __osf__
92 # define __need_system_stdlib_h
93 # include <stdlib.h>
94 # undef __need_system_stdlib_h
95 #endif
96
97 /* Native Windows platforms declare chdir, getcwd, rmdir in
98 <io.h> and/or <direct.h>, not in <unistd.h>.
99 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
100 lseek(), read(), unlink(), write() in <io.h>. */
101 #if ((1 || 1 || 0 \
102 || defined GNULIB_POSIXCHECK) \
103 && (defined _WIN32 && ! defined __CYGWIN__))
104 # include <io.h> /* mingw32, mingw64 */
105 # include <direct.h> /* mingw64, MSVC 9 */
106 #elif (1 || 1 || 1 || 1 \
107 || 1 || 1 || 0 || 0 \
108 || defined GNULIB_POSIXCHECK) \
109 && (defined _WIN32 && ! defined __CYGWIN__)
110 # include <io.h>
111 #endif
112
113 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
114 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
115 /* But avoid namespace pollution on glibc systems. */
116 #if ((0 && (defined _AIX || defined __osf__)) \
117 || (0 && defined __TANDEM)) \
118 && !defined __GLIBC__
119 # include <netdb.h>
120 #endif
121
122 /* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>. */
123 /* But avoid namespace pollution on glibc systems. */
124 #if (0 || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
125 && !defined __GLIBC__
126 # include <sys/stat.h>
127 #endif
128
129 /* MSVC defines off_t in <sys/types.h>.
130 May also define off_t to a 64-bit type on native Windows. */
131 /* But avoid namespace pollution on glibc systems. */
132 #ifndef __GLIBC__
133 /* Get off_t, ssize_t. */
134 # include <sys/types.h>
135 #endif
136
137 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
138 /* C++ compatible function declaration macros.
139 Copyright (C) 2010-2020 Free Software Foundation, Inc.
140
141 This program is free software: you can redistribute it and/or modify it
142 under the terms of the GNU General Public License as published
143 by the Free Software Foundation; either version 3 of the License, or
144 (at your option) any later version.
145
146 This program is distributed in the hope that it will be useful,
147 but WITHOUT ANY WARRANTY; without even the implied warranty of
148 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
149 General Public License for more details.
150
151 You should have received a copy of the GNU General Public License
152 along with this program. If not, see <https://www.gnu.org/licenses/>. */
153
154 #ifndef _GL_CXXDEFS_H
155 #define _GL_CXXDEFS_H
156
157 /* Begin/end the GNULIB_NAMESPACE namespace. */
158 #if defined __cplusplus && defined GNULIB_NAMESPACE
159 # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
160 # define _GL_END_NAMESPACE }
161 #else
162 # define _GL_BEGIN_NAMESPACE
163 # define _GL_END_NAMESPACE
164 #endif
165
166 /* The three most frequent use cases of these macros are:
167
168 * For providing a substitute for a function that is missing on some
169 platforms, but is declared and works fine on the platforms on which
170 it exists:
171
172 #if @GNULIB_FOO@
173 # if !@HAVE_FOO@
174 _GL_FUNCDECL_SYS (foo, ...);
175 # endif
176 _GL_CXXALIAS_SYS (foo, ...);
177 _GL_CXXALIASWARN (foo);
178 #elif defined GNULIB_POSIXCHECK
179 ...
180 #endif
181
182 * For providing a replacement for a function that exists on all platforms,
183 but is broken/insufficient and needs to be replaced on some platforms:
184
185 #if @GNULIB_FOO@
186 # if @REPLACE_FOO@
187 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
188 # undef foo
189 # define foo rpl_foo
190 # endif
191 _GL_FUNCDECL_RPL (foo, ...);
192 _GL_CXXALIAS_RPL (foo, ...);
193 # else
194 _GL_CXXALIAS_SYS (foo, ...);
195 # endif
196 _GL_CXXALIASWARN (foo);
197 #elif defined GNULIB_POSIXCHECK
198 ...
199 #endif
200
201 * For providing a replacement for a function that exists on some platforms
202 but is broken/insufficient and needs to be replaced on some of them and
203 is additionally either missing or undeclared on some other platforms:
204
205 #if @GNULIB_FOO@
206 # if @REPLACE_FOO@
207 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
208 # undef foo
209 # define foo rpl_foo
210 # endif
211 _GL_FUNCDECL_RPL (foo, ...);
212 _GL_CXXALIAS_RPL (foo, ...);
213 # else
214 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
215 _GL_FUNCDECL_SYS (foo, ...);
216 # endif
217 _GL_CXXALIAS_SYS (foo, ...);
218 # endif
219 _GL_CXXALIASWARN (foo);
220 #elif defined GNULIB_POSIXCHECK
221 ...
222 #endif
223 */
224
225 /* _GL_EXTERN_C declaration;
226 performs the declaration with C linkage. */
227 #if defined __cplusplus
228 # define _GL_EXTERN_C extern "C"
229 #else
230 # define _GL_EXTERN_C extern
231 #endif
232
233 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
234 declares a replacement function, named rpl_func, with the given prototype,
235 consisting of return type, parameters, and attributes.
236 Example:
237 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
238 _GL_ARG_NONNULL ((1)));
239 */
240 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
241 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
242 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
243 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
244
245 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
246 declares the system function, named func, with the given prototype,
247 consisting of return type, parameters, and attributes.
248 Example:
249 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
250 _GL_ARG_NONNULL ((1)));
251 */
252 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
253 _GL_EXTERN_C rettype func parameters_and_attributes
254
255 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
256 declares a C++ alias called GNULIB_NAMESPACE::func
257 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
258 Example:
259 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
260
261 Wrapping rpl_func in an object with an inline conversion operator
262 avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
263 actually used in the program. */
264 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
265 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
266 #if defined __cplusplus && defined GNULIB_NAMESPACE
267 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
268 namespace GNULIB_NAMESPACE \
269 { \
270 static const struct _gl_ ## func ## _wrapper \
271 { \
272 typedef rettype (*type) parameters; \
273 \
274 inline operator type () const \
275 { \
276 return ::rpl_func; \
277 } \
278 } func = {}; \
279 } \
280 _GL_EXTERN_C int _gl_cxxalias_dummy
281 #else
282 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
283 _GL_EXTERN_C int _gl_cxxalias_dummy
284 #endif
285
286 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
287 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
288 except that the C function rpl_func may have a slightly different
289 declaration. A cast is used to silence the "invalid conversion" error
290 that would otherwise occur. */
291 #if defined __cplusplus && defined GNULIB_NAMESPACE
292 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
293 namespace GNULIB_NAMESPACE \
294 { \
295 static const struct _gl_ ## func ## _wrapper \
296 { \
297 typedef rettype (*type) parameters; \
298 \
299 inline operator type () const \
300 { \
301 return reinterpret_cast<type>(::rpl_func); \
302 } \
303 } func = {}; \
304 } \
305 _GL_EXTERN_C int _gl_cxxalias_dummy
306 #else
307 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
308 _GL_EXTERN_C int _gl_cxxalias_dummy
309 #endif
310
311 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
312 declares a C++ alias called GNULIB_NAMESPACE::func
313 that redirects to the system provided function func, if GNULIB_NAMESPACE
314 is defined.
315 Example:
316 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
317
318 Wrapping func in an object with an inline conversion operator
319 avoids a reference to func unless GNULIB_NAMESPACE::func is
320 actually used in the program. */
321 #if defined __cplusplus && defined GNULIB_NAMESPACE
322 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
323 namespace GNULIB_NAMESPACE \
324 { \
325 static const struct _gl_ ## func ## _wrapper \
326 { \
327 typedef rettype (*type) parameters; \
328 \
329 inline operator type () const \
330 { \
331 return ::func; \
332 } \
333 } func = {}; \
334 } \
335 _GL_EXTERN_C int _gl_cxxalias_dummy
336 #else
337 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
338 _GL_EXTERN_C int _gl_cxxalias_dummy
339 #endif
340
341 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
342 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
343 except that the C function func may have a slightly different declaration.
344 A cast is used to silence the "invalid conversion" error that would
345 otherwise occur. */
346 #if defined __cplusplus && defined GNULIB_NAMESPACE
347 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
348 namespace GNULIB_NAMESPACE \
349 { \
350 static const struct _gl_ ## func ## _wrapper \
351 { \
352 typedef rettype (*type) parameters; \
353 \
354 inline operator type () const \
355 { \
356 return reinterpret_cast<type>(::func); \
357 } \
358 } func = {}; \
359 } \
360 _GL_EXTERN_C int _gl_cxxalias_dummy
361 #else
362 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
363 _GL_EXTERN_C int _gl_cxxalias_dummy
364 #endif
365
366 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
367 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
368 except that the C function is picked among a set of overloaded functions,
369 namely the one with rettype2 and parameters2. Two consecutive casts
370 are used to silence the "cannot find a match" and "invalid conversion"
371 errors that would otherwise occur. */
372 #if defined __cplusplus && defined GNULIB_NAMESPACE
373 /* The outer cast must be a reinterpret_cast.
374 The inner cast: When the function is defined as a set of overloaded
375 functions, it works as a static_cast<>, choosing the designated variant.
376 When the function is defined as a single variant, it works as a
377 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
378 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
379 namespace GNULIB_NAMESPACE \
380 { \
381 static const struct _gl_ ## func ## _wrapper \
382 { \
383 typedef rettype (*type) parameters; \
384 \
385 inline operator type () const \
386 { \
387 return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
388 } \
389 } func = {}; \
390 } \
391 _GL_EXTERN_C int _gl_cxxalias_dummy
392 #else
393 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
394 _GL_EXTERN_C int _gl_cxxalias_dummy
395 #endif
396
397 /* _GL_CXXALIASWARN (func);
398 causes a warning to be emitted when ::func is used but not when
399 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
400 variants. */
401 #if defined __cplusplus && defined GNULIB_NAMESPACE
402 # define _GL_CXXALIASWARN(func) \
403 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
404 # define _GL_CXXALIASWARN_1(func,namespace) \
405 _GL_CXXALIASWARN_2 (func, namespace)
406 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
407 we enable the warning only when not optimizing. */
408 # if !__OPTIMIZE__
409 # define _GL_CXXALIASWARN_2(func,namespace) \
410 _GL_WARN_ON_USE (func, \
411 "The symbol ::" #func " refers to the system function. " \
412 "Use " #namespace "::" #func " instead.")
413 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
414 # define _GL_CXXALIASWARN_2(func,namespace) \
415 extern __typeof__ (func) func
416 # else
417 # define _GL_CXXALIASWARN_2(func,namespace) \
418 _GL_EXTERN_C int _gl_cxxalias_dummy
419 # endif
420 #else
421 # define _GL_CXXALIASWARN(func) \
422 _GL_EXTERN_C int _gl_cxxalias_dummy
423 #endif
424
425 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
426 causes a warning to be emitted when the given overloaded variant of ::func
427 is used but not when GNULIB_NAMESPACE::func is used. */
428 #if defined __cplusplus && defined GNULIB_NAMESPACE
429 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
430 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
431 GNULIB_NAMESPACE)
432 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
433 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
434 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
435 we enable the warning only when not optimizing. */
436 # if !__OPTIMIZE__
437 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
438 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
439 "The symbol ::" #func " refers to the system function. " \
440 "Use " #namespace "::" #func " instead.")
441 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
442 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
443 extern __typeof__ (func) func
444 # else
445 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
446 _GL_EXTERN_C int _gl_cxxalias_dummy
447 # endif
448 #else
449 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
450 _GL_EXTERN_C int _gl_cxxalias_dummy
451 #endif
452
453 #endif /* _GL_CXXDEFS_H */
454
455 /* The definition of _GL_ARG_NONNULL is copied here. */
456 /* A C macro for declaring that specific arguments must not be NULL.
457 Copyright (C) 2009-2020 Free Software Foundation, Inc.
458
459 This program is free software: you can redistribute it and/or modify it
460 under the terms of the GNU General Public License as published
461 by the Free Software Foundation; either version 3 of the License, or
462 (at your option) any later version.
463
464 This program is distributed in the hope that it will be useful,
465 but WITHOUT ANY WARRANTY; without even the implied warranty of
466 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
467 General Public License for more details.
468
469 You should have received a copy of the GNU General Public License
470 along with this program. If not, see <https://www.gnu.org/licenses/>. */
471
472 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
473 that the values passed as arguments n, ..., m must be non-NULL pointers.
474 n = 1 stands for the first argument, n = 2 for the second argument etc. */
475 #ifndef _GL_ARG_NONNULL
476 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
477 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
478 # else
479 # define _GL_ARG_NONNULL(params)
480 # endif
481 #endif
482
483 /* The definition of _GL_WARN_ON_USE is copied here. */
484 /* A C macro for emitting warnings if a function is used.
485 Copyright (C) 2010-2020 Free Software Foundation, Inc.
486
487 This program is free software: you can redistribute it and/or modify it
488 under the terms of the GNU General Public License as published
489 by the Free Software Foundation; either version 3 of the License, or
490 (at your option) any later version.
491
492 This program is distributed in the hope that it will be useful,
493 but WITHOUT ANY WARRANTY; without even the implied warranty of
494 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
495 General Public License for more details.
496
497 You should have received a copy of the GNU General Public License
498 along with this program. If not, see <https://www.gnu.org/licenses/>. */
499
500 /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
501 for FUNCTION which will then trigger a compiler warning containing
502 the text of "literal string" anywhere that function is called, if
503 supported by the compiler. If the compiler does not support this
504 feature, the macro expands to an unused extern declaration.
505
506 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
507 attribute used in _GL_WARN_ON_USE. If the compiler does not support
508 this feature, it expands to empty.
509
510 These macros are useful for marking a function as a potential
511 portability trap, with the intent that "literal string" include
512 instructions on the replacement function that should be used
513 instead.
514 _GL_WARN_ON_USE is for functions with 'extern' linkage.
515 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
516 linkage.
517
518 However, one of the reasons that a function is a portability trap is
519 if it has the wrong signature. Declaring FUNCTION with a different
520 signature in C is a compilation error, so this macro must use the
521 same type as any existing declaration so that programs that avoid
522 the problematic FUNCTION do not fail to compile merely because they
523 included a header that poisoned the function. But this implies that
524 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
525 have a declaration. Use of this macro implies that there must not
526 be any other macro hiding the declaration of FUNCTION; but
527 undefining FUNCTION first is part of the poisoning process anyway
528 (although for symbols that are provided only via a macro, the result
529 is a compilation error rather than a warning containing
530 "literal string"). Also note that in C++, it is only safe to use if
531 FUNCTION has no overloads.
532
533 For an example, it is possible to poison 'getline' by:
534 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
535 [getline]) in configure.ac, which potentially defines
536 HAVE_RAW_DECL_GETLINE
537 - adding this code to a header that wraps the system <stdio.h>:
538 #undef getline
539 #if HAVE_RAW_DECL_GETLINE
540 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
541 "not universally present; use the gnulib module getline");
542 #endif
543
544 It is not possible to directly poison global variables. But it is
545 possible to write a wrapper accessor function, and poison that
546 (less common usage, like &environ, will cause a compilation error
547 rather than issue the nice warning, but the end result of informing
548 the developer about their portability problem is still achieved):
549 #if HAVE_RAW_DECL_ENVIRON
550 static char ***
551 rpl_environ (void) { return &environ; }
552 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
553 # undef environ
554 # define environ (*rpl_environ ())
555 #endif
556 or better (avoiding contradictory use of 'static' and 'extern'):
557 #if HAVE_RAW_DECL_ENVIRON
558 static char ***
559 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
560 rpl_environ (void) { return &environ; }
561 # undef environ
562 # define environ (*rpl_environ ())
563 #endif
564 */
565 #ifndef _GL_WARN_ON_USE
566
567 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
568 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
569 # define _GL_WARN_ON_USE(function, message) \
570 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
571 # define _GL_WARN_ON_USE_ATTRIBUTE(message) \
572 __attribute__ ((__warning__ (message)))
573 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
574 /* Verify the existence of the function. */
575 # define _GL_WARN_ON_USE(function, message) \
576 extern __typeof__ (function) function
577 # define _GL_WARN_ON_USE_ATTRIBUTE(message)
578 # else /* Unsupported. */
579 # define _GL_WARN_ON_USE(function, message) \
580 _GL_WARN_EXTERN_C int _gl_warn_on_use
581 # define _GL_WARN_ON_USE_ATTRIBUTE(message)
582 # endif
583 #endif
584
585 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
586 is like _GL_WARN_ON_USE (function, "string"), except that the function is
587 declared with the given prototype, consisting of return type, parameters,
588 and attributes.
589 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
590 not work in this case. */
591 #ifndef _GL_WARN_ON_USE_CXX
592 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
593 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
594 extern rettype function parameters_and_attributes \
595 __attribute__ ((__warning__ (msg)))
596 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
597 /* Verify the existence of the function. */
598 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
599 extern rettype function parameters_and_attributes
600 # else /* Unsupported. */
601 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
602 _GL_WARN_EXTERN_C int _gl_warn_on_use
603 # endif
604 #endif
605
606 /* _GL_WARN_EXTERN_C declaration;
607 performs the declaration with C linkage. */
608 #ifndef _GL_WARN_EXTERN_C
609 # if defined __cplusplus
610 # define _GL_WARN_EXTERN_C extern "C"
611 # else
612 # define _GL_WARN_EXTERN_C extern
613 # endif
614 #endif
615
616
617 /* Get getopt(), optarg, optind, opterr, optopt. */
618 #if 01 && !defined _GL_SYSTEM_GETOPT
619 # include <getopt-cdefs.h>
620 # include <getopt-pfx-core.h>
621 #endif
622
623 #ifndef _GL_INLINE_HEADER_BEGIN
624 #error "Please include config.h first."
625 #endif
626 _GL_INLINE_HEADER_BEGIN
627 #ifndef _GL_UNISTD_INLINE
628 # define _GL_UNISTD_INLINE _GL_INLINE
629 #endif
630
631 /* Hide some function declarations from <winsock2.h>. */
632
633 #if 0 && 0
634 # if !defined _GL_SYS_SOCKET_H
635 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
636 # undef socket
637 # define socket socket_used_without_including_sys_socket_h
638 # undef connect
639 # define connect connect_used_without_including_sys_socket_h
640 # undef accept
641 # define accept accept_used_without_including_sys_socket_h
642 # undef bind
643 # define bind bind_used_without_including_sys_socket_h
644 # undef getpeername
645 # define getpeername getpeername_used_without_including_sys_socket_h
646 # undef getsockname
647 # define getsockname getsockname_used_without_including_sys_socket_h
648 # undef getsockopt
649 # define getsockopt getsockopt_used_without_including_sys_socket_h
650 # undef listen
651 # define listen listen_used_without_including_sys_socket_h
652 # undef recv
653 # define recv recv_used_without_including_sys_socket_h
654 # undef send
655 # define send send_used_without_including_sys_socket_h
656 # undef recvfrom
657 # define recvfrom recvfrom_used_without_including_sys_socket_h
658 # undef sendto
659 # define sendto sendto_used_without_including_sys_socket_h
660 # undef setsockopt
661 # define setsockopt setsockopt_used_without_including_sys_socket_h
662 # undef shutdown
663 # define shutdown shutdown_used_without_including_sys_socket_h
664 # else
665 _GL_WARN_ON_USE (socket,
666 "socket() used without including <sys/socket.h>");
667 _GL_WARN_ON_USE (connect,
668 "connect() used without including <sys/socket.h>");
669 _GL_WARN_ON_USE (accept,
670 "accept() used without including <sys/socket.h>");
671 _GL_WARN_ON_USE (bind,
672 "bind() used without including <sys/socket.h>");
673 _GL_WARN_ON_USE (getpeername,
674 "getpeername() used without including <sys/socket.h>");
675 _GL_WARN_ON_USE (getsockname,
676 "getsockname() used without including <sys/socket.h>");
677 _GL_WARN_ON_USE (getsockopt,
678 "getsockopt() used without including <sys/socket.h>");
679 _GL_WARN_ON_USE (listen,
680 "listen() used without including <sys/socket.h>");
681 _GL_WARN_ON_USE (recv,
682 "recv() used without including <sys/socket.h>");
683 _GL_WARN_ON_USE (send,
684 "send() used without including <sys/socket.h>");
685 _GL_WARN_ON_USE (recvfrom,
686 "recvfrom() used without including <sys/socket.h>");
687 _GL_WARN_ON_USE (sendto,
688 "sendto() used without including <sys/socket.h>");
689 _GL_WARN_ON_USE (setsockopt,
690 "setsockopt() used without including <sys/socket.h>");
691 _GL_WARN_ON_USE (shutdown,
692 "shutdown() used without including <sys/socket.h>");
693 # endif
694 # endif
695 # if !defined _GL_SYS_SELECT_H
696 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
697 # undef select
698 # define select select_used_without_including_sys_select_h
699 # else
700 _GL_WARN_ON_USE (select,
701 "select() used without including <sys/select.h>");
702 # endif
703 # endif
704 #endif
705
706
707 /* OS/2 EMX lacks these macros. */
708 #ifndef STDIN_FILENO
709 # define STDIN_FILENO 0
710 #endif
711 #ifndef STDOUT_FILENO
712 # define STDOUT_FILENO 1
713 #endif
714 #ifndef STDERR_FILENO
715 # define STDERR_FILENO 2
716 #endif
717
718 /* Ensure *_OK macros exist. */
719 #ifndef F_OK
720 # define F_OK 0
721 # define X_OK 1
722 # define W_OK 2
723 # define R_OK 4
724 #endif
725
726
727 /* Declare overridden functions. */
728
729
730 #if 0
731 # if 0
732 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
733 # undef access
734 # define access rpl_access
735 # endif
736 _GL_FUNCDECL_RPL (access, int, (const char *file, int mode)
737 _GL_ARG_NONNULL ((1)));
738 _GL_CXXALIAS_RPL (access, int, (const char *file, int mode));
739 # else
740 _GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
741 # endif
742 _GL_CXXALIASWARN (access);
743 #elif defined GNULIB_POSIXCHECK
744 # undef access
745 # if HAVE_RAW_DECL_ACCESS
746 /* The access() function is a security risk. */
747 _GL_WARN_ON_USE (access, "access does not always support X_OK - "
748 "use gnulib module access for portability; "
749 "also, this function is a security risk - "
750 "use the gnulib module faccessat instead");
751 # endif
752 #endif
753
754
755 #if 1
756 _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
757 _GL_CXXALIASWARN (chdir);
758 #elif defined GNULIB_POSIXCHECK
759 # undef chdir
760 # if HAVE_RAW_DECL_CHDIR
761 _GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
762 "use gnulib module chdir for portability");
763 # endif
764 #endif
765
766
767 #if 0
768 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
769 to GID (if GID is not -1). Follow symbolic links.
770 Return 0 if successful, otherwise -1 and errno set.
771 See the POSIX:2008 specification
772 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
773 # if 0
774 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
775 # undef chown
776 # define chown rpl_chown
777 # endif
778 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
779 _GL_ARG_NONNULL ((1)));
780 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
781 # else
782 # if !1
783 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
784 _GL_ARG_NONNULL ((1)));
785 # endif
786 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
787 # endif
788 _GL_CXXALIASWARN (chown);
789 #elif defined GNULIB_POSIXCHECK
790 # undef chown
791 # if HAVE_RAW_DECL_CHOWN
792 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
793 "doesn't treat a uid or gid of -1 on some systems - "
794 "use gnulib module chown for portability");
795 # endif
796 #endif
797
798
799 #if 1
800 # if 0
801 /* Automatically included by modules that need a replacement for close. */
802 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
803 # undef close
804 # define close rpl_close
805 # endif
806 _GL_FUNCDECL_RPL (close, int, (int fd));
807 _GL_CXXALIAS_RPL (close, int, (int fd));
808 # else
809 _GL_CXXALIAS_SYS (close, int, (int fd));
810 # endif
811 _GL_CXXALIASWARN (close);
812 #elif 0
813 # undef close
814 # define close close_used_without_requesting_gnulib_module_close
815 #elif defined GNULIB_POSIXCHECK
816 # undef close
817 /* Assume close is always declared. */
818 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
819 "use gnulib module close for portability");
820 #endif
821
822
823 #if 0
824 # if !1
825 _GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
826 int ofd, off_t *opos,
827 size_t len, unsigned flags));
828 _GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
829 int ofd, off_t *opos,
830 size_t len, unsigned flags));
831 # endif
832 _GL_CXXALIASWARN (copy_file_range);
833 #elif defined GNULIB_POSIXCHECK
834 /* Assume copy_file_range is always declared. */
835 _GL_WARN_ON_USE (copy_file_range,
836 "copy_file_range is unportable - "
837 "use gnulib module copy_file_range for portability");
838 #endif
839
840
841 #if 1
842 # if 0
843 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
844 # define dup rpl_dup
845 # endif
846 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
847 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
848 # else
849 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
850 # endif
851 _GL_CXXALIASWARN (dup);
852 #elif defined GNULIB_POSIXCHECK
853 # undef dup
854 # if HAVE_RAW_DECL_DUP
855 _GL_WARN_ON_USE (dup, "dup is unportable - "
856 "use gnulib module dup for portability");
857 # endif
858 #endif
859
860
861 #if 1
862 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
863 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
864 Return newfd if successful, otherwise -1 and errno set.
865 See the POSIX:2008 specification
866 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
867 # if 1
868 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
869 # define dup2 rpl_dup2
870 # endif
871 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
872 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
873 # else
874 # if !1
875 _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
876 # endif
877 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
878 # endif
879 _GL_CXXALIASWARN (dup2);
880 #elif defined GNULIB_POSIXCHECK
881 # undef dup2
882 # if HAVE_RAW_DECL_DUP2
883 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
884 "use gnulib module dup2 for portability");
885 # endif
886 #endif
887
888
889 #if 0
890 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
891 specified flags.
892 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
893 and O_TEXT, O_BINARY (defined in "binary-io.h").
894 Close NEWFD first if it is open.
895 Return newfd if successful, otherwise -1 and errno set.
896 See the Linux man page at
897 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
898 # if 1
899 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
900 # define dup3 rpl_dup3
901 # endif
902 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
903 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
904 # else
905 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
906 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
907 # endif
908 _GL_CXXALIASWARN (dup3);
909 #elif defined GNULIB_POSIXCHECK
910 # undef dup3
911 # if HAVE_RAW_DECL_DUP3
912 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
913 "use gnulib module dup3 for portability");
914 # endif
915 #endif
916
917
918 #if IN_GREP_GNULIB_TESTS
919 # if defined __CYGWIN__ && !defined __i386__
920 /* The 'environ' variable is defined in a DLL. Therefore its declaration needs
921 the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
922 This leads to a link error on 64-bit Cygwin when the option
923 -Wl,--disable-auto-import is in use. */
924 _GL_EXTERN_C __declspec(dllimport) char **environ;
925 # endif
926 # if !0
927 /* Set of environment variables and values. An array of strings of the form
928 "VARIABLE=VALUE", terminated with a NULL. */
929 # if defined __APPLE__ && defined __MACH__
930 # include <TargetConditionals.h>
931 # if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
932 # define _GL_USE_CRT_EXTERNS
933 # endif
934 # endif
935 # ifdef _GL_USE_CRT_EXTERNS
936 # include <crt_externs.h>
937 # define environ (*_NSGetEnviron ())
938 # else
939 # ifdef __cplusplus
940 extern "C" {
941 # endif
942 extern char **environ;
943 # ifdef __cplusplus
944 }
945 # endif
946 # endif
947 # endif
948 #elif defined GNULIB_POSIXCHECK
949 # if HAVE_RAW_DECL_ENVIRON
950 _GL_UNISTD_INLINE char ***
951 _GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
952 "use gnulib module environ for portability")
rpl_environ(void)953 rpl_environ (void)
954 {
955 return &environ;
956 }
957 # undef environ
958 # define environ (*rpl_environ ())
959 # endif
960 #endif
961
962
963 #if 0
964 /* Like access(), except that it uses the effective user id and group id of
965 the current process. */
966 # if !1
967 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
968 _GL_ARG_NONNULL ((1)));
969 # endif
970 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
971 _GL_CXXALIASWARN (euidaccess);
972 # if defined GNULIB_POSIXCHECK
973 /* Like access(), this function is a security risk. */
974 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
975 "use the gnulib module faccessat instead");
976 # endif
977 #elif defined GNULIB_POSIXCHECK
978 # undef euidaccess
979 # if HAVE_RAW_DECL_EUIDACCESS
980 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
981 "use gnulib module euidaccess for portability");
982 # endif
983 #endif
984
985
986 #if 0
987 # if 0
988 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
989 # undef faccessat
990 # define faccessat rpl_faccessat
991 # endif
992 _GL_FUNCDECL_RPL (faccessat, int,
993 (int fd, char const *name, int mode, int flag)
994 _GL_ARG_NONNULL ((2)));
995 _GL_CXXALIAS_RPL (faccessat, int,
996 (int fd, char const *name, int mode, int flag));
997 # else
998 # if !1
999 _GL_FUNCDECL_SYS (faccessat, int,
1000 (int fd, char const *file, int mode, int flag)
1001 _GL_ARG_NONNULL ((2)));
1002 # endif
1003 _GL_CXXALIAS_SYS (faccessat, int,
1004 (int fd, char const *file, int mode, int flag));
1005 # endif
1006 _GL_CXXALIASWARN (faccessat);
1007 #elif defined GNULIB_POSIXCHECK
1008 # undef faccessat
1009 # if HAVE_RAW_DECL_FACCESSAT
1010 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
1011 "use gnulib module faccessat for portability");
1012 # endif
1013 #endif
1014
1015
1016 #if 1
1017 /* Change the process' current working directory to the directory on which
1018 the given file descriptor is open.
1019 Return 0 if successful, otherwise -1 and errno set.
1020 See the POSIX:2008 specification
1021 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
1022 # if ! 1
1023 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
1024
1025 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
1026 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
1027 _GL_ARG_NONNULL ((2));
1028 _GL_EXTERN_C void _gl_unregister_fd (int fd);
1029 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
1030 _GL_EXTERN_C const char *_gl_directory_name (int fd);
1031
1032 # else
1033 # if !1
1034 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
1035 # endif
1036 # endif
1037 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
1038 _GL_CXXALIASWARN (fchdir);
1039 #elif defined GNULIB_POSIXCHECK
1040 # undef fchdir
1041 # if HAVE_RAW_DECL_FCHDIR
1042 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
1043 "use gnulib module fchdir for portability");
1044 # endif
1045 #endif
1046
1047
1048 #if 0
1049 # if 0
1050 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1051 # undef fchownat
1052 # define fchownat rpl_fchownat
1053 # endif
1054 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
1055 uid_t owner, gid_t group, int flag)
1056 _GL_ARG_NONNULL ((2)));
1057 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
1058 uid_t owner, gid_t group, int flag));
1059 # else
1060 # if !1
1061 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
1062 uid_t owner, gid_t group, int flag)
1063 _GL_ARG_NONNULL ((2)));
1064 # endif
1065 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
1066 uid_t owner, gid_t group, int flag));
1067 # endif
1068 _GL_CXXALIASWARN (fchownat);
1069 #elif defined GNULIB_POSIXCHECK
1070 # undef fchownat
1071 # if HAVE_RAW_DECL_FCHOWNAT
1072 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
1073 "use gnulib module openat for portability");
1074 # endif
1075 #endif
1076
1077
1078 #if 0
1079 /* Synchronize changes to a file.
1080 Return 0 if successful, otherwise -1 and errno set.
1081 See POSIX:2008 specification
1082 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
1083 # if !1 || !1
1084 _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
1085 # endif
1086 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
1087 _GL_CXXALIASWARN (fdatasync);
1088 #elif defined GNULIB_POSIXCHECK
1089 # undef fdatasync
1090 # if HAVE_RAW_DECL_FDATASYNC
1091 _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
1092 "use gnulib module fdatasync for portability");
1093 # endif
1094 #endif
1095
1096
1097 #if 0
1098 /* Synchronize changes, including metadata, to a file.
1099 Return 0 if successful, otherwise -1 and errno set.
1100 See POSIX:2008 specification
1101 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
1102 # if !1
1103 _GL_FUNCDECL_SYS (fsync, int, (int fd));
1104 # endif
1105 _GL_CXXALIAS_SYS (fsync, int, (int fd));
1106 _GL_CXXALIASWARN (fsync);
1107 #elif defined GNULIB_POSIXCHECK
1108 # undef fsync
1109 # if HAVE_RAW_DECL_FSYNC
1110 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
1111 "use gnulib module fsync for portability");
1112 # endif
1113 #endif
1114
1115
1116 #if IN_GREP_GNULIB_TESTS
1117 /* Change the size of the file to which FD is opened to become equal to LENGTH.
1118 Return 0 if successful, otherwise -1 and errno set.
1119 See the POSIX:2008 specification
1120 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
1121 # if 0
1122 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1123 # undef ftruncate
1124 # define ftruncate rpl_ftruncate
1125 # endif
1126 _GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
1127 _GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
1128 # else
1129 # if !1
1130 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
1131 # endif
1132 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
1133 # endif
1134 _GL_CXXALIASWARN (ftruncate);
1135 #elif defined GNULIB_POSIXCHECK
1136 # undef ftruncate
1137 # if HAVE_RAW_DECL_FTRUNCATE
1138 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
1139 "use gnulib module ftruncate for portability");
1140 # endif
1141 #endif
1142
1143
1144 #if 1
1145 /* Get the name of the current working directory, and put it in SIZE bytes
1146 of BUF.
1147 Return BUF if successful, or NULL if the directory couldn't be determined
1148 or SIZE was too small.
1149 See the POSIX:2008 specification
1150 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
1151 Additionally, the gnulib module 'getcwd' guarantees the following GNU
1152 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
1153 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
1154 necessary. */
1155 # if 0
1156 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1157 # define getcwd rpl_getcwd
1158 # endif
1159 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
1160 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
1161 # else
1162 /* Need to cast, because on mingw, the second parameter is
1163 int size. */
1164 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
1165 # endif
1166 _GL_CXXALIASWARN (getcwd);
1167 #elif defined GNULIB_POSIXCHECK
1168 # undef getcwd
1169 # if HAVE_RAW_DECL_GETCWD
1170 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
1171 "use gnulib module getcwd for portability");
1172 # endif
1173 #endif
1174
1175
1176 #if 0
1177 /* Return the NIS domain name of the machine.
1178 WARNING! The NIS domain name is unrelated to the fully qualified host name
1179 of the machine. It is also unrelated to email addresses.
1180 WARNING! The NIS domain name is usually the empty string or "(none)" when
1181 not using NIS.
1182
1183 Put up to LEN bytes of the NIS domain name into NAME.
1184 Null terminate it if the name is shorter than LEN.
1185 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
1186 Return 0 if successful, otherwise set errno and return -1. */
1187 # if 0
1188 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1189 # undef getdomainname
1190 # define getdomainname rpl_getdomainname
1191 # endif
1192 _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
1193 _GL_ARG_NONNULL ((1)));
1194 _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
1195 # else
1196 # if !1
1197 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
1198 _GL_ARG_NONNULL ((1)));
1199 # endif
1200 _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
1201 # endif
1202 _GL_CXXALIASWARN (getdomainname);
1203 #elif defined GNULIB_POSIXCHECK
1204 # undef getdomainname
1205 # if HAVE_RAW_DECL_GETDOMAINNAME
1206 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
1207 "use gnulib module getdomainname for portability");
1208 # endif
1209 #endif
1210
1211
1212 #if 1
1213 /* Return the maximum number of file descriptors in the current process.
1214 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
1215 # if 0
1216 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1217 # undef getdtablesize
1218 # define getdtablesize rpl_getdtablesize
1219 # endif
1220 _GL_FUNCDECL_RPL (getdtablesize, int, (void));
1221 _GL_CXXALIAS_RPL (getdtablesize, int, (void));
1222 # else
1223 # if !1
1224 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
1225 # endif
1226 /* Need to cast, because on AIX, the parameter list is
1227 (...). */
1228 _GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void));
1229 # endif
1230 _GL_CXXALIASWARN (getdtablesize);
1231 #elif defined GNULIB_POSIXCHECK
1232 # undef getdtablesize
1233 # if HAVE_RAW_DECL_GETDTABLESIZE
1234 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
1235 "use gnulib module getdtablesize for portability");
1236 # endif
1237 #endif
1238
1239
1240 #if 0
1241 /* Return the supplemental groups that the current process belongs to.
1242 It is unspecified whether the effective group id is in the list.
1243 If N is 0, return the group count; otherwise, N describes how many
1244 entries are available in GROUPS. Return -1 and set errno if N is
1245 not 0 and not large enough. Fails with ENOSYS on some systems. */
1246 # if 0
1247 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1248 # undef getgroups
1249 # define getgroups rpl_getgroups
1250 # endif
1251 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
1252 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
1253 # else
1254 # if !1
1255 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
1256 # endif
1257 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
1258 # endif
1259 _GL_CXXALIASWARN (getgroups);
1260 #elif defined GNULIB_POSIXCHECK
1261 # undef getgroups
1262 # if HAVE_RAW_DECL_GETGROUPS
1263 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
1264 "use gnulib module getgroups for portability");
1265 # endif
1266 #endif
1267
1268
1269 #if 0
1270 /* Return the standard host name of the machine.
1271 WARNING! The host name may or may not be fully qualified.
1272
1273 Put up to LEN bytes of the host name into NAME.
1274 Null terminate it if the name is shorter than LEN.
1275 If the host name is longer than LEN, set errno = EINVAL and return -1.
1276 Return 0 if successful, otherwise set errno and return -1. */
1277 # if 0
1278 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1279 # undef gethostname
1280 # define gethostname rpl_gethostname
1281 # endif
1282 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
1283 _GL_ARG_NONNULL ((1)));
1284 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
1285 # else
1286 # if !1
1287 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
1288 _GL_ARG_NONNULL ((1)));
1289 # endif
1290 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
1291 parameter is
1292 int len. */
1293 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
1294 # endif
1295 _GL_CXXALIASWARN (gethostname);
1296 #elif 0
1297 # undef gethostname
1298 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
1299 #elif defined GNULIB_POSIXCHECK
1300 # undef gethostname
1301 # if HAVE_RAW_DECL_GETHOSTNAME
1302 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
1303 "use gnulib module gethostname for portability");
1304 # endif
1305 #endif
1306
1307
1308 #if 0
1309 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
1310 returns NULL with errno set.
1311
1312 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1313
1314 Most programs don't need to use this function, because the information is
1315 available through environment variables:
1316 ${LOGNAME-$USER} on Unix platforms,
1317 $USERNAME on native Windows platforms.
1318 */
1319 # if !1
1320 _GL_FUNCDECL_SYS (getlogin, char *, (void));
1321 # endif
1322 _GL_CXXALIAS_SYS (getlogin, char *, (void));
1323 _GL_CXXALIASWARN (getlogin);
1324 #elif defined GNULIB_POSIXCHECK
1325 # undef getlogin
1326 # if HAVE_RAW_DECL_GETLOGIN
1327 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
1328 "use gnulib module getlogin for portability");
1329 # endif
1330 #endif
1331
1332
1333 #if 0
1334 /* Copies the user's login name to NAME.
1335 The array pointed to by NAME has room for SIZE bytes.
1336
1337 Returns 0 if successful. Upon error, an error number is returned, or -1 in
1338 the case that the login name cannot be found but no specific error is
1339 provided (this case is hopefully rare but is left open by the POSIX spec).
1340
1341 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1342
1343 Most programs don't need to use this function, because the information is
1344 available through environment variables:
1345 ${LOGNAME-$USER} on Unix platforms,
1346 $USERNAME on native Windows platforms.
1347 */
1348 # if 0
1349 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1350 # define getlogin_r rpl_getlogin_r
1351 # endif
1352 _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
1353 _GL_ARG_NONNULL ((1)));
1354 _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
1355 # else
1356 # if !1
1357 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
1358 _GL_ARG_NONNULL ((1)));
1359 # endif
1360 /* Need to cast, because on Solaris 10 systems, the second argument is
1361 int size. */
1362 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
1363 # endif
1364 _GL_CXXALIASWARN (getlogin_r);
1365 #elif defined GNULIB_POSIXCHECK
1366 # undef getlogin_r
1367 # if HAVE_RAW_DECL_GETLOGIN_R
1368 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
1369 "use gnulib module getlogin_r for portability");
1370 # endif
1371 #endif
1372
1373
1374 #if 1
1375 # if 0
1376 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1377 # define getpagesize rpl_getpagesize
1378 # endif
1379 _GL_FUNCDECL_RPL (getpagesize, int, (void));
1380 _GL_CXXALIAS_RPL (getpagesize, int, (void));
1381 # else
1382 /* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
1383 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */
1384 # if defined __hpux
1385 _GL_FUNCDECL_SYS (getpagesize, int, (void));
1386 # endif
1387 # if !1
1388 # if !defined getpagesize
1389 /* This is for POSIX systems. */
1390 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
1391 # if ! (defined __VMS && __VMS_VER < 70000000)
1392 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
1393 # endif
1394 # endif
1395 /* This is for older VMS. */
1396 # if !defined _gl_getpagesize && defined __VMS
1397 # ifdef __ALPHA
1398 # define _gl_getpagesize() 8192
1399 # else
1400 # define _gl_getpagesize() 512
1401 # endif
1402 # endif
1403 /* This is for BeOS. */
1404 # if !defined _gl_getpagesize && 0
1405 # include <OS.h>
1406 # if defined B_PAGE_SIZE
1407 # define _gl_getpagesize() B_PAGE_SIZE
1408 # endif
1409 # endif
1410 /* This is for AmigaOS4.0. */
1411 # if !defined _gl_getpagesize && defined __amigaos4__
1412 # define _gl_getpagesize() 2048
1413 # endif
1414 /* This is for older Unix systems. */
1415 # if !defined _gl_getpagesize && 0
1416 # include <sys/param.h>
1417 # ifdef EXEC_PAGESIZE
1418 # define _gl_getpagesize() EXEC_PAGESIZE
1419 # else
1420 # ifdef NBPG
1421 # ifndef CLSIZE
1422 # define CLSIZE 1
1423 # endif
1424 # define _gl_getpagesize() (NBPG * CLSIZE)
1425 # else
1426 # ifdef NBPC
1427 # define _gl_getpagesize() NBPC
1428 # endif
1429 # endif
1430 # endif
1431 # endif
1432 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1433 # define getpagesize() _gl_getpagesize ()
1434 # else
1435 # if !GNULIB_defined_getpagesize_function
1436 _GL_UNISTD_INLINE int
getpagesize()1437 getpagesize ()
1438 {
1439 return _gl_getpagesize ();
1440 }
1441 # define GNULIB_defined_getpagesize_function 1
1442 # endif
1443 # endif
1444 # endif
1445 # endif
1446 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
1447 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
1448 # endif
1449 # if 1
1450 _GL_CXXALIASWARN (getpagesize);
1451 # endif
1452 #elif defined GNULIB_POSIXCHECK
1453 # undef getpagesize
1454 # if HAVE_RAW_DECL_GETPAGESIZE
1455 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
1456 "use gnulib module getpagesize for portability");
1457 # endif
1458 #endif
1459
1460
1461 #if 0
1462 /* Function getpass() from module 'getpass':
1463 Read a password from /dev/tty or stdin.
1464 Function getpass() from module 'getpass-gnu':
1465 Read a password of arbitrary length from /dev/tty or stdin. */
1466 # if 0
1467 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1468 # undef getpass
1469 # define getpass rpl_getpass
1470 # endif
1471 _GL_FUNCDECL_RPL (getpass, char *, (const char *prompt)
1472 _GL_ARG_NONNULL ((1)));
1473 _GL_CXXALIAS_RPL (getpass, char *, (const char *prompt));
1474 # else
1475 # if !1
1476 _GL_FUNCDECL_SYS (getpass, char *, (const char *prompt)
1477 _GL_ARG_NONNULL ((1)));
1478 # endif
1479 _GL_CXXALIAS_SYS (getpass, char *, (const char *prompt));
1480 # endif
1481 _GL_CXXALIASWARN (getpass);
1482 #elif defined GNULIB_POSIXCHECK
1483 # undef getpass
1484 # if HAVE_RAW_DECL_GETPASS
1485 _GL_WARN_ON_USE (getpass, "getpass is unportable - "
1486 "use gnulib module getpass or getpass-gnu for portability");
1487 # endif
1488 #endif
1489
1490
1491 #if 0
1492 /* Return the next valid login shell on the system, or NULL when the end of
1493 the list has been reached. */
1494 # if !1
1495 _GL_FUNCDECL_SYS (getusershell, char *, (void));
1496 # endif
1497 _GL_CXXALIAS_SYS (getusershell, char *, (void));
1498 _GL_CXXALIASWARN (getusershell);
1499 #elif defined GNULIB_POSIXCHECK
1500 # undef getusershell
1501 # if HAVE_RAW_DECL_GETUSERSHELL
1502 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
1503 "use gnulib module getusershell for portability");
1504 # endif
1505 #endif
1506
1507 #if 0
1508 /* Rewind to pointer that is advanced at each getusershell() call. */
1509 # if !1
1510 _GL_FUNCDECL_SYS (setusershell, void, (void));
1511 # endif
1512 _GL_CXXALIAS_SYS (setusershell, void, (void));
1513 _GL_CXXALIASWARN (setusershell);
1514 #elif defined GNULIB_POSIXCHECK
1515 # undef setusershell
1516 # if HAVE_RAW_DECL_SETUSERSHELL
1517 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
1518 "use gnulib module getusershell for portability");
1519 # endif
1520 #endif
1521
1522 #if 0
1523 /* Free the pointer that is advanced at each getusershell() call and
1524 associated resources. */
1525 # if !1
1526 _GL_FUNCDECL_SYS (endusershell, void, (void));
1527 # endif
1528 _GL_CXXALIAS_SYS (endusershell, void, (void));
1529 _GL_CXXALIASWARN (endusershell);
1530 #elif defined GNULIB_POSIXCHECK
1531 # undef endusershell
1532 # if HAVE_RAW_DECL_ENDUSERSHELL
1533 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
1534 "use gnulib module getusershell for portability");
1535 # endif
1536 #endif
1537
1538
1539 #if 0
1540 /* Determine whether group id is in calling user's group list. */
1541 # if !1
1542 _GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
1543 # endif
1544 _GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
1545 _GL_CXXALIASWARN (group_member);
1546 #elif defined GNULIB_POSIXCHECK
1547 # undef group_member
1548 # if HAVE_RAW_DECL_GROUP_MEMBER
1549 _GL_WARN_ON_USE (group_member, "group_member is unportable - "
1550 "use gnulib module group-member for portability");
1551 # endif
1552 #endif
1553
1554
1555 #if 1
1556 # if 0
1557 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1558 # undef isatty
1559 # define isatty rpl_isatty
1560 # endif
1561 _GL_FUNCDECL_RPL (isatty, int, (int fd));
1562 _GL_CXXALIAS_RPL (isatty, int, (int fd));
1563 # else
1564 _GL_CXXALIAS_SYS (isatty, int, (int fd));
1565 # endif
1566 _GL_CXXALIASWARN (isatty);
1567 #elif defined GNULIB_POSIXCHECK
1568 # undef isatty
1569 # if HAVE_RAW_DECL_ISATTY
1570 _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
1571 "use gnulib module isatty for portability");
1572 # endif
1573 #endif
1574
1575
1576 #if 0
1577 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1578 to GID (if GID is not -1). Do not follow symbolic links.
1579 Return 0 if successful, otherwise -1 and errno set.
1580 See the POSIX:2008 specification
1581 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1582 # if 0
1583 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1584 # undef lchown
1585 # define lchown rpl_lchown
1586 # endif
1587 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
1588 _GL_ARG_NONNULL ((1)));
1589 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
1590 # else
1591 # if !1
1592 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
1593 _GL_ARG_NONNULL ((1)));
1594 # endif
1595 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
1596 # endif
1597 _GL_CXXALIASWARN (lchown);
1598 #elif defined GNULIB_POSIXCHECK
1599 # undef lchown
1600 # if HAVE_RAW_DECL_LCHOWN
1601 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1602 "use gnulib module lchown for portability");
1603 # endif
1604 #endif
1605
1606
1607 #if 0
1608 /* Create a new hard link for an existing file.
1609 Return 0 if successful, otherwise -1 and errno set.
1610 See POSIX:2008 specification
1611 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1612 # if 0
1613 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1614 # define link rpl_link
1615 # endif
1616 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
1617 _GL_ARG_NONNULL ((1, 2)));
1618 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
1619 # else
1620 # if !1
1621 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
1622 _GL_ARG_NONNULL ((1, 2)));
1623 # endif
1624 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
1625 # endif
1626 _GL_CXXALIASWARN (link);
1627 #elif defined GNULIB_POSIXCHECK
1628 # undef link
1629 # if HAVE_RAW_DECL_LINK
1630 _GL_WARN_ON_USE (link, "link is unportable - "
1631 "use gnulib module link for portability");
1632 # endif
1633 #endif
1634
1635
1636 #if 0
1637 /* Create a new hard link for an existing file, relative to two
1638 directories. FLAG controls whether symlinks are followed.
1639 Return 0 if successful, otherwise -1 and errno set. */
1640 # if 0
1641 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1642 # undef linkat
1643 # define linkat rpl_linkat
1644 # endif
1645 _GL_FUNCDECL_RPL (linkat, int,
1646 (int fd1, const char *path1, int fd2, const char *path2,
1647 int flag)
1648 _GL_ARG_NONNULL ((2, 4)));
1649 _GL_CXXALIAS_RPL (linkat, int,
1650 (int fd1, const char *path1, int fd2, const char *path2,
1651 int flag));
1652 # else
1653 # if !1
1654 _GL_FUNCDECL_SYS (linkat, int,
1655 (int fd1, const char *path1, int fd2, const char *path2,
1656 int flag)
1657 _GL_ARG_NONNULL ((2, 4)));
1658 # endif
1659 _GL_CXXALIAS_SYS (linkat, int,
1660 (int fd1, const char *path1, int fd2, const char *path2,
1661 int flag));
1662 # endif
1663 _GL_CXXALIASWARN (linkat);
1664 #elif defined GNULIB_POSIXCHECK
1665 # undef linkat
1666 # if HAVE_RAW_DECL_LINKAT
1667 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1668 "use gnulib module linkat for portability");
1669 # endif
1670 #endif
1671
1672
1673 #if 1
1674 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1675 Return the new offset if successful, otherwise -1 and errno set.
1676 See the POSIX:2008 specification
1677 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1678 # if 0
1679 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1680 # define lseek rpl_lseek
1681 # endif
1682 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1683 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1684 # else
1685 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1686 # endif
1687 _GL_CXXALIASWARN (lseek);
1688 #elif defined GNULIB_POSIXCHECK
1689 # undef lseek
1690 # if HAVE_RAW_DECL_LSEEK
1691 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1692 "systems - use gnulib module lseek for portability");
1693 # endif
1694 #endif
1695
1696
1697 #if IN_GREP_GNULIB_TESTS
1698 /* Create a pipe, defaulting to O_BINARY mode.
1699 Store the read-end as fd[0] and the write-end as fd[1].
1700 Return 0 upon success, or -1 with errno set upon failure. */
1701 # if !1
1702 _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1703 # endif
1704 _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1705 _GL_CXXALIASWARN (pipe);
1706 #elif defined GNULIB_POSIXCHECK
1707 # undef pipe
1708 # if HAVE_RAW_DECL_PIPE
1709 _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1710 "use gnulib module pipe-posix for portability");
1711 # endif
1712 #endif
1713
1714
1715 #if 0
1716 /* Create a pipe, applying the given flags when opening the read-end of the
1717 pipe and the write-end of the pipe.
1718 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1719 and O_TEXT, O_BINARY (defined in "binary-io.h").
1720 Store the read-end as fd[0] and the write-end as fd[1].
1721 Return 0 upon success, or -1 with errno set upon failure.
1722 See also the Linux man page at
1723 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1724 # if 1
1725 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1726 # define pipe2 rpl_pipe2
1727 # endif
1728 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1729 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1730 # else
1731 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1732 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1733 # endif
1734 _GL_CXXALIASWARN (pipe2);
1735 #elif defined GNULIB_POSIXCHECK
1736 # undef pipe2
1737 # if HAVE_RAW_DECL_PIPE2
1738 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1739 "use gnulib module pipe2 for portability");
1740 # endif
1741 #endif
1742
1743
1744 #if 0
1745 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1746 Return the number of bytes placed into BUF if successful, otherwise
1747 set errno and return -1. 0 indicates EOF.
1748 See the POSIX:2008 specification
1749 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1750 # if 0
1751 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1752 # undef pread
1753 # define pread rpl_pread
1754 # endif
1755 _GL_FUNCDECL_RPL (pread, ssize_t,
1756 (int fd, void *buf, size_t bufsize, off_t offset)
1757 _GL_ARG_NONNULL ((2)));
1758 _GL_CXXALIAS_RPL (pread, ssize_t,
1759 (int fd, void *buf, size_t bufsize, off_t offset));
1760 # else
1761 # if !1
1762 _GL_FUNCDECL_SYS (pread, ssize_t,
1763 (int fd, void *buf, size_t bufsize, off_t offset)
1764 _GL_ARG_NONNULL ((2)));
1765 # endif
1766 _GL_CXXALIAS_SYS (pread, ssize_t,
1767 (int fd, void *buf, size_t bufsize, off_t offset));
1768 # endif
1769 _GL_CXXALIASWARN (pread);
1770 #elif defined GNULIB_POSIXCHECK
1771 # undef pread
1772 # if HAVE_RAW_DECL_PREAD
1773 _GL_WARN_ON_USE (pread, "pread is unportable - "
1774 "use gnulib module pread for portability");
1775 # endif
1776 #endif
1777
1778
1779 #if 0
1780 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1781 Return the number of bytes written if successful, otherwise
1782 set errno and return -1. 0 indicates nothing written. See the
1783 POSIX:2008 specification
1784 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1785 # if 0
1786 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1787 # undef pwrite
1788 # define pwrite rpl_pwrite
1789 # endif
1790 _GL_FUNCDECL_RPL (pwrite, ssize_t,
1791 (int fd, const void *buf, size_t bufsize, off_t offset)
1792 _GL_ARG_NONNULL ((2)));
1793 _GL_CXXALIAS_RPL (pwrite, ssize_t,
1794 (int fd, const void *buf, size_t bufsize, off_t offset));
1795 # else
1796 # if !1
1797 _GL_FUNCDECL_SYS (pwrite, ssize_t,
1798 (int fd, const void *buf, size_t bufsize, off_t offset)
1799 _GL_ARG_NONNULL ((2)));
1800 # endif
1801 _GL_CXXALIAS_SYS (pwrite, ssize_t,
1802 (int fd, const void *buf, size_t bufsize, off_t offset));
1803 # endif
1804 _GL_CXXALIASWARN (pwrite);
1805 #elif defined GNULIB_POSIXCHECK
1806 # undef pwrite
1807 # if HAVE_RAW_DECL_PWRITE
1808 _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1809 "use gnulib module pwrite for portability");
1810 # endif
1811 #endif
1812
1813
1814 #if 1
1815 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1816 at BUF. See the POSIX:2008 specification
1817 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1818 # if 0
1819 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1820 # undef read
1821 # define read rpl_read
1822 # endif
1823 _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1824 _GL_ARG_NONNULL ((2)));
1825 _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1826 # else
1827 /* Need to cast, because on mingw, the third parameter is
1828 unsigned int count
1829 and the return type is 'int'. */
1830 _GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1831 # endif
1832 _GL_CXXALIASWARN (read);
1833 #endif
1834
1835
1836 #if 0
1837 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1838 bytes of it into BUF. Return the number of bytes placed into BUF if
1839 successful, otherwise -1 and errno set.
1840 See the POSIX:2008 specification
1841 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1842 # if 0
1843 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1844 # define readlink rpl_readlink
1845 # endif
1846 _GL_FUNCDECL_RPL (readlink, ssize_t,
1847 (const char *file, char *buf, size_t bufsize)
1848 _GL_ARG_NONNULL ((1, 2)));
1849 _GL_CXXALIAS_RPL (readlink, ssize_t,
1850 (const char *file, char *buf, size_t bufsize));
1851 # else
1852 # if !1
1853 _GL_FUNCDECL_SYS (readlink, ssize_t,
1854 (const char *file, char *buf, size_t bufsize)
1855 _GL_ARG_NONNULL ((1, 2)));
1856 # endif
1857 _GL_CXXALIAS_SYS (readlink, ssize_t,
1858 (const char *file, char *buf, size_t bufsize));
1859 # endif
1860 _GL_CXXALIASWARN (readlink);
1861 #elif defined GNULIB_POSIXCHECK
1862 # undef readlink
1863 # if HAVE_RAW_DECL_READLINK
1864 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1865 "use gnulib module readlink for portability");
1866 # endif
1867 #endif
1868
1869
1870 #if 0
1871 # if 0
1872 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1873 # define readlinkat rpl_readlinkat
1874 # endif
1875 _GL_FUNCDECL_RPL (readlinkat, ssize_t,
1876 (int fd, char const *file, char *buf, size_t len)
1877 _GL_ARG_NONNULL ((2, 3)));
1878 _GL_CXXALIAS_RPL (readlinkat, ssize_t,
1879 (int fd, char const *file, char *buf, size_t len));
1880 # else
1881 # if !1
1882 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
1883 (int fd, char const *file, char *buf, size_t len)
1884 _GL_ARG_NONNULL ((2, 3)));
1885 # endif
1886 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1887 (int fd, char const *file, char *buf, size_t len));
1888 # endif
1889 _GL_CXXALIASWARN (readlinkat);
1890 #elif defined GNULIB_POSIXCHECK
1891 # undef readlinkat
1892 # if HAVE_RAW_DECL_READLINKAT
1893 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1894 "use gnulib module readlinkat for portability");
1895 # endif
1896 #endif
1897
1898
1899 #if 0
1900 /* Remove the directory DIR. */
1901 # if 0
1902 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1903 # define rmdir rpl_rmdir
1904 # endif
1905 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1906 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1907 # else
1908 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1909 # endif
1910 _GL_CXXALIASWARN (rmdir);
1911 #elif defined GNULIB_POSIXCHECK
1912 # undef rmdir
1913 # if HAVE_RAW_DECL_RMDIR
1914 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1915 "use gnulib module rmdir for portability");
1916 # endif
1917 #endif
1918
1919
1920 #if 0
1921 /* Set the host name of the machine.
1922 The host name may or may not be fully qualified.
1923
1924 Put LEN bytes of NAME into the host name.
1925 Return 0 if successful, otherwise, set errno and return -1.
1926
1927 Platforms with no ability to set the hostname return -1 and set
1928 errno = ENOSYS. */
1929 # if !1 || !1
1930 _GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
1931 _GL_ARG_NONNULL ((1)));
1932 # endif
1933 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1934 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1935 2011-10, the first parameter is not const. */
1936 _GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
1937 _GL_CXXALIASWARN (sethostname);
1938 #elif defined GNULIB_POSIXCHECK
1939 # undef sethostname
1940 # if HAVE_RAW_DECL_SETHOSTNAME
1941 _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1942 "use gnulib module sethostname for portability");
1943 # endif
1944 #endif
1945
1946
1947 #if IN_GREP_GNULIB_TESTS
1948 /* Pause the execution of the current thread for N seconds.
1949 Returns the number of seconds left to sleep.
1950 See the POSIX:2008 specification
1951 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1952 # if 0
1953 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1954 # undef sleep
1955 # define sleep rpl_sleep
1956 # endif
1957 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1958 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1959 # else
1960 # if !1
1961 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1962 # endif
1963 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1964 # endif
1965 _GL_CXXALIASWARN (sleep);
1966 #elif defined GNULIB_POSIXCHECK
1967 # undef sleep
1968 # if HAVE_RAW_DECL_SLEEP
1969 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1970 "use gnulib module sleep for portability");
1971 # endif
1972 #endif
1973
1974
1975 #if IN_GREP_GNULIB_TESTS
1976 # if 0
1977 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1978 # undef symlink
1979 # define symlink rpl_symlink
1980 # endif
1981 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1982 _GL_ARG_NONNULL ((1, 2)));
1983 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1984 # else
1985 # if !1
1986 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1987 _GL_ARG_NONNULL ((1, 2)));
1988 # endif
1989 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1990 # endif
1991 _GL_CXXALIASWARN (symlink);
1992 #elif defined GNULIB_POSIXCHECK
1993 # undef symlink
1994 # if HAVE_RAW_DECL_SYMLINK
1995 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1996 "use gnulib module symlink for portability");
1997 # endif
1998 #endif
1999
2000
2001 #if 0
2002 # if 0
2003 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2004 # undef symlinkat
2005 # define symlinkat rpl_symlinkat
2006 # endif
2007 _GL_FUNCDECL_RPL (symlinkat, int,
2008 (char const *contents, int fd, char const *file)
2009 _GL_ARG_NONNULL ((1, 3)));
2010 _GL_CXXALIAS_RPL (symlinkat, int,
2011 (char const *contents, int fd, char const *file));
2012 # else
2013 # if !1
2014 _GL_FUNCDECL_SYS (symlinkat, int,
2015 (char const *contents, int fd, char const *file)
2016 _GL_ARG_NONNULL ((1, 3)));
2017 # endif
2018 _GL_CXXALIAS_SYS (symlinkat, int,
2019 (char const *contents, int fd, char const *file));
2020 # endif
2021 _GL_CXXALIASWARN (symlinkat);
2022 #elif defined GNULIB_POSIXCHECK
2023 # undef symlinkat
2024 # if HAVE_RAW_DECL_SYMLINKAT
2025 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
2026 "use gnulib module symlinkat for portability");
2027 # endif
2028 #endif
2029
2030
2031 #if 0
2032 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
2033 Return 0 if successful, otherwise -1 and errno set.
2034 See the POSIX:2008 specification
2035 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
2036 # if 0
2037 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2038 # undef truncate
2039 # define truncate rpl_truncate
2040 # endif
2041 _GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
2042 _GL_ARG_NONNULL ((1)));
2043 _GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
2044 # else
2045 # if !1
2046 _GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
2047 _GL_ARG_NONNULL ((1)));
2048 # endif
2049 _GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
2050 # endif
2051 _GL_CXXALIASWARN (truncate);
2052 #elif defined GNULIB_POSIXCHECK
2053 # undef truncate
2054 # if HAVE_RAW_DECL_TRUNCATE
2055 _GL_WARN_ON_USE (truncate, "truncate is unportable - "
2056 "use gnulib module truncate for portability");
2057 # endif
2058 #endif
2059
2060
2061 #if 0
2062 /* Store at most BUFLEN characters of the pathname of the terminal FD is
2063 open on in BUF. Return 0 on success, otherwise an error number. */
2064 # if 0
2065 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2066 # undef ttyname_r
2067 # define ttyname_r rpl_ttyname_r
2068 # endif
2069 _GL_FUNCDECL_RPL (ttyname_r, int,
2070 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
2071 _GL_CXXALIAS_RPL (ttyname_r, int,
2072 (int fd, char *buf, size_t buflen));
2073 # else
2074 # if !1
2075 _GL_FUNCDECL_SYS (ttyname_r, int,
2076 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
2077 # endif
2078 _GL_CXXALIAS_SYS (ttyname_r, int,
2079 (int fd, char *buf, size_t buflen));
2080 # endif
2081 _GL_CXXALIASWARN (ttyname_r);
2082 #elif defined GNULIB_POSIXCHECK
2083 # undef ttyname_r
2084 # if HAVE_RAW_DECL_TTYNAME_R
2085 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
2086 "use gnulib module ttyname_r for portability");
2087 # endif
2088 #endif
2089
2090
2091 #if 0
2092 # if 0
2093 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2094 # undef unlink
2095 # define unlink rpl_unlink
2096 # endif
2097 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
2098 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
2099 # else
2100 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
2101 # endif
2102 _GL_CXXALIASWARN (unlink);
2103 #elif defined GNULIB_POSIXCHECK
2104 # undef unlink
2105 # if HAVE_RAW_DECL_UNLINK
2106 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
2107 "use gnulib module unlink for portability");
2108 # endif
2109 #endif
2110
2111
2112 #if 0
2113 # if 0
2114 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2115 # undef unlinkat
2116 # define unlinkat rpl_unlinkat
2117 # endif
2118 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
2119 _GL_ARG_NONNULL ((2)));
2120 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
2121 # else
2122 # if !1
2123 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
2124 _GL_ARG_NONNULL ((2)));
2125 # endif
2126 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
2127 # endif
2128 _GL_CXXALIASWARN (unlinkat);
2129 #elif defined GNULIB_POSIXCHECK
2130 # undef unlinkat
2131 # if HAVE_RAW_DECL_UNLINKAT
2132 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
2133 "use gnulib module openat for portability");
2134 # endif
2135 #endif
2136
2137
2138 #if 0
2139 /* Pause the execution of the current thread for N microseconds.
2140 Returns 0 on completion, or -1 on range error.
2141 See the POSIX:2001 specification
2142 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
2143 # if 0
2144 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2145 # undef usleep
2146 # define usleep rpl_usleep
2147 # endif
2148 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
2149 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
2150 # else
2151 # if !1
2152 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
2153 # endif
2154 /* Need to cast, because on Haiku, the first parameter is
2155 unsigned int n. */
2156 _GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n));
2157 # endif
2158 _GL_CXXALIASWARN (usleep);
2159 #elif defined GNULIB_POSIXCHECK
2160 # undef usleep
2161 # if HAVE_RAW_DECL_USLEEP
2162 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
2163 "use gnulib module usleep for portability");
2164 # endif
2165 #endif
2166
2167
2168 #if 0
2169 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
2170 See the POSIX:2008 specification
2171 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
2172 # if 0
2173 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2174 # undef write
2175 # define write rpl_write
2176 # endif
2177 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
2178 _GL_ARG_NONNULL ((2)));
2179 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
2180 # else
2181 /* Need to cast, because on mingw, the third parameter is
2182 unsigned int count
2183 and the return type is 'int'. */
2184 _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
2185 # endif
2186 _GL_CXXALIASWARN (write);
2187 #endif
2188
2189 _GL_INLINE_HEADER_END
2190
2191 #endif /* _GL_UNISTD_H */
2192 #endif /* _GL_INCLUDING_UNISTD_H */
2193 #endif /* _GL_UNISTD_H */
2194