1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2021 Free Software Foundation, Inc.
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.
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.
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/>. */
17 #ifndef _@GUARD_PREFIX@_UNISTD_H
20 @PRAGMA_SYSTEM_HEADER@
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. */
31 #@INCLUDE_NEXT@ @NEXT_UNISTD_H@
34 /* Normal invocation convention. */
36 /* The include_next requires a split double-inclusion guard. */
38 # define _GL_INCLUDING_UNISTD_H
39 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
40 # undef _GL_INCLUDING_UNISTD_H
43 /* Get all possible declarations of gethostname(). */
44 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
45 && !defined _GL_INCLUDING_WINSOCK2_H
46 # define _GL_INCLUDING_WINSOCK2_H
47 # include <winsock2.h>
48 # undef _GL_INCLUDING_WINSOCK2_H
51 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
52 #define _@GUARD_PREFIX@_UNISTD_H
54 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
55 /* But avoid namespace pollution on glibc systems. */
60 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
61 /* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>. We must include
62 it before we #define unlink rpl_unlink. */
63 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
64 /* But avoid namespace pollution on glibc systems. */
65 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
66 || ((@GNULIB_UNLINK@ || defined GNULIB_POSIXCHECK) \
67 && (defined _WIN32 && ! defined __CYGWIN__)) \
68 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
69 && defined __CYGWIN__)) \
70 && ! defined __GLIBC__
74 /* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
76 /* But avoid namespace pollution on glibc systems. */
77 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
78 && (defined __CYGWIN__ || defined __ANDROID__) \
79 && ! defined __GLIBC__
83 /* mingw fails to declare _exit in <unistd.h>. */
84 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
86 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
87 /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
89 /* But avoid namespace pollution on glibc systems. */
90 #if !defined __GLIBC__ && !defined __osf__
91 # define __need_system_stdlib_h
93 # undef __need_system_stdlib_h
96 /* Native Windows platforms declare _chdir, _getcwd, _rmdir in
97 <io.h> and/or <direct.h>, not in <unistd.h>.
98 They also declare _access(), _chmod(), _close(), _dup(), _dup2(), _isatty(),
99 _lseek(), _read(), _unlink(), _write() in <io.h>. */
100 #if defined _WIN32 && !defined __CYGWIN__
105 /* Native Windows platforms declare _execl*, _execv* in <process.h>. */
106 #if defined _WIN32 && !defined __CYGWIN__
107 # include <process.h>
110 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
111 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
112 /* But avoid namespace pollution on glibc systems. */
113 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
114 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
115 && !defined __GLIBC__
119 /* Mac OS X 10.13, Solaris 11.4, and Android 9.0 declare getentropy in
120 <sys/random.h>, not in <unistd.h>. */
121 /* But avoid namespace pollution on glibc systems. */
122 #if (@GNULIB_GETENTROPY@ || defined GNULIB_POSIXCHECK) \
123 && ((defined __APPLE__ && defined __MACH__) || defined __sun \
124 || defined __ANDROID__) \
125 && @UNISTD_H_HAVE_SYS_RANDOM_H@ \
126 && !defined __GLIBC__
127 # include <sys/random.h>
130 /* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>. */
131 /* But avoid namespace pollution on glibc systems. */
132 #if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
133 && !defined __GLIBC__
134 # include <sys/stat.h>
137 /* MSVC defines off_t in <sys/types.h>.
138 May also define off_t to a 64-bit type on native Windows. */
139 /* Get off_t, ssize_t, mode_t. */
140 #include <sys/types.h>
142 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
144 /* The definition of _GL_ARG_NONNULL is copied here. */
146 /* The definition of _GL_WARN_ON_USE is copied here. */
149 /* Get getopt(), optarg, optind, opterr, optopt. */
150 #if @GNULIB_GETOPT_POSIX@ && @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
151 # include <getopt-cdefs.h>
152 # include <getopt-pfx-core.h>
155 #ifndef _GL_INLINE_HEADER_BEGIN
156 #error "Please include config.h first."
158 _GL_INLINE_HEADER_BEGIN
159 #ifndef _GL_UNISTD_INLINE
160 # define _GL_UNISTD_INLINE _GL_INLINE
163 /* Hide some function declarations from <winsock2.h>. */
165 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
166 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
167 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
169 # define socket socket_used_without_including_sys_socket_h
171 # define connect connect_used_without_including_sys_socket_h
173 # define accept accept_used_without_including_sys_socket_h
175 # define bind bind_used_without_including_sys_socket_h
177 # define getpeername getpeername_used_without_including_sys_socket_h
179 # define getsockname getsockname_used_without_including_sys_socket_h
181 # define getsockopt getsockopt_used_without_including_sys_socket_h
183 # define listen listen_used_without_including_sys_socket_h
185 # define recv recv_used_without_including_sys_socket_h
187 # define send send_used_without_including_sys_socket_h
189 # define recvfrom recvfrom_used_without_including_sys_socket_h
191 # define sendto sendto_used_without_including_sys_socket_h
193 # define setsockopt setsockopt_used_without_including_sys_socket_h
195 # define shutdown shutdown_used_without_including_sys_socket_h
197 _GL_WARN_ON_USE (socket,
198 "socket() used without including <sys/socket.h>");
199 _GL_WARN_ON_USE (connect,
200 "connect() used without including <sys/socket.h>");
201 _GL_WARN_ON_USE (accept,
202 "accept() used without including <sys/socket.h>");
203 _GL_WARN_ON_USE (bind,
204 "bind() used without including <sys/socket.h>");
205 _GL_WARN_ON_USE (getpeername,
206 "getpeername() used without including <sys/socket.h>");
207 _GL_WARN_ON_USE (getsockname,
208 "getsockname() used without including <sys/socket.h>");
209 _GL_WARN_ON_USE (getsockopt,
210 "getsockopt() used without including <sys/socket.h>");
211 _GL_WARN_ON_USE (listen,
212 "listen() used without including <sys/socket.h>");
213 _GL_WARN_ON_USE (recv,
214 "recv() used without including <sys/socket.h>");
215 _GL_WARN_ON_USE (send,
216 "send() used without including <sys/socket.h>");
217 _GL_WARN_ON_USE (recvfrom,
218 "recvfrom() used without including <sys/socket.h>");
219 _GL_WARN_ON_USE (sendto,
220 "sendto() used without including <sys/socket.h>");
221 _GL_WARN_ON_USE (setsockopt,
222 "setsockopt() used without including <sys/socket.h>");
223 _GL_WARN_ON_USE (shutdown,
224 "shutdown() used without including <sys/socket.h>");
227 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
228 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
230 # define select select_used_without_including_sys_select_h
232 _GL_WARN_ON_USE (select,
233 "select() used without including <sys/select.h>");
239 /* OS/2 EMX lacks these macros. */
241 # define STDIN_FILENO 0
243 #ifndef STDOUT_FILENO
244 # define STDOUT_FILENO 1
246 #ifndef STDERR_FILENO
247 # define STDERR_FILENO 2
250 /* Ensure *_OK macros exist. */
259 /* Declare overridden functions. */
263 # if @REPLACE_ACCESS@
264 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
266 # define access rpl_access
268 _GL_FUNCDECL_RPL (access, int, (const char *file, int mode)
269 _GL_ARG_NONNULL ((1)));
270 _GL_CXXALIAS_RPL (access, int, (const char *file, int mode));
271 # elif defined _WIN32 && !defined __CYGWIN__
272 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
274 # define access _access
276 _GL_CXXALIAS_MDA (access, int, (const char *file, int mode));
278 _GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
280 _GL_CXXALIASWARN (access);
281 #elif defined GNULIB_POSIXCHECK
283 # if HAVE_RAW_DECL_ACCESS
284 /* The access() function is a security risk. */
285 _GL_WARN_ON_USE (access, "access does not always support X_OK - "
286 "use gnulib module access for portability; "
287 "also, this function is a security risk - "
288 "use the gnulib module faccessat instead");
290 #elif @GNULIB_MDA_ACCESS@
291 /* On native Windows, map 'access' to '_access', so that -loldnames is not
292 required. In C++ with GNULIB_NAMESPACE, avoid differences between
293 platforms by defining GNULIB_NAMESPACE::access always. */
294 # if defined _WIN32 && !defined __CYGWIN__
295 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
297 # define access _access
299 _GL_CXXALIAS_MDA (access, int, (const char *file, int mode));
301 _GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
303 _GL_CXXALIASWARN (access);
308 # if defined _WIN32 && !defined __CYGWIN__
309 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
311 # define chdir _chdir
313 _GL_CXXALIAS_MDA (chdir, int, (const char *file));
315 _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
317 _GL_CXXALIASWARN (chdir);
318 #elif defined GNULIB_POSIXCHECK
320 # if HAVE_RAW_DECL_CHDIR
321 _GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
322 "use gnulib module chdir for portability");
324 #elif @GNULIB_MDA_CHDIR@
325 /* On native Windows, map 'chdir' to '_chdir', so that -loldnames is not
326 required. In C++ with GNULIB_NAMESPACE, avoid differences between
327 platforms by defining GNULIB_NAMESPACE::chdir always. */
328 # if defined _WIN32 && !defined __CYGWIN__
329 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
331 # define chdir _chdir
333 _GL_CXXALIAS_MDA (chdir, int, (const char *file));
335 _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
337 _GL_CXXALIASWARN (chdir);
342 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
343 to GID (if GID is not -1). Follow symbolic links.
344 Return 0 if successful, otherwise -1 and errno set.
345 See the POSIX:2008 specification
346 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
348 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
350 # define chown rpl_chown
352 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
353 _GL_ARG_NONNULL ((1)));
354 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
357 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
358 _GL_ARG_NONNULL ((1)));
360 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
362 _GL_CXXALIASWARN (chown);
363 #elif defined GNULIB_POSIXCHECK
365 # if HAVE_RAW_DECL_CHOWN
366 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
367 "doesn't treat a uid or gid of -1 on some systems - "
368 "use gnulib module chown for portability");
375 /* Automatically included by modules that need a replacement for close. */
376 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
378 # define close rpl_close
380 _GL_FUNCDECL_RPL (close, int, (int fd));
381 _GL_CXXALIAS_RPL (close, int, (int fd));
382 # elif defined _WIN32 && !defined __CYGWIN__
383 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
385 # define close _close
387 _GL_CXXALIAS_MDA (close, int, (int fd));
389 _GL_CXXALIAS_SYS (close, int, (int fd));
391 _GL_CXXALIASWARN (close);
392 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
394 # define close close_used_without_requesting_gnulib_module_close
395 #elif defined GNULIB_POSIXCHECK
397 /* Assume close is always declared. */
398 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
399 "use gnulib module close for portability");
400 #elif @GNULIB_MDA_CLOSE@
401 /* On native Windows, map 'close' to '_close', so that -loldnames is not
402 required. In C++ with GNULIB_NAMESPACE, avoid differences between
403 platforms by defining GNULIB_NAMESPACE::close always. */
404 # if defined _WIN32 && !defined __CYGWIN__
405 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
407 # define close _close
409 _GL_CXXALIAS_MDA (close, int, (int fd));
411 _GL_CXXALIAS_SYS (close, int, (int fd));
413 _GL_CXXALIASWARN (close);
417 #if @GNULIB_COPY_FILE_RANGE@
418 # if !@HAVE_COPY_FILE_RANGE@
419 _GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
420 int ofd, off_t *opos,
421 size_t len, unsigned flags));
422 _GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
423 int ofd, off_t *opos,
424 size_t len, unsigned flags));
426 _GL_CXXALIASWARN (copy_file_range);
427 #elif defined GNULIB_POSIXCHECK
428 # if HAVE_RAW_DECL_COPY_FILE_RANGE
429 _GL_WARN_ON_USE (copy_file_range,
430 "copy_file_range is unportable - "
431 "use gnulib module copy_file_range for portability");
438 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
441 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
442 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
443 # elif defined _WIN32 && !defined __CYGWIN__
444 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
448 _GL_CXXALIAS_MDA (dup, int, (int oldfd));
450 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
452 _GL_CXXALIASWARN (dup);
453 #elif defined GNULIB_POSIXCHECK
455 # if HAVE_RAW_DECL_DUP
456 _GL_WARN_ON_USE (dup, "dup is unportable - "
457 "use gnulib module dup for portability");
459 #elif @GNULIB_MDA_DUP@
460 /* On native Windows, map 'dup' to '_dup', so that -loldnames is not
461 required. In C++ with GNULIB_NAMESPACE, avoid differences between
462 platforms by defining GNULIB_NAMESPACE::dup always. */
463 # if defined _WIN32 && !defined __CYGWIN__
464 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
468 _GL_CXXALIAS_MDA (dup, int, (int oldfd));
470 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
472 _GL_CXXALIASWARN (dup);
477 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
478 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
479 Return newfd if successful, otherwise -1 and errno set.
480 See the POSIX:2008 specification
481 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
483 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
484 # define dup2 rpl_dup2
486 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
487 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
488 # elif defined _WIN32 && !defined __CYGWIN__
489 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
493 _GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
495 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
497 _GL_CXXALIASWARN (dup2);
498 #elif defined GNULIB_POSIXCHECK
500 # if HAVE_RAW_DECL_DUP2
501 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
502 "use gnulib module dup2 for portability");
504 #elif @GNULIB_MDA_DUP2@
505 /* On native Windows, map 'dup2' to '_dup2', so that -loldnames is not
506 required. In C++ with GNULIB_NAMESPACE, avoid differences between
507 platforms by defining GNULIB_NAMESPACE::dup2 always. */
508 # if defined _WIN32 && !defined __CYGWIN__
509 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
513 _GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
515 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
517 _GL_CXXALIASWARN (dup2);
522 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
524 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
525 and O_TEXT, O_BINARY (defined in "binary-io.h").
526 Close NEWFD first if it is open.
527 Return newfd if successful, otherwise -1 and errno set.
528 See the Linux man page at
529 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
531 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
532 # define dup3 rpl_dup3
534 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
535 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
537 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
538 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
540 _GL_CXXALIASWARN (dup3);
541 #elif defined GNULIB_POSIXCHECK
543 # if HAVE_RAW_DECL_DUP3
544 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
545 "use gnulib module dup3 for portability");
551 # if defined __CYGWIN__ && !defined __i386__
552 /* The 'environ' variable is defined in a DLL. Therefore its declaration needs
553 the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
554 This leads to a link error on 64-bit Cygwin when the option
555 -Wl,--disable-auto-import is in use. */
556 _GL_EXTERN_C __declspec(dllimport) char **environ;
558 # if !@HAVE_DECL_ENVIRON@
559 /* Set of environment variables and values. An array of strings of the form
560 "VARIABLE=VALUE", terminated with a NULL. */
561 # if defined __APPLE__ && defined __MACH__
562 # include <TargetConditionals.h>
563 # if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
564 # define _GL_USE_CRT_EXTERNS
567 # ifdef _GL_USE_CRT_EXTERNS
568 # include <crt_externs.h>
569 # define environ (*_NSGetEnviron ())
574 extern char **environ;
580 #elif defined GNULIB_POSIXCHECK
581 # if HAVE_RAW_DECL_ENVIRON
582 _GL_UNISTD_INLINE char ***
583 _GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
584 "use gnulib module environ for portability")
590 # define environ (*rpl_environ ())
595 #if @GNULIB_EUIDACCESS@
596 /* Like access(), except that it uses the effective user id and group id of
597 the current process. */
598 # if !@HAVE_EUIDACCESS@
599 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
600 _GL_ARG_NONNULL ((1)));
602 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
603 _GL_CXXALIASWARN (euidaccess);
604 # if defined GNULIB_POSIXCHECK
605 /* Like access(), this function is a security risk. */
606 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
607 "use the gnulib module faccessat instead");
609 #elif defined GNULIB_POSIXCHECK
611 # if HAVE_RAW_DECL_EUIDACCESS
612 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
613 "use gnulib module euidaccess for portability");
620 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
622 # define execl rpl_execl
624 _GL_FUNCDECL_RPL (execl, int, (const char *program, const char *arg, ...)
625 _GL_ARG_NONNULL ((1)));
626 _GL_CXXALIAS_RPL (execl, int, (const char *program, const char *arg, ...));
628 _GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
630 _GL_CXXALIASWARN (execl);
631 #elif defined GNULIB_POSIXCHECK
633 # if HAVE_RAW_DECL_EXECL
634 _GL_WARN_ON_USE (execl, "execl behaves very differently on mingw - "
635 "use gnulib module execl for portability");
637 #elif @GNULIB_MDA_EXECL@
638 /* On native Windows, map 'execl' to '_execl', so that -loldnames is not
639 required. In C++ with GNULIB_NAMESPACE, avoid differences between
640 platforms by defining GNULIB_NAMESPACE::execl always. */
641 # if defined _WIN32 && !defined __CYGWIN__
642 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
644 # define execl _execl
646 _GL_CXXALIAS_MDA (execl, intptr_t, (const char *program, const char *arg, ...));
648 _GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
650 _GL_CXXALIASWARN (execl);
654 # if @REPLACE_EXECLE@
655 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
657 # define execle rpl_execle
659 _GL_FUNCDECL_RPL (execle, int, (const char *program, const char *arg, ...)
660 _GL_ARG_NONNULL ((1)));
661 _GL_CXXALIAS_RPL (execle, int, (const char *program, const char *arg, ...));
663 _GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
665 _GL_CXXALIASWARN (execle);
666 #elif defined GNULIB_POSIXCHECK
668 # if HAVE_RAW_DECL_EXECLE
669 _GL_WARN_ON_USE (execle, "execle behaves very differently on mingw - "
670 "use gnulib module execle for portability");
672 #elif @GNULIB_MDA_EXECLE@
673 /* On native Windows, map 'execle' to '_execle', so that -loldnames is not
674 required. In C++ with GNULIB_NAMESPACE, avoid differences between
675 platforms by defining GNULIB_NAMESPACE::execle always. */
676 # if defined _WIN32 && !defined __CYGWIN__
677 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
679 # define execle _execle
681 _GL_CXXALIAS_MDA (execle, intptr_t,
682 (const char *program, const char *arg, ...));
684 _GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
686 _GL_CXXALIASWARN (execle);
690 # if @REPLACE_EXECLP@
691 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
693 # define execlp rpl_execlp
695 _GL_FUNCDECL_RPL (execlp, int, (const char *program, const char *arg, ...)
696 _GL_ARG_NONNULL ((1)));
697 _GL_CXXALIAS_RPL (execlp, int, (const char *program, const char *arg, ...));
699 _GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
701 _GL_CXXALIASWARN (execlp);
702 #elif defined GNULIB_POSIXCHECK
704 # if HAVE_RAW_DECL_EXECLP
705 _GL_WARN_ON_USE (execlp, "execlp behaves very differently on mingw - "
706 "use gnulib module execlp for portability");
708 #elif @GNULIB_MDA_EXECLP@
709 /* On native Windows, map 'execlp' to '_execlp', so that -loldnames is not
710 required. In C++ with GNULIB_NAMESPACE, avoid differences between
711 platforms by defining GNULIB_NAMESPACE::execlp always. */
712 # if defined _WIN32 && !defined __CYGWIN__
713 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
715 # define execlp _execlp
717 _GL_CXXALIAS_MDA (execlp, intptr_t,
718 (const char *program, const char *arg, ...));
720 _GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
722 _GL_CXXALIASWARN (execlp);
728 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
730 # define execv rpl_execv
732 _GL_FUNCDECL_RPL (execv, int, (const char *program, char * const *argv)
733 _GL_ARG_NONNULL ((1, 2)));
734 _GL_CXXALIAS_RPL (execv, int, (const char *program, char * const *argv));
736 _GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
738 _GL_CXXALIASWARN (execv);
739 #elif defined GNULIB_POSIXCHECK
741 # if HAVE_RAW_DECL_EXECV
742 _GL_WARN_ON_USE (execv, "execv behaves very differently on mingw - "
743 "use gnulib module execv for portability");
745 #elif @GNULIB_MDA_EXECV@
746 /* On native Windows, map 'execv' to '_execv', so that -loldnames is not
747 required. In C++ with GNULIB_NAMESPACE, avoid differences between
748 platforms by defining GNULIB_NAMESPACE::execv always. */
749 # if defined _WIN32 && !defined __CYGWIN__
750 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
752 # define execv _execv
754 _GL_CXXALIAS_MDA_CAST (execv, intptr_t,
755 (const char *program, char * const *argv));
757 _GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
759 _GL_CXXALIASWARN (execv);
763 # if @REPLACE_EXECVE@
764 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
766 # define execve rpl_execve
768 _GL_FUNCDECL_RPL (execve, int,
769 (const char *program, char * const *argv, char * const *env)
770 _GL_ARG_NONNULL ((1, 2)));
771 _GL_CXXALIAS_RPL (execve, int,
772 (const char *program, char * const *argv, char * const *env));
774 _GL_CXXALIAS_SYS (execve, int,
775 (const char *program, char * const *argv, char * const *env));
777 _GL_CXXALIASWARN (execve);
778 #elif defined GNULIB_POSIXCHECK
780 # if HAVE_RAW_DECL_EXECVE
781 _GL_WARN_ON_USE (execve, "execve behaves very differently on mingw - "
782 "use gnulib module execve for portability");
784 #elif @GNULIB_MDA_EXECVE@
785 /* On native Windows, map 'execve' to '_execve', so that -loldnames is not
786 required. In C++ with GNULIB_NAMESPACE, avoid differences between
787 platforms by defining GNULIB_NAMESPACE::execve always. */
788 # if defined _WIN32 && !defined __CYGWIN__
789 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
791 # define execve _execve
793 _GL_CXXALIAS_MDA_CAST (execve, intptr_t,
794 (const char *program, char * const *argv,
797 _GL_CXXALIAS_SYS (execve, int,
798 (const char *program, char * const *argv, char * const *env));
800 _GL_CXXALIASWARN (execve);
804 # if @REPLACE_EXECVP@
805 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
807 # define execvp rpl_execvp
809 _GL_FUNCDECL_RPL (execvp, int, (const char *program, char * const *argv)
810 _GL_ARG_NONNULL ((1, 2)));
811 _GL_CXXALIAS_RPL (execvp, int, (const char *program, char * const *argv));
813 _GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
815 _GL_CXXALIASWARN (execvp);
816 #elif defined GNULIB_POSIXCHECK
818 # if HAVE_RAW_DECL_EXECVP
819 _GL_WARN_ON_USE (execvp, "execvp behaves very differently on mingw - "
820 "use gnulib module execvp for portability");
822 #elif @GNULIB_MDA_EXECVP@
823 /* On native Windows, map 'execvp' to '_execvp', so that -loldnames is not
824 required. In C++ with GNULIB_NAMESPACE, avoid differences between
825 platforms by defining GNULIB_NAMESPACE::execvp always. */
826 # if defined _WIN32 && !defined __CYGWIN__
827 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
829 # define execvp _execvp
831 _GL_CXXALIAS_MDA_CAST (execvp, intptr_t,
832 (const char *program, char * const *argv));
834 _GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
836 _GL_CXXALIASWARN (execvp);
840 # if @REPLACE_EXECVPE@
841 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
843 # define execvpe rpl_execvpe
845 _GL_FUNCDECL_RPL (execvpe, int,
846 (const char *program, char * const *argv, char * const *env)
847 _GL_ARG_NONNULL ((1, 2)));
848 _GL_CXXALIAS_RPL (execvpe, int,
849 (const char *program, char * const *argv, char * const *env));
851 # if !@HAVE_DECL_EXECVPE@
852 _GL_FUNCDECL_SYS (execvpe, int,
853 (const char *program, char * const *argv, char * const *env)
854 _GL_ARG_NONNULL ((1, 2)));
856 _GL_CXXALIAS_SYS (execvpe, int,
857 (const char *program, char * const *argv, char * const *env));
859 _GL_CXXALIASWARN (execvpe);
860 #elif defined GNULIB_POSIXCHECK
862 # if HAVE_RAW_DECL_EXECVPE
863 _GL_WARN_ON_USE (execvpe, "execvpe behaves very differently on mingw - "
864 "use gnulib module execvpe for portability");
866 #elif @GNULIB_MDA_EXECVPE@
867 /* On native Windows, map 'execvpe' to '_execvpe', so that -loldnames is not
868 required. In C++ with GNULIB_NAMESPACE, avoid differences between
869 platforms by defining GNULIB_NAMESPACE::execvpe on all platforms that have
871 # if defined _WIN32 && !defined __CYGWIN__
872 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
874 # define execvpe _execvpe
876 _GL_CXXALIAS_MDA_CAST (execvpe, intptr_t,
877 (const char *program, char * const *argv,
879 # elif @HAVE_EXECVPE@
880 # if !@HAVE_DECL_EXECVPE@
881 _GL_FUNCDECL_SYS (execvpe, int,
882 (const char *program, char * const *argv, char * const *env)
883 _GL_ARG_NONNULL ((1, 2)));
885 _GL_CXXALIAS_SYS (execvpe, int,
886 (const char *program, char * const *argv, char * const *env));
888 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_EXECVPE@
889 _GL_CXXALIASWARN (execvpe);
894 #if @GNULIB_FACCESSAT@
895 # if @REPLACE_FACCESSAT@
896 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
898 # define faccessat rpl_faccessat
900 _GL_FUNCDECL_RPL (faccessat, int,
901 (int fd, char const *name, int mode, int flag)
902 _GL_ARG_NONNULL ((2)));
903 _GL_CXXALIAS_RPL (faccessat, int,
904 (int fd, char const *name, int mode, int flag));
906 # if !@HAVE_FACCESSAT@
907 _GL_FUNCDECL_SYS (faccessat, int,
908 (int fd, char const *file, int mode, int flag)
909 _GL_ARG_NONNULL ((2)));
911 _GL_CXXALIAS_SYS (faccessat, int,
912 (int fd, char const *file, int mode, int flag));
914 _GL_CXXALIASWARN (faccessat);
915 #elif defined GNULIB_POSIXCHECK
917 # if HAVE_RAW_DECL_FACCESSAT
918 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
919 "use gnulib module faccessat for portability");
925 /* Change the process' current working directory to the directory on which
926 the given file descriptor is open.
927 Return 0 if successful, otherwise -1 and errno set.
928 See the POSIX:2008 specification
929 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
931 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
933 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
934 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
935 _GL_ARG_NONNULL ((2));
936 _GL_EXTERN_C void _gl_unregister_fd (int fd);
937 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
938 _GL_EXTERN_C const char *_gl_directory_name (int fd);
941 # if !@HAVE_DECL_FCHDIR@
942 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
945 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
946 _GL_CXXALIASWARN (fchdir);
947 #elif defined GNULIB_POSIXCHECK
949 # if HAVE_RAW_DECL_FCHDIR
950 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
951 "use gnulib module fchdir for portability");
956 #if @GNULIB_FCHOWNAT@
957 # if @REPLACE_FCHOWNAT@
958 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
960 # define fchownat rpl_fchownat
962 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
963 uid_t owner, gid_t group, int flag)
964 _GL_ARG_NONNULL ((2)));
965 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
966 uid_t owner, gid_t group, int flag));
968 # if !@HAVE_FCHOWNAT@
969 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
970 uid_t owner, gid_t group, int flag)
971 _GL_ARG_NONNULL ((2)));
973 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
974 uid_t owner, gid_t group, int flag));
976 _GL_CXXALIASWARN (fchownat);
977 #elif defined GNULIB_POSIXCHECK
979 # if HAVE_RAW_DECL_FCHOWNAT
980 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
981 "use gnulib module fchownat for portability");
986 #if @GNULIB_FDATASYNC@
987 /* Synchronize changes to a file.
988 Return 0 if successful, otherwise -1 and errno set.
989 See POSIX:2008 specification
990 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
991 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
992 _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
994 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
995 _GL_CXXALIASWARN (fdatasync);
996 #elif defined GNULIB_POSIXCHECK
998 # if HAVE_RAW_DECL_FDATASYNC
999 _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
1000 "use gnulib module fdatasync for portability");
1006 /* Synchronize changes, including metadata, to a file.
1007 Return 0 if successful, otherwise -1 and errno set.
1008 See POSIX:2008 specification
1009 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
1011 _GL_FUNCDECL_SYS (fsync, int, (int fd));
1013 _GL_CXXALIAS_SYS (fsync, int, (int fd));
1014 _GL_CXXALIASWARN (fsync);
1015 #elif defined GNULIB_POSIXCHECK
1017 # if HAVE_RAW_DECL_FSYNC
1018 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
1019 "use gnulib module fsync for portability");
1024 #if @GNULIB_FTRUNCATE@
1025 /* Change the size of the file to which FD is opened to become equal to LENGTH.
1026 Return 0 if successful, otherwise -1 and errno set.
1027 See the POSIX:2008 specification
1028 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
1029 # if @REPLACE_FTRUNCATE@
1030 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1032 # define ftruncate rpl_ftruncate
1034 _GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
1035 _GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
1037 # if !@HAVE_FTRUNCATE@
1038 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
1040 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
1042 _GL_CXXALIASWARN (ftruncate);
1043 #elif defined GNULIB_POSIXCHECK
1045 # if HAVE_RAW_DECL_FTRUNCATE
1046 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
1047 "use gnulib module ftruncate for portability");
1053 /* Get the name of the current working directory, and put it in SIZE bytes
1055 Return BUF if successful, or NULL if the directory couldn't be determined
1056 or SIZE was too small.
1057 See the POSIX:2008 specification
1058 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
1059 Additionally, the gnulib module 'getcwd' guarantees the following GNU
1060 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
1061 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
1063 # if @REPLACE_GETCWD@
1064 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1065 # define getcwd rpl_getcwd
1067 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
1068 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
1069 # elif defined _WIN32 && !defined __CYGWIN__
1070 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1072 # define getcwd _getcwd
1074 _GL_CXXALIAS_MDA (getcwd, char *, (char *buf, size_t size));
1076 /* Need to cast, because on mingw, the second parameter is
1078 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
1080 _GL_CXXALIASWARN (getcwd);
1081 #elif defined GNULIB_POSIXCHECK
1083 # if HAVE_RAW_DECL_GETCWD
1084 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
1085 "use gnulib module getcwd for portability");
1087 #elif @GNULIB_MDA_GETCWD@
1088 /* On native Windows, map 'getcwd' to '_getcwd', so that -loldnames is not
1089 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1090 platforms by defining GNULIB_NAMESPACE::getcwd always. */
1091 # if defined _WIN32 && !defined __CYGWIN__
1092 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1094 # define getcwd _getcwd
1096 /* Need to cast, because on mingw, the second parameter is either
1097 'int size' or 'size_t size'. */
1098 _GL_CXXALIAS_MDA_CAST (getcwd, char *, (char *buf, size_t size));
1100 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
1102 _GL_CXXALIASWARN (getcwd);
1106 #if @GNULIB_GETDOMAINNAME@
1107 /* Return the NIS domain name of the machine.
1108 WARNING! The NIS domain name is unrelated to the fully qualified host name
1109 of the machine. It is also unrelated to email addresses.
1110 WARNING! The NIS domain name is usually the empty string or "(none)" when
1113 Put up to LEN bytes of the NIS domain name into NAME.
1114 Null terminate it if the name is shorter than LEN.
1115 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
1116 Return 0 if successful, otherwise set errno and return -1. */
1117 # if @REPLACE_GETDOMAINNAME@
1118 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1119 # undef getdomainname
1120 # define getdomainname rpl_getdomainname
1122 _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
1123 _GL_ARG_NONNULL ((1)));
1124 _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
1126 # if !@HAVE_DECL_GETDOMAINNAME@
1127 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
1128 _GL_ARG_NONNULL ((1)));
1130 _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
1132 _GL_CXXALIASWARN (getdomainname);
1133 #elif defined GNULIB_POSIXCHECK
1134 # undef getdomainname
1135 # if HAVE_RAW_DECL_GETDOMAINNAME
1136 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
1137 "use gnulib module getdomainname for portability");
1142 #if @GNULIB_GETDTABLESIZE@
1143 /* Return the maximum number of file descriptors in the current process.
1144 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
1145 # if @REPLACE_GETDTABLESIZE@
1146 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1147 # undef getdtablesize
1148 # define getdtablesize rpl_getdtablesize
1150 _GL_FUNCDECL_RPL (getdtablesize, int, (void));
1151 _GL_CXXALIAS_RPL (getdtablesize, int, (void));
1153 # if !@HAVE_GETDTABLESIZE@
1154 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
1156 /* Need to cast, because on AIX, the parameter list is
1158 _GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void));
1160 _GL_CXXALIASWARN (getdtablesize);
1161 #elif defined GNULIB_POSIXCHECK
1162 # undef getdtablesize
1163 # if HAVE_RAW_DECL_GETDTABLESIZE
1164 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
1165 "use gnulib module getdtablesize for portability");
1170 #if @GNULIB_GETENTROPY@
1171 /* Fill a buffer with random bytes. */
1172 # if !@HAVE_GETENTROPY@
1173 _GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length));
1175 _GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length));
1176 _GL_CXXALIASWARN (getentropy);
1177 #elif defined GNULIB_POSIXCHECK
1179 # if HAVE_RAW_DECL_GETENTROPY
1180 _GL_WARN_ON_USE (getentropy, "getentropy is unportable - "
1181 "use gnulib module getentropy for portability");
1186 #if @GNULIB_GETGROUPS@
1187 /* Return the supplemental groups that the current process belongs to.
1188 It is unspecified whether the effective group id is in the list.
1189 If N is 0, return the group count; otherwise, N describes how many
1190 entries are available in GROUPS. Return -1 and set errno if N is
1191 not 0 and not large enough. Fails with ENOSYS on some systems. */
1192 # if @REPLACE_GETGROUPS@
1193 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1195 # define getgroups rpl_getgroups
1197 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
1198 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
1200 # if !@HAVE_GETGROUPS@
1201 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
1203 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
1205 _GL_CXXALIASWARN (getgroups);
1206 #elif defined GNULIB_POSIXCHECK
1208 # if HAVE_RAW_DECL_GETGROUPS
1209 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
1210 "use gnulib module getgroups for portability");
1215 #if @GNULIB_GETHOSTNAME@
1216 /* Return the standard host name of the machine.
1217 WARNING! The host name may or may not be fully qualified.
1219 Put up to LEN bytes of the host name into NAME.
1220 Null terminate it if the name is shorter than LEN.
1221 If the host name is longer than LEN, set errno = EINVAL and return -1.
1222 Return 0 if successful, otherwise set errno and return -1. */
1223 # if @UNISTD_H_HAVE_WINSOCK2_H@
1224 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1226 # define gethostname rpl_gethostname
1228 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
1229 _GL_ARG_NONNULL ((1)));
1230 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
1232 # if !@HAVE_GETHOSTNAME@
1233 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
1234 _GL_ARG_NONNULL ((1)));
1236 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
1239 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
1241 _GL_CXXALIASWARN (gethostname);
1242 #elif @UNISTD_H_HAVE_WINSOCK2_H@
1244 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
1245 #elif defined GNULIB_POSIXCHECK
1247 # if HAVE_RAW_DECL_GETHOSTNAME
1248 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
1249 "use gnulib module gethostname for portability");
1254 #if @GNULIB_GETLOGIN@
1255 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
1256 returns NULL with errno set.
1258 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1260 Most programs don't need to use this function, because the information is
1261 available through environment variables:
1262 ${LOGNAME-$USER} on Unix platforms,
1263 $USERNAME on native Windows platforms.
1265 # if !@HAVE_DECL_GETLOGIN@
1266 _GL_FUNCDECL_SYS (getlogin, char *, (void));
1268 _GL_CXXALIAS_SYS (getlogin, char *, (void));
1269 _GL_CXXALIASWARN (getlogin);
1270 #elif defined GNULIB_POSIXCHECK
1272 # if HAVE_RAW_DECL_GETLOGIN
1273 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
1274 "use gnulib module getlogin for portability");
1279 #if @GNULIB_GETLOGIN_R@
1280 /* Copies the user's login name to NAME.
1281 The array pointed to by NAME has room for SIZE bytes.
1283 Returns 0 if successful. Upon error, an error number is returned, or -1 in
1284 the case that the login name cannot be found but no specific error is
1285 provided (this case is hopefully rare but is left open by the POSIX spec).
1287 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1289 Most programs don't need to use this function, because the information is
1290 available through environment variables:
1291 ${LOGNAME-$USER} on Unix platforms,
1292 $USERNAME on native Windows platforms.
1294 # if @REPLACE_GETLOGIN_R@
1295 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1296 # define getlogin_r rpl_getlogin_r
1298 _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
1299 _GL_ARG_NONNULL ((1)));
1300 _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
1302 # if !@HAVE_DECL_GETLOGIN_R@
1303 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
1304 _GL_ARG_NONNULL ((1)));
1306 /* Need to cast, because on Solaris 10 systems, the second argument is
1308 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
1310 _GL_CXXALIASWARN (getlogin_r);
1311 #elif defined GNULIB_POSIXCHECK
1313 # if HAVE_RAW_DECL_GETLOGIN_R
1314 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
1315 "use gnulib module getlogin_r for portability");
1320 #if @GNULIB_GETPAGESIZE@
1321 # if @REPLACE_GETPAGESIZE@
1322 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1323 # define getpagesize rpl_getpagesize
1325 _GL_FUNCDECL_RPL (getpagesize, int, (void));
1326 _GL_CXXALIAS_RPL (getpagesize, int, (void));
1328 /* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
1329 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */
1331 _GL_FUNCDECL_SYS (getpagesize, int, (void));
1333 # if !@HAVE_GETPAGESIZE@
1334 # if !defined getpagesize
1335 /* This is for POSIX systems. */
1336 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
1337 # if ! (defined __VMS && __VMS_VER < 70000000)
1338 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
1341 /* This is for older VMS. */
1342 # if !defined _gl_getpagesize && defined __VMS
1344 # define _gl_getpagesize() 8192
1346 # define _gl_getpagesize() 512
1349 /* This is for BeOS. */
1350 # if !defined _gl_getpagesize && @HAVE_OS_H@
1352 # if defined B_PAGE_SIZE
1353 # define _gl_getpagesize() B_PAGE_SIZE
1356 /* This is for AmigaOS4.0. */
1357 # if !defined _gl_getpagesize && defined __amigaos4__
1358 # define _gl_getpagesize() 2048
1360 /* This is for older Unix systems. */
1361 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
1362 # include <sys/param.h>
1363 # ifdef EXEC_PAGESIZE
1364 # define _gl_getpagesize() EXEC_PAGESIZE
1370 # define _gl_getpagesize() (NBPG * CLSIZE)
1373 # define _gl_getpagesize() NBPC
1378 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1379 # define getpagesize() _gl_getpagesize ()
1381 # if !GNULIB_defined_getpagesize_function
1382 _GL_UNISTD_INLINE int
1385 return _gl_getpagesize ();
1387 # define GNULIB_defined_getpagesize_function 1
1392 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
1393 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
1395 # if @HAVE_DECL_GETPAGESIZE@
1396 _GL_CXXALIASWARN (getpagesize);
1398 #elif defined GNULIB_POSIXCHECK
1400 # if HAVE_RAW_DECL_GETPAGESIZE
1401 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
1402 "use gnulib module getpagesize for portability");
1407 #if @GNULIB_GETPASS@
1408 /* Function getpass() from module 'getpass':
1409 Read a password from /dev/tty or stdin.
1410 Function getpass() from module 'getpass-gnu':
1411 Read a password of arbitrary length from /dev/tty or stdin. */
1412 # if @REPLACE_GETPASS@
1413 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1415 # define getpass rpl_getpass
1417 _GL_FUNCDECL_RPL (getpass, char *, (const char *prompt)
1418 _GL_ARG_NONNULL ((1)));
1419 _GL_CXXALIAS_RPL (getpass, char *, (const char *prompt));
1421 # if !@HAVE_GETPASS@
1422 _GL_FUNCDECL_SYS (getpass, char *, (const char *prompt)
1423 _GL_ARG_NONNULL ((1)));
1425 _GL_CXXALIAS_SYS (getpass, char *, (const char *prompt));
1427 _GL_CXXALIASWARN (getpass);
1428 #elif defined GNULIB_POSIXCHECK
1430 # if HAVE_RAW_DECL_GETPASS
1431 _GL_WARN_ON_USE (getpass, "getpass is unportable - "
1432 "use gnulib module getpass or getpass-gnu for portability");
1437 #if @GNULIB_MDA_GETPID@
1438 /* On native Windows, map 'getpid' to '_getpid', so that -loldnames is not
1439 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1440 platforms by defining GNULIB_NAMESPACE::getpid always. */
1441 # if defined _WIN32 && !defined __CYGWIN__
1442 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1444 # define getpid _getpid
1446 _GL_CXXALIAS_MDA (getpid, int, (void));
1448 _GL_CXXALIAS_SYS (getpid, pid_t, (void));
1450 _GL_CXXALIASWARN (getpid);
1454 #if @GNULIB_GETUSERSHELL@
1455 /* Return the next valid login shell on the system, or NULL when the end of
1456 the list has been reached. */
1457 # if !@HAVE_DECL_GETUSERSHELL@
1458 _GL_FUNCDECL_SYS (getusershell, char *, (void));
1460 _GL_CXXALIAS_SYS (getusershell, char *, (void));
1461 _GL_CXXALIASWARN (getusershell);
1462 #elif defined GNULIB_POSIXCHECK
1463 # undef getusershell
1464 # if HAVE_RAW_DECL_GETUSERSHELL
1465 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
1466 "use gnulib module getusershell for portability");
1470 #if @GNULIB_GETUSERSHELL@
1471 /* Rewind to pointer that is advanced at each getusershell() call. */
1472 # if !@HAVE_DECL_GETUSERSHELL@
1473 _GL_FUNCDECL_SYS (setusershell, void, (void));
1475 _GL_CXXALIAS_SYS (setusershell, void, (void));
1476 _GL_CXXALIASWARN (setusershell);
1477 #elif defined GNULIB_POSIXCHECK
1478 # undef setusershell
1479 # if HAVE_RAW_DECL_SETUSERSHELL
1480 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
1481 "use gnulib module getusershell for portability");
1485 #if @GNULIB_GETUSERSHELL@
1486 /* Free the pointer that is advanced at each getusershell() call and
1487 associated resources. */
1488 # if !@HAVE_DECL_GETUSERSHELL@
1489 _GL_FUNCDECL_SYS (endusershell, void, (void));
1491 _GL_CXXALIAS_SYS (endusershell, void, (void));
1492 _GL_CXXALIASWARN (endusershell);
1493 #elif defined GNULIB_POSIXCHECK
1494 # undef endusershell
1495 # if HAVE_RAW_DECL_ENDUSERSHELL
1496 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
1497 "use gnulib module getusershell for portability");
1502 #if @GNULIB_GROUP_MEMBER@
1503 /* Determine whether group id is in calling user's group list. */
1504 # if !@HAVE_GROUP_MEMBER@
1505 _GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
1507 _GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
1508 _GL_CXXALIASWARN (group_member);
1509 #elif defined GNULIB_POSIXCHECK
1510 # undef group_member
1511 # if HAVE_RAW_DECL_GROUP_MEMBER
1512 _GL_WARN_ON_USE (group_member, "group_member is unportable - "
1513 "use gnulib module group-member for portability");
1519 # if @REPLACE_ISATTY@
1520 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1522 # define isatty rpl_isatty
1524 # define GNULIB_defined_isatty 1
1525 _GL_FUNCDECL_RPL (isatty, int, (int fd));
1526 _GL_CXXALIAS_RPL (isatty, int, (int fd));
1527 # elif defined _WIN32 && !defined __CYGWIN__
1528 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1530 # define isatty _isatty
1532 _GL_CXXALIAS_MDA (isatty, int, (int fd));
1534 _GL_CXXALIAS_SYS (isatty, int, (int fd));
1536 _GL_CXXALIASWARN (isatty);
1537 #elif defined GNULIB_POSIXCHECK
1539 # if HAVE_RAW_DECL_ISATTY
1540 _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
1541 "use gnulib module isatty for portability");
1543 #elif @GNULIB_MDA_ISATTY@
1544 /* On native Windows, map 'isatty' to '_isatty', so that -loldnames is not
1545 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1546 platforms by defining GNULIB_NAMESPACE::isatty always. */
1547 # if defined _WIN32 && !defined __CYGWIN__
1548 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1550 # define isatty _isatty
1552 _GL_CXXALIAS_MDA (isatty, int, (int fd));
1554 _GL_CXXALIAS_SYS (isatty, int, (int fd));
1556 _GL_CXXALIASWARN (isatty);
1561 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1562 to GID (if GID is not -1). Do not follow symbolic links.
1563 Return 0 if successful, otherwise -1 and errno set.
1564 See the POSIX:2008 specification
1565 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1566 # if @REPLACE_LCHOWN@
1567 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1569 # define lchown rpl_lchown
1571 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
1572 _GL_ARG_NONNULL ((1)));
1573 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
1576 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
1577 _GL_ARG_NONNULL ((1)));
1579 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
1581 _GL_CXXALIASWARN (lchown);
1582 #elif defined GNULIB_POSIXCHECK
1584 # if HAVE_RAW_DECL_LCHOWN
1585 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1586 "use gnulib module lchown for portability");
1592 /* Create a new hard link for an existing file.
1593 Return 0 if successful, otherwise -1 and errno set.
1594 See POSIX:2008 specification
1595 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1597 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1598 # define link rpl_link
1600 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
1601 _GL_ARG_NONNULL ((1, 2)));
1602 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
1605 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
1606 _GL_ARG_NONNULL ((1, 2)));
1608 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
1610 _GL_CXXALIASWARN (link);
1611 #elif defined GNULIB_POSIXCHECK
1613 # if HAVE_RAW_DECL_LINK
1614 _GL_WARN_ON_USE (link, "link is unportable - "
1615 "use gnulib module link for portability");
1621 /* Create a new hard link for an existing file, relative to two
1622 directories. FLAG controls whether symlinks are followed.
1623 Return 0 if successful, otherwise -1 and errno set. */
1624 # if @REPLACE_LINKAT@
1625 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1627 # define linkat rpl_linkat
1629 _GL_FUNCDECL_RPL (linkat, int,
1630 (int fd1, const char *path1, int fd2, const char *path2,
1632 _GL_ARG_NONNULL ((2, 4)));
1633 _GL_CXXALIAS_RPL (linkat, int,
1634 (int fd1, const char *path1, int fd2, const char *path2,
1638 _GL_FUNCDECL_SYS (linkat, int,
1639 (int fd1, const char *path1, int fd2, const char *path2,
1641 _GL_ARG_NONNULL ((2, 4)));
1643 _GL_CXXALIAS_SYS (linkat, int,
1644 (int fd1, const char *path1, int fd2, const char *path2,
1647 _GL_CXXALIASWARN (linkat);
1648 #elif defined GNULIB_POSIXCHECK
1650 # if HAVE_RAW_DECL_LINKAT
1651 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1652 "use gnulib module linkat for portability");
1658 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1659 Return the new offset if successful, otherwise -1 and errno set.
1660 See the POSIX:2008 specification
1661 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1662 # if @REPLACE_LSEEK@
1663 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1664 # define lseek rpl_lseek
1666 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1667 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1668 # elif defined _WIN32 && !defined __CYGWIN__
1669 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1671 # define lseek _lseek
1673 _GL_CXXALIAS_MDA (lseek, off_t, (int fd, off_t offset, int whence));
1675 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1677 _GL_CXXALIASWARN (lseek);
1678 #elif defined GNULIB_POSIXCHECK
1680 # if HAVE_RAW_DECL_LSEEK
1681 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1682 "systems - use gnulib module lseek for portability");
1684 #elif @GNULIB_MDA_LSEEK@
1685 /* On native Windows, map 'lseek' to '_lseek', so that -loldnames is not
1686 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1687 platforms by defining GNULIB_NAMESPACE::lseek always. */
1688 # if defined _WIN32 && !defined __CYGWIN__
1689 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1691 # define lseek _lseek
1693 _GL_CXXALIAS_MDA (lseek, long, (int fd, long offset, int whence));
1695 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1697 _GL_CXXALIASWARN (lseek);
1702 /* Create a pipe, defaulting to O_BINARY mode.
1703 Store the read-end as fd[0] and the write-end as fd[1].
1704 Return 0 upon success, or -1 with errno set upon failure. */
1706 _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1708 _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1709 _GL_CXXALIASWARN (pipe);
1710 #elif defined GNULIB_POSIXCHECK
1712 # if HAVE_RAW_DECL_PIPE
1713 _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1714 "use gnulib module pipe-posix for portability");
1720 /* Create a pipe, applying the given flags when opening the read-end of the
1721 pipe and the write-end of the pipe.
1722 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1723 and O_TEXT, O_BINARY (defined in "binary-io.h").
1724 Store the read-end as fd[0] and the write-end as fd[1].
1725 Return 0 upon success, or -1 with errno set upon failure.
1726 See also the Linux man page at
1727 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1729 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1730 # define pipe2 rpl_pipe2
1732 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1733 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1735 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1736 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1738 _GL_CXXALIASWARN (pipe2);
1739 #elif defined GNULIB_POSIXCHECK
1741 # if HAVE_RAW_DECL_PIPE2
1742 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1743 "use gnulib module pipe2 for portability");
1749 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1750 Return the number of bytes placed into BUF if successful, otherwise
1751 set errno and return -1. 0 indicates EOF.
1752 See the POSIX:2008 specification
1753 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1754 # if @REPLACE_PREAD@
1755 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1757 # define pread rpl_pread
1759 _GL_FUNCDECL_RPL (pread, ssize_t,
1760 (int fd, void *buf, size_t bufsize, off_t offset)
1761 _GL_ARG_NONNULL ((2)));
1762 _GL_CXXALIAS_RPL (pread, ssize_t,
1763 (int fd, void *buf, size_t bufsize, off_t offset));
1766 _GL_FUNCDECL_SYS (pread, ssize_t,
1767 (int fd, void *buf, size_t bufsize, off_t offset)
1768 _GL_ARG_NONNULL ((2)));
1770 _GL_CXXALIAS_SYS (pread, ssize_t,
1771 (int fd, void *buf, size_t bufsize, off_t offset));
1773 _GL_CXXALIASWARN (pread);
1774 #elif defined GNULIB_POSIXCHECK
1776 # if HAVE_RAW_DECL_PREAD
1777 _GL_WARN_ON_USE (pread, "pread is unportable - "
1778 "use gnulib module pread for portability");
1784 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1785 Return the number of bytes written if successful, otherwise
1786 set errno and return -1. 0 indicates nothing written. See the
1787 POSIX:2008 specification
1788 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1789 # if @REPLACE_PWRITE@
1790 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1792 # define pwrite rpl_pwrite
1794 _GL_FUNCDECL_RPL (pwrite, ssize_t,
1795 (int fd, const void *buf, size_t bufsize, off_t offset)
1796 _GL_ARG_NONNULL ((2)));
1797 _GL_CXXALIAS_RPL (pwrite, ssize_t,
1798 (int fd, const void *buf, size_t bufsize, off_t offset));
1801 _GL_FUNCDECL_SYS (pwrite, ssize_t,
1802 (int fd, const void *buf, size_t bufsize, off_t offset)
1803 _GL_ARG_NONNULL ((2)));
1805 _GL_CXXALIAS_SYS (pwrite, ssize_t,
1806 (int fd, const void *buf, size_t bufsize, off_t offset));
1808 _GL_CXXALIASWARN (pwrite);
1809 #elif defined GNULIB_POSIXCHECK
1811 # if HAVE_RAW_DECL_PWRITE
1812 _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1813 "use gnulib module pwrite for portability");
1819 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1820 at BUF. See the POSIX:2008 specification
1821 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1823 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1825 # define read rpl_read
1827 _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1828 _GL_ARG_NONNULL ((2)));
1829 _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1830 # elif defined _WIN32 && !defined __CYGWIN__
1831 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1835 _GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, size_t count));
1837 _GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1839 _GL_CXXALIASWARN (read);
1840 #elif @GNULIB_MDA_READ@
1841 /* On native Windows, map 'read' to '_read', so that -loldnames is not
1842 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1843 platforms by defining GNULIB_NAMESPACE::read always. */
1844 # if defined _WIN32 && !defined __CYGWIN__
1845 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1850 _GL_CXXALIAS_MDA (read, int, (int fd, void *buf, unsigned int count));
1852 _GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, unsigned int count));
1855 _GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1857 _GL_CXXALIASWARN (read);
1861 #if @GNULIB_READLINK@
1862 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1863 bytes of it into BUF. Return the number of bytes placed into BUF if
1864 successful, otherwise -1 and errno set.
1865 See the POSIX:2008 specification
1866 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1867 # if @REPLACE_READLINK@
1868 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1869 # define readlink rpl_readlink
1871 _GL_FUNCDECL_RPL (readlink, ssize_t,
1872 (const char *restrict file,
1873 char *restrict buf, size_t bufsize)
1874 _GL_ARG_NONNULL ((1, 2)));
1875 _GL_CXXALIAS_RPL (readlink, ssize_t,
1876 (const char *restrict file,
1877 char *restrict buf, size_t bufsize));
1879 # if !@HAVE_READLINK@
1880 _GL_FUNCDECL_SYS (readlink, ssize_t,
1881 (const char *restrict file,
1882 char *restrict buf, size_t bufsize)
1883 _GL_ARG_NONNULL ((1, 2)));
1885 _GL_CXXALIAS_SYS (readlink, ssize_t,
1886 (const char *restrict file,
1887 char *restrict buf, size_t bufsize));
1889 _GL_CXXALIASWARN (readlink);
1890 #elif defined GNULIB_POSIXCHECK
1892 # if HAVE_RAW_DECL_READLINK
1893 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1894 "use gnulib module readlink for portability");
1899 #if @GNULIB_READLINKAT@
1900 # if @REPLACE_READLINKAT@
1901 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1902 # define readlinkat rpl_readlinkat
1904 _GL_FUNCDECL_RPL (readlinkat, ssize_t,
1905 (int fd, char const *restrict file,
1906 char *restrict buf, size_t len)
1907 _GL_ARG_NONNULL ((2, 3)));
1908 _GL_CXXALIAS_RPL (readlinkat, ssize_t,
1909 (int fd, char const *restrict file,
1910 char *restrict buf, size_t len));
1912 # if !@HAVE_READLINKAT@
1913 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
1914 (int fd, char const *restrict file,
1915 char *restrict buf, size_t len)
1916 _GL_ARG_NONNULL ((2, 3)));
1918 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1919 (int fd, char const *restrict file,
1920 char *restrict buf, size_t len));
1922 _GL_CXXALIASWARN (readlinkat);
1923 #elif defined GNULIB_POSIXCHECK
1925 # if HAVE_RAW_DECL_READLINKAT
1926 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1927 "use gnulib module readlinkat for portability");
1933 /* Remove the directory DIR. */
1934 # if @REPLACE_RMDIR@
1935 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1936 # define rmdir rpl_rmdir
1938 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1939 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1940 # elif defined _WIN32 && !defined __CYGWIN__
1941 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1943 # define rmdir _rmdir
1945 _GL_CXXALIAS_MDA (rmdir, int, (char const *name));
1947 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1949 _GL_CXXALIASWARN (rmdir);
1950 #elif defined GNULIB_POSIXCHECK
1952 # if HAVE_RAW_DECL_RMDIR
1953 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1954 "use gnulib module rmdir for portability");
1956 #elif @GNULIB_MDA_RMDIR@
1957 /* On native Windows, map 'rmdir' to '_rmdir', so that -loldnames is not
1958 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1959 platforms by defining GNULIB_NAMESPACE::rmdir always. */
1960 # if defined _WIN32 && !defined __CYGWIN__
1961 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1963 # define rmdir _rmdir
1965 _GL_CXXALIAS_MDA (rmdir, int, (char const *name));
1967 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1969 _GL_CXXALIASWARN (rmdir);
1973 #if @GNULIB_SETHOSTNAME@
1974 /* Set the host name of the machine.
1975 The host name may or may not be fully qualified.
1977 Put LEN bytes of NAME into the host name.
1978 Return 0 if successful, otherwise, set errno and return -1.
1980 Platforms with no ability to set the hostname return -1 and set
1982 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1983 _GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
1984 _GL_ARG_NONNULL ((1)));
1986 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1987 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1988 2011-10, the first parameter is not const. */
1989 _GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
1990 _GL_CXXALIASWARN (sethostname);
1991 #elif defined GNULIB_POSIXCHECK
1993 # if HAVE_RAW_DECL_SETHOSTNAME
1994 _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1995 "use gnulib module sethostname for portability");
2001 /* Pause the execution of the current thread for N seconds.
2002 Returns the number of seconds left to sleep.
2003 See the POSIX:2008 specification
2004 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
2005 # if @REPLACE_SLEEP@
2006 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2008 # define sleep rpl_sleep
2010 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
2011 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
2014 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
2016 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
2018 _GL_CXXALIASWARN (sleep);
2019 #elif defined GNULIB_POSIXCHECK
2021 # if HAVE_RAW_DECL_SLEEP
2022 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
2023 "use gnulib module sleep for portability");
2028 #if @GNULIB_MDA_SWAB@
2029 /* On native Windows, map 'swab' to '_swab', so that -loldnames is not
2030 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2031 platforms by defining GNULIB_NAMESPACE::swab always. */
2032 # if defined _WIN32 && !defined __CYGWIN__
2033 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2037 /* Need to cast, because in old mingw the arguments are
2038 (const char *from, char *to, size_t n). */
2039 _GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n));
2041 # if defined __hpux /* HP-UX */
2042 _GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
2043 # elif defined __sun && !defined _XPG4 /* Solaris */
2044 _GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
2046 _GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));
2049 _GL_CXXALIASWARN (swab);
2053 #if @GNULIB_SYMLINK@
2054 # if @REPLACE_SYMLINK@
2055 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2057 # define symlink rpl_symlink
2059 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
2060 _GL_ARG_NONNULL ((1, 2)));
2061 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
2063 # if !@HAVE_SYMLINK@
2064 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
2065 _GL_ARG_NONNULL ((1, 2)));
2067 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
2069 _GL_CXXALIASWARN (symlink);
2070 #elif defined GNULIB_POSIXCHECK
2072 # if HAVE_RAW_DECL_SYMLINK
2073 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
2074 "use gnulib module symlink for portability");
2079 #if @GNULIB_SYMLINKAT@
2080 # if @REPLACE_SYMLINKAT@
2081 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2083 # define symlinkat rpl_symlinkat
2085 _GL_FUNCDECL_RPL (symlinkat, int,
2086 (char const *contents, int fd, char const *file)
2087 _GL_ARG_NONNULL ((1, 3)));
2088 _GL_CXXALIAS_RPL (symlinkat, int,
2089 (char const *contents, int fd, char const *file));
2091 # if !@HAVE_SYMLINKAT@
2092 _GL_FUNCDECL_SYS (symlinkat, int,
2093 (char const *contents, int fd, char const *file)
2094 _GL_ARG_NONNULL ((1, 3)));
2096 _GL_CXXALIAS_SYS (symlinkat, int,
2097 (char const *contents, int fd, char const *file));
2099 _GL_CXXALIASWARN (symlinkat);
2100 #elif defined GNULIB_POSIXCHECK
2102 # if HAVE_RAW_DECL_SYMLINKAT
2103 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
2104 "use gnulib module symlinkat for portability");
2109 #if @GNULIB_TRUNCATE@
2110 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
2111 Return 0 if successful, otherwise -1 and errno set.
2112 See the POSIX:2008 specification
2113 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
2114 # if @REPLACE_TRUNCATE@
2115 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2117 # define truncate rpl_truncate
2119 _GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
2120 _GL_ARG_NONNULL ((1)));
2121 _GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
2123 # if !@HAVE_DECL_TRUNCATE@
2124 _GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
2125 _GL_ARG_NONNULL ((1)));
2127 _GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
2129 _GL_CXXALIASWARN (truncate);
2130 #elif defined GNULIB_POSIXCHECK
2132 # if HAVE_RAW_DECL_TRUNCATE
2133 _GL_WARN_ON_USE (truncate, "truncate is unportable - "
2134 "use gnulib module truncate for portability");
2139 #if @GNULIB_TTYNAME_R@
2140 /* Store at most BUFLEN characters of the pathname of the terminal FD is
2141 open on in BUF. Return 0 on success, otherwise an error number. */
2142 # if @REPLACE_TTYNAME_R@
2143 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2145 # define ttyname_r rpl_ttyname_r
2147 _GL_FUNCDECL_RPL (ttyname_r, int,
2148 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
2149 _GL_CXXALIAS_RPL (ttyname_r, int,
2150 (int fd, char *buf, size_t buflen));
2152 # if !@HAVE_DECL_TTYNAME_R@
2153 _GL_FUNCDECL_SYS (ttyname_r, int,
2154 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
2156 _GL_CXXALIAS_SYS (ttyname_r, int,
2157 (int fd, char *buf, size_t buflen));
2159 _GL_CXXALIASWARN (ttyname_r);
2160 #elif defined GNULIB_POSIXCHECK
2162 # if HAVE_RAW_DECL_TTYNAME_R
2163 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
2164 "use gnulib module ttyname_r for portability");
2170 # if @REPLACE_UNLINK@
2171 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2173 # define unlink rpl_unlink
2175 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
2176 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
2177 # elif defined _WIN32 && !defined __CYGWIN__
2178 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2180 # define unlink _unlink
2182 _GL_CXXALIAS_MDA (unlink, int, (char const *file));
2184 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
2186 _GL_CXXALIASWARN (unlink);
2187 #elif defined GNULIB_POSIXCHECK
2189 # if HAVE_RAW_DECL_UNLINK
2190 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
2191 "use gnulib module unlink for portability");
2193 #elif @GNULIB_MDA_UNLINK@
2194 /* On native Windows, map 'unlink' to '_unlink', so that -loldnames is not
2195 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2196 platforms by defining GNULIB_NAMESPACE::unlink always. */
2197 # if defined _WIN32 && !defined __CYGWIN__
2198 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2200 # define unlink _unlink
2202 _GL_CXXALIAS_MDA (unlink, int, (char const *file));
2204 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
2206 _GL_CXXALIASWARN (unlink);
2210 #if @GNULIB_UNLINKAT@
2211 # if @REPLACE_UNLINKAT@
2212 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2214 # define unlinkat rpl_unlinkat
2216 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
2217 _GL_ARG_NONNULL ((2)));
2218 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
2220 # if !@HAVE_UNLINKAT@
2221 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
2222 _GL_ARG_NONNULL ((2)));
2224 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
2226 _GL_CXXALIASWARN (unlinkat);
2227 #elif defined GNULIB_POSIXCHECK
2229 # if HAVE_RAW_DECL_UNLINKAT
2230 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
2231 "use gnulib module unlinkat for portability");
2237 /* Pause the execution of the current thread for N microseconds.
2238 Returns 0 on completion, or -1 on range error.
2239 See the POSIX:2001 specification
2240 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
2241 # if @REPLACE_USLEEP@
2242 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2244 # define usleep rpl_usleep
2246 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
2247 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
2250 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
2252 /* Need to cast, because on Haiku, the first parameter is
2254 _GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n));
2256 _GL_CXXALIASWARN (usleep);
2257 #elif defined GNULIB_POSIXCHECK
2259 # if HAVE_RAW_DECL_USLEEP
2260 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
2261 "use gnulib module usleep for portability");
2267 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
2268 See the POSIX:2008 specification
2269 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
2270 # if @REPLACE_WRITE@
2271 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2273 # define write rpl_write
2275 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
2276 _GL_ARG_NONNULL ((2)));
2277 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
2278 # elif defined _WIN32 && !defined __CYGWIN__
2279 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2281 # define write _write
2283 _GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, size_t count));
2285 _GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
2287 _GL_CXXALIASWARN (write);
2288 #elif @GNULIB_MDA_WRITE@
2289 /* On native Windows, map 'write' to '_write', so that -loldnames is not
2290 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2291 platforms by defining GNULIB_NAMESPACE::write always. */
2292 # if defined _WIN32 && !defined __CYGWIN__
2293 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2295 # define write _write
2298 _GL_CXXALIAS_MDA (write, int, (int fd, const void *buf, unsigned int count));
2300 _GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, unsigned int count));
2303 _GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
2305 _GL_CXXALIASWARN (write);
2308 _GL_INLINE_HEADER_END
2310 #endif /* _@GUARD_PREFIX@_UNISTD_H */
2311 #endif /* _GL_INCLUDING_UNISTD_H */
2312 #endif /* _@GUARD_PREFIX@_UNISTD_H */