Debian Codegraph @

lib/unistd.in.h

raw
1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2025 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17 #ifndef _@GUARD_PREFIX@_UNISTD_H
18
19 #if __GNUC__ >= 3
20 @PRAGMA_SYSTEM_HEADER@
21 #endif
22 @PRAGMA_COLUMNS@
23
24 #if @HAVE_UNISTD_H@ && defined _GL_INCLUDING_UNISTD_H
25 /* Special invocation convention:
26 - On Mac OS X 10.3.9 we have a sequence of nested includes
27 <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>
28 In this situation, the functions are not yet declared, therefore we cannot
29 provide the C++ aliases. */
30
31 #@INCLUDE_NEXT@ @NEXT_UNISTD_H@
32
33 #else
34 /* Normal invocation convention. */
35
36 /* The include_next requires a split double-inclusion guard. */
37 #if @HAVE_UNISTD_H@
38 # define _GL_INCLUDING_UNISTD_H
39 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
40 # undef _GL_INCLUDING_UNISTD_H
41 #endif
42
43 /* Avoid lseek bugs in FreeBSD, macOS <https://bugs.gnu.org/61386>.
44 This bug is fixed after FreeBSD 13; see <https://bugs.freebsd.org/256205>.
45 Use macOS "9999" to stand for a future fixed macOS version. */
46 #if defined __FreeBSD__ && __FreeBSD__ < 14
47 # undef SEEK_DATA
48 # undef SEEK_HOLE
49 #elif defined __APPLE__ && defined __MACH__ && defined SEEK_DATA
50 # ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
51 # include <AvailabilityMacros.h>
52 # endif
53 # if (!defined MAC_OS_X_VERSION_MIN_REQUIRED \
54 || MAC_OS_X_VERSION_MIN_REQUIRED < 99990000)
55 # include <sys/fcntl.h> /* It also defines the two macros. */
56 # undef SEEK_DATA
57 # undef SEEK_HOLE
58 # endif
59 #endif
60
61 /* Get all possible declarations of gethostname(). */
62 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
63 && !defined _GL_INCLUDING_WINSOCK2_H
64 # define _GL_INCLUDING_WINSOCK2_H
65 # include <winsock2.h>
66 # undef _GL_INCLUDING_WINSOCK2_H
67 #endif
68
69 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
70 #define _@GUARD_PREFIX@_UNISTD_H
71
72 /* This file uses _GL_ATTRIBUTE_NODISCARD, _GL_INLINE_HEADER_BEGIN, _GL_INLINE,
73 GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
74 #if !_GL_CONFIG_H_INCLUDED
75 #error "Please include config.h first."
76 #endif
77
78 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
79 /* But avoid namespace pollution on glibc systems. */
80 #ifndef __GLIBC__
81 # include <stddef.h>
82 #endif
83
84 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
85 /* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>. We must include
86 it before we #define unlink rpl_unlink. */
87 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
88 /* But avoid namespace pollution on glibc systems. */
89 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
90 || ((@GNULIB_UNLINK@ || defined GNULIB_POSIXCHECK) \
91 && (defined _WIN32 && ! defined __CYGWIN__)) \
92 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
93 && defined __CYGWIN__)) \
94 && ! defined __GLIBC__
95 # include <stdio.h>
96 #endif
97
98 /* FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Solaris 11.4, and glibc 2.41
99 do not define O_CLOEXEC in <unistd.h>. */
100 /* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
101 <unistd.h>. */
102 /* But avoid namespace pollution on glibc systems. */
103 #if ! defined O_CLOEXEC \
104 || ((@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
105 && (defined __CYGWIN__ || defined __ANDROID__) \
106 && ! defined __GLIBC__)
107 # include <fcntl.h>
108 #endif
109
110 /* mingw fails to declare _exit in <unistd.h>. */
111 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
112 <unistd.h>. */
113 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
114 /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
115 included here. */
116 /* But avoid namespace pollution on glibc systems. */
117 #if !defined __GLIBC__ && !defined __osf__
118 # define __need_system_stdlib_h
119 # include <stdlib.h>
120 # undef __need_system_stdlib_h
121 #endif
122
123 /* Native Windows platforms declare _chdir, _getcwd, _rmdir in
124 <io.h> and/or <direct.h>, not in <unistd.h>.
125 They also declare _access(), _chmod(), _close(), _dup(), _dup2(), _isatty(),
126 _lseek(), _read(), _unlink(), _write() in <io.h>. */
127 #if defined _WIN32 && !defined __CYGWIN__
128 # include <io.h>
129 # include <direct.h>
130 #endif
131
132 /* Native Windows platforms declare _execl*, _execv* in <process.h>. */
133 #if defined _WIN32 && !defined __CYGWIN__
134 # include <process.h>
135 #endif
136
137 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
138 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
139 /* But avoid namespace pollution on glibc systems. */
140 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
141 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
142 && !defined __GLIBC__
143 # include <netdb.h>
144 #endif
145
146 /* Mac OS X 10.13, Solaris 11.4, and Android 9.0 declare getentropy in
147 <sys/random.h>, not in <unistd.h>. */
148 /* But avoid namespace pollution on glibc systems. */
149 #if (@GNULIB_GETENTROPY@ || defined GNULIB_POSIXCHECK) \
150 && ((defined __APPLE__ && defined __MACH__) || defined __sun \
151 || defined __ANDROID__) \
152 && @UNISTD_H_HAVE_SYS_RANDOM_H@ \
153 && !defined __GLIBC__
154 # include <sys/random.h>
155 #endif
156
157 /* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>. */
158 /* But avoid namespace pollution on glibc systems. */
159 #if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
160 && !defined __GLIBC__
161 # include <sys/stat.h>
162 #endif
163
164 /* MSVC defines off_t in <sys/types.h>.
165 May also define off_t to a 64-bit type on native Windows.
166 Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */
167 /* Get off_t, off64_t, ssize_t, mode_t. */
168 #include <sys/types.h>
169
170 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
171
172 /* The definition of _GL_ARG_NONNULL is copied here. */
173
174 /* The definition of _GL_WARN_ON_USE is copied here. */
175
176
177 /* Get getopt(), optarg, optind, opterr, optopt. */
178 #if @GNULIB_GETOPT_POSIX@ && @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
179 # include <getopt-cdefs.h>
180 # include <getopt-pfx-core.h>
181 #endif
182
183 _GL_INLINE_HEADER_BEGIN
184 #ifndef _GL_UNISTD_INLINE
185 # define _GL_UNISTD_INLINE _GL_INLINE
186 #endif
187 #ifndef _GL_GETPAGESIZE_INLINE
188 # define _GL_GETPAGESIZE_INLINE _GL_INLINE
189 #endif
190
191 /* Hide some function declarations from <winsock2.h>. */
192
193 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
194 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
195 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
196 # undef socket
197 # define socket socket_used_without_including_sys_socket_h
198 # undef connect
199 # define connect connect_used_without_including_sys_socket_h
200 # undef accept
201 # define accept accept_used_without_including_sys_socket_h
202 # undef bind
203 # define bind bind_used_without_including_sys_socket_h
204 # undef getpeername
205 # define getpeername getpeername_used_without_including_sys_socket_h
206 # undef getsockname
207 # define getsockname getsockname_used_without_including_sys_socket_h
208 # undef getsockopt
209 # define getsockopt getsockopt_used_without_including_sys_socket_h
210 # undef listen
211 # define listen listen_used_without_including_sys_socket_h
212 # undef recv
213 # define recv recv_used_without_including_sys_socket_h
214 # undef send
215 # define send send_used_without_including_sys_socket_h
216 # undef recvfrom
217 # define recvfrom recvfrom_used_without_including_sys_socket_h
218 # undef sendto
219 # define sendto sendto_used_without_including_sys_socket_h
220 # undef setsockopt
221 # define setsockopt setsockopt_used_without_including_sys_socket_h
222 # undef shutdown
223 # define shutdown shutdown_used_without_including_sys_socket_h
224 # else
225 _GL_WARN_ON_USE (socket,
226 "socket() used without including <sys/socket.h>");
227 _GL_WARN_ON_USE (connect,
228 "connect() used without including <sys/socket.h>");
229 _GL_WARN_ON_USE (accept,
230 "accept() used without including <sys/socket.h>");
231 _GL_WARN_ON_USE (bind,
232 "bind() used without including <sys/socket.h>");
233 _GL_WARN_ON_USE (getpeername,
234 "getpeername() used without including <sys/socket.h>");
235 _GL_WARN_ON_USE (getsockname,
236 "getsockname() used without including <sys/socket.h>");
237 _GL_WARN_ON_USE (getsockopt,
238 "getsockopt() used without including <sys/socket.h>");
239 _GL_WARN_ON_USE (listen,
240 "listen() used without including <sys/socket.h>");
241 _GL_WARN_ON_USE (recv,
242 "recv() used without including <sys/socket.h>");
243 _GL_WARN_ON_USE (send,
244 "send() used without including <sys/socket.h>");
245 _GL_WARN_ON_USE (recvfrom,
246 "recvfrom() used without including <sys/socket.h>");
247 _GL_WARN_ON_USE (sendto,
248 "sendto() used without including <sys/socket.h>");
249 _GL_WARN_ON_USE (setsockopt,
250 "setsockopt() used without including <sys/socket.h>");
251 _GL_WARN_ON_USE (shutdown,
252 "shutdown() used without including <sys/socket.h>");
253 # endif
254 # endif
255 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
256 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
257 # undef select
258 # define select select_used_without_including_sys_select_h
259 # else
260 _GL_WARN_ON_USE (select,
261 "select() used without including <sys/select.h>");
262 # endif
263 # endif
264 #endif
265
266
267 /* OS/2 EMX lacks these macros. */
268 #ifndef STDIN_FILENO
269 # define STDIN_FILENO 0
270 #endif
271 #ifndef STDOUT_FILENO
272 # define STDOUT_FILENO 1
273 #endif
274 #ifndef STDERR_FILENO
275 # define STDERR_FILENO 2
276 #endif
277
278 /* Ensure *_OK macros exist. */
279 #ifndef F_OK
280 # define F_OK 0
281 # define X_OK 1
282 # define W_OK 2
283 # define R_OK 4
284 #endif
285
286
287 /* Declare overridden functions. */
288
289
290 #if @GNULIB_ACCESS@
291 # if @REPLACE_ACCESS@
292 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
293 # undef access
294 # define access rpl_access
295 # endif
296 _GL_FUNCDECL_RPL (access, int, (const char *file, int mode),
297 _GL_ARG_NONNULL ((1)));
298 _GL_CXXALIAS_RPL (access, int, (const char *file, int mode));
299 # elif defined _WIN32 && !defined __CYGWIN__
300 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
301 # undef access
302 # define access _access
303 # endif
304 _GL_CXXALIAS_MDA (access, int, (const char *file, int mode));
305 # else
306 _GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
307 # endif
308 _GL_CXXALIASWARN (access);
309 #elif defined GNULIB_POSIXCHECK
310 # undef access
311 # if HAVE_RAW_DECL_ACCESS
312 /* The access() function is a security risk. */
313 _GL_WARN_ON_USE (access, "access does not always support X_OK - "
314 "use gnulib module access for portability; "
315 "also, this function is a security risk - "
316 "use the gnulib module faccessat instead");
317 # endif
318 #elif @GNULIB_MDA_ACCESS@
319 /* On native Windows, map 'access' to '_access', so that -loldnames is not
320 required. In C++ with GNULIB_NAMESPACE, avoid differences between
321 platforms by defining GNULIB_NAMESPACE::access always. */
322 # if defined _WIN32 && !defined __CYGWIN__
323 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
324 # undef access
325 # define access _access
326 # endif
327 _GL_CXXALIAS_MDA (access, int, (const char *file, int mode));
328 # else
329 _GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
330 # endif
331 _GL_CXXALIASWARN (access);
332 #endif
333
334
335 #if @GNULIB_CHDIR@
336 # if defined _WIN32 && !defined __CYGWIN__
337 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
338 # undef chdir
339 # define chdir _chdir
340 # endif
341 _GL_CXXALIAS_MDA (chdir, int, (const char *file));
342 # else
343 _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
344 # endif
345 _GL_CXXALIASWARN (chdir);
346 #elif defined GNULIB_POSIXCHECK
347 # undef chdir
348 # if HAVE_RAW_DECL_CHDIR
349 _GL_WARN_ON_USE (chdir, "chdir is not always in <unistd.h> - "
350 "use gnulib module chdir for portability");
351 # endif
352 #elif @GNULIB_MDA_CHDIR@
353 /* On native Windows, map 'chdir' to '_chdir', so that -loldnames is not
354 required. In C++ with GNULIB_NAMESPACE, avoid differences between
355 platforms by defining GNULIB_NAMESPACE::chdir always. */
356 # if defined _WIN32 && !defined __CYGWIN__
357 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
358 # undef chdir
359 # define chdir _chdir
360 # endif
361 _GL_CXXALIAS_MDA (chdir, int, (const char *file));
362 # else
363 _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
364 # endif
365 _GL_CXXALIASWARN (chdir);
366 #endif
367
368
369 #if @GNULIB_CHOWN@
370 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
371 to GID (if GID is not -1). Follow symbolic links.
372 Return 0 if successful, otherwise -1 and errno set.
373 See the POSIX:2008 specification
374 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
375 # if @REPLACE_CHOWN@
376 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
377 # undef chown
378 # define chown rpl_chown
379 # endif
380 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid),
381 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
382 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
383 # else
384 # if !@HAVE_CHOWN@
385 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid),
386 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
387 # endif
388 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
389 # endif
390 _GL_CXXALIASWARN (chown);
391 #elif defined GNULIB_POSIXCHECK
392 # undef chown
393 # if HAVE_RAW_DECL_CHOWN
394 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
395 "doesn't treat a uid or gid of -1 on some systems - "
396 "use gnulib module chown for portability");
397 # endif
398 #endif
399
400
401 #if @GNULIB_CLOSE@
402 # if @REPLACE_CLOSE@
403 /* Automatically included by modules that need a replacement for close. */
404 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
405 # undef close
406 # define close rpl_close
407 # endif
408 _GL_FUNCDECL_RPL (close, int, (int fd), );
409 _GL_CXXALIAS_RPL (close, int, (int fd));
410 # elif defined _WIN32 && !defined __CYGWIN__
411 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
412 # undef close
413 # define close _close
414 # endif
415 _GL_CXXALIAS_MDA (close, int, (int fd));
416 # else
417 _GL_CXXALIAS_SYS (close, int, (int fd));
418 # endif
419 _GL_CXXALIASWARN (close);
420 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
421 # if !GNULIB_CLOSE
422 # undef close
423 # define close close_used_without_requesting_gnulib_module_close
424 # endif
425 #elif defined GNULIB_POSIXCHECK
426 # undef close
427 /* Assume close is always declared. */
428 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
429 "use gnulib module close for portability");
430 #elif @GNULIB_MDA_CLOSE@
431 /* On native Windows, map 'close' to '_close', so that -loldnames is not
432 required. In C++ with GNULIB_NAMESPACE, avoid differences between
433 platforms by defining GNULIB_NAMESPACE::close always. */
434 # if defined _WIN32 && !defined __CYGWIN__
435 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
436 # undef close
437 # define close _close
438 # endif
439 _GL_CXXALIAS_MDA (close, int, (int fd));
440 # else
441 _GL_CXXALIAS_SYS (close, int, (int fd));
442 # endif
443 _GL_CXXALIASWARN (close);
444 #endif
445
446
447 #if @GNULIB_COPY_FILE_RANGE@
448 # if @REPLACE_COPY_FILE_RANGE@
449 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
450 # undef copy_file_range
451 # define copy_file_range rpl_copy_file_range
452 # endif
453 _GL_FUNCDECL_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
454 int ofd, off_t *opos,
455 size_t len, unsigned flags), );
456 _GL_CXXALIAS_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
457 int ofd, off_t *opos,
458 size_t len, unsigned flags));
459 # else
460 # if !@HAVE_COPY_FILE_RANGE@
461 _GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
462 int ofd, off_t *opos,
463 size_t len, unsigned flags), );
464 # endif
465 _GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
466 int ofd, off_t *opos,
467 size_t len, unsigned flags));
468 # endif
469 # if __GLIBC__ >= 2
470 _GL_CXXALIASWARN (copy_file_range);
471 # endif
472 #elif defined GNULIB_POSIXCHECK
473 # undef copy_file_range
474 # if HAVE_RAW_DECL_COPY_FILE_RANGE
475 _GL_WARN_ON_USE (copy_file_range,
476 "copy_file_range is unportable - "
477 "use gnulib module copy_file_range for portability");
478 # endif
479 #endif
480
481
482 #if @GNULIB_DUP@
483 # if @REPLACE_DUP@
484 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
485 # define dup rpl_dup
486 # endif
487 _GL_FUNCDECL_RPL (dup, int, (int oldfd), _GL_ATTRIBUTE_NODISCARD);
488 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
489 # elif defined _WIN32 && !defined __CYGWIN__
490 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
491 # undef dup
492 # define dup _dup
493 # endif
494 _GL_CXXALIAS_MDA (dup, int, (int oldfd));
495 # else
496 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
497 # endif
498 _GL_CXXALIASWARN (dup);
499 #elif defined GNULIB_POSIXCHECK
500 # undef dup
501 # if HAVE_RAW_DECL_DUP
502 _GL_WARN_ON_USE (dup, "dup is unportable - "
503 "use gnulib module dup for portability");
504 # endif
505 #elif @GNULIB_MDA_DUP@
506 /* On native Windows, map 'dup' to '_dup', so that -loldnames is not
507 required. In C++ with GNULIB_NAMESPACE, avoid differences between
508 platforms by defining GNULIB_NAMESPACE::dup always. */
509 # if defined _WIN32 && !defined __CYGWIN__
510 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
511 # undef dup
512 # define dup _dup
513 # endif
514 _GL_CXXALIAS_MDA (dup, int, (int oldfd));
515 # else
516 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
517 # endif
518 _GL_CXXALIASWARN (dup);
519 #endif
520
521
522 #if @GNULIB_DUP2@
523 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
524 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
525 Return newfd if successful, otherwise -1 and errno set.
526 See the POSIX:2008 specification
527 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
528 # if @REPLACE_DUP2@
529 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
530 # define dup2 rpl_dup2
531 # endif
532 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd), );
533 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
534 # elif defined _WIN32 && !defined __CYGWIN__
535 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
536 # undef dup2
537 # define dup2 _dup2
538 # endif
539 _GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
540 # else
541 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
542 # endif
543 _GL_CXXALIASWARN (dup2);
544 #elif defined GNULIB_POSIXCHECK
545 # undef dup2
546 # if HAVE_RAW_DECL_DUP2
547 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
548 "use gnulib module dup2 for portability");
549 # endif
550 #elif @GNULIB_MDA_DUP2@
551 /* On native Windows, map 'dup2' to '_dup2', so that -loldnames is not
552 required. In C++ with GNULIB_NAMESPACE, avoid differences between
553 platforms by defining GNULIB_NAMESPACE::dup2 always. */
554 # if defined _WIN32 && !defined __CYGWIN__
555 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
556 # undef dup2
557 # define dup2 _dup2
558 # endif
559 _GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
560 # else
561 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
562 # endif
563 _GL_CXXALIASWARN (dup2);
564 #endif
565
566
567 #if @GNULIB_DUP3@
568 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
569 specified flags.
570 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
571 and O_TEXT, O_BINARY (defined in "binary-io.h").
572 Close NEWFD first if it is open.
573 Return newfd if successful, otherwise -1 and errno set.
574 See the Linux man page at
575 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
576 # if @REPLACE_DUP3@
577 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
578 # undef dup3
579 # define dup3 rpl_dup3
580 # endif
581 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags), );
582 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
583 # else
584 # if !@HAVE_DUP3@
585 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags), );
586 # endif
587 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
588 # endif
589 # if __GLIBC__ >= 2
590 _GL_CXXALIASWARN (dup3);
591 # endif
592 #elif defined GNULIB_POSIXCHECK
593 # undef dup3
594 # if HAVE_RAW_DECL_DUP3
595 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
596 "use gnulib module dup3 for portability");
597 # endif
598 #endif
599
600
601 #if @GNULIB_ENVIRON@
602 # if defined __CYGWIN__ && !defined __i386__
603 /* The 'environ' variable is defined in a DLL. Therefore its declaration needs
604 the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
605 This leads to a link error on 64-bit Cygwin when the option
606 -Wl,--disable-auto-import is in use. */
607 _GL_EXTERN_C __declspec(dllimport) char **environ;
608 # endif
609 # if !@HAVE_DECL_ENVIRON@
610 /* Set of environment variables and values. An array of strings of the form
611 "VARIABLE=VALUE", terminated with a NULL. */
612 # if defined __APPLE__ && defined __MACH__
613 # include <TargetConditionals.h>
614 # if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
615 # define _GL_USE_CRT_EXTERNS
616 # endif
617 # endif
618 # ifdef _GL_USE_CRT_EXTERNS
619 # include <crt_externs.h>
620 # define environ (*_NSGetEnviron ())
621 # else
622 # ifdef __cplusplus
623 extern "C" {
624 # endif
625 extern char **environ;
626 # ifdef __cplusplus
627 }
628 # endif
629 # endif
630 # endif
631 #elif defined GNULIB_POSIXCHECK
632 # if HAVE_RAW_DECL_ENVIRON
633 _GL_UNISTD_INLINE char ***
634 _GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
635 "use gnulib module environ for portability")
636 rpl_environ (void)
637 {
638 return &environ;
639 }
640 # undef environ
641 # define environ (*rpl_environ ())
642 # endif
643 #endif
644
645
646 #if @GNULIB_EUIDACCESS@
647 /* Like access(), except that it uses the effective user id and group id of
648 the current process. */
649 # if !@HAVE_EUIDACCESS@
650 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode),
651 _GL_ARG_NONNULL ((1)));
652 # endif
653 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
654 _GL_CXXALIASWARN (euidaccess);
655 # if defined GNULIB_POSIXCHECK
656 /* Like access(), this function is a security risk. */
657 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
658 "use the gnulib module faccessat instead");
659 # endif
660 #elif defined GNULIB_POSIXCHECK
661 # undef euidaccess
662 # if HAVE_RAW_DECL_EUIDACCESS
663 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
664 "use gnulib module euidaccess for portability");
665 # endif
666 #endif
667
668
669 #if @GNULIB_EXECL@
670 # if @REPLACE_EXECL@
671 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
672 # undef execl
673 # define execl rpl_execl
674 # endif
675 _GL_FUNCDECL_RPL (execl, int, (const char *program, const char *arg, ...),
676 _GL_ARG_NONNULL ((1)));
677 _GL_CXXALIAS_RPL (execl, int, (const char *program, const char *arg, ...));
678 # else
679 _GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
680 # endif
681 _GL_CXXALIASWARN (execl);
682 #elif defined GNULIB_POSIXCHECK
683 # undef execl
684 # if HAVE_RAW_DECL_EXECL
685 _GL_WARN_ON_USE (execl, "execl behaves very differently on mingw - "
686 "use gnulib module execl for portability");
687 # endif
688 #elif @GNULIB_MDA_EXECL@
689 /* On native Windows, map 'execl' to '_execl', so that -loldnames is not
690 required. In C++ with GNULIB_NAMESPACE, avoid differences between
691 platforms by defining GNULIB_NAMESPACE::execl always. */
692 # if defined _WIN32 && !defined __CYGWIN__
693 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
694 # undef execl
695 # define execl _execl
696 # endif
697 _GL_CXXALIAS_MDA (execl, intptr_t, (const char *program, const char *arg, ...));
698 # else
699 _GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
700 # endif
701 _GL_CXXALIASWARN (execl);
702 #endif
703
704 #if @GNULIB_EXECLE@
705 # if @REPLACE_EXECLE@
706 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
707 # undef execle
708 # define execle rpl_execle
709 # endif
710 _GL_FUNCDECL_RPL (execle, int, (const char *program, const char *arg, ...),
711 _GL_ARG_NONNULL ((1)));
712 _GL_CXXALIAS_RPL (execle, int, (const char *program, const char *arg, ...));
713 # else
714 _GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
715 # endif
716 _GL_CXXALIASWARN (execle);
717 #elif defined GNULIB_POSIXCHECK
718 # undef execle
719 # if HAVE_RAW_DECL_EXECLE
720 _GL_WARN_ON_USE (execle, "execle behaves very differently on mingw - "
721 "use gnulib module execle for portability");
722 # endif
723 #elif @GNULIB_MDA_EXECLE@
724 /* On native Windows, map 'execle' to '_execle', so that -loldnames is not
725 required. In C++ with GNULIB_NAMESPACE, avoid differences between
726 platforms by defining GNULIB_NAMESPACE::execle always. */
727 # if defined _WIN32 && !defined __CYGWIN__
728 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
729 # undef execle
730 # define execle _execle
731 # endif
732 _GL_CXXALIAS_MDA (execle, intptr_t,
733 (const char *program, const char *arg, ...));
734 # else
735 _GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
736 # endif
737 _GL_CXXALIASWARN (execle);
738 #endif
739
740 #if @GNULIB_EXECLP@
741 # if @REPLACE_EXECLP@
742 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
743 # undef execlp
744 # define execlp rpl_execlp
745 # endif
746 _GL_FUNCDECL_RPL (execlp, int, (const char *program, const char *arg, ...),
747 _GL_ARG_NONNULL ((1)));
748 _GL_CXXALIAS_RPL (execlp, int, (const char *program, const char *arg, ...));
749 # else
750 _GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
751 # endif
752 _GL_CXXALIASWARN (execlp);
753 #elif defined GNULIB_POSIXCHECK
754 # undef execlp
755 # if HAVE_RAW_DECL_EXECLP
756 _GL_WARN_ON_USE (execlp, "execlp behaves very differently on mingw - "
757 "use gnulib module execlp for portability");
758 # endif
759 #elif @GNULIB_MDA_EXECLP@
760 /* On native Windows, map 'execlp' to '_execlp', so that -loldnames is not
761 required. In C++ with GNULIB_NAMESPACE, avoid differences between
762 platforms by defining GNULIB_NAMESPACE::execlp always. */
763 # if defined _WIN32 && !defined __CYGWIN__
764 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
765 # undef execlp
766 # define execlp _execlp
767 # endif
768 _GL_CXXALIAS_MDA (execlp, intptr_t,
769 (const char *program, const char *arg, ...));
770 # else
771 _GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
772 # endif
773 _GL_CXXALIASWARN (execlp);
774 #endif
775
776
777 #if @GNULIB_EXECV@
778 # if @REPLACE_EXECV@
779 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
780 # undef execv
781 # define execv rpl_execv
782 # endif
783 _GL_FUNCDECL_RPL (execv, int, (const char *program, char * const *argv),
784 _GL_ARG_NONNULL ((1, 2)));
785 _GL_CXXALIAS_RPL (execv, int, (const char *program, char * const *argv));
786 # else
787 _GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
788 # endif
789 _GL_CXXALIASWARN (execv);
790 #elif defined GNULIB_POSIXCHECK
791 # undef execv
792 # if HAVE_RAW_DECL_EXECV
793 _GL_WARN_ON_USE (execv, "execv behaves very differently on mingw - "
794 "use gnulib module execv for portability");
795 # endif
796 #elif @GNULIB_MDA_EXECV@
797 /* On native Windows, map 'execv' to '_execv', so that -loldnames is not
798 required. In C++ with GNULIB_NAMESPACE, avoid differences between
799 platforms by defining GNULIB_NAMESPACE::execv always. */
800 # if defined _WIN32 && !defined __CYGWIN__
801 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
802 # undef execv
803 # define execv _execv
804 # endif
805 _GL_CXXALIAS_MDA_CAST (execv, intptr_t,
806 (const char *program, char * const *argv));
807 # else
808 _GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
809 # endif
810 _GL_CXXALIASWARN (execv);
811 #endif
812
813 #if @GNULIB_EXECVE@
814 # if @REPLACE_EXECVE@
815 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
816 # undef execve
817 # define execve rpl_execve
818 # endif
819 _GL_FUNCDECL_RPL (execve, int,
820 (const char *program, char * const *argv, char * const *env),
821 _GL_ARG_NONNULL ((1, 2)));
822 _GL_CXXALIAS_RPL (execve, int,
823 (const char *program, char * const *argv, char * const *env));
824 # else
825 _GL_CXXALIAS_SYS (execve, int,
826 (const char *program, char * const *argv, char * const *env));
827 # endif
828 _GL_CXXALIASWARN (execve);
829 #elif defined GNULIB_POSIXCHECK
830 # undef execve
831 # if HAVE_RAW_DECL_EXECVE
832 _GL_WARN_ON_USE (execve, "execve behaves very differently on mingw - "
833 "use gnulib module execve for portability");
834 # endif
835 #elif @GNULIB_MDA_EXECVE@
836 /* On native Windows, map 'execve' to '_execve', so that -loldnames is not
837 required. In C++ with GNULIB_NAMESPACE, avoid differences between
838 platforms by defining GNULIB_NAMESPACE::execve always. */
839 # if defined _WIN32 && !defined __CYGWIN__
840 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
841 # undef execve
842 # define execve _execve
843 # endif
844 _GL_CXXALIAS_MDA_CAST (execve, intptr_t,
845 (const char *program, char * const *argv,
846 char * const *env));
847 # else
848 _GL_CXXALIAS_SYS (execve, int,
849 (const char *program, char * const *argv, char * const *env));
850 # endif
851 _GL_CXXALIASWARN (execve);
852 #endif
853
854 #if @GNULIB_EXECVP@
855 # if @REPLACE_EXECVP@
856 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
857 # undef execvp
858 # define execvp rpl_execvp
859 # endif
860 _GL_FUNCDECL_RPL (execvp, int, (const char *program, char * const *argv),
861 _GL_ARG_NONNULL ((1, 2)));
862 _GL_CXXALIAS_RPL (execvp, int, (const char *program, char * const *argv));
863 # else
864 _GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
865 # endif
866 _GL_CXXALIASWARN (execvp);
867 #elif defined GNULIB_POSIXCHECK
868 # undef execvp
869 # if HAVE_RAW_DECL_EXECVP
870 _GL_WARN_ON_USE (execvp, "execvp behaves very differently on mingw - "
871 "use gnulib module execvp for portability");
872 # endif
873 #elif @GNULIB_MDA_EXECVP@
874 /* On native Windows, map 'execvp' to '_execvp', so that -loldnames is not
875 required. In C++ with GNULIB_NAMESPACE, avoid differences between
876 platforms by defining GNULIB_NAMESPACE::execvp always. */
877 # if defined _WIN32 && !defined __CYGWIN__
878 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
879 # undef execvp
880 # define execvp _execvp
881 # endif
882 _GL_CXXALIAS_MDA_CAST (execvp, intptr_t,
883 (const char *program, char * const *argv));
884 # else
885 _GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
886 # endif
887 _GL_CXXALIASWARN (execvp);
888 #endif
889
890 #if @GNULIB_EXECVPE@
891 # if @REPLACE_EXECVPE@
892 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
893 # undef execvpe
894 # define execvpe rpl_execvpe
895 # endif
896 _GL_FUNCDECL_RPL (execvpe, int,
897 (const char *program, char * const *argv, char * const *env),
898 _GL_ARG_NONNULL ((1, 2)));
899 _GL_CXXALIAS_RPL (execvpe, int,
900 (const char *program, char * const *argv, char * const *env));
901 # else
902 # if !@HAVE_DECL_EXECVPE@
903 _GL_FUNCDECL_SYS (execvpe, int,
904 (const char *program, char * const *argv, char * const *env),
905 _GL_ARG_NONNULL ((1, 2)));
906 # endif
907 _GL_CXXALIAS_SYS (execvpe, int,
908 (const char *program, char * const *argv, char * const *env));
909 # endif
910 # if __GLIBC__ >= 2
911 _GL_CXXALIASWARN (execvpe);
912 # endif
913 #elif defined GNULIB_POSIXCHECK
914 # undef execvpe
915 # if HAVE_RAW_DECL_EXECVPE
916 _GL_WARN_ON_USE (execvpe, "execvpe behaves very differently on mingw - "
917 "use gnulib module execvpe for portability");
918 # endif
919 #elif @GNULIB_MDA_EXECVPE@
920 /* On native Windows, map 'execvpe' to '_execvpe', so that -loldnames is not
921 required. In C++ with GNULIB_NAMESPACE, avoid differences between
922 platforms by defining GNULIB_NAMESPACE::execvpe on all platforms that have
923 it. */
924 # if defined _WIN32 && !defined __CYGWIN__
925 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
926 # undef execvpe
927 # define execvpe _execvpe
928 # endif
929 _GL_CXXALIAS_MDA_CAST (execvpe, intptr_t,
930 (const char *program, char * const *argv,
931 char * const *env));
932 # elif @HAVE_EXECVPE@
933 # if !@HAVE_DECL_EXECVPE@
934 _GL_FUNCDECL_SYS (execvpe, int,
935 (const char *program, char * const *argv, char * const *env),
936 _GL_ARG_NONNULL ((1, 2)));
937 # endif
938 _GL_CXXALIAS_SYS (execvpe, int,
939 (const char *program, char * const *argv, char * const *env));
940 # endif
941 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_EXECVPE@
942 _GL_CXXALIASWARN (execvpe);
943 # endif
944 #endif
945
946
947 #if @GNULIB_FACCESSAT@
948 # if @REPLACE_FACCESSAT@
949 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
950 # undef faccessat
951 # define faccessat rpl_faccessat
952 # endif
953 _GL_FUNCDECL_RPL (faccessat, int,
954 (int fd, char const *name, int mode, int flag),
955 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
956 _GL_CXXALIAS_RPL (faccessat, int,
957 (int fd, char const *name, int mode, int flag));
958 # else
959 # if !@HAVE_FACCESSAT@
960 _GL_FUNCDECL_SYS (faccessat, int,
961 (int fd, char const *file, int mode, int flag),
962 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
963 # endif
964 _GL_CXXALIAS_SYS (faccessat, int,
965 (int fd, char const *file, int mode, int flag));
966 # endif
967 # if __GLIBC__ >= 2
968 _GL_CXXALIASWARN (faccessat);
969 # endif
970 #elif defined GNULIB_POSIXCHECK
971 # undef faccessat
972 # if HAVE_RAW_DECL_FACCESSAT
973 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
974 "use gnulib module faccessat for portability");
975 # endif
976 #endif
977
978
979 #if @GNULIB_FCHDIR@
980 /* Change the process' current working directory to the directory on which
981 the given file descriptor is open.
982 Return 0 if successful, otherwise -1 and errno set.
983 See the POSIX:2008 specification
984 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
985 # if @REPLACE_FCHDIR@
986 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
987 # undef fchdir
988 # define fchdir rpl_fchdir
989 # endif
990 _GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/), _GL_ATTRIBUTE_NODISCARD);
991 _GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/));
992 # else
993 # if !@HAVE_FCHDIR@ || !@HAVE_DECL_FCHDIR@
994 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/), _GL_ATTRIBUTE_NODISCARD);
995 # endif
996 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
997 # endif
998 _GL_CXXALIASWARN (fchdir);
999 # if @REPLACE_FCHDIR@ || !@HAVE_FCHDIR@
1000 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
1001 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
1002 _GL_ARG_NONNULL ((2));
1003 _GL_EXTERN_C void _gl_unregister_fd (int fd);
1004 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
1005 _GL_EXTERN_C const char *_gl_directory_name (int fd);
1006 # endif
1007 #elif defined GNULIB_POSIXCHECK
1008 # undef fchdir
1009 # if HAVE_RAW_DECL_FCHDIR
1010 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
1011 "use gnulib module fchdir for portability");
1012 # endif
1013 #endif
1014
1015
1016 #if @GNULIB_FCHOWNAT@
1017 # if @REPLACE_FCHOWNAT@
1018 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1019 # undef fchownat
1020 # define fchownat rpl_fchownat
1021 # endif
1022 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
1023 uid_t owner, gid_t group, int flag),
1024 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
1025 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
1026 uid_t owner, gid_t group, int flag));
1027 # else
1028 # if !@HAVE_FCHOWNAT@
1029 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
1030 uid_t owner, gid_t group, int flag),
1031 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
1032 # endif
1033 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
1034 uid_t owner, gid_t group, int flag));
1035 # endif
1036 _GL_CXXALIASWARN (fchownat);
1037 #elif defined GNULIB_POSIXCHECK
1038 # undef fchownat
1039 # if HAVE_RAW_DECL_FCHOWNAT
1040 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
1041 "use gnulib module fchownat for portability");
1042 # endif
1043 #endif
1044
1045
1046 #if @GNULIB_FDATASYNC@
1047 /* Synchronize changes to a file.
1048 Return 0 if successful, otherwise -1 and errno set.
1049 See POSIX:2008 specification
1050 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
1051 # if @REPLACE_FDATASYNC@
1052 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1053 # undef fdatasync
1054 # define fdatasync rpl_fdatasync
1055 # endif
1056 _GL_FUNCDECL_RPL (fdatasync, int, (int fd), );
1057 _GL_CXXALIAS_RPL (fdatasync, int, (int fd));
1058 # else
1059 # if !@HAVE_FDATASYNC@|| !@HAVE_DECL_FDATASYNC@
1060 _GL_FUNCDECL_SYS (fdatasync, int, (int fd), );
1061 # endif
1062 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
1063 # endif
1064 # if __GLIBC__ >= 2
1065 _GL_CXXALIASWARN (fdatasync);
1066 # endif
1067 #elif defined GNULIB_POSIXCHECK
1068 # undef fdatasync
1069 # if HAVE_RAW_DECL_FDATASYNC
1070 _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
1071 "use gnulib module fdatasync for portability");
1072 # endif
1073 #endif
1074
1075
1076 #if @GNULIB_FSYNC@
1077 /* Synchronize changes, including metadata, to a file.
1078 Return 0 if successful, otherwise -1 and errno set.
1079 See POSIX:2008 specification
1080 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
1081 # if !@HAVE_FSYNC@
1082 _GL_FUNCDECL_SYS (fsync, int, (int fd), );
1083 # endif
1084 _GL_CXXALIAS_SYS (fsync, int, (int fd));
1085 _GL_CXXALIASWARN (fsync);
1086 #elif defined GNULIB_POSIXCHECK
1087 # undef fsync
1088 # if HAVE_RAW_DECL_FSYNC
1089 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
1090 "use gnulib module fsync for portability");
1091 # endif
1092 #endif
1093
1094
1095 #if @GNULIB_FTRUNCATE@
1096 /* Change the size of the file to which FD is opened to become equal to LENGTH.
1097 Return 0 if successful, otherwise -1 and errno set.
1098 See the POSIX:2008 specification
1099 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
1100 # if @REPLACE_FTRUNCATE@
1101 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1102 # undef ftruncate
1103 # define ftruncate rpl_ftruncate
1104 # endif
1105 _GL_FUNCDECL_RPL (ftruncate, int,
1106 (int fd, off_t length), _GL_ATTRIBUTE_NODISCARD);
1107 _GL_CXXALIAS_RPL (ftruncate, int,
1108 (int fd, off_t length));
1109 # else
1110 # if !@HAVE_FTRUNCATE@
1111 _GL_FUNCDECL_SYS (ftruncate, int,
1112 (int fd, off_t length), _GL_ATTRIBUTE_NODISCARD);
1113 # endif
1114 _GL_CXXALIAS_SYS (ftruncate, int,
1115 (int fd, off_t length));
1116 # endif
1117 # if __GLIBC__ >= 2
1118 _GL_CXXALIASWARN (ftruncate);
1119 # endif
1120 #elif defined GNULIB_POSIXCHECK
1121 # undef ftruncate
1122 # if HAVE_RAW_DECL_FTRUNCATE
1123 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
1124 "use gnulib module ftruncate for portability");
1125 # endif
1126 #endif
1127
1128
1129 #if @GNULIB_GETCWD@
1130 /* Get the name of the current working directory, and put it in SIZE bytes
1131 of BUF.
1132 Return BUF if successful, or NULL if the directory couldn't be determined
1133 or SIZE was too small.
1134 See the POSIX:2008 specification
1135 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
1136 Additionally, the gnulib module 'getcwd' or 'getcwd-lgpl' guarantees the
1137 following GNU extension: If BUF is NULL, an array is allocated with
1138 'malloc'; the array is SIZE bytes long, unless SIZE == 0, in which case
1139 it is as big as necessary. */
1140 # if @REPLACE_GETCWD@
1141 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1142 # define getcwd rpl_getcwd
1143 # endif
1144 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size),
1145 _GL_ATTRIBUTE_NODISCARD);
1146 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
1147 # elif defined _WIN32 && !defined __CYGWIN__
1148 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1149 # undef getcwd
1150 # define getcwd _getcwd
1151 # endif
1152 _GL_CXXALIAS_MDA (getcwd, char *, (char *buf, size_t size));
1153 # else
1154 /* Need to cast, because on mingw, the second parameter is
1155 int size. */
1156 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
1157 # endif
1158 _GL_CXXALIASWARN (getcwd);
1159 #elif defined GNULIB_POSIXCHECK
1160 # undef getcwd
1161 # if HAVE_RAW_DECL_GETCWD
1162 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
1163 "use gnulib module getcwd for portability");
1164 # endif
1165 #elif @GNULIB_MDA_GETCWD@
1166 /* On native Windows, map 'getcwd' to '_getcwd', so that -loldnames is not
1167 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1168 platforms by defining GNULIB_NAMESPACE::getcwd always. */
1169 # if defined _WIN32 && !defined __CYGWIN__
1170 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1171 # undef getcwd
1172 # define getcwd _getcwd
1173 # endif
1174 /* Need to cast, because on mingw, the second parameter is either
1175 'int size' or 'size_t size'. */
1176 _GL_CXXALIAS_MDA_CAST (getcwd, char *, (char *buf, size_t size));
1177 # else
1178 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
1179 # endif
1180 _GL_CXXALIASWARN (getcwd);
1181 #endif
1182
1183
1184 #if @GNULIB_GETDOMAINNAME@
1185 /* Return the NIS domain name of the machine.
1186 WARNING! The NIS domain name is unrelated to the fully qualified host name
1187 of the machine. It is also unrelated to email addresses.
1188 WARNING! The NIS domain name is usually the empty string or "(none)" when
1189 not using NIS.
1190
1191 Put up to LEN bytes of the NIS domain name into NAME.
1192 Null terminate it if the name is shorter than LEN.
1193 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
1194 Return 0 if successful, otherwise set errno and return -1. */
1195 # if @REPLACE_GETDOMAINNAME@
1196 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1197 # undef getdomainname
1198 # define getdomainname rpl_getdomainname
1199 # endif
1200 _GL_FUNCDECL_RPL (getdomainname, int,
1201 (char *name, size_t len),
1202 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1203 _GL_CXXALIAS_RPL (getdomainname, int,
1204 (char *name, size_t len));
1205 # else
1206 # if !@HAVE_DECL_GETDOMAINNAME@
1207 _GL_FUNCDECL_SYS (getdomainname, int,
1208 (char *name, size_t len),
1209 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1210 # endif
1211 _GL_CXXALIAS_SYS (getdomainname, int,
1212 (char *name, size_t len));
1213 # endif
1214 # if __GLIBC__ >= 2
1215 _GL_CXXALIASWARN (getdomainname);
1216 # endif
1217 #elif defined GNULIB_POSIXCHECK
1218 # undef getdomainname
1219 # if HAVE_RAW_DECL_GETDOMAINNAME
1220 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
1221 "use gnulib module getdomainname for portability");
1222 # endif
1223 #endif
1224
1225
1226 #if @GNULIB_GETDTABLESIZE@
1227 /* Return the maximum number of file descriptors in the current process.
1228 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
1229 # if @REPLACE_GETDTABLESIZE@
1230 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1231 # undef getdtablesize
1232 # define getdtablesize rpl_getdtablesize
1233 # endif
1234 _GL_FUNCDECL_RPL (getdtablesize, int, (void), );
1235 _GL_CXXALIAS_RPL (getdtablesize, int, (void));
1236 # else
1237 # if !@HAVE_GETDTABLESIZE@
1238 _GL_FUNCDECL_SYS (getdtablesize, int, (void), );
1239 # endif
1240 /* Need to cast, because on AIX, the parameter list is
1241 (...). */
1242 _GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void));
1243 # endif
1244 _GL_CXXALIASWARN (getdtablesize);
1245 #elif defined GNULIB_POSIXCHECK
1246 # undef getdtablesize
1247 # if HAVE_RAW_DECL_GETDTABLESIZE
1248 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
1249 "use gnulib module getdtablesize for portability");
1250 # endif
1251 #endif
1252
1253
1254 #if @GNULIB_GETENTROPY@
1255 /* Fill a buffer with random bytes. */
1256 # if @REPLACE_GETENTROPY@
1257 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1258 # undef getentropy
1259 # define getentropy rpl_getentropy
1260 # endif
1261 _GL_FUNCDECL_RPL (getentropy, int,
1262 (void *buffer, size_t length), _GL_ATTRIBUTE_NODISCARD);
1263 _GL_CXXALIAS_RPL (getentropy, int,
1264 (void *buffer, size_t length));
1265 # else
1266 # if !@HAVE_GETENTROPY@
1267 _GL_FUNCDECL_SYS (getentropy, int,
1268 (void *buffer, size_t length), _GL_ATTRIBUTE_NODISCARD);
1269 # endif
1270 _GL_CXXALIAS_SYS (getentropy, int,
1271 (void *buffer, size_t length));
1272 # endif
1273 # if __GLIBC__ >= 2
1274 _GL_CXXALIASWARN (getentropy);
1275 # endif
1276 #elif defined GNULIB_POSIXCHECK
1277 # undef getentropy
1278 # if HAVE_RAW_DECL_GETENTROPY
1279 _GL_WARN_ON_USE (getentropy, "getentropy is unportable - "
1280 "use gnulib module getentropy for portability");
1281 # endif
1282 #endif
1283
1284
1285 #if @GNULIB_GETGROUPS@
1286 /* Return the supplemental groups that the current process belongs to.
1287 It is unspecified whether the effective group id is in the list.
1288 If N is 0, return the group count; otherwise, N describes how many
1289 entries are available in GROUPS. Return -1 and set errno if N is
1290 not 0 and not large enough. Fails with ENOSYS on some systems. */
1291 # if @REPLACE_GETGROUPS@
1292 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1293 # undef getgroups
1294 # define getgroups rpl_getgroups
1295 # endif
1296 _GL_FUNCDECL_RPL (getgroups, int,
1297 (int n, gid_t *groups), _GL_ATTRIBUTE_NODISCARD);
1298 _GL_CXXALIAS_RPL (getgroups, int,
1299 (int n, gid_t *groups));
1300 # else
1301 # if !@HAVE_GETGROUPS@
1302 _GL_FUNCDECL_SYS (getgroups, int,
1303 (int n, gid_t *groups), _GL_ATTRIBUTE_NODISCARD);
1304 # endif
1305 _GL_CXXALIAS_SYS (getgroups, int,
1306 (int n, gid_t *groups));
1307 # endif
1308 _GL_CXXALIASWARN (getgroups);
1309 #elif defined GNULIB_POSIXCHECK
1310 # undef getgroups
1311 # if HAVE_RAW_DECL_GETGROUPS
1312 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
1313 "use gnulib module getgroups for portability");
1314 # endif
1315 #endif
1316
1317
1318 #if @GNULIB_GETHOSTNAME@
1319 /* Return the standard host name of the machine.
1320 WARNING! The host name may or may not be fully qualified.
1321
1322 Put up to LEN bytes of the host name into NAME.
1323 Null terminate it if the name is shorter than LEN.
1324 If the host name is longer than LEN, set errno = EINVAL and return -1.
1325 Return 0 if successful, otherwise set errno and return -1. */
1326 # if @UNISTD_H_HAVE_WINSOCK2_H@
1327 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1328 # undef gethostname
1329 # define gethostname rpl_gethostname
1330 # endif
1331 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len),
1332 _GL_ARG_NONNULL ((1)));
1333 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
1334 # else
1335 # if !@HAVE_GETHOSTNAME@
1336 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len),
1337 _GL_ARG_NONNULL ((1)));
1338 # endif
1339 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
1340 parameter is
1341 int len. */
1342 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
1343 # endif
1344 _GL_CXXALIASWARN (gethostname);
1345 #elif @UNISTD_H_HAVE_WINSOCK2_H@
1346 # if !GNULIB_GETHOSTNAME
1347 # undef gethostname
1348 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
1349 # endif
1350 #elif defined GNULIB_POSIXCHECK
1351 # undef gethostname
1352 # if HAVE_RAW_DECL_GETHOSTNAME
1353 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
1354 "use gnulib module gethostname for portability");
1355 # endif
1356 #endif
1357
1358
1359 #if @GNULIB_GETLOGIN@
1360 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
1361 returns NULL with errno set.
1362
1363 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1364
1365 Most programs don't need to use this function, because the information is
1366 available through environment variables:
1367 ${LOGNAME-$USER} on Unix platforms,
1368 $USERNAME on native Windows platforms.
1369 */
1370 # if @REPLACE_GETLOGIN@
1371 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1372 # define getlogin rpl_getlogin
1373 # endif
1374 _GL_FUNCDECL_RPL (getlogin, char *, (void), );
1375 _GL_CXXALIAS_RPL (getlogin, char *, (void));
1376 # else
1377 # if !@HAVE_DECL_GETLOGIN@
1378 _GL_FUNCDECL_SYS (getlogin, char *, (void), );
1379 # endif
1380 _GL_CXXALIAS_SYS (getlogin, char *, (void));
1381 # endif
1382 # if __GLIBC__ >= 2
1383 _GL_CXXALIASWARN (getlogin);
1384 # endif
1385 #elif defined GNULIB_POSIXCHECK
1386 # undef getlogin
1387 # if HAVE_RAW_DECL_GETLOGIN
1388 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
1389 "use gnulib module getlogin for portability");
1390 # endif
1391 #endif
1392
1393
1394 #if @GNULIB_GETLOGIN_R@
1395 /* Copies the user's login name to NAME.
1396 The array pointed to by NAME has room for SIZE bytes.
1397
1398 Returns 0 if successful. Upon error, an error number is returned, or -1 in
1399 the case that the login name cannot be found but no specific error is
1400 provided (this case is hopefully rare but is left open by the POSIX spec).
1401
1402 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1403
1404 Most programs don't need to use this function, because the information is
1405 available through environment variables:
1406 ${LOGNAME-$USER} on Unix platforms,
1407 $USERNAME on native Windows platforms.
1408 */
1409 # if @REPLACE_GETLOGIN_R@
1410 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1411 # define getlogin_r rpl_getlogin_r
1412 # endif
1413 _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size),
1414 _GL_ARG_NONNULL ((1)));
1415 _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
1416 # else
1417 # if !@HAVE_DECL_GETLOGIN_R@
1418 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size),
1419 _GL_ARG_NONNULL ((1)));
1420 # endif
1421 /* Need to cast, because on Solaris 10 systems, the second argument is
1422 int size. */
1423 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
1424 # endif
1425 # if __GLIBC__ >= 2
1426 _GL_CXXALIASWARN (getlogin_r);
1427 # endif
1428 #elif defined GNULIB_POSIXCHECK
1429 # undef getlogin_r
1430 # if HAVE_RAW_DECL_GETLOGIN_R
1431 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
1432 "use gnulib module getlogin_r for portability");
1433 # endif
1434 #endif
1435
1436
1437 #if @GNULIB_GETPAGESIZE@
1438 # if @REPLACE_GETPAGESIZE@
1439 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1440 # define getpagesize rpl_getpagesize
1441 # endif
1442 _GL_FUNCDECL_RPL (getpagesize, int, (void), );
1443 _GL_CXXALIAS_RPL (getpagesize, int, (void));
1444 # else
1445 /* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
1446 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */
1447 # if defined __hpux
1448 _GL_FUNCDECL_SYS (getpagesize, int, (void), );
1449 # endif
1450 # if !@HAVE_GETPAGESIZE@
1451 # if !defined getpagesize
1452 /* This is for POSIX systems. */
1453 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
1454 # if ! (defined __VMS && __VMS_VER < 70000000)
1455 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
1456 # endif
1457 # endif
1458 /* This is for older VMS. */
1459 # if !defined _gl_getpagesize && defined __VMS
1460 # ifdef __ALPHA
1461 # define _gl_getpagesize() 8192
1462 # else
1463 # define _gl_getpagesize() 512
1464 # endif
1465 # endif
1466 /* This is for BeOS. */
1467 # if !defined _gl_getpagesize && @HAVE_OS_H@
1468 # include <OS.h>
1469 # if defined B_PAGE_SIZE
1470 # define _gl_getpagesize() B_PAGE_SIZE
1471 # endif
1472 # endif
1473 /* This is for AmigaOS4.0. */
1474 # if !defined _gl_getpagesize && defined __amigaos4__
1475 # define _gl_getpagesize() 2048
1476 # endif
1477 /* This is for older Unix systems. */
1478 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
1479 # include <sys/param.h>
1480 # ifdef EXEC_PAGESIZE
1481 # define _gl_getpagesize() EXEC_PAGESIZE
1482 # else
1483 # ifdef NBPG
1484 # ifndef CLSIZE
1485 # define CLSIZE 1
1486 # endif
1487 # define _gl_getpagesize() (NBPG * CLSIZE)
1488 # else
1489 # ifdef NBPC
1490 # define _gl_getpagesize() NBPC
1491 # endif
1492 # endif
1493 # endif
1494 # endif
1495 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1496 # define getpagesize() _gl_getpagesize ()
1497 # else
1498 # if !GNULIB_defined_getpagesize_function
1499 _GL_GETPAGESIZE_INLINE int
1500 getpagesize ()
1501 {
1502 return _gl_getpagesize ();
1503 }
1504 # define GNULIB_defined_getpagesize_function 1
1505 # endif
1506 # endif
1507 # endif
1508 # endif
1509 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
1510 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
1511 # endif
1512 # if @HAVE_DECL_GETPAGESIZE@
1513 _GL_CXXALIASWARN (getpagesize);
1514 # endif
1515 #elif defined GNULIB_POSIXCHECK
1516 # undef getpagesize
1517 # if HAVE_RAW_DECL_GETPAGESIZE
1518 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
1519 "use gnulib module getpagesize for portability");
1520 # endif
1521 #endif
1522
1523
1524 #if @GNULIB_GETPASS@
1525 /* Function getpass() from module 'getpass':
1526 Read a password from /dev/tty or stdin.
1527 Function getpass() from module 'getpass-gnu':
1528 Read a password of arbitrary length from /dev/tty or stdin. */
1529 # if (@GNULIB_GETPASS@ && @REPLACE_GETPASS@) \
1530 || (@GNULIB_GETPASS_GNU@ && @REPLACE_GETPASS_FOR_GETPASS_GNU@)
1531 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1532 # undef getpass
1533 # define getpass rpl_getpass
1534 # endif
1535 _GL_FUNCDECL_RPL (getpass, char *, (const char *prompt),
1536 _GL_ARG_NONNULL ((1)));
1537 _GL_CXXALIAS_RPL (getpass, char *, (const char *prompt));
1538 # else
1539 # if !@HAVE_GETPASS@
1540 _GL_FUNCDECL_SYS (getpass, char *, (const char *prompt),
1541 _GL_ARG_NONNULL ((1)));
1542 # endif
1543 _GL_CXXALIAS_SYS (getpass, char *, (const char *prompt));
1544 # endif
1545 _GL_CXXALIASWARN (getpass);
1546 #elif defined GNULIB_POSIXCHECK
1547 # undef getpass
1548 # if HAVE_RAW_DECL_GETPASS
1549 _GL_WARN_ON_USE (getpass, "getpass is unportable - "
1550 "use gnulib module getpass or getpass-gnu for portability");
1551 # endif
1552 #endif
1553
1554
1555 #if @GNULIB_MDA_GETPID@
1556 /* On native Windows, map 'getpid' to '_getpid', so that -loldnames is not
1557 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1558 platforms by defining GNULIB_NAMESPACE::getpid always. */
1559 # if defined _WIN32 && !defined __CYGWIN__
1560 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1561 # undef getpid
1562 # define getpid _getpid
1563 # endif
1564 _GL_CXXALIAS_MDA (getpid, int, (void));
1565 # else
1566 _GL_CXXALIAS_SYS (getpid, pid_t, (void));
1567 # endif
1568 _GL_CXXALIASWARN (getpid);
1569 #endif
1570
1571
1572 #if @GNULIB_GETUSERSHELL@
1573 # if @REPLACE_GETUSERSHELL@
1574 /* Return the next valid login shell on the system, or NULL when the end of
1575 the list has been reached. */
1576 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1577 # undef getusershell
1578 # define getusershell rpl_getusershell
1579 # endif
1580 _GL_FUNCDECL_RPL (getusershell, char *, (void), );
1581 _GL_CXXALIAS_RPL (getusershell, char *, (void));
1582 # else
1583 # if !@HAVE_DECL_GETUSERSHELL@
1584 _GL_FUNCDECL_SYS (getusershell, char *, (void), );
1585 # endif
1586 _GL_CXXALIAS_SYS (getusershell, char *, (void));
1587 # endif
1588 _GL_CXXALIASWARN (getusershell);
1589 #elif defined GNULIB_POSIXCHECK
1590 # undef getusershell
1591 # if HAVE_RAW_DECL_GETUSERSHELL
1592 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
1593 "use gnulib module getusershell for portability");
1594 # endif
1595 #endif
1596
1597 #if @GNULIB_GETUSERSHELL@
1598 /* Rewind to pointer that is advanced at each getusershell() call. */
1599 # if @REPLACE_GETUSERSHELL@
1600 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1601 # undef setusershell
1602 # define setusershell rpl_setusershell
1603 # endif
1604 _GL_FUNCDECL_RPL (setusershell, void, (void), );
1605 _GL_CXXALIAS_RPL (setusershell, void, (void));
1606 # else
1607 # if !@HAVE_DECL_GETUSERSHELL@
1608 _GL_FUNCDECL_SYS (setusershell, void, (void), );
1609 # endif
1610 _GL_CXXALIAS_SYS (setusershell, void, (void));
1611 # endif
1612 _GL_CXXALIASWARN (setusershell);
1613 #elif defined GNULIB_POSIXCHECK
1614 # undef setusershell
1615 # if HAVE_RAW_DECL_SETUSERSHELL
1616 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
1617 "use gnulib module getusershell for portability");
1618 # endif
1619 #endif
1620
1621 #if @GNULIB_GETUSERSHELL@
1622 /* Free the pointer that is advanced at each getusershell() call and
1623 associated resources. */
1624 # if @REPLACE_GETUSERSHELL@
1625 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1626 # undef endusershell
1627 # define endusershell rpl_endusershell
1628 # endif
1629 _GL_FUNCDECL_RPL (endusershell, void, (void), );
1630 _GL_CXXALIAS_RPL (endusershell, void, (void));
1631 # else
1632 # if !@HAVE_DECL_GETUSERSHELL@
1633 _GL_FUNCDECL_SYS (endusershell, void, (void), );
1634 # endif
1635 _GL_CXXALIAS_SYS (endusershell, void, (void));
1636 # endif
1637 _GL_CXXALIASWARN (endusershell);
1638 #elif defined GNULIB_POSIXCHECK
1639 # undef endusershell
1640 # if HAVE_RAW_DECL_ENDUSERSHELL
1641 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
1642 "use gnulib module getusershell for portability");
1643 # endif
1644 #endif
1645
1646
1647 #if @GNULIB_GROUP_MEMBER@
1648 /* Determine whether group id is in calling user's group list. */
1649 # if !@HAVE_GROUP_MEMBER@
1650 _GL_FUNCDECL_SYS (group_member, int, (gid_t gid), );
1651 # endif
1652 _GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
1653 _GL_CXXALIASWARN (group_member);
1654 #elif defined GNULIB_POSIXCHECK
1655 # undef group_member
1656 # if HAVE_RAW_DECL_GROUP_MEMBER
1657 _GL_WARN_ON_USE (group_member, "group_member is unportable - "
1658 "use gnulib module group-member for portability");
1659 # endif
1660 #endif
1661
1662
1663 #if @GNULIB_ISATTY@
1664 # if @REPLACE_ISATTY@
1665 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1666 # undef isatty
1667 # define isatty rpl_isatty
1668 # endif
1669 # define GNULIB_defined_isatty 1
1670 _GL_FUNCDECL_RPL (isatty, int, (int fd), );
1671 _GL_CXXALIAS_RPL (isatty, int, (int fd));
1672 # elif defined _WIN32 && !defined __CYGWIN__
1673 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1674 # undef isatty
1675 # define isatty _isatty
1676 # endif
1677 _GL_CXXALIAS_MDA (isatty, int, (int fd));
1678 # else
1679 _GL_CXXALIAS_SYS (isatty, int, (int fd));
1680 # endif
1681 _GL_CXXALIASWARN (isatty);
1682 #elif defined GNULIB_POSIXCHECK
1683 # undef isatty
1684 # if HAVE_RAW_DECL_ISATTY
1685 _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
1686 "use gnulib module isatty for portability");
1687 # endif
1688 #elif @GNULIB_MDA_ISATTY@
1689 /* On native Windows, map 'isatty' to '_isatty', so that -loldnames is not
1690 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1691 platforms by defining GNULIB_NAMESPACE::isatty always. */
1692 # if defined _WIN32 && !defined __CYGWIN__
1693 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1694 # undef isatty
1695 # define isatty _isatty
1696 # endif
1697 _GL_CXXALIAS_MDA (isatty, int, (int fd));
1698 # else
1699 _GL_CXXALIAS_SYS (isatty, int, (int fd));
1700 # endif
1701 _GL_CXXALIASWARN (isatty);
1702 #endif
1703
1704
1705 #if @GNULIB_LCHOWN@
1706 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1707 to GID (if GID is not -1). Do not follow symbolic links.
1708 Return 0 if successful, otherwise -1 and errno set.
1709 See the POSIX:2008 specification
1710 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1711 # if @REPLACE_LCHOWN@
1712 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1713 # undef lchown
1714 # define lchown rpl_lchown
1715 # endif
1716 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group),
1717 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1718 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
1719 # else
1720 # if !@HAVE_LCHOWN@
1721 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group),
1722 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1723 # endif
1724 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
1725 # endif
1726 _GL_CXXALIASWARN (lchown);
1727 #elif defined GNULIB_POSIXCHECK
1728 # undef lchown
1729 # if HAVE_RAW_DECL_LCHOWN
1730 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1731 "use gnulib module lchown for portability");
1732 # endif
1733 #endif
1734
1735
1736 #if @GNULIB_LINK@
1737 /* Create a new hard link for an existing file.
1738 Return 0 if successful, otherwise -1 and errno set.
1739 See POSIX:2008 specification
1740 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1741 # if @REPLACE_LINK@
1742 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1743 # define link rpl_link
1744 # endif
1745 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2),
1746 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
1747 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
1748 # else
1749 # if !@HAVE_LINK@
1750 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2),
1751 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
1752 # endif
1753 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
1754 # endif
1755 _GL_CXXALIASWARN (link);
1756 #elif defined GNULIB_POSIXCHECK
1757 # undef link
1758 # if HAVE_RAW_DECL_LINK
1759 _GL_WARN_ON_USE (link, "link is unportable - "
1760 "use gnulib module link for portability");
1761 # endif
1762 #endif
1763
1764
1765 #if @GNULIB_LINKAT@
1766 /* Create a new hard link for an existing file, relative to two
1767 directories. FLAG controls whether symlinks are followed.
1768 Return 0 if successful, otherwise -1 and errno set. */
1769 # if @REPLACE_LINKAT@
1770 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1771 # undef linkat
1772 # define linkat rpl_linkat
1773 # endif
1774 _GL_FUNCDECL_RPL (linkat, int,
1775 (int fd1, const char *path1, int fd2, const char *path2,
1776 int flag),
1777 _GL_ARG_NONNULL ((2, 4)) _GL_ATTRIBUTE_NODISCARD);
1778 _GL_CXXALIAS_RPL (linkat, int,
1779 (int fd1, const char *path1, int fd2, const char *path2,
1780 int flag));
1781 # else
1782 # if !@HAVE_LINKAT@
1783 _GL_FUNCDECL_SYS (linkat, int,
1784 (int fd1, const char *path1, int fd2, const char *path2,
1785 int flag),
1786 _GL_ARG_NONNULL ((2, 4)) _GL_ATTRIBUTE_NODISCARD);
1787 # endif
1788 _GL_CXXALIAS_SYS (linkat, int,
1789 (int fd1, const char *path1, int fd2, const char *path2,
1790 int flag));
1791 # endif
1792 # if __GLIBC__ >= 2
1793 _GL_CXXALIASWARN (linkat);
1794 # endif
1795 #elif defined GNULIB_POSIXCHECK
1796 # undef linkat
1797 # if HAVE_RAW_DECL_LINKAT
1798 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1799 "use gnulib module linkat for portability");
1800 # endif
1801 #endif
1802
1803
1804 #if @GNULIB_LSEEK@
1805 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1806 Return the new offset if successful, otherwise -1 and errno set.
1807 See the POSIX:2008 specification
1808 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1809 # if @REPLACE_LSEEK@
1810 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1811 # define lseek rpl_lseek
1812 # endif
1813 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence), );
1814 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1815 # elif defined _WIN32 && !defined __CYGWIN__
1816 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1817 # undef lseek
1818 # define lseek _lseek
1819 # endif
1820 _GL_CXXALIAS_MDA (lseek, off_t, (int fd, off_t offset, int whence));
1821 # else
1822 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1823 # endif
1824 _GL_CXXALIASWARN (lseek);
1825 #elif defined GNULIB_POSIXCHECK
1826 # undef lseek
1827 # if HAVE_RAW_DECL_LSEEK
1828 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1829 "systems - use gnulib module lseek for portability");
1830 # endif
1831 #elif @GNULIB_MDA_LSEEK@
1832 /* On native Windows, map 'lseek' to '_lseek', so that -loldnames is not
1833 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1834 platforms by defining GNULIB_NAMESPACE::lseek always. */
1835 # if defined _WIN32 && !defined __CYGWIN__
1836 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1837 # undef lseek
1838 # define lseek _lseek
1839 # endif
1840 _GL_CXXALIAS_MDA (lseek, long, (int fd, long offset, int whence));
1841 # else
1842 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1843 # endif
1844 _GL_CXXALIASWARN (lseek);
1845 #endif
1846
1847
1848 #if @GNULIB_PIPE@
1849 /* Create a pipe, defaulting to O_BINARY mode.
1850 Store the read-end as fd[0] and the write-end as fd[1].
1851 Return 0 upon success, or -1 with errno set upon failure. */
1852 # if !@HAVE_PIPE@
1853 _GL_FUNCDECL_SYS (pipe, int, (int fd[2]),
1854 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1855 # endif
1856 _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1857 _GL_CXXALIASWARN (pipe);
1858 #elif defined GNULIB_POSIXCHECK
1859 # undef pipe
1860 # if HAVE_RAW_DECL_PIPE
1861 _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1862 "use gnulib module pipe-posix for portability");
1863 # endif
1864 #endif
1865
1866
1867 #if @GNULIB_PIPE2@
1868 /* Create a pipe, applying the given flags when opening the read-end of the
1869 pipe and the write-end of the pipe.
1870 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1871 and O_TEXT, O_BINARY (defined in "binary-io.h").
1872 Store the read-end as fd[0] and the write-end as fd[1].
1873 Return 0 upon success, or -1 with errno set upon failure.
1874 See also the Linux man page at
1875 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1876 # if @REPLACE_PIPE2@
1877 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1878 # undef pipe2
1879 # define pipe2 rpl_pipe2
1880 # endif
1881 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags),
1882 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1883 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1884 # else
1885 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags),
1886 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1887 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1888 # endif
1889 # if __GLIBC__ >= 2
1890 _GL_CXXALIASWARN (pipe2);
1891 # endif
1892 #elif defined GNULIB_POSIXCHECK
1893 # undef pipe2
1894 # if HAVE_RAW_DECL_PIPE2
1895 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1896 "use gnulib module pipe2 for portability");
1897 # endif
1898 #endif
1899
1900
1901 #if @GNULIB_PREAD@
1902 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1903 Return the number of bytes placed into BUF if successful, otherwise
1904 set errno and return -1. 0 indicates EOF.
1905 See the POSIX:2008 specification
1906 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1907 # if @REPLACE_PREAD@
1908 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1909 # undef pread
1910 # define pread rpl_pread
1911 # endif
1912 _GL_FUNCDECL_RPL (pread, ssize_t,
1913 (int fd, void *buf, size_t bufsize, off_t offset),
1914 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
1915 _GL_CXXALIAS_RPL (pread, ssize_t,
1916 (int fd, void *buf, size_t bufsize, off_t offset));
1917 # else
1918 # if !@HAVE_PREAD@
1919 _GL_FUNCDECL_SYS (pread, ssize_t,
1920 (int fd, void *buf, size_t bufsize, off_t offset),
1921 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
1922 # endif
1923 _GL_CXXALIAS_SYS (pread, ssize_t,
1924 (int fd, void *buf, size_t bufsize, off_t offset));
1925 # endif
1926 # if __GLIBC__ >= 2
1927 _GL_CXXALIASWARN (pread);
1928 # endif
1929 #elif defined GNULIB_POSIXCHECK
1930 # undef pread
1931 # if HAVE_RAW_DECL_PREAD
1932 _GL_WARN_ON_USE (pread, "pread is unportable - "
1933 "use gnulib module pread for portability");
1934 # endif
1935 #endif
1936
1937
1938 #if @GNULIB_PWRITE@
1939 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1940 Return the number of bytes written if successful, otherwise
1941 set errno and return -1. 0 indicates nothing written. See the
1942 POSIX:2008 specification
1943 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1944 # if @REPLACE_PWRITE@
1945 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1946 # undef pwrite
1947 # define pwrite rpl_pwrite
1948 # endif
1949 _GL_FUNCDECL_RPL (pwrite, ssize_t,
1950 (int fd, const void *buf, size_t bufsize, off_t offset),
1951 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
1952 _GL_CXXALIAS_RPL (pwrite, ssize_t,
1953 (int fd, const void *buf, size_t bufsize, off_t offset));
1954 # else
1955 # if !@HAVE_PWRITE@
1956 _GL_FUNCDECL_SYS (pwrite, ssize_t,
1957 (int fd, const void *buf, size_t bufsize, off_t offset),
1958 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
1959 # endif
1960 _GL_CXXALIAS_SYS (pwrite, ssize_t,
1961 (int fd, const void *buf, size_t bufsize, off_t offset));
1962 # endif
1963 # if __GLIBC__ >= 2
1964 _GL_CXXALIASWARN (pwrite);
1965 # endif
1966 #elif defined GNULIB_POSIXCHECK
1967 # undef pwrite
1968 # if HAVE_RAW_DECL_PWRITE
1969 _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1970 "use gnulib module pwrite for portability");
1971 # endif
1972 #endif
1973
1974
1975 #if @GNULIB_READ@
1976 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1977 at BUF. See the POSIX:2008 specification
1978 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1979 # if @REPLACE_READ@
1980 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1981 # undef read
1982 # define read rpl_read
1983 # endif
1984
1985 _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count),
1986 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
1987 _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1988 # elif defined _WIN32 && !defined __CYGWIN__
1989 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1990 # undef read
1991 # define read _read
1992 # endif
1993 _GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, size_t count));
1994 # else
1995 _GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1996 # endif
1997 _GL_CXXALIASWARN (read);
1998 #elif @GNULIB_MDA_READ@
1999 /* On native Windows, map 'read' to '_read', so that -loldnames is not
2000 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2001 platforms by defining GNULIB_NAMESPACE::read always. */
2002 # if defined _WIN32 && !defined __CYGWIN__
2003 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2004 # undef read
2005 # define read _read
2006 # endif
2007 _GL_CXXALIAS_MDA_CAST (read, ssize_t, (int fd, void *buf, unsigned int count));
2008 # else
2009 _GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
2010 # endif
2011 _GL_CXXALIASWARN (read);
2012 #endif
2013
2014
2015 #if @GNULIB_READLINK@
2016 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
2017 bytes of it into BUF. Return the number of bytes placed into BUF if
2018 successful, otherwise -1 and errno set.
2019 See the POSIX:2008 specification
2020 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
2021 # if @REPLACE_READLINK@
2022 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2023 # define readlink rpl_readlink
2024 # endif
2025 _GL_FUNCDECL_RPL (readlink, ssize_t,
2026 (const char *restrict file,
2027 char *restrict buf, size_t bufsize),
2028 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
2029 _GL_CXXALIAS_RPL (readlink, ssize_t,
2030 (const char *restrict file,
2031 char *restrict buf, size_t bufsize));
2032 # else
2033 # if !@HAVE_READLINK@
2034 _GL_FUNCDECL_SYS (readlink, ssize_t,
2035 (const char *restrict file,
2036 char *restrict buf, size_t bufsize),
2037 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
2038 # endif
2039 _GL_CXXALIAS_SYS (readlink, ssize_t,
2040 (const char *restrict file,
2041 char *restrict buf, size_t bufsize));
2042 # endif
2043 _GL_CXXALIASWARN (readlink);
2044 #elif defined GNULIB_POSIXCHECK
2045 # undef readlink
2046 # if HAVE_RAW_DECL_READLINK
2047 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
2048 "use gnulib module readlink for portability");
2049 # endif
2050 #endif
2051
2052
2053 #if @GNULIB_READLINKAT@
2054 # if @REPLACE_READLINKAT@
2055 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2056 # define readlinkat rpl_readlinkat
2057 # endif
2058 _GL_FUNCDECL_RPL (readlinkat, ssize_t,
2059 (int fd, char const *restrict file,
2060 char *restrict buf, size_t len),
2061 _GL_ARG_NONNULL ((2, 3)) _GL_ATTRIBUTE_NODISCARD);
2062 _GL_CXXALIAS_RPL (readlinkat, ssize_t,
2063 (int fd, char const *restrict file,
2064 char *restrict buf, size_t len));
2065 # else
2066 # if !@HAVE_READLINKAT@
2067 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
2068 (int fd, char const *restrict file,
2069 char *restrict buf, size_t len),
2070 _GL_ARG_NONNULL ((2, 3)) _GL_ATTRIBUTE_NODISCARD);
2071 # endif
2072 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
2073 (int fd, char const *restrict file,
2074 char *restrict buf, size_t len));
2075 # endif
2076 # if __GLIBC__ >= 2
2077 _GL_CXXALIASWARN (readlinkat);
2078 # endif
2079 #elif defined GNULIB_POSIXCHECK
2080 # undef readlinkat
2081 # if HAVE_RAW_DECL_READLINKAT
2082 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
2083 "use gnulib module readlinkat for portability");
2084 # endif
2085 #endif
2086
2087
2088 #if @GNULIB_RMDIR@
2089 /* Remove the directory DIR. */
2090 # if @REPLACE_RMDIR@
2091 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2092 # define rmdir rpl_rmdir
2093 # endif
2094 _GL_FUNCDECL_RPL (rmdir, int, (char const *name), _GL_ARG_NONNULL ((1)));
2095 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
2096 # elif defined _WIN32 && !defined __CYGWIN__
2097 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2098 # undef rmdir
2099 # define rmdir _rmdir
2100 # endif
2101 _GL_CXXALIAS_MDA (rmdir, int, (char const *name));
2102 # else
2103 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
2104 # endif
2105 _GL_CXXALIASWARN (rmdir);
2106 #elif defined GNULIB_POSIXCHECK
2107 # undef rmdir
2108 # if HAVE_RAW_DECL_RMDIR
2109 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
2110 "use gnulib module rmdir for portability");
2111 # endif
2112 #elif @GNULIB_MDA_RMDIR@
2113 /* On native Windows, map 'rmdir' to '_rmdir', so that -loldnames is not
2114 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2115 platforms by defining GNULIB_NAMESPACE::rmdir always. */
2116 # if defined _WIN32 && !defined __CYGWIN__
2117 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2118 # undef rmdir
2119 # define rmdir _rmdir
2120 # endif
2121 _GL_CXXALIAS_MDA (rmdir, int, (char const *name));
2122 # else
2123 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
2124 # endif
2125 _GL_CXXALIASWARN (rmdir);
2126 #endif
2127
2128
2129 #if @GNULIB_SETHOSTNAME@
2130 /* Set the host name of the machine.
2131 The host name may or may not be fully qualified.
2132
2133 Put LEN bytes of NAME into the host name.
2134 Return 0 if successful, otherwise, set errno and return -1.
2135
2136 Platforms with no ability to set the hostname return -1 and set
2137 errno = ENOSYS. */
2138 # if @REPLACE_SETHOSTNAME@
2139 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2140 # undef sethostname
2141 # define sethostname rpl_sethostname
2142 # endif
2143 _GL_FUNCDECL_RPL (sethostname, int,
2144 (const char *name, size_t len),
2145 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
2146 _GL_CXXALIAS_RPL (sethostname, int,
2147 (const char *name, size_t len));
2148 # else
2149 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
2150 _GL_FUNCDECL_SYS (sethostname, int,
2151 (const char *name, size_t len),
2152 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
2153 # endif
2154 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
2155 and FreeBSD 6.4 the second parameter is int. On Solaris 11
2156 2011-10, the first parameter is not const. */
2157 _GL_CXXALIAS_SYS_CAST (sethostname, int,
2158 (const char *name, size_t len));
2159 # endif
2160 # if __GLIBC__ >= 2
2161 _GL_CXXALIASWARN (sethostname);
2162 # endif
2163 #elif defined GNULIB_POSIXCHECK
2164 # undef sethostname
2165 # if HAVE_RAW_DECL_SETHOSTNAME
2166 _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
2167 "use gnulib module sethostname for portability");
2168 # endif
2169 #endif
2170
2171
2172 #if @GNULIB_SLEEP@
2173 /* Pause the execution of the current thread for N seconds.
2174 Returns the number of seconds left to sleep.
2175 See the POSIX:2008 specification
2176 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
2177 # if @REPLACE_SLEEP@
2178 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2179 # undef sleep
2180 # define sleep rpl_sleep
2181 # endif
2182 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n), );
2183 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
2184 # else
2185 # if !@HAVE_SLEEP@
2186 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n), );
2187 # endif
2188 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
2189 # endif
2190 _GL_CXXALIASWARN (sleep);
2191 #elif defined GNULIB_POSIXCHECK
2192 # undef sleep
2193 # if HAVE_RAW_DECL_SLEEP
2194 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
2195 "use gnulib module sleep for portability");
2196 # endif
2197 #endif
2198
2199
2200 #if @GNULIB_MDA_SWAB@
2201 /* On native Windows, map 'swab' to '_swab', so that -loldnames is not
2202 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2203 platforms by defining GNULIB_NAMESPACE::swab always. */
2204 # if defined _WIN32 && !defined __CYGWIN__
2205 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2206 # undef swab
2207 # define swab _swab
2208 # endif
2209 /* Need to cast, because in old mingw the arguments are
2210 (const char *from, char *to, size_t n). */
2211 _GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n));
2212 # else
2213 # if defined __hpux /* HP-UX */
2214 _GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
2215 # elif defined __sun && (defined __SunOS_5_10 || defined __XOPEN_OR_POSIX) && !defined _XPG4 /* Solaris */
2216 _GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
2217 # else
2218 _GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));
2219 # endif
2220 # endif
2221 _GL_CXXALIASWARN (swab);
2222 #endif
2223
2224
2225 #if @GNULIB_SYMLINK@
2226 # if @REPLACE_SYMLINK@
2227 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2228 # undef symlink
2229 # define symlink rpl_symlink
2230 # endif
2231 _GL_FUNCDECL_RPL (symlink, int,
2232 (char const *contents, char const *file),
2233 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
2234 _GL_CXXALIAS_RPL (symlink, int,
2235 (char const *contents, char const *file));
2236 # else
2237 # if !@HAVE_SYMLINK@
2238 _GL_FUNCDECL_SYS (symlink, int,
2239 (char const *contents, char const *file),
2240 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
2241 # endif
2242 _GL_CXXALIAS_SYS (symlink, int,
2243 (char const *contents, char const *file));
2244 # endif
2245 _GL_CXXALIASWARN (symlink);
2246 #elif defined GNULIB_POSIXCHECK
2247 # undef symlink
2248 # if HAVE_RAW_DECL_SYMLINK
2249 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
2250 "use gnulib module symlink for portability");
2251 # endif
2252 #endif
2253
2254
2255 #if @GNULIB_SYMLINKAT@
2256 # if @REPLACE_SYMLINKAT@
2257 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2258 # undef symlinkat
2259 # define symlinkat rpl_symlinkat
2260 # endif
2261 _GL_FUNCDECL_RPL (symlinkat, int,
2262 (char const *contents, int fd, char const *file),
2263 _GL_ARG_NONNULL ((1, 3)) _GL_ATTRIBUTE_NODISCARD);
2264 _GL_CXXALIAS_RPL (symlinkat, int,
2265 (char const *contents, int fd, char const *file));
2266 # else
2267 # if !@HAVE_SYMLINKAT@
2268 _GL_FUNCDECL_SYS (symlinkat, int,
2269 (char const *contents, int fd, char const *file),
2270 _GL_ARG_NONNULL ((1, 3)) _GL_ATTRIBUTE_NODISCARD);
2271 # endif
2272 _GL_CXXALIAS_SYS (symlinkat, int,
2273 (char const *contents, int fd, char const *file));
2274 # endif
2275 # if __GLIBC__ >= 2
2276 _GL_CXXALIASWARN (symlinkat);
2277 # endif
2278 #elif defined GNULIB_POSIXCHECK
2279 # undef symlinkat
2280 # if HAVE_RAW_DECL_SYMLINKAT
2281 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
2282 "use gnulib module symlinkat for portability");
2283 # endif
2284 #endif
2285
2286
2287 #if @GNULIB_TRUNCATE@
2288 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
2289 Return 0 if successful, otherwise -1 and errno set.
2290 See the POSIX:2008 specification
2291 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
2292 # if @REPLACE_TRUNCATE@
2293 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2294 # undef truncate
2295 # define truncate rpl_truncate
2296 # endif
2297 _GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length),
2298 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
2299 _GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
2300 # else
2301 # if !@HAVE_DECL_TRUNCATE@
2302 _GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length),
2303 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
2304 # endif
2305 _GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
2306 # endif
2307 # if __GLIBC__ >= 2
2308 _GL_CXXALIASWARN (truncate);
2309 # endif
2310 #elif defined GNULIB_POSIXCHECK
2311 # undef truncate
2312 # if HAVE_RAW_DECL_TRUNCATE
2313 _GL_WARN_ON_USE (truncate, "truncate is unportable - "
2314 "use gnulib module truncate for portability");
2315 # endif
2316 #endif
2317
2318
2319 #if @GNULIB_TTYNAME_R@
2320 /* Store at most BUFLEN characters of the pathname of the terminal FD is
2321 open on in BUF. Return 0 on success, otherwise an error number. */
2322 # if @REPLACE_TTYNAME_R@
2323 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2324 # undef ttyname_r
2325 # define ttyname_r rpl_ttyname_r
2326 # endif
2327 _GL_FUNCDECL_RPL (ttyname_r, int,
2328 (int fd, char *buf, size_t buflen),
2329 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
2330 _GL_CXXALIAS_RPL (ttyname_r, int,
2331 (int fd, char *buf, size_t buflen));
2332 # else
2333 # if !@HAVE_DECL_TTYNAME_R@
2334 _GL_FUNCDECL_SYS (ttyname_r, int,
2335 (int fd, char *buf, size_t buflen),
2336 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
2337 # endif
2338 _GL_CXXALIAS_SYS (ttyname_r, int,
2339 (int fd, char *buf, size_t buflen));
2340 # endif
2341 # if __GLIBC__ >= 2
2342 _GL_CXXALIASWARN (ttyname_r);
2343 # endif
2344 #elif defined GNULIB_POSIXCHECK
2345 # undef ttyname_r
2346 # if HAVE_RAW_DECL_TTYNAME_R
2347 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
2348 "use gnulib module ttyname_r for portability");
2349 # endif
2350 #endif
2351
2352
2353 #if @GNULIB_UNLINK@
2354 # if @REPLACE_UNLINK@
2355 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2356 # undef unlink
2357 # define unlink rpl_unlink
2358 # endif
2359 _GL_FUNCDECL_RPL (unlink, int, (char const *file), _GL_ARG_NONNULL ((1)));
2360 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
2361 # elif defined _WIN32 && !defined __CYGWIN__
2362 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2363 # undef unlink
2364 # define unlink _unlink
2365 # endif
2366 _GL_CXXALIAS_MDA (unlink, int, (char const *file));
2367 # else
2368 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
2369 # endif
2370 _GL_CXXALIASWARN (unlink);
2371 #elif defined GNULIB_POSIXCHECK
2372 # undef unlink
2373 # if HAVE_RAW_DECL_UNLINK
2374 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
2375 "use gnulib module unlink for portability");
2376 # endif
2377 #elif @GNULIB_MDA_UNLINK@
2378 /* On native Windows, map 'unlink' to '_unlink', so that -loldnames is not
2379 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2380 platforms by defining GNULIB_NAMESPACE::unlink always. */
2381 # if defined _WIN32 && !defined __CYGWIN__
2382 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2383 # undef unlink
2384 # define unlink _unlink
2385 # endif
2386 _GL_CXXALIAS_MDA (unlink, int, (char const *file));
2387 # else
2388 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
2389 # endif
2390 _GL_CXXALIASWARN (unlink);
2391 #endif
2392
2393
2394 #if @GNULIB_UNLINKAT@
2395 # if @REPLACE_UNLINKAT@
2396 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2397 # undef unlinkat
2398 # define unlinkat rpl_unlinkat
2399 # endif
2400 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag),
2401 _GL_ARG_NONNULL ((2)));
2402 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
2403 # else
2404 # if !@HAVE_UNLINKAT@
2405 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag),
2406 _GL_ARG_NONNULL ((2)));
2407 # endif
2408 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
2409 # endif
2410 _GL_CXXALIASWARN (unlinkat);
2411 #elif defined GNULIB_POSIXCHECK
2412 # undef unlinkat
2413 # if HAVE_RAW_DECL_UNLINKAT
2414 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
2415 "use gnulib module unlinkat for portability");
2416 # endif
2417 #endif
2418
2419
2420 #if @GNULIB_USLEEP@
2421 /* Pause the execution of the current thread for N microseconds.
2422 Returns 0 on completion, or -1 on range error.
2423 See the POSIX:2001 specification
2424 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
2425 # if @REPLACE_USLEEP@
2426 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2427 # undef usleep
2428 # define usleep rpl_usleep
2429 # endif
2430 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n), );
2431 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
2432 # else
2433 # if !@HAVE_USLEEP@
2434 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n), );
2435 # endif
2436 /* Need to cast, because on Haiku, the first parameter is
2437 unsigned int n. */
2438 _GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n));
2439 # endif
2440 _GL_CXXALIASWARN (usleep);
2441 #elif defined GNULIB_POSIXCHECK
2442 # undef usleep
2443 # if HAVE_RAW_DECL_USLEEP
2444 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
2445 "use gnulib module usleep for portability");
2446 # endif
2447 #endif
2448
2449
2450 #if @GNULIB_WRITE@
2451 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
2452 See the POSIX:2008 specification
2453 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
2454 # if @REPLACE_WRITE@
2455 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2456 # undef write
2457 # define write rpl_write
2458 # endif
2459 _GL_FUNCDECL_RPL (write, ssize_t,
2460 (int fd, const void *buf, size_t count),
2461 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
2462 _GL_CXXALIAS_RPL (write, ssize_t,
2463 (int fd, const void *buf, size_t count));
2464 # elif defined _WIN32 && !defined __CYGWIN__
2465 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2466 # undef write
2467 # define write _write
2468 # endif
2469 _GL_CXXALIAS_MDA (write, ssize_t,
2470 (int fd, const void *buf, size_t count));
2471 # else
2472 _GL_CXXALIAS_SYS (write, ssize_t,
2473 (int fd, const void *buf, size_t count));
2474 # endif
2475 _GL_CXXALIASWARN (write);
2476 #elif @GNULIB_MDA_WRITE@
2477 /* On native Windows, map 'write' to '_write', so that -loldnames is not
2478 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2479 platforms by defining GNULIB_NAMESPACE::write always. */
2480 # if defined _WIN32 && !defined __CYGWIN__
2481 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2482 # undef write
2483 # define write _write
2484 # endif
2485 _GL_CXXALIAS_MDA_CAST (write, ssize_t,
2486 (int fd, const void *buf, unsigned int count));
2487 # else
2488 _GL_CXXALIAS_SYS (write, ssize_t,
2489 (int fd, const void *buf, size_t count));
2490 # endif
2491 _GL_CXXALIASWARN (write);
2492 #endif
2493
2494 _GL_INLINE_HEADER_END
2495
2496 #endif /* _@GUARD_PREFIX@_UNISTD_H */
2497 #endif /* _GL_INCLUDING_UNISTD_H */
2498 #endif /* _@GUARD_PREFIX@_UNISTD_H */