1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2022 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 @REPLACE_COPY_FILE_RANGE@
419 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
420 # undef copy_file_range
421 # define copy_file_range rpl_copy_file_range
423 _GL_FUNCDECL_RPL (copy_file_range
, ssize_t
, (int ifd
, off_t
*ipos
,
424 int ofd
, off_t
*opos
,
425 size_t len
, unsigned flags
));
426 _GL_CXXALIAS_RPL (copy_file_range
, ssize_t
, (int ifd
, off_t
*ipos
,
427 int ofd
, off_t
*opos
,
428 size_t len
, unsigned flags
));
430 # if !@HAVE_COPY_FILE_RANGE@
431 _GL_FUNCDECL_SYS (copy_file_range
, ssize_t
, (int ifd
, off_t
*ipos
,
432 int ofd
, off_t
*opos
,
433 size_t len
, unsigned flags
));
435 _GL_CXXALIAS_SYS (copy_file_range
, ssize_t
, (int ifd
, off_t
*ipos
,
436 int ofd
, off_t
*opos
,
437 size_t len
, unsigned flags
));
439 _GL_CXXALIASWARN (copy_file_range
);
440 #elif defined GNULIB_POSIXCHECK
441 # undef copy_file_range
442 # if HAVE_RAW_DECL_COPY_FILE_RANGE
443 _GL_WARN_ON_USE (copy_file_range
,
444 "copy_file_range is unportable - "
445 "use gnulib module copy_file_range for portability");
452 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
455 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
456 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
457 # elif defined _WIN32 && !defined __CYGWIN__
458 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
462 _GL_CXXALIAS_MDA (dup
, int, (int oldfd
));
464 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
466 _GL_CXXALIASWARN (dup
);
467 #elif defined GNULIB_POSIXCHECK
469 # if HAVE_RAW_DECL_DUP
470 _GL_WARN_ON_USE (dup
, "dup is unportable - "
471 "use gnulib module dup for portability");
473 #elif @GNULIB_MDA_DUP@
474 /* On native Windows, map 'dup' to '_dup', so that -loldnames is not
475 required. In C++ with GNULIB_NAMESPACE, avoid differences between
476 platforms by defining GNULIB_NAMESPACE::dup always. */
477 # if defined _WIN32 && !defined __CYGWIN__
478 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
482 _GL_CXXALIAS_MDA (dup
, int, (int oldfd
));
484 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
486 _GL_CXXALIASWARN (dup
);
491 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
492 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
493 Return newfd if successful, otherwise -1 and errno set.
494 See the POSIX:2008 specification
495 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
497 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
498 # define dup2 rpl_dup2
500 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
501 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
502 # elif defined _WIN32 && !defined __CYGWIN__
503 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
507 _GL_CXXALIAS_MDA (dup2
, int, (int oldfd
, int newfd
));
509 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
511 _GL_CXXALIASWARN (dup2
);
512 #elif defined GNULIB_POSIXCHECK
514 # if HAVE_RAW_DECL_DUP2
515 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
516 "use gnulib module dup2 for portability");
518 #elif @GNULIB_MDA_DUP2@
519 /* On native Windows, map 'dup2' to '_dup2', so that -loldnames is not
520 required. In C++ with GNULIB_NAMESPACE, avoid differences between
521 platforms by defining GNULIB_NAMESPACE::dup2 always. */
522 # if defined _WIN32 && !defined __CYGWIN__
523 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
527 _GL_CXXALIAS_MDA (dup2
, int, (int oldfd
, int newfd
));
529 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
531 _GL_CXXALIASWARN (dup2
);
536 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
538 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
539 and O_TEXT, O_BINARY (defined in "binary-io.h").
540 Close NEWFD first if it is open.
541 Return newfd if successful, otherwise -1 and errno set.
542 See the Linux man page at
543 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
545 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
546 # define dup3 rpl_dup3
548 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
549 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
551 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
552 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
554 _GL_CXXALIASWARN (dup3
);
555 #elif defined GNULIB_POSIXCHECK
557 # if HAVE_RAW_DECL_DUP3
558 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
559 "use gnulib module dup3 for portability");
565 # if defined __CYGWIN__ && !defined __i386__
566 /* The 'environ' variable is defined in a DLL. Therefore its declaration needs
567 the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
568 This leads to a link error on 64-bit Cygwin when the option
569 -Wl,--disable-auto-import is in use. */
570 _GL_EXTERN_C
__declspec(dllimport
) char **environ
;
572 # if !@HAVE_DECL_ENVIRON@
573 /* Set of environment variables and values. An array of strings of the form
574 "VARIABLE=VALUE", terminated with a NULL. */
575 # if defined __APPLE__ && defined __MACH__
576 # include <TargetConditionals.h>
577 # if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
578 # define _GL_USE_CRT_EXTERNS
581 # ifdef _GL_USE_CRT_EXTERNS
582 # include <crt_externs.h>
583 # define environ (*_NSGetEnviron ())
588 extern char **environ
;
594 #elif defined GNULIB_POSIXCHECK
595 # if HAVE_RAW_DECL_ENVIRON
596 _GL_UNISTD_INLINE
char ***
597 _GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
598 "use gnulib module environ for portability")
604 # define environ (*rpl_environ ())
609 #if @GNULIB_EUIDACCESS@
610 /* Like access(), except that it uses the effective user id and group id of
611 the current process. */
612 # if !@HAVE_EUIDACCESS@
613 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
614 _GL_ARG_NONNULL ((1)));
616 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
617 _GL_CXXALIASWARN (euidaccess
);
618 # if defined GNULIB_POSIXCHECK
619 /* Like access(), this function is a security risk. */
620 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
621 "use the gnulib module faccessat instead");
623 #elif defined GNULIB_POSIXCHECK
625 # if HAVE_RAW_DECL_EUIDACCESS
626 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
627 "use gnulib module euidaccess for portability");
634 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
636 # define execl rpl_execl
638 _GL_FUNCDECL_RPL (execl
, int, (const char *program
, const char *arg
, ...)
639 _GL_ARG_NONNULL ((1)));
640 _GL_CXXALIAS_RPL (execl
, int, (const char *program
, const char *arg
, ...));
642 _GL_CXXALIAS_SYS (execl
, int, (const char *program
, const char *arg
, ...));
644 _GL_CXXALIASWARN (execl
);
645 #elif defined GNULIB_POSIXCHECK
647 # if HAVE_RAW_DECL_EXECL
648 _GL_WARN_ON_USE (execl
, "execl behaves very differently on mingw - "
649 "use gnulib module execl for portability");
651 #elif @GNULIB_MDA_EXECL@
652 /* On native Windows, map 'execl' to '_execl', so that -loldnames is not
653 required. In C++ with GNULIB_NAMESPACE, avoid differences between
654 platforms by defining GNULIB_NAMESPACE::execl always. */
655 # if defined _WIN32 && !defined __CYGWIN__
656 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
658 # define execl _execl
660 _GL_CXXALIAS_MDA (execl
, intptr_t, (const char *program
, const char *arg
, ...));
662 _GL_CXXALIAS_SYS (execl
, int, (const char *program
, const char *arg
, ...));
664 _GL_CXXALIASWARN (execl
);
668 # if @REPLACE_EXECLE@
669 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
671 # define execle rpl_execle
673 _GL_FUNCDECL_RPL (execle
, int, (const char *program
, const char *arg
, ...)
674 _GL_ARG_NONNULL ((1)));
675 _GL_CXXALIAS_RPL (execle
, int, (const char *program
, const char *arg
, ...));
677 _GL_CXXALIAS_SYS (execle
, int, (const char *program
, const char *arg
, ...));
679 _GL_CXXALIASWARN (execle
);
680 #elif defined GNULIB_POSIXCHECK
682 # if HAVE_RAW_DECL_EXECLE
683 _GL_WARN_ON_USE (execle
, "execle behaves very differently on mingw - "
684 "use gnulib module execle for portability");
686 #elif @GNULIB_MDA_EXECLE@
687 /* On native Windows, map 'execle' to '_execle', so that -loldnames is not
688 required. In C++ with GNULIB_NAMESPACE, avoid differences between
689 platforms by defining GNULIB_NAMESPACE::execle always. */
690 # if defined _WIN32 && !defined __CYGWIN__
691 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
693 # define execle _execle
695 _GL_CXXALIAS_MDA (execle
, intptr_t,
696 (const char *program
, const char *arg
, ...));
698 _GL_CXXALIAS_SYS (execle
, int, (const char *program
, const char *arg
, ...));
700 _GL_CXXALIASWARN (execle
);
704 # if @REPLACE_EXECLP@
705 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
707 # define execlp rpl_execlp
709 _GL_FUNCDECL_RPL (execlp
, int, (const char *program
, const char *arg
, ...)
710 _GL_ARG_NONNULL ((1)));
711 _GL_CXXALIAS_RPL (execlp
, int, (const char *program
, const char *arg
, ...));
713 _GL_CXXALIAS_SYS (execlp
, int, (const char *program
, const char *arg
, ...));
715 _GL_CXXALIASWARN (execlp
);
716 #elif defined GNULIB_POSIXCHECK
718 # if HAVE_RAW_DECL_EXECLP
719 _GL_WARN_ON_USE (execlp
, "execlp behaves very differently on mingw - "
720 "use gnulib module execlp for portability");
722 #elif @GNULIB_MDA_EXECLP@
723 /* On native Windows, map 'execlp' to '_execlp', so that -loldnames is not
724 required. In C++ with GNULIB_NAMESPACE, avoid differences between
725 platforms by defining GNULIB_NAMESPACE::execlp always. */
726 # if defined _WIN32 && !defined __CYGWIN__
727 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
729 # define execlp _execlp
731 _GL_CXXALIAS_MDA (execlp
, intptr_t,
732 (const char *program
, const char *arg
, ...));
734 _GL_CXXALIAS_SYS (execlp
, int, (const char *program
, const char *arg
, ...));
736 _GL_CXXALIASWARN (execlp
);
742 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
744 # define execv rpl_execv
746 _GL_FUNCDECL_RPL (execv
, int, (const char *program
, char * const *argv
)
747 _GL_ARG_NONNULL ((1, 2)));
748 _GL_CXXALIAS_RPL (execv
, int, (const char *program
, char * const *argv
));
750 _GL_CXXALIAS_SYS (execv
, int, (const char *program
, char * const *argv
));
752 _GL_CXXALIASWARN (execv
);
753 #elif defined GNULIB_POSIXCHECK
755 # if HAVE_RAW_DECL_EXECV
756 _GL_WARN_ON_USE (execv
, "execv behaves very differently on mingw - "
757 "use gnulib module execv for portability");
759 #elif @GNULIB_MDA_EXECV@
760 /* On native Windows, map 'execv' to '_execv', so that -loldnames is not
761 required. In C++ with GNULIB_NAMESPACE, avoid differences between
762 platforms by defining GNULIB_NAMESPACE::execv always. */
763 # if defined _WIN32 && !defined __CYGWIN__
764 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
766 # define execv _execv
768 _GL_CXXALIAS_MDA_CAST (execv
, intptr_t,
769 (const char *program
, char * const *argv
));
771 _GL_CXXALIAS_SYS (execv
, int, (const char *program
, char * const *argv
));
773 _GL_CXXALIASWARN (execv
);
777 # if @REPLACE_EXECVE@
778 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
780 # define execve rpl_execve
782 _GL_FUNCDECL_RPL (execve
, int,
783 (const char *program
, char * const *argv
, char * const *env
)
784 _GL_ARG_NONNULL ((1, 2)));
785 _GL_CXXALIAS_RPL (execve
, int,
786 (const char *program
, char * const *argv
, char * const *env
));
788 _GL_CXXALIAS_SYS (execve
, int,
789 (const char *program
, char * const *argv
, char * const *env
));
791 _GL_CXXALIASWARN (execve
);
792 #elif defined GNULIB_POSIXCHECK
794 # if HAVE_RAW_DECL_EXECVE
795 _GL_WARN_ON_USE (execve
, "execve behaves very differently on mingw - "
796 "use gnulib module execve for portability");
798 #elif @GNULIB_MDA_EXECVE@
799 /* On native Windows, map 'execve' to '_execve', so that -loldnames is not
800 required. In C++ with GNULIB_NAMESPACE, avoid differences between
801 platforms by defining GNULIB_NAMESPACE::execve always. */
802 # if defined _WIN32 && !defined __CYGWIN__
803 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
805 # define execve _execve
807 _GL_CXXALIAS_MDA_CAST (execve
, intptr_t,
808 (const char *program
, char * const *argv
,
811 _GL_CXXALIAS_SYS (execve
, int,
812 (const char *program
, char * const *argv
, char * const *env
));
814 _GL_CXXALIASWARN (execve
);
818 # if @REPLACE_EXECVP@
819 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
821 # define execvp rpl_execvp
823 _GL_FUNCDECL_RPL (execvp
, int, (const char *program
, char * const *argv
)
824 _GL_ARG_NONNULL ((1, 2)));
825 _GL_CXXALIAS_RPL (execvp
, int, (const char *program
, char * const *argv
));
827 _GL_CXXALIAS_SYS (execvp
, int, (const char *program
, char * const *argv
));
829 _GL_CXXALIASWARN (execvp
);
830 #elif defined GNULIB_POSIXCHECK
832 # if HAVE_RAW_DECL_EXECVP
833 _GL_WARN_ON_USE (execvp
, "execvp behaves very differently on mingw - "
834 "use gnulib module execvp for portability");
836 #elif @GNULIB_MDA_EXECVP@
837 /* On native Windows, map 'execvp' to '_execvp', so that -loldnames is not
838 required. In C++ with GNULIB_NAMESPACE, avoid differences between
839 platforms by defining GNULIB_NAMESPACE::execvp always. */
840 # if defined _WIN32 && !defined __CYGWIN__
841 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
843 # define execvp _execvp
845 _GL_CXXALIAS_MDA_CAST (execvp
, intptr_t,
846 (const char *program
, char * const *argv
));
848 _GL_CXXALIAS_SYS (execvp
, int, (const char *program
, char * const *argv
));
850 _GL_CXXALIASWARN (execvp
);
854 # if @REPLACE_EXECVPE@
855 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
857 # define execvpe rpl_execvpe
859 _GL_FUNCDECL_RPL (execvpe
, int,
860 (const char *program
, char * const *argv
, char * const *env
)
861 _GL_ARG_NONNULL ((1, 2)));
862 _GL_CXXALIAS_RPL (execvpe
, int,
863 (const char *program
, char * const *argv
, char * const *env
));
865 # if !@HAVE_DECL_EXECVPE@
866 _GL_FUNCDECL_SYS (execvpe
, int,
867 (const char *program
, char * const *argv
, char * const *env
)
868 _GL_ARG_NONNULL ((1, 2)));
870 _GL_CXXALIAS_SYS (execvpe
, int,
871 (const char *program
, char * const *argv
, char * const *env
));
873 _GL_CXXALIASWARN (execvpe
);
874 #elif defined GNULIB_POSIXCHECK
876 # if HAVE_RAW_DECL_EXECVPE
877 _GL_WARN_ON_USE (execvpe
, "execvpe behaves very differently on mingw - "
878 "use gnulib module execvpe for portability");
880 #elif @GNULIB_MDA_EXECVPE@
881 /* On native Windows, map 'execvpe' to '_execvpe', so that -loldnames is not
882 required. In C++ with GNULIB_NAMESPACE, avoid differences between
883 platforms by defining GNULIB_NAMESPACE::execvpe on all platforms that have
885 # if defined _WIN32 && !defined __CYGWIN__
886 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
888 # define execvpe _execvpe
890 _GL_CXXALIAS_MDA_CAST (execvpe
, intptr_t,
891 (const char *program
, char * const *argv
,
893 # elif @HAVE_EXECVPE@
894 # if !@HAVE_DECL_EXECVPE@
895 _GL_FUNCDECL_SYS (execvpe
, int,
896 (const char *program
, char * const *argv
, char * const *env
)
897 _GL_ARG_NONNULL ((1, 2)));
899 _GL_CXXALIAS_SYS (execvpe
, int,
900 (const char *program
, char * const *argv
, char * const *env
));
902 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_EXECVPE@
903 _GL_CXXALIASWARN (execvpe
);
908 #if @GNULIB_FACCESSAT@
909 # if @REPLACE_FACCESSAT@
910 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
912 # define faccessat rpl_faccessat
914 _GL_FUNCDECL_RPL (faccessat
, int,
915 (int fd
, char const *name
, int mode
, int flag
)
916 _GL_ARG_NONNULL ((2)));
917 _GL_CXXALIAS_RPL (faccessat
, int,
918 (int fd
, char const *name
, int mode
, int flag
));
920 # if !@HAVE_FACCESSAT@
921 _GL_FUNCDECL_SYS (faccessat
, int,
922 (int fd
, char const *file
, int mode
, int flag
)
923 _GL_ARG_NONNULL ((2)));
925 _GL_CXXALIAS_SYS (faccessat
, int,
926 (int fd
, char const *file
, int mode
, int flag
));
928 _GL_CXXALIASWARN (faccessat
);
929 #elif defined GNULIB_POSIXCHECK
931 # if HAVE_RAW_DECL_FACCESSAT
932 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
933 "use gnulib module faccessat for portability");
939 /* Change the process' current working directory to the directory on which
940 the given file descriptor is open.
941 Return 0 if successful, otherwise -1 and errno set.
942 See the POSIX:2008 specification
943 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
945 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
947 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
948 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
949 _GL_ARG_NONNULL ((2));
950 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
951 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
952 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
955 # if !@HAVE_DECL_FCHDIR@
956 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
959 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
960 _GL_CXXALIASWARN (fchdir
);
961 #elif defined GNULIB_POSIXCHECK
963 # if HAVE_RAW_DECL_FCHDIR
964 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
965 "use gnulib module fchdir for portability");
970 #if @GNULIB_FCHOWNAT@
971 # if @REPLACE_FCHOWNAT@
972 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
974 # define fchownat rpl_fchownat
976 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
977 uid_t owner
, gid_t group
, int flag
)
978 _GL_ARG_NONNULL ((2)));
979 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
980 uid_t owner
, gid_t group
, int flag
));
982 # if !@HAVE_FCHOWNAT@
983 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
984 uid_t owner
, gid_t group
, int flag
)
985 _GL_ARG_NONNULL ((2)));
987 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
988 uid_t owner
, gid_t group
, int flag
));
990 _GL_CXXALIASWARN (fchownat
);
991 #elif defined GNULIB_POSIXCHECK
993 # if HAVE_RAW_DECL_FCHOWNAT
994 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
995 "use gnulib module fchownat for portability");
1000 #if @GNULIB_FDATASYNC@
1001 /* Synchronize changes to a file.
1002 Return 0 if successful, otherwise -1 and errno set.
1003 See POSIX:2008 specification
1004 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
1005 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
1006 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
1008 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
1009 _GL_CXXALIASWARN (fdatasync
);
1010 #elif defined GNULIB_POSIXCHECK
1012 # if HAVE_RAW_DECL_FDATASYNC
1013 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
1014 "use gnulib module fdatasync for portability");
1020 /* Synchronize changes, including metadata, to a file.
1021 Return 0 if successful, otherwise -1 and errno set.
1022 See POSIX:2008 specification
1023 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
1025 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
1027 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
1028 _GL_CXXALIASWARN (fsync
);
1029 #elif defined GNULIB_POSIXCHECK
1031 # if HAVE_RAW_DECL_FSYNC
1032 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
1033 "use gnulib module fsync for portability");
1038 #if @GNULIB_FTRUNCATE@
1039 /* Change the size of the file to which FD is opened to become equal to LENGTH.
1040 Return 0 if successful, otherwise -1 and errno set.
1041 See the POSIX:2008 specification
1042 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
1043 # if @REPLACE_FTRUNCATE@
1044 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1046 # define ftruncate rpl_ftruncate
1048 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
1049 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
1051 # if !@HAVE_FTRUNCATE@
1052 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
1054 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
1056 _GL_CXXALIASWARN (ftruncate
);
1057 #elif defined GNULIB_POSIXCHECK
1059 # if HAVE_RAW_DECL_FTRUNCATE
1060 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
1061 "use gnulib module ftruncate for portability");
1067 /* Get the name of the current working directory, and put it in SIZE bytes
1069 Return BUF if successful, or NULL if the directory couldn't be determined
1070 or SIZE was too small.
1071 See the POSIX:2008 specification
1072 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
1073 Additionally, the gnulib module 'getcwd' guarantees the following GNU
1074 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
1075 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
1077 # if @REPLACE_GETCWD@
1078 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1079 # define getcwd rpl_getcwd
1081 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
1082 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
1083 # elif defined _WIN32 && !defined __CYGWIN__
1084 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1086 # define getcwd _getcwd
1088 _GL_CXXALIAS_MDA (getcwd
, char *, (char *buf
, size_t size
));
1090 /* Need to cast, because on mingw, the second parameter is
1092 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
1094 _GL_CXXALIASWARN (getcwd
);
1095 #elif defined GNULIB_POSIXCHECK
1097 # if HAVE_RAW_DECL_GETCWD
1098 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
1099 "use gnulib module getcwd for portability");
1101 #elif @GNULIB_MDA_GETCWD@
1102 /* On native Windows, map 'getcwd' to '_getcwd', so that -loldnames is not
1103 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1104 platforms by defining GNULIB_NAMESPACE::getcwd always. */
1105 # if defined _WIN32 && !defined __CYGWIN__
1106 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1108 # define getcwd _getcwd
1110 /* Need to cast, because on mingw, the second parameter is either
1111 'int size' or 'size_t size'. */
1112 _GL_CXXALIAS_MDA_CAST (getcwd
, char *, (char *buf
, size_t size
));
1114 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
1116 _GL_CXXALIASWARN (getcwd
);
1120 #if @GNULIB_GETDOMAINNAME@
1121 /* Return the NIS domain name of the machine.
1122 WARNING! The NIS domain name is unrelated to the fully qualified host name
1123 of the machine. It is also unrelated to email addresses.
1124 WARNING! The NIS domain name is usually the empty string or "(none)" when
1127 Put up to LEN bytes of the NIS domain name into NAME.
1128 Null terminate it if the name is shorter than LEN.
1129 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
1130 Return 0 if successful, otherwise set errno and return -1. */
1131 # if @REPLACE_GETDOMAINNAME@
1132 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1133 # undef getdomainname
1134 # define getdomainname rpl_getdomainname
1136 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
1137 _GL_ARG_NONNULL ((1)));
1138 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
1140 # if !@HAVE_DECL_GETDOMAINNAME@
1141 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
1142 _GL_ARG_NONNULL ((1)));
1144 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
1146 _GL_CXXALIASWARN (getdomainname
);
1147 #elif defined GNULIB_POSIXCHECK
1148 # undef getdomainname
1149 # if HAVE_RAW_DECL_GETDOMAINNAME
1150 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
1151 "use gnulib module getdomainname for portability");
1156 #if @GNULIB_GETDTABLESIZE@
1157 /* Return the maximum number of file descriptors in the current process.
1158 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
1159 # if @REPLACE_GETDTABLESIZE@
1160 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1161 # undef getdtablesize
1162 # define getdtablesize rpl_getdtablesize
1164 _GL_FUNCDECL_RPL (getdtablesize
, int, (void));
1165 _GL_CXXALIAS_RPL (getdtablesize
, int, (void));
1167 # if !@HAVE_GETDTABLESIZE@
1168 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
1170 /* Need to cast, because on AIX, the parameter list is
1172 _GL_CXXALIAS_SYS_CAST (getdtablesize
, int, (void));
1174 _GL_CXXALIASWARN (getdtablesize
);
1175 #elif defined GNULIB_POSIXCHECK
1176 # undef getdtablesize
1177 # if HAVE_RAW_DECL_GETDTABLESIZE
1178 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
1179 "use gnulib module getdtablesize for portability");
1184 #if @GNULIB_GETENTROPY@
1185 /* Fill a buffer with random bytes. */
1186 # if !@HAVE_GETENTROPY@
1187 _GL_FUNCDECL_SYS (getentropy
, int, (void *buffer
, size_t length
));
1189 _GL_CXXALIAS_SYS (getentropy
, int, (void *buffer
, size_t length
));
1190 _GL_CXXALIASWARN (getentropy
);
1191 #elif defined GNULIB_POSIXCHECK
1193 # if HAVE_RAW_DECL_GETENTROPY
1194 _GL_WARN_ON_USE (getentropy
, "getentropy is unportable - "
1195 "use gnulib module getentropy for portability");
1200 #if @GNULIB_GETGROUPS@
1201 /* Return the supplemental groups that the current process belongs to.
1202 It is unspecified whether the effective group id is in the list.
1203 If N is 0, return the group count; otherwise, N describes how many
1204 entries are available in GROUPS. Return -1 and set errno if N is
1205 not 0 and not large enough. Fails with ENOSYS on some systems. */
1206 # if @REPLACE_GETGROUPS@
1207 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1209 # define getgroups rpl_getgroups
1211 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
1212 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
1214 # if !@HAVE_GETGROUPS@
1215 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
1217 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
1219 _GL_CXXALIASWARN (getgroups
);
1220 #elif defined GNULIB_POSIXCHECK
1222 # if HAVE_RAW_DECL_GETGROUPS
1223 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
1224 "use gnulib module getgroups for portability");
1229 #if @GNULIB_GETHOSTNAME@
1230 /* Return the standard host name of the machine.
1231 WARNING! The host name may or may not be fully qualified.
1233 Put up to LEN bytes of the host name into NAME.
1234 Null terminate it if the name is shorter than LEN.
1235 If the host name is longer than LEN, set errno = EINVAL and return -1.
1236 Return 0 if successful, otherwise set errno and return -1. */
1237 # if @UNISTD_H_HAVE_WINSOCK2_H@
1238 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1240 # define gethostname rpl_gethostname
1242 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
1243 _GL_ARG_NONNULL ((1)));
1244 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
1246 # if !@HAVE_GETHOSTNAME@
1247 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
1248 _GL_ARG_NONNULL ((1)));
1250 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
1253 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
1255 _GL_CXXALIASWARN (gethostname
);
1256 #elif @UNISTD_H_HAVE_WINSOCK2_H@
1258 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
1259 #elif defined GNULIB_POSIXCHECK
1261 # if HAVE_RAW_DECL_GETHOSTNAME
1262 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
1263 "use gnulib module gethostname for portability");
1268 #if @GNULIB_GETLOGIN@
1269 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
1270 returns NULL with errno set.
1272 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1274 Most programs don't need to use this function, because the information is
1275 available through environment variables:
1276 ${LOGNAME-$USER} on Unix platforms,
1277 $USERNAME on native Windows platforms.
1279 # if !@HAVE_DECL_GETLOGIN@
1280 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
1282 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
1283 _GL_CXXALIASWARN (getlogin
);
1284 #elif defined GNULIB_POSIXCHECK
1286 # if HAVE_RAW_DECL_GETLOGIN
1287 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
1288 "use gnulib module getlogin for portability");
1293 #if @GNULIB_GETLOGIN_R@
1294 /* Copies the user's login name to NAME.
1295 The array pointed to by NAME has room for SIZE bytes.
1297 Returns 0 if successful. Upon error, an error number is returned, or -1 in
1298 the case that the login name cannot be found but no specific error is
1299 provided (this case is hopefully rare but is left open by the POSIX spec).
1301 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1303 Most programs don't need to use this function, because the information is
1304 available through environment variables:
1305 ${LOGNAME-$USER} on Unix platforms,
1306 $USERNAME on native Windows platforms.
1308 # if @REPLACE_GETLOGIN_R@
1309 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1310 # define getlogin_r rpl_getlogin_r
1312 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
1313 _GL_ARG_NONNULL ((1)));
1314 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
1316 # if !@HAVE_DECL_GETLOGIN_R@
1317 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
1318 _GL_ARG_NONNULL ((1)));
1320 /* Need to cast, because on Solaris 10 systems, the second argument is
1322 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
1324 _GL_CXXALIASWARN (getlogin_r
);
1325 #elif defined GNULIB_POSIXCHECK
1327 # if HAVE_RAW_DECL_GETLOGIN_R
1328 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
1329 "use gnulib module getlogin_r for portability");
1334 #if @GNULIB_GETPAGESIZE@
1335 # if @REPLACE_GETPAGESIZE@
1336 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1337 # define getpagesize rpl_getpagesize
1339 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
1340 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
1342 /* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
1343 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */
1345 _GL_FUNCDECL_SYS (getpagesize
, int, (void));
1347 # if !@HAVE_GETPAGESIZE@
1348 # if !defined getpagesize
1349 /* This is for POSIX systems. */
1350 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
1351 # if ! (defined __VMS && __VMS_VER < 70000000)
1352 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
1355 /* This is for older VMS. */
1356 # if !defined _gl_getpagesize && defined __VMS
1358 # define _gl_getpagesize() 8192
1360 # define _gl_getpagesize() 512
1363 /* This is for BeOS. */
1364 # if !defined _gl_getpagesize && @HAVE_OS_H@
1366 # if defined B_PAGE_SIZE
1367 # define _gl_getpagesize() B_PAGE_SIZE
1370 /* This is for AmigaOS4.0. */
1371 # if !defined _gl_getpagesize && defined __amigaos4__
1372 # define _gl_getpagesize() 2048
1374 /* This is for older Unix systems. */
1375 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
1376 # include <sys/param.h>
1377 # ifdef EXEC_PAGESIZE
1378 # define _gl_getpagesize() EXEC_PAGESIZE
1384 # define _gl_getpagesize() (NBPG * CLSIZE)
1387 # define _gl_getpagesize() NBPC
1392 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1393 # define getpagesize() _gl_getpagesize ()
1395 # if !GNULIB_defined_getpagesize_function
1396 _GL_UNISTD_INLINE
int
1399 return _gl_getpagesize ();
1401 # define GNULIB_defined_getpagesize_function 1
1406 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
1407 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
1409 # if @HAVE_DECL_GETPAGESIZE@
1410 _GL_CXXALIASWARN (getpagesize
);
1412 #elif defined GNULIB_POSIXCHECK
1414 # if HAVE_RAW_DECL_GETPAGESIZE
1415 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
1416 "use gnulib module getpagesize for portability");
1421 #if @GNULIB_GETPASS@
1422 /* Function getpass() from module 'getpass':
1423 Read a password from /dev/tty or stdin.
1424 Function getpass() from module 'getpass-gnu':
1425 Read a password of arbitrary length from /dev/tty or stdin. */
1426 # if (@GNULIB_GETPASS@ && @REPLACE_GETPASS@) \
1427 || (@GNULIB_GETPASS_GNU@ && @REPLACE_GETPASS_FOR_GETPASS_GNU@)
1428 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1430 # define getpass rpl_getpass
1432 _GL_FUNCDECL_RPL (getpass
, char *, (const char *prompt
)
1433 _GL_ARG_NONNULL ((1)));
1434 _GL_CXXALIAS_RPL (getpass
, char *, (const char *prompt
));
1436 # if !@HAVE_GETPASS@
1437 _GL_FUNCDECL_SYS (getpass
, char *, (const char *prompt
)
1438 _GL_ARG_NONNULL ((1)));
1440 _GL_CXXALIAS_SYS (getpass
, char *, (const char *prompt
));
1442 _GL_CXXALIASWARN (getpass
);
1443 #elif defined GNULIB_POSIXCHECK
1445 # if HAVE_RAW_DECL_GETPASS
1446 _GL_WARN_ON_USE (getpass
, "getpass is unportable - "
1447 "use gnulib module getpass or getpass-gnu for portability");
1452 #if @GNULIB_MDA_GETPID@
1453 /* On native Windows, map 'getpid' to '_getpid', so that -loldnames is not
1454 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1455 platforms by defining GNULIB_NAMESPACE::getpid always. */
1456 # if defined _WIN32 && !defined __CYGWIN__
1457 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1459 # define getpid _getpid
1461 _GL_CXXALIAS_MDA (getpid
, int, (void));
1463 _GL_CXXALIAS_SYS (getpid
, pid_t
, (void));
1465 _GL_CXXALIASWARN (getpid
);
1469 #if @GNULIB_GETUSERSHELL@
1470 /* Return the next valid login shell on the system, or NULL when the end of
1471 the list has been reached. */
1472 # if !@HAVE_DECL_GETUSERSHELL@
1473 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
1475 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
1476 _GL_CXXALIASWARN (getusershell
);
1477 #elif defined GNULIB_POSIXCHECK
1478 # undef getusershell
1479 # if HAVE_RAW_DECL_GETUSERSHELL
1480 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
1481 "use gnulib module getusershell for portability");
1485 #if @GNULIB_GETUSERSHELL@
1486 /* Rewind to pointer that is advanced at each getusershell() call. */
1487 # if !@HAVE_DECL_GETUSERSHELL@
1488 _GL_FUNCDECL_SYS (setusershell
, void, (void));
1490 _GL_CXXALIAS_SYS (setusershell
, void, (void));
1491 _GL_CXXALIASWARN (setusershell
);
1492 #elif defined GNULIB_POSIXCHECK
1493 # undef setusershell
1494 # if HAVE_RAW_DECL_SETUSERSHELL
1495 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
1496 "use gnulib module getusershell for portability");
1500 #if @GNULIB_GETUSERSHELL@
1501 /* Free the pointer that is advanced at each getusershell() call and
1502 associated resources. */
1503 # if !@HAVE_DECL_GETUSERSHELL@
1504 _GL_FUNCDECL_SYS (endusershell
, void, (void));
1506 _GL_CXXALIAS_SYS (endusershell
, void, (void));
1507 _GL_CXXALIASWARN (endusershell
);
1508 #elif defined GNULIB_POSIXCHECK
1509 # undef endusershell
1510 # if HAVE_RAW_DECL_ENDUSERSHELL
1511 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
1512 "use gnulib module getusershell for portability");
1517 #if @GNULIB_GROUP_MEMBER@
1518 /* Determine whether group id is in calling user's group list. */
1519 # if !@HAVE_GROUP_MEMBER@
1520 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
1522 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
1523 _GL_CXXALIASWARN (group_member
);
1524 #elif defined GNULIB_POSIXCHECK
1525 # undef group_member
1526 # if HAVE_RAW_DECL_GROUP_MEMBER
1527 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
1528 "use gnulib module group-member for portability");
1534 # if @REPLACE_ISATTY@
1535 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1537 # define isatty rpl_isatty
1539 # define GNULIB_defined_isatty 1
1540 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
1541 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
1542 # elif defined _WIN32 && !defined __CYGWIN__
1543 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1545 # define isatty _isatty
1547 _GL_CXXALIAS_MDA (isatty
, int, (int fd
));
1549 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
1551 _GL_CXXALIASWARN (isatty
);
1552 #elif defined GNULIB_POSIXCHECK
1554 # if HAVE_RAW_DECL_ISATTY
1555 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
1556 "use gnulib module isatty for portability");
1558 #elif @GNULIB_MDA_ISATTY@
1559 /* On native Windows, map 'isatty' to '_isatty', so that -loldnames is not
1560 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1561 platforms by defining GNULIB_NAMESPACE::isatty always. */
1562 # if defined _WIN32 && !defined __CYGWIN__
1563 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1565 # define isatty _isatty
1567 _GL_CXXALIAS_MDA (isatty
, int, (int fd
));
1569 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
1571 _GL_CXXALIASWARN (isatty
);
1576 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1577 to GID (if GID is not -1). Do not follow symbolic links.
1578 Return 0 if successful, otherwise -1 and errno set.
1579 See the POSIX:2008 specification
1580 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1581 # if @REPLACE_LCHOWN@
1582 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1584 # define lchown rpl_lchown
1586 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1587 _GL_ARG_NONNULL ((1)));
1588 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1591 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1592 _GL_ARG_NONNULL ((1)));
1594 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1596 _GL_CXXALIASWARN (lchown
);
1597 #elif defined GNULIB_POSIXCHECK
1599 # if HAVE_RAW_DECL_LCHOWN
1600 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1601 "use gnulib module lchown for portability");
1607 /* Create a new hard link for an existing file.
1608 Return 0 if successful, otherwise -1 and errno set.
1609 See POSIX:2008 specification
1610 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1612 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1613 # define link rpl_link
1615 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1616 _GL_ARG_NONNULL ((1, 2)));
1617 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1620 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1621 _GL_ARG_NONNULL ((1, 2)));
1623 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1625 _GL_CXXALIASWARN (link
);
1626 #elif defined GNULIB_POSIXCHECK
1628 # if HAVE_RAW_DECL_LINK
1629 _GL_WARN_ON_USE (link
, "link is unportable - "
1630 "use gnulib module link for portability");
1636 /* Create a new hard link for an existing file, relative to two
1637 directories. FLAG controls whether symlinks are followed.
1638 Return 0 if successful, otherwise -1 and errno set. */
1639 # if @REPLACE_LINKAT@
1640 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1642 # define linkat rpl_linkat
1644 _GL_FUNCDECL_RPL (linkat
, int,
1645 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1647 _GL_ARG_NONNULL ((2, 4)));
1648 _GL_CXXALIAS_RPL (linkat
, int,
1649 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1653 _GL_FUNCDECL_SYS (linkat
, int,
1654 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1656 _GL_ARG_NONNULL ((2, 4)));
1658 _GL_CXXALIAS_SYS (linkat
, int,
1659 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1662 _GL_CXXALIASWARN (linkat
);
1663 #elif defined GNULIB_POSIXCHECK
1665 # if HAVE_RAW_DECL_LINKAT
1666 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1667 "use gnulib module linkat for portability");
1673 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1674 Return the new offset if successful, otherwise -1 and errno set.
1675 See the POSIX:2008 specification
1676 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1677 # if @REPLACE_LSEEK@
1678 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1679 # define lseek rpl_lseek
1681 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1682 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1683 # elif defined _WIN32 && !defined __CYGWIN__
1684 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1686 # define lseek _lseek
1688 _GL_CXXALIAS_MDA (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1690 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1692 _GL_CXXALIASWARN (lseek
);
1693 #elif defined GNULIB_POSIXCHECK
1695 # if HAVE_RAW_DECL_LSEEK
1696 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1697 "systems - use gnulib module lseek for portability");
1699 #elif @GNULIB_MDA_LSEEK@
1700 /* On native Windows, map 'lseek' to '_lseek', so that -loldnames is not
1701 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1702 platforms by defining GNULIB_NAMESPACE::lseek always. */
1703 # if defined _WIN32 && !defined __CYGWIN__
1704 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1706 # define lseek _lseek
1708 _GL_CXXALIAS_MDA (lseek
, long, (int fd
, long offset
, int whence
));
1710 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1712 _GL_CXXALIASWARN (lseek
);
1717 /* Create a pipe, defaulting to O_BINARY mode.
1718 Store the read-end as fd[0] and the write-end as fd[1].
1719 Return 0 upon success, or -1 with errno set upon failure. */
1721 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1723 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1724 _GL_CXXALIASWARN (pipe
);
1725 #elif defined GNULIB_POSIXCHECK
1727 # if HAVE_RAW_DECL_PIPE
1728 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1729 "use gnulib module pipe-posix for portability");
1735 /* Create a pipe, applying the given flags when opening the read-end of the
1736 pipe and the write-end of the pipe.
1737 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1738 and O_TEXT, O_BINARY (defined in "binary-io.h").
1739 Store the read-end as fd[0] and the write-end as fd[1].
1740 Return 0 upon success, or -1 with errno set upon failure.
1741 See also the Linux man page at
1742 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1744 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1745 # define pipe2 rpl_pipe2
1747 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1748 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1750 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1751 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1753 _GL_CXXALIASWARN (pipe2
);
1754 #elif defined GNULIB_POSIXCHECK
1756 # if HAVE_RAW_DECL_PIPE2
1757 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1758 "use gnulib module pipe2 for portability");
1764 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1765 Return the number of bytes placed into BUF if successful, otherwise
1766 set errno and return -1. 0 indicates EOF.
1767 See the POSIX:2008 specification
1768 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1769 # if @REPLACE_PREAD@
1770 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1772 # define pread rpl_pread
1774 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1775 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1776 _GL_ARG_NONNULL ((2)));
1777 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1778 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1781 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1782 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1783 _GL_ARG_NONNULL ((2)));
1785 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1786 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1788 _GL_CXXALIASWARN (pread
);
1789 #elif defined GNULIB_POSIXCHECK
1791 # if HAVE_RAW_DECL_PREAD
1792 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1793 "use gnulib module pread for portability");
1799 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1800 Return the number of bytes written if successful, otherwise
1801 set errno and return -1. 0 indicates nothing written. See the
1802 POSIX:2008 specification
1803 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1804 # if @REPLACE_PWRITE@
1805 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1807 # define pwrite rpl_pwrite
1809 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1810 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1811 _GL_ARG_NONNULL ((2)));
1812 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1813 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1816 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1817 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1818 _GL_ARG_NONNULL ((2)));
1820 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1821 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1823 _GL_CXXALIASWARN (pwrite
);
1824 #elif defined GNULIB_POSIXCHECK
1826 # if HAVE_RAW_DECL_PWRITE
1827 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1828 "use gnulib module pwrite for portability");
1834 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1835 at BUF. See the POSIX:2008 specification
1836 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1838 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1840 # define read rpl_read
1842 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1843 _GL_ARG_NONNULL ((2)));
1844 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1845 # elif defined _WIN32 && !defined __CYGWIN__
1846 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1850 _GL_CXXALIAS_MDA (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1852 _GL_CXXALIAS_SYS (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1854 _GL_CXXALIASWARN (read
);
1855 #elif @GNULIB_MDA_READ@
1856 /* On native Windows, map 'read' to '_read', so that -loldnames is not
1857 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1858 platforms by defining GNULIB_NAMESPACE::read always. */
1859 # if defined _WIN32 && !defined __CYGWIN__
1860 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1865 _GL_CXXALIAS_MDA (read
, int, (int fd
, void *buf
, unsigned int count
));
1867 _GL_CXXALIAS_MDA (read
, ssize_t
, (int fd
, void *buf
, unsigned int count
));
1870 _GL_CXXALIAS_SYS (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1872 _GL_CXXALIASWARN (read
);
1876 #if @GNULIB_READLINK@
1877 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1878 bytes of it into BUF. Return the number of bytes placed into BUF if
1879 successful, otherwise -1 and errno set.
1880 See the POSIX:2008 specification
1881 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1882 # if @REPLACE_READLINK@
1883 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1884 # define readlink rpl_readlink
1886 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1887 (const char *restrict file
,
1888 char *restrict buf
, size_t bufsize
)
1889 _GL_ARG_NONNULL ((1, 2)));
1890 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1891 (const char *restrict file
,
1892 char *restrict buf
, size_t bufsize
));
1894 # if !@HAVE_READLINK@
1895 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1896 (const char *restrict file
,
1897 char *restrict buf
, size_t bufsize
)
1898 _GL_ARG_NONNULL ((1, 2)));
1900 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1901 (const char *restrict file
,
1902 char *restrict buf
, size_t bufsize
));
1904 _GL_CXXALIASWARN (readlink
);
1905 #elif defined GNULIB_POSIXCHECK
1907 # if HAVE_RAW_DECL_READLINK
1908 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1909 "use gnulib module readlink for portability");
1914 #if @GNULIB_READLINKAT@
1915 # if @REPLACE_READLINKAT@
1916 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1917 # define readlinkat rpl_readlinkat
1919 _GL_FUNCDECL_RPL (readlinkat
, ssize_t
,
1920 (int fd
, char const *restrict file
,
1921 char *restrict buf
, size_t len
)
1922 _GL_ARG_NONNULL ((2, 3)));
1923 _GL_CXXALIAS_RPL (readlinkat
, ssize_t
,
1924 (int fd
, char const *restrict file
,
1925 char *restrict buf
, size_t len
));
1927 # if !@HAVE_READLINKAT@
1928 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1929 (int fd
, char const *restrict file
,
1930 char *restrict buf
, size_t len
)
1931 _GL_ARG_NONNULL ((2, 3)));
1933 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1934 (int fd
, char const *restrict file
,
1935 char *restrict buf
, size_t len
));
1937 _GL_CXXALIASWARN (readlinkat
);
1938 #elif defined GNULIB_POSIXCHECK
1940 # if HAVE_RAW_DECL_READLINKAT
1941 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1942 "use gnulib module readlinkat for portability");
1948 /* Remove the directory DIR. */
1949 # if @REPLACE_RMDIR@
1950 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1951 # define rmdir rpl_rmdir
1953 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1954 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1955 # elif defined _WIN32 && !defined __CYGWIN__
1956 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1958 # define rmdir _rmdir
1960 _GL_CXXALIAS_MDA (rmdir
, int, (char const *name
));
1962 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1964 _GL_CXXALIASWARN (rmdir
);
1965 #elif defined GNULIB_POSIXCHECK
1967 # if HAVE_RAW_DECL_RMDIR
1968 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1969 "use gnulib module rmdir for portability");
1971 #elif @GNULIB_MDA_RMDIR@
1972 /* On native Windows, map 'rmdir' to '_rmdir', so that -loldnames is not
1973 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1974 platforms by defining GNULIB_NAMESPACE::rmdir always. */
1975 # if defined _WIN32 && !defined __CYGWIN__
1976 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1978 # define rmdir _rmdir
1980 _GL_CXXALIAS_MDA (rmdir
, int, (char const *name
));
1982 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1984 _GL_CXXALIASWARN (rmdir
);
1988 #if @GNULIB_SETHOSTNAME@
1989 /* Set the host name of the machine.
1990 The host name may or may not be fully qualified.
1992 Put LEN bytes of NAME into the host name.
1993 Return 0 if successful, otherwise, set errno and return -1.
1995 Platforms with no ability to set the hostname return -1 and set
1997 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1998 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1999 _GL_ARG_NONNULL ((1)));
2001 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
2002 and FreeBSD 6.4 the second parameter is int. On Solaris 11
2003 2011-10, the first parameter is not const. */
2004 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
2005 _GL_CXXALIASWARN (sethostname
);
2006 #elif defined GNULIB_POSIXCHECK
2008 # if HAVE_RAW_DECL_SETHOSTNAME
2009 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
2010 "use gnulib module sethostname for portability");
2016 /* Pause the execution of the current thread for N seconds.
2017 Returns the number of seconds left to sleep.
2018 See the POSIX:2008 specification
2019 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
2020 # if @REPLACE_SLEEP@
2021 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2023 # define sleep rpl_sleep
2025 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
2026 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
2029 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
2031 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
2033 _GL_CXXALIASWARN (sleep
);
2034 #elif defined GNULIB_POSIXCHECK
2036 # if HAVE_RAW_DECL_SLEEP
2037 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
2038 "use gnulib module sleep for portability");
2043 #if @GNULIB_MDA_SWAB@
2044 /* On native Windows, map 'swab' to '_swab', so that -loldnames is not
2045 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2046 platforms by defining GNULIB_NAMESPACE::swab always. */
2047 # if defined _WIN32 && !defined __CYGWIN__
2048 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2052 /* Need to cast, because in old mingw the arguments are
2053 (const char *from, char *to, size_t n). */
2054 _GL_CXXALIAS_MDA_CAST (swab
, void, (char *from
, char *to
, int n
));
2056 # if defined __hpux /* HP-UX */
2057 _GL_CXXALIAS_SYS (swab
, void, (const char *from
, char *to
, int n
));
2058 # elif defined __sun && !defined _XPG4 /* Solaris */
2059 _GL_CXXALIAS_SYS (swab
, void, (const char *from
, char *to
, ssize_t n
));
2061 _GL_CXXALIAS_SYS (swab
, void, (const void *from
, void *to
, ssize_t n
));
2064 _GL_CXXALIASWARN (swab
);
2068 #if @GNULIB_SYMLINK@
2069 # if @REPLACE_SYMLINK@
2070 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2072 # define symlink rpl_symlink
2074 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
2075 _GL_ARG_NONNULL ((1, 2)));
2076 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
2078 # if !@HAVE_SYMLINK@
2079 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
2080 _GL_ARG_NONNULL ((1, 2)));
2082 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
2084 _GL_CXXALIASWARN (symlink
);
2085 #elif defined GNULIB_POSIXCHECK
2087 # if HAVE_RAW_DECL_SYMLINK
2088 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
2089 "use gnulib module symlink for portability");
2094 #if @GNULIB_SYMLINKAT@
2095 # if @REPLACE_SYMLINKAT@
2096 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2098 # define symlinkat rpl_symlinkat
2100 _GL_FUNCDECL_RPL (symlinkat
, int,
2101 (char const *contents
, int fd
, char const *file
)
2102 _GL_ARG_NONNULL ((1, 3)));
2103 _GL_CXXALIAS_RPL (symlinkat
, int,
2104 (char const *contents
, int fd
, char const *file
));
2106 # if !@HAVE_SYMLINKAT@
2107 _GL_FUNCDECL_SYS (symlinkat
, int,
2108 (char const *contents
, int fd
, char const *file
)
2109 _GL_ARG_NONNULL ((1, 3)));
2111 _GL_CXXALIAS_SYS (symlinkat
, int,
2112 (char const *contents
, int fd
, char const *file
));
2114 _GL_CXXALIASWARN (symlinkat
);
2115 #elif defined GNULIB_POSIXCHECK
2117 # if HAVE_RAW_DECL_SYMLINKAT
2118 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
2119 "use gnulib module symlinkat for portability");
2124 #if @GNULIB_TRUNCATE@
2125 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
2126 Return 0 if successful, otherwise -1 and errno set.
2127 See the POSIX:2008 specification
2128 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
2129 # if @REPLACE_TRUNCATE@
2130 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2132 # define truncate rpl_truncate
2134 _GL_FUNCDECL_RPL (truncate
, int, (const char *filename
, off_t length
)
2135 _GL_ARG_NONNULL ((1)));
2136 _GL_CXXALIAS_RPL (truncate
, int, (const char *filename
, off_t length
));
2138 # if !@HAVE_DECL_TRUNCATE@
2139 _GL_FUNCDECL_SYS (truncate
, int, (const char *filename
, off_t length
)
2140 _GL_ARG_NONNULL ((1)));
2142 _GL_CXXALIAS_SYS (truncate
, int, (const char *filename
, off_t length
));
2144 _GL_CXXALIASWARN (truncate
);
2145 #elif defined GNULIB_POSIXCHECK
2147 # if HAVE_RAW_DECL_TRUNCATE
2148 _GL_WARN_ON_USE (truncate
, "truncate is unportable - "
2149 "use gnulib module truncate for portability");
2154 #if @GNULIB_TTYNAME_R@
2155 /* Store at most BUFLEN characters of the pathname of the terminal FD is
2156 open on in BUF. Return 0 on success, otherwise an error number. */
2157 # if @REPLACE_TTYNAME_R@
2158 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2160 # define ttyname_r rpl_ttyname_r
2162 _GL_FUNCDECL_RPL (ttyname_r
, int,
2163 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
2164 _GL_CXXALIAS_RPL (ttyname_r
, int,
2165 (int fd
, char *buf
, size_t buflen
));
2167 # if !@HAVE_DECL_TTYNAME_R@
2168 _GL_FUNCDECL_SYS (ttyname_r
, int,
2169 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
2171 _GL_CXXALIAS_SYS (ttyname_r
, int,
2172 (int fd
, char *buf
, size_t buflen
));
2174 _GL_CXXALIASWARN (ttyname_r
);
2175 #elif defined GNULIB_POSIXCHECK
2177 # if HAVE_RAW_DECL_TTYNAME_R
2178 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
2179 "use gnulib module ttyname_r for portability");
2185 # if @REPLACE_UNLINK@
2186 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2188 # define unlink rpl_unlink
2190 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
2191 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
2192 # elif defined _WIN32 && !defined __CYGWIN__
2193 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2195 # define unlink _unlink
2197 _GL_CXXALIAS_MDA (unlink
, int, (char const *file
));
2199 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
2201 _GL_CXXALIASWARN (unlink
);
2202 #elif defined GNULIB_POSIXCHECK
2204 # if HAVE_RAW_DECL_UNLINK
2205 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
2206 "use gnulib module unlink for portability");
2208 #elif @GNULIB_MDA_UNLINK@
2209 /* On native Windows, map 'unlink' to '_unlink', so that -loldnames is not
2210 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2211 platforms by defining GNULIB_NAMESPACE::unlink always. */
2212 # if defined _WIN32 && !defined __CYGWIN__
2213 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2215 # define unlink _unlink
2217 _GL_CXXALIAS_MDA (unlink
, int, (char const *file
));
2219 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
2221 _GL_CXXALIASWARN (unlink
);
2225 #if @GNULIB_UNLINKAT@
2226 # if @REPLACE_UNLINKAT@
2227 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2229 # define unlinkat rpl_unlinkat
2231 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
2232 _GL_ARG_NONNULL ((2)));
2233 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
2235 # if !@HAVE_UNLINKAT@
2236 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
2237 _GL_ARG_NONNULL ((2)));
2239 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
2241 _GL_CXXALIASWARN (unlinkat
);
2242 #elif defined GNULIB_POSIXCHECK
2244 # if HAVE_RAW_DECL_UNLINKAT
2245 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
2246 "use gnulib module unlinkat for portability");
2252 /* Pause the execution of the current thread for N microseconds.
2253 Returns 0 on completion, or -1 on range error.
2254 See the POSIX:2001 specification
2255 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
2256 # if @REPLACE_USLEEP@
2257 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2259 # define usleep rpl_usleep
2261 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
2262 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
2265 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
2267 /* Need to cast, because on Haiku, the first parameter is
2269 _GL_CXXALIAS_SYS_CAST (usleep
, int, (useconds_t n
));
2271 _GL_CXXALIASWARN (usleep
);
2272 #elif defined GNULIB_POSIXCHECK
2274 # if HAVE_RAW_DECL_USLEEP
2275 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
2276 "use gnulib module usleep for portability");
2282 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
2283 See the POSIX:2008 specification
2284 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
2285 # if @REPLACE_WRITE@
2286 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2288 # define write rpl_write
2290 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
2291 _GL_ARG_NONNULL ((2)));
2292 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2293 # elif defined _WIN32 && !defined __CYGWIN__
2294 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2296 # define write _write
2298 _GL_CXXALIAS_MDA (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2300 _GL_CXXALIAS_SYS (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2302 _GL_CXXALIASWARN (write
);
2303 #elif @GNULIB_MDA_WRITE@
2304 /* On native Windows, map 'write' to '_write', so that -loldnames is not
2305 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2306 platforms by defining GNULIB_NAMESPACE::write always. */
2307 # if defined _WIN32 && !defined __CYGWIN__
2308 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2310 # define write _write
2313 _GL_CXXALIAS_MDA (write
, int, (int fd
, const void *buf
, unsigned int count
));
2315 _GL_CXXALIAS_MDA (write
, ssize_t
, (int fd
, const void *buf
, unsigned int count
));
2318 _GL_CXXALIAS_SYS (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2320 _GL_CXXALIASWARN (write
);
2323 _GL_INLINE_HEADER_END
2325 #endif /* _@GUARD_PREFIX@_UNISTD_H */
2326 #endif /* _GL_INCLUDING_UNISTD_H */
2327 #endif /* _@GUARD_PREFIX@_UNISTD_H */