1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2020 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program 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 General Public License for more details.
14 You should have received a copy of the GNU 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 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
1525 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
1526 # elif defined _WIN32 && !defined __CYGWIN__
1527 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1529 # define isatty _isatty
1531 _GL_CXXALIAS_MDA (isatty
, int, (int fd
));
1533 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
1535 _GL_CXXALIASWARN (isatty
);
1536 #elif defined GNULIB_POSIXCHECK
1538 # if HAVE_RAW_DECL_ISATTY
1539 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
1540 "use gnulib module isatty for portability");
1542 #elif @GNULIB_MDA_ISATTY@
1543 /* On native Windows, map 'isatty' to '_isatty', so that -loldnames is not
1544 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1545 platforms by defining GNULIB_NAMESPACE::isatty always. */
1546 # if defined _WIN32 && !defined __CYGWIN__
1547 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1549 # define isatty _isatty
1551 _GL_CXXALIAS_MDA (isatty
, int, (int fd
));
1553 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
1555 _GL_CXXALIASWARN (isatty
);
1560 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1561 to GID (if GID is not -1). Do not follow symbolic links.
1562 Return 0 if successful, otherwise -1 and errno set.
1563 See the POSIX:2008 specification
1564 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1565 # if @REPLACE_LCHOWN@
1566 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1568 # define lchown rpl_lchown
1570 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1571 _GL_ARG_NONNULL ((1)));
1572 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1575 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1576 _GL_ARG_NONNULL ((1)));
1578 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1580 _GL_CXXALIASWARN (lchown
);
1581 #elif defined GNULIB_POSIXCHECK
1583 # if HAVE_RAW_DECL_LCHOWN
1584 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1585 "use gnulib module lchown for portability");
1591 /* Create a new hard link for an existing file.
1592 Return 0 if successful, otherwise -1 and errno set.
1593 See POSIX:2008 specification
1594 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1596 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1597 # define link rpl_link
1599 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1600 _GL_ARG_NONNULL ((1, 2)));
1601 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1604 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1605 _GL_ARG_NONNULL ((1, 2)));
1607 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1609 _GL_CXXALIASWARN (link
);
1610 #elif defined GNULIB_POSIXCHECK
1612 # if HAVE_RAW_DECL_LINK
1613 _GL_WARN_ON_USE (link
, "link is unportable - "
1614 "use gnulib module link for portability");
1620 /* Create a new hard link for an existing file, relative to two
1621 directories. FLAG controls whether symlinks are followed.
1622 Return 0 if successful, otherwise -1 and errno set. */
1623 # if @REPLACE_LINKAT@
1624 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1626 # define linkat rpl_linkat
1628 _GL_FUNCDECL_RPL (linkat
, int,
1629 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1631 _GL_ARG_NONNULL ((2, 4)));
1632 _GL_CXXALIAS_RPL (linkat
, int,
1633 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1637 _GL_FUNCDECL_SYS (linkat
, int,
1638 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1640 _GL_ARG_NONNULL ((2, 4)));
1642 _GL_CXXALIAS_SYS (linkat
, int,
1643 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1646 _GL_CXXALIASWARN (linkat
);
1647 #elif defined GNULIB_POSIXCHECK
1649 # if HAVE_RAW_DECL_LINKAT
1650 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1651 "use gnulib module linkat for portability");
1657 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1658 Return the new offset if successful, otherwise -1 and errno set.
1659 See the POSIX:2008 specification
1660 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1661 # if @REPLACE_LSEEK@
1662 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1663 # define lseek rpl_lseek
1665 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1666 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1667 # elif defined _WIN32 && !defined __CYGWIN__
1668 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1670 # define lseek _lseek
1672 _GL_CXXALIAS_MDA (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1674 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1676 _GL_CXXALIASWARN (lseek
);
1677 #elif defined GNULIB_POSIXCHECK
1679 # if HAVE_RAW_DECL_LSEEK
1680 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1681 "systems - use gnulib module lseek for portability");
1683 #elif @GNULIB_MDA_LSEEK@
1684 /* On native Windows, map 'lseek' to '_lseek', so that -loldnames is not
1685 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1686 platforms by defining GNULIB_NAMESPACE::lseek always. */
1687 # if defined _WIN32 && !defined __CYGWIN__
1688 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1690 # define lseek _lseek
1692 _GL_CXXALIAS_MDA (lseek
, long, (int fd
, long offset
, int whence
));
1694 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1696 _GL_CXXALIASWARN (lseek
);
1701 /* Create a pipe, defaulting to O_BINARY mode.
1702 Store the read-end as fd[0] and the write-end as fd[1].
1703 Return 0 upon success, or -1 with errno set upon failure. */
1705 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1707 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1708 _GL_CXXALIASWARN (pipe
);
1709 #elif defined GNULIB_POSIXCHECK
1711 # if HAVE_RAW_DECL_PIPE
1712 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1713 "use gnulib module pipe-posix for portability");
1719 /* Create a pipe, applying the given flags when opening the read-end of the
1720 pipe and the write-end of the pipe.
1721 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1722 and O_TEXT, O_BINARY (defined in "binary-io.h").
1723 Store the read-end as fd[0] and the write-end as fd[1].
1724 Return 0 upon success, or -1 with errno set upon failure.
1725 See also the Linux man page at
1726 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1728 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1729 # define pipe2 rpl_pipe2
1731 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1732 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1734 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1735 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1737 _GL_CXXALIASWARN (pipe2
);
1738 #elif defined GNULIB_POSIXCHECK
1740 # if HAVE_RAW_DECL_PIPE2
1741 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1742 "use gnulib module pipe2 for portability");
1748 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1749 Return the number of bytes placed into BUF if successful, otherwise
1750 set errno and return -1. 0 indicates EOF.
1751 See the POSIX:2008 specification
1752 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1753 # if @REPLACE_PREAD@
1754 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1756 # define pread rpl_pread
1758 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1759 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1760 _GL_ARG_NONNULL ((2)));
1761 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1762 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1765 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1766 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1767 _GL_ARG_NONNULL ((2)));
1769 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1770 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1772 _GL_CXXALIASWARN (pread
);
1773 #elif defined GNULIB_POSIXCHECK
1775 # if HAVE_RAW_DECL_PREAD
1776 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1777 "use gnulib module pread for portability");
1783 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1784 Return the number of bytes written if successful, otherwise
1785 set errno and return -1. 0 indicates nothing written. See the
1786 POSIX:2008 specification
1787 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1788 # if @REPLACE_PWRITE@
1789 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1791 # define pwrite rpl_pwrite
1793 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1794 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1795 _GL_ARG_NONNULL ((2)));
1796 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1797 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1800 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1801 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1802 _GL_ARG_NONNULL ((2)));
1804 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1805 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1807 _GL_CXXALIASWARN (pwrite
);
1808 #elif defined GNULIB_POSIXCHECK
1810 # if HAVE_RAW_DECL_PWRITE
1811 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1812 "use gnulib module pwrite for portability");
1818 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1819 at BUF. See the POSIX:2008 specification
1820 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1822 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1824 # define read rpl_read
1826 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1827 _GL_ARG_NONNULL ((2)));
1828 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1829 # elif defined _WIN32 && !defined __CYGWIN__
1830 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1834 _GL_CXXALIAS_MDA (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1836 _GL_CXXALIAS_SYS (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1838 _GL_CXXALIASWARN (read
);
1839 #elif @GNULIB_MDA_READ@
1840 /* On native Windows, map 'read' to '_read', so that -loldnames is not
1841 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1842 platforms by defining GNULIB_NAMESPACE::read always. */
1843 # if defined _WIN32 && !defined __CYGWIN__
1844 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1849 _GL_CXXALIAS_MDA (read
, int, (int fd
, void *buf
, unsigned int count
));
1851 _GL_CXXALIAS_MDA (read
, ssize_t
, (int fd
, void *buf
, unsigned int count
));
1854 _GL_CXXALIAS_SYS (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1856 _GL_CXXALIASWARN (read
);
1860 #if @GNULIB_READLINK@
1861 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1862 bytes of it into BUF. Return the number of bytes placed into BUF if
1863 successful, otherwise -1 and errno set.
1864 See the POSIX:2008 specification
1865 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1866 # if @REPLACE_READLINK@
1867 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1868 # define readlink rpl_readlink
1870 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1871 (const char *restrict file
,
1872 char *restrict buf
, size_t bufsize
)
1873 _GL_ARG_NONNULL ((1, 2)));
1874 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1875 (const char *restrict file
,
1876 char *restrict buf
, size_t bufsize
));
1878 # if !@HAVE_READLINK@
1879 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1880 (const char *restrict file
,
1881 char *restrict buf
, size_t bufsize
)
1882 _GL_ARG_NONNULL ((1, 2)));
1884 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1885 (const char *restrict file
,
1886 char *restrict buf
, size_t bufsize
));
1888 _GL_CXXALIASWARN (readlink
);
1889 #elif defined GNULIB_POSIXCHECK
1891 # if HAVE_RAW_DECL_READLINK
1892 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1893 "use gnulib module readlink for portability");
1898 #if @GNULIB_READLINKAT@
1899 # if @REPLACE_READLINKAT@
1900 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1901 # define readlinkat rpl_readlinkat
1903 _GL_FUNCDECL_RPL (readlinkat
, ssize_t
,
1904 (int fd
, char const *restrict file
,
1905 char *restrict buf
, size_t len
)
1906 _GL_ARG_NONNULL ((2, 3)));
1907 _GL_CXXALIAS_RPL (readlinkat
, ssize_t
,
1908 (int fd
, char const *restrict file
,
1909 char *restrict buf
, size_t len
));
1911 # if !@HAVE_READLINKAT@
1912 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1913 (int fd
, char const *restrict file
,
1914 char *restrict buf
, size_t len
)
1915 _GL_ARG_NONNULL ((2, 3)));
1917 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1918 (int fd
, char const *restrict file
,
1919 char *restrict buf
, size_t len
));
1921 _GL_CXXALIASWARN (readlinkat
);
1922 #elif defined GNULIB_POSIXCHECK
1924 # if HAVE_RAW_DECL_READLINKAT
1925 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1926 "use gnulib module readlinkat for portability");
1932 /* Remove the directory DIR. */
1933 # if @REPLACE_RMDIR@
1934 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1935 # define rmdir rpl_rmdir
1937 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1938 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1939 # elif defined _WIN32 && !defined __CYGWIN__
1940 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1942 # define rmdir _rmdir
1944 _GL_CXXALIAS_MDA (rmdir
, int, (char const *name
));
1946 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1948 _GL_CXXALIASWARN (rmdir
);
1949 #elif defined GNULIB_POSIXCHECK
1951 # if HAVE_RAW_DECL_RMDIR
1952 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1953 "use gnulib module rmdir for portability");
1955 #elif @GNULIB_MDA_RMDIR@
1956 /* On native Windows, map 'rmdir' to '_rmdir', so that -loldnames is not
1957 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1958 platforms by defining GNULIB_NAMESPACE::rmdir always. */
1959 # if defined _WIN32 && !defined __CYGWIN__
1960 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1962 # define rmdir _rmdir
1964 _GL_CXXALIAS_MDA (rmdir
, int, (char const *name
));
1966 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1968 _GL_CXXALIASWARN (rmdir
);
1972 #if @GNULIB_SETHOSTNAME@
1973 /* Set the host name of the machine.
1974 The host name may or may not be fully qualified.
1976 Put LEN bytes of NAME into the host name.
1977 Return 0 if successful, otherwise, set errno and return -1.
1979 Platforms with no ability to set the hostname return -1 and set
1981 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1982 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1983 _GL_ARG_NONNULL ((1)));
1985 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1986 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1987 2011-10, the first parameter is not const. */
1988 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1989 _GL_CXXALIASWARN (sethostname
);
1990 #elif defined GNULIB_POSIXCHECK
1992 # if HAVE_RAW_DECL_SETHOSTNAME
1993 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1994 "use gnulib module sethostname for portability");
2000 /* Pause the execution of the current thread for N seconds.
2001 Returns the number of seconds left to sleep.
2002 See the POSIX:2008 specification
2003 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
2004 # if @REPLACE_SLEEP@
2005 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2007 # define sleep rpl_sleep
2009 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
2010 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
2013 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
2015 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
2017 _GL_CXXALIASWARN (sleep
);
2018 #elif defined GNULIB_POSIXCHECK
2020 # if HAVE_RAW_DECL_SLEEP
2021 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
2022 "use gnulib module sleep for portability");
2027 #if @GNULIB_MDA_SWAB@
2028 /* On native Windows, map 'swab' to '_swab', so that -loldnames is not
2029 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2030 platforms by defining GNULIB_NAMESPACE::creat always. */
2031 # if defined _WIN32 && !defined __CYGWIN__
2032 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2036 _GL_CXXALIAS_MDA (swab
, void, (char *from
, char *to
, int n
));
2038 _GL_CXXALIAS_SYS (swab
, void, (const void *from
, void *to
, ssize_t n
));
2040 _GL_CXXALIASWARN (swab
);
2044 #if @GNULIB_SYMLINK@
2045 # if @REPLACE_SYMLINK@
2046 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2048 # define symlink rpl_symlink
2050 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
2051 _GL_ARG_NONNULL ((1, 2)));
2052 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
2054 # if !@HAVE_SYMLINK@
2055 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
2056 _GL_ARG_NONNULL ((1, 2)));
2058 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
2060 _GL_CXXALIASWARN (symlink
);
2061 #elif defined GNULIB_POSIXCHECK
2063 # if HAVE_RAW_DECL_SYMLINK
2064 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
2065 "use gnulib module symlink for portability");
2070 #if @GNULIB_SYMLINKAT@
2071 # if @REPLACE_SYMLINKAT@
2072 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2074 # define symlinkat rpl_symlinkat
2076 _GL_FUNCDECL_RPL (symlinkat
, int,
2077 (char const *contents
, int fd
, char const *file
)
2078 _GL_ARG_NONNULL ((1, 3)));
2079 _GL_CXXALIAS_RPL (symlinkat
, int,
2080 (char const *contents
, int fd
, char const *file
));
2082 # if !@HAVE_SYMLINKAT@
2083 _GL_FUNCDECL_SYS (symlinkat
, int,
2084 (char const *contents
, int fd
, char const *file
)
2085 _GL_ARG_NONNULL ((1, 3)));
2087 _GL_CXXALIAS_SYS (symlinkat
, int,
2088 (char const *contents
, int fd
, char const *file
));
2090 _GL_CXXALIASWARN (symlinkat
);
2091 #elif defined GNULIB_POSIXCHECK
2093 # if HAVE_RAW_DECL_SYMLINKAT
2094 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
2095 "use gnulib module symlinkat for portability");
2100 #if @GNULIB_TRUNCATE@
2101 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
2102 Return 0 if successful, otherwise -1 and errno set.
2103 See the POSIX:2008 specification
2104 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
2105 # if @REPLACE_TRUNCATE@
2106 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2108 # define truncate rpl_truncate
2110 _GL_FUNCDECL_RPL (truncate
, int, (const char *filename
, off_t length
)
2111 _GL_ARG_NONNULL ((1)));
2112 _GL_CXXALIAS_RPL (truncate
, int, (const char *filename
, off_t length
));
2114 # if !@HAVE_DECL_TRUNCATE@
2115 _GL_FUNCDECL_SYS (truncate
, int, (const char *filename
, off_t length
)
2116 _GL_ARG_NONNULL ((1)));
2118 _GL_CXXALIAS_SYS (truncate
, int, (const char *filename
, off_t length
));
2120 _GL_CXXALIASWARN (truncate
);
2121 #elif defined GNULIB_POSIXCHECK
2123 # if HAVE_RAW_DECL_TRUNCATE
2124 _GL_WARN_ON_USE (truncate
, "truncate is unportable - "
2125 "use gnulib module truncate for portability");
2130 #if @GNULIB_TTYNAME_R@
2131 /* Store at most BUFLEN characters of the pathname of the terminal FD is
2132 open on in BUF. Return 0 on success, otherwise an error number. */
2133 # if @REPLACE_TTYNAME_R@
2134 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2136 # define ttyname_r rpl_ttyname_r
2138 _GL_FUNCDECL_RPL (ttyname_r
, int,
2139 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
2140 _GL_CXXALIAS_RPL (ttyname_r
, int,
2141 (int fd
, char *buf
, size_t buflen
));
2143 # if !@HAVE_DECL_TTYNAME_R@
2144 _GL_FUNCDECL_SYS (ttyname_r
, int,
2145 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
2147 _GL_CXXALIAS_SYS (ttyname_r
, int,
2148 (int fd
, char *buf
, size_t buflen
));
2150 _GL_CXXALIASWARN (ttyname_r
);
2151 #elif defined GNULIB_POSIXCHECK
2153 # if HAVE_RAW_DECL_TTYNAME_R
2154 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
2155 "use gnulib module ttyname_r for portability");
2161 # if @REPLACE_UNLINK@
2162 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2164 # define unlink rpl_unlink
2166 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
2167 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
2168 # elif defined _WIN32 && !defined __CYGWIN__
2169 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2171 # define unlink _unlink
2173 _GL_CXXALIAS_MDA (unlink
, int, (char const *file
));
2175 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
2177 _GL_CXXALIASWARN (unlink
);
2178 #elif defined GNULIB_POSIXCHECK
2180 # if HAVE_RAW_DECL_UNLINK
2181 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
2182 "use gnulib module unlink for portability");
2184 #elif @GNULIB_MDA_UNLINK@
2185 /* On native Windows, map 'unlink' to '_unlink', so that -loldnames is not
2186 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2187 platforms by defining GNULIB_NAMESPACE::unlink always. */
2188 # if defined _WIN32 && !defined __CYGWIN__
2189 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2191 # define unlink _unlink
2193 _GL_CXXALIAS_MDA (unlink
, int, (char const *file
));
2195 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
2197 _GL_CXXALIASWARN (unlink
);
2201 #if @GNULIB_UNLINKAT@
2202 # if @REPLACE_UNLINKAT@
2203 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2205 # define unlinkat rpl_unlinkat
2207 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
2208 _GL_ARG_NONNULL ((2)));
2209 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
2211 # if !@HAVE_UNLINKAT@
2212 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
2213 _GL_ARG_NONNULL ((2)));
2215 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
2217 _GL_CXXALIASWARN (unlinkat
);
2218 #elif defined GNULIB_POSIXCHECK
2220 # if HAVE_RAW_DECL_UNLINKAT
2221 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
2222 "use gnulib module unlinkat for portability");
2228 /* Pause the execution of the current thread for N microseconds.
2229 Returns 0 on completion, or -1 on range error.
2230 See the POSIX:2001 specification
2231 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
2232 # if @REPLACE_USLEEP@
2233 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2235 # define usleep rpl_usleep
2237 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
2238 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
2241 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
2243 /* Need to cast, because on Haiku, the first parameter is
2245 _GL_CXXALIAS_SYS_CAST (usleep
, int, (useconds_t n
));
2247 _GL_CXXALIASWARN (usleep
);
2248 #elif defined GNULIB_POSIXCHECK
2250 # if HAVE_RAW_DECL_USLEEP
2251 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
2252 "use gnulib module usleep for portability");
2258 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
2259 See the POSIX:2008 specification
2260 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
2261 # if @REPLACE_WRITE@
2262 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2264 # define write rpl_write
2266 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
2267 _GL_ARG_NONNULL ((2)));
2268 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2269 # elif defined _WIN32 && !defined __CYGWIN__
2270 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2272 # define write _write
2274 _GL_CXXALIAS_MDA (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2276 _GL_CXXALIAS_SYS (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2278 _GL_CXXALIASWARN (write
);
2279 #elif @GNULIB_MDA_WRITE@
2280 /* On native Windows, map 'write' to '_write', so that -loldnames is not
2281 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2282 platforms by defining GNULIB_NAMESPACE::write always. */
2283 # if defined _WIN32 && !defined __CYGWIN__
2284 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2286 # define write _write
2289 _GL_CXXALIAS_MDA (write
, int, (int fd
, const void *buf
, unsigned int count
));
2291 _GL_CXXALIAS_MDA (write
, ssize_t
, (int fd
, const void *buf
, unsigned int count
));
2294 _GL_CXXALIAS_SYS (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2296 _GL_CXXALIASWARN (write
);
2299 _GL_INLINE_HEADER_END
2301 #endif /* _@GUARD_PREFIX@_UNISTD_H */
2302 #endif /* _GL_INCLUDING_UNISTD_H */
2303 #endif /* _@GUARD_PREFIX@_UNISTD_H */