1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2023 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
));
1147 _GL_CXXALIASWARN (getdomainname
);
1149 #elif defined GNULIB_POSIXCHECK
1150 # undef getdomainname
1151 # if HAVE_RAW_DECL_GETDOMAINNAME
1152 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
1153 "use gnulib module getdomainname for portability");
1158 #if @GNULIB_GETDTABLESIZE@
1159 /* Return the maximum number of file descriptors in the current process.
1160 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
1161 # if @REPLACE_GETDTABLESIZE@
1162 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1163 # undef getdtablesize
1164 # define getdtablesize rpl_getdtablesize
1166 _GL_FUNCDECL_RPL (getdtablesize
, int, (void));
1167 _GL_CXXALIAS_RPL (getdtablesize
, int, (void));
1169 # if !@HAVE_GETDTABLESIZE@
1170 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
1172 /* Need to cast, because on AIX, the parameter list is
1174 _GL_CXXALIAS_SYS_CAST (getdtablesize
, int, (void));
1176 _GL_CXXALIASWARN (getdtablesize
);
1177 #elif defined GNULIB_POSIXCHECK
1178 # undef getdtablesize
1179 # if HAVE_RAW_DECL_GETDTABLESIZE
1180 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
1181 "use gnulib module getdtablesize for portability");
1186 #if @GNULIB_GETENTROPY@
1187 /* Fill a buffer with random bytes. */
1188 # if !@HAVE_GETENTROPY@
1189 _GL_FUNCDECL_SYS (getentropy
, int, (void *buffer
, size_t length
));
1191 _GL_CXXALIAS_SYS (getentropy
, int, (void *buffer
, size_t length
));
1192 _GL_CXXALIASWARN (getentropy
);
1193 #elif defined GNULIB_POSIXCHECK
1195 # if HAVE_RAW_DECL_GETENTROPY
1196 _GL_WARN_ON_USE (getentropy
, "getentropy is unportable - "
1197 "use gnulib module getentropy for portability");
1202 #if @GNULIB_GETGROUPS@
1203 /* Return the supplemental groups that the current process belongs to.
1204 It is unspecified whether the effective group id is in the list.
1205 If N is 0, return the group count; otherwise, N describes how many
1206 entries are available in GROUPS. Return -1 and set errno if N is
1207 not 0 and not large enough. Fails with ENOSYS on some systems. */
1208 # if @REPLACE_GETGROUPS@
1209 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1211 # define getgroups rpl_getgroups
1213 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
1214 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
1216 # if !@HAVE_GETGROUPS@
1217 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
1219 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
1221 _GL_CXXALIASWARN (getgroups
);
1222 #elif defined GNULIB_POSIXCHECK
1224 # if HAVE_RAW_DECL_GETGROUPS
1225 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
1226 "use gnulib module getgroups for portability");
1231 #if @GNULIB_GETHOSTNAME@
1232 /* Return the standard host name of the machine.
1233 WARNING! The host name may or may not be fully qualified.
1235 Put up to LEN bytes of the host name into NAME.
1236 Null terminate it if the name is shorter than LEN.
1237 If the host name is longer than LEN, set errno = EINVAL and return -1.
1238 Return 0 if successful, otherwise set errno and return -1. */
1239 # if @UNISTD_H_HAVE_WINSOCK2_H@
1240 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1242 # define gethostname rpl_gethostname
1244 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
1245 _GL_ARG_NONNULL ((1)));
1246 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
1248 # if !@HAVE_GETHOSTNAME@
1249 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
1250 _GL_ARG_NONNULL ((1)));
1252 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
1255 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
1257 _GL_CXXALIASWARN (gethostname
);
1258 #elif @UNISTD_H_HAVE_WINSOCK2_H@
1260 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
1261 #elif defined GNULIB_POSIXCHECK
1263 # if HAVE_RAW_DECL_GETHOSTNAME
1264 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
1265 "use gnulib module gethostname for portability");
1270 #if @GNULIB_GETLOGIN@
1271 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
1272 returns NULL with errno set.
1274 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1276 Most programs don't need to use this function, because the information is
1277 available through environment variables:
1278 ${LOGNAME-$USER} on Unix platforms,
1279 $USERNAME on native Windows platforms.
1281 # if !@HAVE_DECL_GETLOGIN@
1282 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
1284 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
1285 _GL_CXXALIASWARN (getlogin
);
1286 #elif defined GNULIB_POSIXCHECK
1288 # if HAVE_RAW_DECL_GETLOGIN
1289 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
1290 "use gnulib module getlogin for portability");
1295 #if @GNULIB_GETLOGIN_R@
1296 /* Copies the user's login name to NAME.
1297 The array pointed to by NAME has room for SIZE bytes.
1299 Returns 0 if successful. Upon error, an error number is returned, or -1 in
1300 the case that the login name cannot be found but no specific error is
1301 provided (this case is hopefully rare but is left open by the POSIX spec).
1303 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1305 Most programs don't need to use this function, because the information is
1306 available through environment variables:
1307 ${LOGNAME-$USER} on Unix platforms,
1308 $USERNAME on native Windows platforms.
1310 # if @REPLACE_GETLOGIN_R@
1311 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1312 # define getlogin_r rpl_getlogin_r
1314 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
1315 _GL_ARG_NONNULL ((1)));
1316 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
1318 # if !@HAVE_DECL_GETLOGIN_R@
1319 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
1320 _GL_ARG_NONNULL ((1)));
1322 /* Need to cast, because on Solaris 10 systems, the second argument is
1324 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
1326 _GL_CXXALIASWARN (getlogin_r
);
1327 #elif defined GNULIB_POSIXCHECK
1329 # if HAVE_RAW_DECL_GETLOGIN_R
1330 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
1331 "use gnulib module getlogin_r for portability");
1336 #if @GNULIB_GETPAGESIZE@
1337 # if @REPLACE_GETPAGESIZE@
1338 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1339 # define getpagesize rpl_getpagesize
1341 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
1342 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
1344 /* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
1345 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */
1347 _GL_FUNCDECL_SYS (getpagesize
, int, (void));
1349 # if !@HAVE_GETPAGESIZE@
1350 # if !defined getpagesize
1351 /* This is for POSIX systems. */
1352 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
1353 # if ! (defined __VMS && __VMS_VER < 70000000)
1354 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
1357 /* This is for older VMS. */
1358 # if !defined _gl_getpagesize && defined __VMS
1360 # define _gl_getpagesize() 8192
1362 # define _gl_getpagesize() 512
1365 /* This is for BeOS. */
1366 # if !defined _gl_getpagesize && @HAVE_OS_H@
1368 # if defined B_PAGE_SIZE
1369 # define _gl_getpagesize() B_PAGE_SIZE
1372 /* This is for AmigaOS4.0. */
1373 # if !defined _gl_getpagesize && defined __amigaos4__
1374 # define _gl_getpagesize() 2048
1376 /* This is for older Unix systems. */
1377 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
1378 # include <sys/param.h>
1379 # ifdef EXEC_PAGESIZE
1380 # define _gl_getpagesize() EXEC_PAGESIZE
1386 # define _gl_getpagesize() (NBPG * CLSIZE)
1389 # define _gl_getpagesize() NBPC
1394 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1395 # define getpagesize() _gl_getpagesize ()
1397 # if !GNULIB_defined_getpagesize_function
1398 _GL_UNISTD_INLINE
int
1401 return _gl_getpagesize ();
1403 # define GNULIB_defined_getpagesize_function 1
1408 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
1409 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
1411 # if @HAVE_DECL_GETPAGESIZE@
1412 _GL_CXXALIASWARN (getpagesize
);
1414 #elif defined GNULIB_POSIXCHECK
1416 # if HAVE_RAW_DECL_GETPAGESIZE
1417 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
1418 "use gnulib module getpagesize for portability");
1423 #if @GNULIB_GETPASS@
1424 /* Function getpass() from module 'getpass':
1425 Read a password from /dev/tty or stdin.
1426 Function getpass() from module 'getpass-gnu':
1427 Read a password of arbitrary length from /dev/tty or stdin. */
1428 # if (@GNULIB_GETPASS@ && @REPLACE_GETPASS@) \
1429 || (@GNULIB_GETPASS_GNU@ && @REPLACE_GETPASS_FOR_GETPASS_GNU@)
1430 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1432 # define getpass rpl_getpass
1434 _GL_FUNCDECL_RPL (getpass
, char *, (const char *prompt
)
1435 _GL_ARG_NONNULL ((1)));
1436 _GL_CXXALIAS_RPL (getpass
, char *, (const char *prompt
));
1438 # if !@HAVE_GETPASS@
1439 _GL_FUNCDECL_SYS (getpass
, char *, (const char *prompt
)
1440 _GL_ARG_NONNULL ((1)));
1442 _GL_CXXALIAS_SYS (getpass
, char *, (const char *prompt
));
1444 _GL_CXXALIASWARN (getpass
);
1445 #elif defined GNULIB_POSIXCHECK
1447 # if HAVE_RAW_DECL_GETPASS
1448 _GL_WARN_ON_USE (getpass
, "getpass is unportable - "
1449 "use gnulib module getpass or getpass-gnu for portability");
1454 #if @GNULIB_MDA_GETPID@
1455 /* On native Windows, map 'getpid' to '_getpid', so that -loldnames is not
1456 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1457 platforms by defining GNULIB_NAMESPACE::getpid always. */
1458 # if defined _WIN32 && !defined __CYGWIN__
1459 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1461 # define getpid _getpid
1463 _GL_CXXALIAS_MDA (getpid
, int, (void));
1465 _GL_CXXALIAS_SYS (getpid
, pid_t
, (void));
1467 _GL_CXXALIASWARN (getpid
);
1471 #if @GNULIB_GETUSERSHELL@
1472 /* Return the next valid login shell on the system, or NULL when the end of
1473 the list has been reached. */
1474 # if !@HAVE_DECL_GETUSERSHELL@
1475 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
1477 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
1478 _GL_CXXALIASWARN (getusershell
);
1479 #elif defined GNULIB_POSIXCHECK
1480 # undef getusershell
1481 # if HAVE_RAW_DECL_GETUSERSHELL
1482 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
1483 "use gnulib module getusershell for portability");
1487 #if @GNULIB_GETUSERSHELL@
1488 /* Rewind to pointer that is advanced at each getusershell() call. */
1489 # if !@HAVE_DECL_GETUSERSHELL@
1490 _GL_FUNCDECL_SYS (setusershell
, void, (void));
1492 _GL_CXXALIAS_SYS (setusershell
, void, (void));
1493 _GL_CXXALIASWARN (setusershell
);
1494 #elif defined GNULIB_POSIXCHECK
1495 # undef setusershell
1496 # if HAVE_RAW_DECL_SETUSERSHELL
1497 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
1498 "use gnulib module getusershell for portability");
1502 #if @GNULIB_GETUSERSHELL@
1503 /* Free the pointer that is advanced at each getusershell() call and
1504 associated resources. */
1505 # if !@HAVE_DECL_GETUSERSHELL@
1506 _GL_FUNCDECL_SYS (endusershell
, void, (void));
1508 _GL_CXXALIAS_SYS (endusershell
, void, (void));
1509 _GL_CXXALIASWARN (endusershell
);
1510 #elif defined GNULIB_POSIXCHECK
1511 # undef endusershell
1512 # if HAVE_RAW_DECL_ENDUSERSHELL
1513 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
1514 "use gnulib module getusershell for portability");
1519 #if @GNULIB_GROUP_MEMBER@
1520 /* Determine whether group id is in calling user's group list. */
1521 # if !@HAVE_GROUP_MEMBER@
1522 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
1524 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
1525 _GL_CXXALIASWARN (group_member
);
1526 #elif defined GNULIB_POSIXCHECK
1527 # undef group_member
1528 # if HAVE_RAW_DECL_GROUP_MEMBER
1529 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
1530 "use gnulib module group-member for portability");
1536 # if @REPLACE_ISATTY@
1537 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1539 # define isatty rpl_isatty
1541 # define GNULIB_defined_isatty 1
1542 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
1543 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
1544 # elif defined _WIN32 && !defined __CYGWIN__
1545 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1547 # define isatty _isatty
1549 _GL_CXXALIAS_MDA (isatty
, int, (int fd
));
1551 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
1553 _GL_CXXALIASWARN (isatty
);
1554 #elif defined GNULIB_POSIXCHECK
1556 # if HAVE_RAW_DECL_ISATTY
1557 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
1558 "use gnulib module isatty for portability");
1560 #elif @GNULIB_MDA_ISATTY@
1561 /* On native Windows, map 'isatty' to '_isatty', so that -loldnames is not
1562 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1563 platforms by defining GNULIB_NAMESPACE::isatty always. */
1564 # if defined _WIN32 && !defined __CYGWIN__
1565 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1567 # define isatty _isatty
1569 _GL_CXXALIAS_MDA (isatty
, int, (int fd
));
1571 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
1573 _GL_CXXALIASWARN (isatty
);
1578 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1579 to GID (if GID is not -1). Do not follow symbolic links.
1580 Return 0 if successful, otherwise -1 and errno set.
1581 See the POSIX:2008 specification
1582 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1583 # if @REPLACE_LCHOWN@
1584 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1586 # define lchown rpl_lchown
1588 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1589 _GL_ARG_NONNULL ((1)));
1590 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1593 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1594 _GL_ARG_NONNULL ((1)));
1596 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1598 _GL_CXXALIASWARN (lchown
);
1599 #elif defined GNULIB_POSIXCHECK
1601 # if HAVE_RAW_DECL_LCHOWN
1602 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1603 "use gnulib module lchown for portability");
1609 /* Create a new hard link for an existing file.
1610 Return 0 if successful, otherwise -1 and errno set.
1611 See POSIX:2008 specification
1612 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1614 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1615 # define link rpl_link
1617 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1618 _GL_ARG_NONNULL ((1, 2)));
1619 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1622 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1623 _GL_ARG_NONNULL ((1, 2)));
1625 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1627 _GL_CXXALIASWARN (link
);
1628 #elif defined GNULIB_POSIXCHECK
1630 # if HAVE_RAW_DECL_LINK
1631 _GL_WARN_ON_USE (link
, "link is unportable - "
1632 "use gnulib module link for portability");
1638 /* Create a new hard link for an existing file, relative to two
1639 directories. FLAG controls whether symlinks are followed.
1640 Return 0 if successful, otherwise -1 and errno set. */
1641 # if @REPLACE_LINKAT@
1642 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1644 # define linkat rpl_linkat
1646 _GL_FUNCDECL_RPL (linkat
, int,
1647 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1649 _GL_ARG_NONNULL ((2, 4)));
1650 _GL_CXXALIAS_RPL (linkat
, int,
1651 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1655 _GL_FUNCDECL_SYS (linkat
, int,
1656 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1658 _GL_ARG_NONNULL ((2, 4)));
1660 _GL_CXXALIAS_SYS (linkat
, int,
1661 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1664 _GL_CXXALIASWARN (linkat
);
1665 #elif defined GNULIB_POSIXCHECK
1667 # if HAVE_RAW_DECL_LINKAT
1668 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1669 "use gnulib module linkat for portability");
1675 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1676 Return the new offset if successful, otherwise -1 and errno set.
1677 See the POSIX:2008 specification
1678 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1679 # if @REPLACE_LSEEK@
1680 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1681 # define lseek rpl_lseek
1683 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1684 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1685 # elif defined _WIN32 && !defined __CYGWIN__
1686 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1688 # define lseek _lseek
1690 _GL_CXXALIAS_MDA (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1692 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1694 _GL_CXXALIASWARN (lseek
);
1695 #elif defined GNULIB_POSIXCHECK
1697 # if HAVE_RAW_DECL_LSEEK
1698 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1699 "systems - use gnulib module lseek for portability");
1701 #elif @GNULIB_MDA_LSEEK@
1702 /* On native Windows, map 'lseek' to '_lseek', so that -loldnames is not
1703 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1704 platforms by defining GNULIB_NAMESPACE::lseek always. */
1705 # if defined _WIN32 && !defined __CYGWIN__
1706 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1708 # define lseek _lseek
1710 _GL_CXXALIAS_MDA (lseek
, long, (int fd
, long offset
, int whence
));
1712 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1714 _GL_CXXALIASWARN (lseek
);
1719 /* Create a pipe, defaulting to O_BINARY mode.
1720 Store the read-end as fd[0] and the write-end as fd[1].
1721 Return 0 upon success, or -1 with errno set upon failure. */
1723 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1725 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1726 _GL_CXXALIASWARN (pipe
);
1727 #elif defined GNULIB_POSIXCHECK
1729 # if HAVE_RAW_DECL_PIPE
1730 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1731 "use gnulib module pipe-posix for portability");
1737 /* Create a pipe, applying the given flags when opening the read-end of the
1738 pipe and the write-end of the pipe.
1739 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1740 and O_TEXT, O_BINARY (defined in "binary-io.h").
1741 Store the read-end as fd[0] and the write-end as fd[1].
1742 Return 0 upon success, or -1 with errno set upon failure.
1743 See also the Linux man page at
1744 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1746 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1747 # define pipe2 rpl_pipe2
1749 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1750 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1752 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1753 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1755 _GL_CXXALIASWARN (pipe2
);
1756 #elif defined GNULIB_POSIXCHECK
1758 # if HAVE_RAW_DECL_PIPE2
1759 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1760 "use gnulib module pipe2 for portability");
1766 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1767 Return the number of bytes placed into BUF if successful, otherwise
1768 set errno and return -1. 0 indicates EOF.
1769 See the POSIX:2008 specification
1770 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1771 # if @REPLACE_PREAD@
1772 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1774 # define pread rpl_pread
1776 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1777 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1778 _GL_ARG_NONNULL ((2)));
1779 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1780 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1783 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1784 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1785 _GL_ARG_NONNULL ((2)));
1787 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1788 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1790 _GL_CXXALIASWARN (pread
);
1791 #elif defined GNULIB_POSIXCHECK
1793 # if HAVE_RAW_DECL_PREAD
1794 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1795 "use gnulib module pread for portability");
1801 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1802 Return the number of bytes written if successful, otherwise
1803 set errno and return -1. 0 indicates nothing written. See the
1804 POSIX:2008 specification
1805 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1806 # if @REPLACE_PWRITE@
1807 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1809 # define pwrite rpl_pwrite
1811 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1812 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1813 _GL_ARG_NONNULL ((2)));
1814 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1815 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1818 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1819 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1820 _GL_ARG_NONNULL ((2)));
1822 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1823 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1825 _GL_CXXALIASWARN (pwrite
);
1826 #elif defined GNULIB_POSIXCHECK
1828 # if HAVE_RAW_DECL_PWRITE
1829 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1830 "use gnulib module pwrite for portability");
1836 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1837 at BUF. See the POSIX:2008 specification
1838 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1840 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1842 # define read rpl_read
1844 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1845 _GL_ARG_NONNULL ((2)));
1846 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1847 # elif defined _WIN32 && !defined __CYGWIN__
1848 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1852 _GL_CXXALIAS_MDA (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1854 _GL_CXXALIAS_SYS (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1856 _GL_CXXALIASWARN (read
);
1857 #elif @GNULIB_MDA_READ@
1858 /* On native Windows, map 'read' to '_read', so that -loldnames is not
1859 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1860 platforms by defining GNULIB_NAMESPACE::read always. */
1861 # if defined _WIN32 && !defined __CYGWIN__
1862 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1867 _GL_CXXALIAS_MDA (read
, int, (int fd
, void *buf
, unsigned int count
));
1869 _GL_CXXALIAS_MDA (read
, ssize_t
, (int fd
, void *buf
, unsigned int count
));
1872 _GL_CXXALIAS_SYS (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1874 _GL_CXXALIASWARN (read
);
1878 #if @GNULIB_READLINK@
1879 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1880 bytes of it into BUF. Return the number of bytes placed into BUF if
1881 successful, otherwise -1 and errno set.
1882 See the POSIX:2008 specification
1883 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1884 # if @REPLACE_READLINK@
1885 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1886 # define readlink rpl_readlink
1888 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1889 (const char *restrict file
,
1890 char *restrict buf
, size_t bufsize
)
1891 _GL_ARG_NONNULL ((1, 2)));
1892 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1893 (const char *restrict file
,
1894 char *restrict buf
, size_t bufsize
));
1896 # if !@HAVE_READLINK@
1897 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1898 (const char *restrict file
,
1899 char *restrict buf
, size_t bufsize
)
1900 _GL_ARG_NONNULL ((1, 2)));
1902 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1903 (const char *restrict file
,
1904 char *restrict buf
, size_t bufsize
));
1906 _GL_CXXALIASWARN (readlink
);
1907 #elif defined GNULIB_POSIXCHECK
1909 # if HAVE_RAW_DECL_READLINK
1910 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1911 "use gnulib module readlink for portability");
1916 #if @GNULIB_READLINKAT@
1917 # if @REPLACE_READLINKAT@
1918 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1919 # define readlinkat rpl_readlinkat
1921 _GL_FUNCDECL_RPL (readlinkat
, ssize_t
,
1922 (int fd
, char const *restrict file
,
1923 char *restrict buf
, size_t len
)
1924 _GL_ARG_NONNULL ((2, 3)));
1925 _GL_CXXALIAS_RPL (readlinkat
, ssize_t
,
1926 (int fd
, char const *restrict file
,
1927 char *restrict buf
, size_t len
));
1929 # if !@HAVE_READLINKAT@
1930 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1931 (int fd
, char const *restrict file
,
1932 char *restrict buf
, size_t len
)
1933 _GL_ARG_NONNULL ((2, 3)));
1935 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1936 (int fd
, char const *restrict file
,
1937 char *restrict buf
, size_t len
));
1939 _GL_CXXALIASWARN (readlinkat
);
1940 #elif defined GNULIB_POSIXCHECK
1942 # if HAVE_RAW_DECL_READLINKAT
1943 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1944 "use gnulib module readlinkat for portability");
1950 /* Remove the directory DIR. */
1951 # if @REPLACE_RMDIR@
1952 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1953 # define rmdir rpl_rmdir
1955 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1956 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1957 # elif defined _WIN32 && !defined __CYGWIN__
1958 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1960 # define rmdir _rmdir
1962 _GL_CXXALIAS_MDA (rmdir
, int, (char const *name
));
1964 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1966 _GL_CXXALIASWARN (rmdir
);
1967 #elif defined GNULIB_POSIXCHECK
1969 # if HAVE_RAW_DECL_RMDIR
1970 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1971 "use gnulib module rmdir for portability");
1973 #elif @GNULIB_MDA_RMDIR@
1974 /* On native Windows, map 'rmdir' to '_rmdir', so that -loldnames is not
1975 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1976 platforms by defining GNULIB_NAMESPACE::rmdir always. */
1977 # if defined _WIN32 && !defined __CYGWIN__
1978 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1980 # define rmdir _rmdir
1982 _GL_CXXALIAS_MDA (rmdir
, int, (char const *name
));
1984 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1986 _GL_CXXALIASWARN (rmdir
);
1990 #if @GNULIB_SETHOSTNAME@
1991 /* Set the host name of the machine.
1992 The host name may or may not be fully qualified.
1994 Put LEN bytes of NAME into the host name.
1995 Return 0 if successful, otherwise, set errno and return -1.
1997 Platforms with no ability to set the hostname return -1 and set
1999 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
2000 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
2001 _GL_ARG_NONNULL ((1)));
2003 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
2004 and FreeBSD 6.4 the second parameter is int. On Solaris 11
2005 2011-10, the first parameter is not const. */
2006 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
2007 _GL_CXXALIASWARN (sethostname
);
2008 #elif defined GNULIB_POSIXCHECK
2010 # if HAVE_RAW_DECL_SETHOSTNAME
2011 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
2012 "use gnulib module sethostname for portability");
2018 /* Pause the execution of the current thread for N seconds.
2019 Returns the number of seconds left to sleep.
2020 See the POSIX:2008 specification
2021 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
2022 # if @REPLACE_SLEEP@
2023 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2025 # define sleep rpl_sleep
2027 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
2028 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
2031 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
2033 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
2035 _GL_CXXALIASWARN (sleep
);
2036 #elif defined GNULIB_POSIXCHECK
2038 # if HAVE_RAW_DECL_SLEEP
2039 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
2040 "use gnulib module sleep for portability");
2045 #if @GNULIB_MDA_SWAB@
2046 /* On native Windows, map 'swab' to '_swab', so that -loldnames is not
2047 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2048 platforms by defining GNULIB_NAMESPACE::swab always. */
2049 # if defined _WIN32 && !defined __CYGWIN__
2050 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2054 /* Need to cast, because in old mingw the arguments are
2055 (const char *from, char *to, size_t n). */
2056 _GL_CXXALIAS_MDA_CAST (swab
, void, (char *from
, char *to
, int n
));
2058 # if defined __hpux /* HP-UX */
2059 _GL_CXXALIAS_SYS (swab
, void, (const char *from
, char *to
, int n
));
2060 # elif defined __sun && (defined __SunOS_5_10 || defined __XOPEN_OR_POSIX) && !defined _XPG4 /* Solaris */
2061 _GL_CXXALIAS_SYS (swab
, void, (const char *from
, char *to
, ssize_t n
));
2063 _GL_CXXALIAS_SYS (swab
, void, (const void *from
, void *to
, ssize_t n
));
2066 _GL_CXXALIASWARN (swab
);
2070 #if @GNULIB_SYMLINK@
2071 # if @REPLACE_SYMLINK@
2072 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2074 # define symlink rpl_symlink
2076 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
2077 _GL_ARG_NONNULL ((1, 2)));
2078 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
2080 # if !@HAVE_SYMLINK@
2081 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
2082 _GL_ARG_NONNULL ((1, 2)));
2084 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
2086 _GL_CXXALIASWARN (symlink
);
2087 #elif defined GNULIB_POSIXCHECK
2089 # if HAVE_RAW_DECL_SYMLINK
2090 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
2091 "use gnulib module symlink for portability");
2096 #if @GNULIB_SYMLINKAT@
2097 # if @REPLACE_SYMLINKAT@
2098 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2100 # define symlinkat rpl_symlinkat
2102 _GL_FUNCDECL_RPL (symlinkat
, int,
2103 (char const *contents
, int fd
, char const *file
)
2104 _GL_ARG_NONNULL ((1, 3)));
2105 _GL_CXXALIAS_RPL (symlinkat
, int,
2106 (char const *contents
, int fd
, char const *file
));
2108 # if !@HAVE_SYMLINKAT@
2109 _GL_FUNCDECL_SYS (symlinkat
, int,
2110 (char const *contents
, int fd
, char const *file
)
2111 _GL_ARG_NONNULL ((1, 3)));
2113 _GL_CXXALIAS_SYS (symlinkat
, int,
2114 (char const *contents
, int fd
, char const *file
));
2116 _GL_CXXALIASWARN (symlinkat
);
2117 #elif defined GNULIB_POSIXCHECK
2119 # if HAVE_RAW_DECL_SYMLINKAT
2120 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
2121 "use gnulib module symlinkat for portability");
2126 #if @GNULIB_TRUNCATE@
2127 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
2128 Return 0 if successful, otherwise -1 and errno set.
2129 See the POSIX:2008 specification
2130 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
2131 # if @REPLACE_TRUNCATE@
2132 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2134 # define truncate rpl_truncate
2136 _GL_FUNCDECL_RPL (truncate
, int, (const char *filename
, off_t length
)
2137 _GL_ARG_NONNULL ((1)));
2138 _GL_CXXALIAS_RPL (truncate
, int, (const char *filename
, off_t length
));
2140 # if !@HAVE_DECL_TRUNCATE@
2141 _GL_FUNCDECL_SYS (truncate
, int, (const char *filename
, off_t length
)
2142 _GL_ARG_NONNULL ((1)));
2144 _GL_CXXALIAS_SYS (truncate
, int, (const char *filename
, off_t length
));
2146 _GL_CXXALIASWARN (truncate
);
2147 #elif defined GNULIB_POSIXCHECK
2149 # if HAVE_RAW_DECL_TRUNCATE
2150 _GL_WARN_ON_USE (truncate
, "truncate is unportable - "
2151 "use gnulib module truncate for portability");
2156 #if @GNULIB_TTYNAME_R@
2157 /* Store at most BUFLEN characters of the pathname of the terminal FD is
2158 open on in BUF. Return 0 on success, otherwise an error number. */
2159 # if @REPLACE_TTYNAME_R@
2160 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2162 # define ttyname_r rpl_ttyname_r
2164 _GL_FUNCDECL_RPL (ttyname_r
, int,
2165 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
2166 _GL_CXXALIAS_RPL (ttyname_r
, int,
2167 (int fd
, char *buf
, size_t buflen
));
2169 # if !@HAVE_DECL_TTYNAME_R@
2170 _GL_FUNCDECL_SYS (ttyname_r
, int,
2171 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
2173 _GL_CXXALIAS_SYS (ttyname_r
, int,
2174 (int fd
, char *buf
, size_t buflen
));
2176 _GL_CXXALIASWARN (ttyname_r
);
2177 #elif defined GNULIB_POSIXCHECK
2179 # if HAVE_RAW_DECL_TTYNAME_R
2180 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
2181 "use gnulib module ttyname_r for portability");
2187 # if @REPLACE_UNLINK@
2188 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2190 # define unlink rpl_unlink
2192 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
2193 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
2194 # elif defined _WIN32 && !defined __CYGWIN__
2195 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2197 # define unlink _unlink
2199 _GL_CXXALIAS_MDA (unlink
, int, (char const *file
));
2201 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
2203 _GL_CXXALIASWARN (unlink
);
2204 #elif defined GNULIB_POSIXCHECK
2206 # if HAVE_RAW_DECL_UNLINK
2207 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
2208 "use gnulib module unlink for portability");
2210 #elif @GNULIB_MDA_UNLINK@
2211 /* On native Windows, map 'unlink' to '_unlink', so that -loldnames is not
2212 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2213 platforms by defining GNULIB_NAMESPACE::unlink always. */
2214 # if defined _WIN32 && !defined __CYGWIN__
2215 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2217 # define unlink _unlink
2219 _GL_CXXALIAS_MDA (unlink
, int, (char const *file
));
2221 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
2223 _GL_CXXALIASWARN (unlink
);
2227 #if @GNULIB_UNLINKAT@
2228 # if @REPLACE_UNLINKAT@
2229 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2231 # define unlinkat rpl_unlinkat
2233 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
2234 _GL_ARG_NONNULL ((2)));
2235 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
2237 # if !@HAVE_UNLINKAT@
2238 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
2239 _GL_ARG_NONNULL ((2)));
2241 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
2243 _GL_CXXALIASWARN (unlinkat
);
2244 #elif defined GNULIB_POSIXCHECK
2246 # if HAVE_RAW_DECL_UNLINKAT
2247 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
2248 "use gnulib module unlinkat for portability");
2254 /* Pause the execution of the current thread for N microseconds.
2255 Returns 0 on completion, or -1 on range error.
2256 See the POSIX:2001 specification
2257 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
2258 # if @REPLACE_USLEEP@
2259 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2261 # define usleep rpl_usleep
2263 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
2264 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
2267 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
2269 /* Need to cast, because on Haiku, the first parameter is
2271 _GL_CXXALIAS_SYS_CAST (usleep
, int, (useconds_t n
));
2273 _GL_CXXALIASWARN (usleep
);
2274 #elif defined GNULIB_POSIXCHECK
2276 # if HAVE_RAW_DECL_USLEEP
2277 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
2278 "use gnulib module usleep for portability");
2284 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
2285 See the POSIX:2008 specification
2286 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
2287 # if @REPLACE_WRITE@
2288 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2290 # define write rpl_write
2292 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
2293 _GL_ARG_NONNULL ((2)));
2294 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2295 # elif defined _WIN32 && !defined __CYGWIN__
2296 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2298 # define write _write
2300 _GL_CXXALIAS_MDA (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2302 _GL_CXXALIAS_SYS (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2304 _GL_CXXALIASWARN (write
);
2305 #elif @GNULIB_MDA_WRITE@
2306 /* On native Windows, map 'write' to '_write', so that -loldnames is not
2307 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2308 platforms by defining GNULIB_NAMESPACE::write always. */
2309 # if defined _WIN32 && !defined __CYGWIN__
2310 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2312 # define write _write
2315 _GL_CXXALIAS_MDA (write
, int, (int fd
, const void *buf
, unsigned int count
));
2317 _GL_CXXALIAS_MDA (write
, ssize_t
, (int fd
, const void *buf
, unsigned int count
));
2320 _GL_CXXALIAS_SYS (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2322 _GL_CXXALIASWARN (write
);
2325 _GL_INLINE_HEADER_END
2327 #endif /* _@GUARD_PREFIX@_UNISTD_H */
2328 #endif /* _GL_INCLUDING_UNISTD_H */
2329 #endif /* _@GUARD_PREFIX@_UNISTD_H */