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 ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
101 || defined GNULIB_POSIXCHECK) \
102 && (defined _WIN32 && ! defined __CYGWIN__))
103 # include <io.h> /* mingw32, mingw64 */
104 # include <direct.h> /* mingw64, MSVC 9 */
105 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
106 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
107 || defined GNULIB_POSIXCHECK) \
108 && (defined _WIN32 && ! defined __CYGWIN__)
112 /* Native Windows platforms declare _execl*, _execv* in <process.h>. */
113 #if defined _WIN32 && !defined __CYGWIN__
114 # include <process.h>
117 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
118 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
119 /* But avoid namespace pollution on glibc systems. */
120 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
121 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
122 && !defined __GLIBC__
126 /* Mac OS X 10.13, Solaris 11.4, and Android 9.0 declare getentropy in
127 <sys/random.h>, not in <unistd.h>. */
128 /* But avoid namespace pollution on glibc systems. */
129 #if (@GNULIB_GETENTROPY@ || defined GNULIB_POSIXCHECK) \
130 && ((defined __APPLE__ && defined __MACH__) || defined __sun \
131 || defined __ANDROID__) \
132 && @UNISTD_H_HAVE_SYS_RANDOM_H@ \
133 && !defined __GLIBC__
134 # include <sys/random.h>
137 /* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>. */
138 /* But avoid namespace pollution on glibc systems. */
139 #if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
140 && !defined __GLIBC__
141 # include <sys/stat.h>
144 /* MSVC defines off_t in <sys/types.h>.
145 May also define off_t to a 64-bit type on native Windows. */
146 /* Get off_t, ssize_t, mode_t. */
147 #include <sys/types.h>
149 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
151 /* The definition of _GL_ARG_NONNULL is copied here. */
153 /* The definition of _GL_WARN_ON_USE is copied here. */
156 /* Get getopt(), optarg, optind, opterr, optopt. */
157 #if @GNULIB_GETOPT_POSIX@ && @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
158 # include <getopt-cdefs.h>
159 # include <getopt-pfx-core.h>
162 #ifndef _GL_INLINE_HEADER_BEGIN
163 #error "Please include config.h first."
165 _GL_INLINE_HEADER_BEGIN
166 #ifndef _GL_UNISTD_INLINE
167 # define _GL_UNISTD_INLINE _GL_INLINE
170 /* Hide some function declarations from <winsock2.h>. */
172 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
173 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
174 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
176 # define socket socket_used_without_including_sys_socket_h
178 # define connect connect_used_without_including_sys_socket_h
180 # define accept accept_used_without_including_sys_socket_h
182 # define bind bind_used_without_including_sys_socket_h
184 # define getpeername getpeername_used_without_including_sys_socket_h
186 # define getsockname getsockname_used_without_including_sys_socket_h
188 # define getsockopt getsockopt_used_without_including_sys_socket_h
190 # define listen listen_used_without_including_sys_socket_h
192 # define recv recv_used_without_including_sys_socket_h
194 # define send send_used_without_including_sys_socket_h
196 # define recvfrom recvfrom_used_without_including_sys_socket_h
198 # define sendto sendto_used_without_including_sys_socket_h
200 # define setsockopt setsockopt_used_without_including_sys_socket_h
202 # define shutdown shutdown_used_without_including_sys_socket_h
204 _GL_WARN_ON_USE (socket
,
205 "socket() used without including <sys/socket.h>");
206 _GL_WARN_ON_USE (connect
,
207 "connect() used without including <sys/socket.h>");
208 _GL_WARN_ON_USE (accept
,
209 "accept() used without including <sys/socket.h>");
210 _GL_WARN_ON_USE (bind
,
211 "bind() used without including <sys/socket.h>");
212 _GL_WARN_ON_USE (getpeername
,
213 "getpeername() used without including <sys/socket.h>");
214 _GL_WARN_ON_USE (getsockname
,
215 "getsockname() used without including <sys/socket.h>");
216 _GL_WARN_ON_USE (getsockopt
,
217 "getsockopt() used without including <sys/socket.h>");
218 _GL_WARN_ON_USE (listen
,
219 "listen() used without including <sys/socket.h>");
220 _GL_WARN_ON_USE (recv
,
221 "recv() used without including <sys/socket.h>");
222 _GL_WARN_ON_USE (send
,
223 "send() used without including <sys/socket.h>");
224 _GL_WARN_ON_USE (recvfrom
,
225 "recvfrom() used without including <sys/socket.h>");
226 _GL_WARN_ON_USE (sendto
,
227 "sendto() used without including <sys/socket.h>");
228 _GL_WARN_ON_USE (setsockopt
,
229 "setsockopt() used without including <sys/socket.h>");
230 _GL_WARN_ON_USE (shutdown
,
231 "shutdown() used without including <sys/socket.h>");
234 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
235 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
237 # define select select_used_without_including_sys_select_h
239 _GL_WARN_ON_USE (select
,
240 "select() used without including <sys/select.h>");
246 /* OS/2 EMX lacks these macros. */
248 # define STDIN_FILENO 0
250 #ifndef STDOUT_FILENO
251 # define STDOUT_FILENO 1
253 #ifndef STDERR_FILENO
254 # define STDERR_FILENO 2
257 /* Ensure *_OK macros exist. */
266 /* Declare overridden functions. */
270 # if @REPLACE_ACCESS@
271 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
273 # define access rpl_access
275 _GL_FUNCDECL_RPL (access
, int, (const char *file
, int mode
)
276 _GL_ARG_NONNULL ((1)));
277 _GL_CXXALIAS_RPL (access
, int, (const char *file
, int mode
));
278 # elif defined _WIN32 && !defined __CYGWIN__
279 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
281 # define access _access
283 _GL_CXXALIAS_MDA (access
, int, (const char *file
, int mode
));
285 _GL_CXXALIAS_SYS (access
, int, (const char *file
, int mode
));
287 _GL_CXXALIASWARN (access
);
288 #elif defined GNULIB_POSIXCHECK
290 # if HAVE_RAW_DECL_ACCESS
291 /* The access() function is a security risk. */
292 _GL_WARN_ON_USE (access
, "access does not always support X_OK - "
293 "use gnulib module access for portability; "
294 "also, this function is a security risk - "
295 "use the gnulib module faccessat instead");
298 /* On native Windows, map 'access' to '_access', so that -loldnames is not
299 required. In C++ with GNULIB_NAMESPACE, avoid differences between
300 platforms by defining GNULIB_NAMESPACE::access always. */
301 # if defined _WIN32 && !defined __CYGWIN__
302 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
304 # define access _access
306 _GL_CXXALIAS_MDA (access
, int, (const char *file
, int mode
));
308 _GL_CXXALIAS_SYS (access
, int, (const char *file
, int mode
));
310 _GL_CXXALIASWARN (access
);
315 # if defined _WIN32 && !defined __CYGWIN__
316 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
318 # define chdir _chdir
320 _GL_CXXALIAS_MDA (chdir
, int, (const char *file
));
322 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
324 _GL_CXXALIASWARN (chdir
);
325 #elif defined GNULIB_POSIXCHECK
327 # if HAVE_RAW_DECL_CHDIR
328 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
329 "use gnulib module chdir for portability");
332 /* On native Windows, map 'chdir' to '_chdir', so that -loldnames is not
333 required. In C++ with GNULIB_NAMESPACE, avoid differences between
334 platforms by defining GNULIB_NAMESPACE::chdir always. */
335 # if defined _WIN32 && !defined __CYGWIN__
336 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
338 # define chdir _chdir
340 _GL_CXXALIAS_MDA (chdir
, int, (const char *file
));
342 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
344 _GL_CXXALIASWARN (chdir
);
349 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
350 to GID (if GID is not -1). Follow symbolic links.
351 Return 0 if successful, otherwise -1 and errno set.
352 See the POSIX:2008 specification
353 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
355 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
357 # define chown rpl_chown
359 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
360 _GL_ARG_NONNULL ((1)));
361 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
364 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
365 _GL_ARG_NONNULL ((1)));
367 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
369 _GL_CXXALIASWARN (chown
);
370 #elif defined GNULIB_POSIXCHECK
372 # if HAVE_RAW_DECL_CHOWN
373 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
374 "doesn't treat a uid or gid of -1 on some systems - "
375 "use gnulib module chown for portability");
382 /* Automatically included by modules that need a replacement for close. */
383 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
385 # define close rpl_close
387 _GL_FUNCDECL_RPL (close
, int, (int fd
));
388 _GL_CXXALIAS_RPL (close
, int, (int fd
));
389 # elif defined _WIN32 && !defined __CYGWIN__
390 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
392 # define close _close
394 _GL_CXXALIAS_MDA (close
, int, (int fd
));
396 _GL_CXXALIAS_SYS (close
, int, (int fd
));
398 _GL_CXXALIASWARN (close
);
399 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
401 # define close close_used_without_requesting_gnulib_module_close
402 #elif defined GNULIB_POSIXCHECK
404 /* Assume close is always declared. */
405 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
406 "use gnulib module close for portability");
408 /* On native Windows, map 'close' to '_close', so that -loldnames is not
409 required. In C++ with GNULIB_NAMESPACE, avoid differences between
410 platforms by defining GNULIB_NAMESPACE::close always. */
411 # if defined _WIN32 && !defined __CYGWIN__
412 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
414 # define close _close
416 _GL_CXXALIAS_MDA (close
, int, (int fd
));
418 _GL_CXXALIAS_SYS (close
, int, (int fd
));
420 _GL_CXXALIASWARN (close
);
424 #if @GNULIB_COPY_FILE_RANGE@
425 # if !@HAVE_COPY_FILE_RANGE@
426 _GL_FUNCDECL_SYS (copy_file_range
, ssize_t
, (int ifd
, off_t
*ipos
,
427 int ofd
, off_t
*opos
,
428 size_t len
, unsigned flags
));
429 _GL_CXXALIAS_SYS (copy_file_range
, ssize_t
, (int ifd
, off_t
*ipos
,
430 int ofd
, off_t
*opos
,
431 size_t len
, unsigned flags
));
433 _GL_CXXALIASWARN (copy_file_range
);
434 #elif defined GNULIB_POSIXCHECK
435 # if HAVE_RAW_DECL_COPY_FILE_RANGE
436 _GL_WARN_ON_USE (copy_file_range
,
437 "copy_file_range is unportable - "
438 "use gnulib module copy_file_range for portability");
445 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
448 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
449 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
450 # elif defined _WIN32 && !defined __CYGWIN__
451 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
455 _GL_CXXALIAS_MDA (dup
, int, (int oldfd
));
457 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
459 _GL_CXXALIASWARN (dup
);
460 #elif defined GNULIB_POSIXCHECK
462 # if HAVE_RAW_DECL_DUP
463 _GL_WARN_ON_USE (dup
, "dup is unportable - "
464 "use gnulib module dup for portability");
467 /* On native Windows, map 'dup' to '_dup', so that -loldnames is not
468 required. In C++ with GNULIB_NAMESPACE, avoid differences between
469 platforms by defining GNULIB_NAMESPACE::dup always. */
470 # if defined _WIN32 && !defined __CYGWIN__
471 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
475 _GL_CXXALIAS_MDA (dup
, int, (int oldfd
));
477 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
479 _GL_CXXALIASWARN (dup
);
484 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
485 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
486 Return newfd if successful, otherwise -1 and errno set.
487 See the POSIX:2008 specification
488 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
490 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
491 # define dup2 rpl_dup2
493 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
494 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
495 # elif defined _WIN32 && !defined __CYGWIN__
496 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
500 _GL_CXXALIAS_MDA (dup2
, int, (int oldfd
, int newfd
));
502 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
504 _GL_CXXALIASWARN (dup2
);
505 #elif defined GNULIB_POSIXCHECK
507 # if HAVE_RAW_DECL_DUP2
508 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
509 "use gnulib module dup2 for portability");
512 /* On native Windows, map 'dup2' to '_dup2', so that -loldnames is not
513 required. In C++ with GNULIB_NAMESPACE, avoid differences between
514 platforms by defining GNULIB_NAMESPACE::dup2 always. */
515 # if defined _WIN32 && !defined __CYGWIN__
516 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
520 _GL_CXXALIAS_MDA (dup2
, int, (int oldfd
, int newfd
));
522 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
524 _GL_CXXALIASWARN (dup2
);
529 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
531 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
532 and O_TEXT, O_BINARY (defined in "binary-io.h").
533 Close NEWFD first if it is open.
534 Return newfd if successful, otherwise -1 and errno set.
535 See the Linux man page at
536 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
538 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
539 # define dup3 rpl_dup3
541 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
542 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
544 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
545 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
547 _GL_CXXALIASWARN (dup3
);
548 #elif defined GNULIB_POSIXCHECK
550 # if HAVE_RAW_DECL_DUP3
551 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
552 "use gnulib module dup3 for portability");
558 # if defined __CYGWIN__ && !defined __i386__
559 /* The 'environ' variable is defined in a DLL. Therefore its declaration needs
560 the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
561 This leads to a link error on 64-bit Cygwin when the option
562 -Wl,--disable-auto-import is in use. */
563 _GL_EXTERN_C
__declspec(dllimport
) char **environ
;
565 # if !@HAVE_DECL_ENVIRON@
566 /* Set of environment variables and values. An array of strings of the form
567 "VARIABLE=VALUE", terminated with a NULL. */
568 # if defined __APPLE__ && defined __MACH__
569 # include <TargetConditionals.h>
570 # if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
571 # define _GL_USE_CRT_EXTERNS
574 # ifdef _GL_USE_CRT_EXTERNS
575 # include <crt_externs.h>
576 # define environ (*_NSGetEnviron ())
581 extern char **environ
;
587 #elif defined GNULIB_POSIXCHECK
588 # if HAVE_RAW_DECL_ENVIRON
589 _GL_UNISTD_INLINE
char ***
590 _GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
591 "use gnulib module environ for portability")
597 # define environ (*rpl_environ ())
602 #if @GNULIB_EUIDACCESS@
603 /* Like access(), except that it uses the effective user id and group id of
604 the current process. */
605 # if !@HAVE_EUIDACCESS@
606 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
607 _GL_ARG_NONNULL ((1)));
609 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
610 _GL_CXXALIASWARN (euidaccess
);
611 # if defined GNULIB_POSIXCHECK
612 /* Like access(), this function is a security risk. */
613 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
614 "use the gnulib module faccessat instead");
616 #elif defined GNULIB_POSIXCHECK
618 # if HAVE_RAW_DECL_EUIDACCESS
619 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
620 "use gnulib module euidaccess for portability");
625 /* On native Windows, map 'execl' to '_execl', so that -loldnames is not
626 required. In C++ with GNULIB_NAMESPACE, avoid differences between
627 platforms by defining GNULIB_NAMESPACE::execl always. */
628 #if defined _WIN32 && !defined __CYGWIN__
629 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
631 # define execl _execl
633 _GL_CXXALIAS_MDA (execl
, intptr_t, (const char *program
, const char *arg
, ...));
635 _GL_CXXALIAS_SYS (execl
, int, (const char *program
, const char *arg
, ...));
637 _GL_CXXALIASWARN (execl
);
639 /* On native Windows, map 'execle' to '_execle', so that -loldnames is not
640 required. In C++ with GNULIB_NAMESPACE, avoid differences between
641 platforms by defining GNULIB_NAMESPACE::execle always. */
642 #if defined _WIN32 && !defined __CYGWIN__
643 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
645 # define execle _execle
647 _GL_CXXALIAS_MDA (execle
, intptr_t, (const char *program
, const char *arg
, ...));
649 _GL_CXXALIAS_SYS (execle
, int, (const char *program
, const char *arg
, ...));
651 _GL_CXXALIASWARN (execle
);
653 /* On native Windows, map 'execlp' to '_execlp', so that -loldnames is not
654 required. In C++ with GNULIB_NAMESPACE, avoid differences between
655 platforms by defining GNULIB_NAMESPACE::execlp always. */
656 #if defined _WIN32 && !defined __CYGWIN__
657 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
659 # define execlp _execlp
661 _GL_CXXALIAS_MDA (execlp
, intptr_t, (const char *program
, const char *arg
, ...));
663 _GL_CXXALIAS_SYS (execlp
, int, (const char *program
, const char *arg
, ...));
665 _GL_CXXALIASWARN (execlp
);
668 /* On native Windows, map 'execv' to '_execv', so that -loldnames is not
669 required. In C++ with GNULIB_NAMESPACE, avoid differences between
670 platforms by defining GNULIB_NAMESPACE::execv always. */
671 #if defined _WIN32 && !defined __CYGWIN__
672 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
674 # define execv _execv
676 _GL_CXXALIAS_MDA (execv
, intptr_t,
677 (const char *program
, const char * const *argv
));
679 _GL_CXXALIAS_SYS (execv
, int, (const char *program
, char * const *argv
));
681 _GL_CXXALIASWARN (execv
);
683 /* On native Windows, map 'execve' to '_execve', so that -loldnames is not
684 required. In C++ with GNULIB_NAMESPACE, avoid differences between
685 platforms by defining GNULIB_NAMESPACE::execve always. */
686 #if defined _WIN32 && !defined __CYGWIN__
687 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
689 # define execve _execve
691 _GL_CXXALIAS_MDA (execve
, intptr_t,
692 (const char *program
, const char * const *argv
,
693 const char * const *env
));
695 _GL_CXXALIAS_SYS (execve
, int,
696 (const char *program
, char * const *argv
, char * const *env
));
698 _GL_CXXALIASWARN (execve
);
700 /* On native Windows, map 'execvp' to '_execvp', so that -loldnames is not
701 required. In C++ with GNULIB_NAMESPACE, avoid differences between
702 platforms by defining GNULIB_NAMESPACE::execvp always. */
703 #if defined _WIN32 && !defined __CYGWIN__
704 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
706 # define execvp _execvp
708 _GL_CXXALIAS_MDA (execvp
, intptr_t,
709 (const char *program
, const char * const *argv
));
711 _GL_CXXALIAS_SYS (execvp
, int, (const char *program
, char * const *argv
));
713 _GL_CXXALIASWARN (execvp
);
715 /* On native Windows, map 'execvpe' to '_execvpe', so that -loldnames is not
716 required. In C++ with GNULIB_NAMESPACE, avoid differences between
717 platforms by defining GNULIB_NAMESPACE::execvpe on all platforms that have
719 #if defined _WIN32 && !defined __CYGWIN__
720 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
722 # define execvpe _execvpe
724 _GL_CXXALIAS_MDA (execvpe
, intptr_t,
725 (const char *program
, const char * const *argv
,
726 const char * const *env
));
728 # if @HAVE_DECL_EXECVPE@
729 _GL_CXXALIAS_SYS (execvpe
, int,
730 (const char *program
, char * const *argv
, char * const *env
));
733 #if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_EXECVPE@
734 _GL_CXXALIASWARN (execvpe
);
738 #if @GNULIB_FACCESSAT@
739 # if @REPLACE_FACCESSAT@
740 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
742 # define faccessat rpl_faccessat
744 _GL_FUNCDECL_RPL (faccessat
, int,
745 (int fd
, char const *name
, int mode
, int flag
)
746 _GL_ARG_NONNULL ((2)));
747 _GL_CXXALIAS_RPL (faccessat
, int,
748 (int fd
, char const *name
, int mode
, int flag
));
750 # if !@HAVE_FACCESSAT@
751 _GL_FUNCDECL_SYS (faccessat
, int,
752 (int fd
, char const *file
, int mode
, int flag
)
753 _GL_ARG_NONNULL ((2)));
755 _GL_CXXALIAS_SYS (faccessat
, int,
756 (int fd
, char const *file
, int mode
, int flag
));
758 _GL_CXXALIASWARN (faccessat
);
759 #elif defined GNULIB_POSIXCHECK
761 # if HAVE_RAW_DECL_FACCESSAT
762 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
763 "use gnulib module faccessat for portability");
769 /* Change the process' current working directory to the directory on which
770 the given file descriptor is open.
771 Return 0 if successful, otherwise -1 and errno set.
772 See the POSIX:2008 specification
773 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
775 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
777 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
778 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
779 _GL_ARG_NONNULL ((2));
780 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
781 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
782 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
785 # if !@HAVE_DECL_FCHDIR@
786 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
789 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
790 _GL_CXXALIASWARN (fchdir
);
791 #elif defined GNULIB_POSIXCHECK
793 # if HAVE_RAW_DECL_FCHDIR
794 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
795 "use gnulib module fchdir for portability");
800 #if @GNULIB_FCHOWNAT@
801 # if @REPLACE_FCHOWNAT@
802 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
804 # define fchownat rpl_fchownat
806 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
807 uid_t owner
, gid_t group
, int flag
)
808 _GL_ARG_NONNULL ((2)));
809 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
810 uid_t owner
, gid_t group
, int flag
));
812 # if !@HAVE_FCHOWNAT@
813 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
814 uid_t owner
, gid_t group
, int flag
)
815 _GL_ARG_NONNULL ((2)));
817 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
818 uid_t owner
, gid_t group
, int flag
));
820 _GL_CXXALIASWARN (fchownat
);
821 #elif defined GNULIB_POSIXCHECK
823 # if HAVE_RAW_DECL_FCHOWNAT
824 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
825 "use gnulib module openat for portability");
830 #if @GNULIB_FDATASYNC@
831 /* Synchronize changes to a file.
832 Return 0 if successful, otherwise -1 and errno set.
833 See POSIX:2008 specification
834 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
835 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
836 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
838 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
839 _GL_CXXALIASWARN (fdatasync
);
840 #elif defined GNULIB_POSIXCHECK
842 # if HAVE_RAW_DECL_FDATASYNC
843 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
844 "use gnulib module fdatasync for portability");
850 /* Synchronize changes, including metadata, to a file.
851 Return 0 if successful, otherwise -1 and errno set.
852 See POSIX:2008 specification
853 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
855 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
857 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
858 _GL_CXXALIASWARN (fsync
);
859 #elif defined GNULIB_POSIXCHECK
861 # if HAVE_RAW_DECL_FSYNC
862 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
863 "use gnulib module fsync for portability");
868 #if @GNULIB_FTRUNCATE@
869 /* Change the size of the file to which FD is opened to become equal to LENGTH.
870 Return 0 if successful, otherwise -1 and errno set.
871 See the POSIX:2008 specification
872 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
873 # if @REPLACE_FTRUNCATE@
874 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
876 # define ftruncate rpl_ftruncate
878 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
879 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
881 # if !@HAVE_FTRUNCATE@
882 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
884 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
886 _GL_CXXALIASWARN (ftruncate
);
887 #elif defined GNULIB_POSIXCHECK
889 # if HAVE_RAW_DECL_FTRUNCATE
890 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
891 "use gnulib module ftruncate for portability");
897 /* Get the name of the current working directory, and put it in SIZE bytes
899 Return BUF if successful, or NULL if the directory couldn't be determined
900 or SIZE was too small.
901 See the POSIX:2008 specification
902 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
903 Additionally, the gnulib module 'getcwd' guarantees the following GNU
904 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
905 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
907 # if @REPLACE_GETCWD@
908 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
909 # define getcwd rpl_getcwd
911 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
912 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
913 # elif defined _WIN32 && !defined __CYGWIN__
914 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
916 # define getcwd _getcwd
918 _GL_CXXALIAS_MDA (getcwd
, char *, (char *buf
, size_t size
));
920 /* Need to cast, because on mingw, the second parameter is
922 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
924 _GL_CXXALIASWARN (getcwd
);
925 #elif defined GNULIB_POSIXCHECK
927 # if HAVE_RAW_DECL_GETCWD
928 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
929 "use gnulib module getcwd for portability");
932 /* On native Windows, map 'getcwd' to '_getcwd', so that -loldnames is not
933 required. In C++ with GNULIB_NAMESPACE, avoid differences between
934 platforms by defining GNULIB_NAMESPACE::getcwd always. */
935 # if defined _WIN32 && !defined __CYGWIN__
936 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
938 # define getcwd _getcwd
940 _GL_CXXALIAS_MDA (getcwd
, char *, (char *buf
, size_t size
));
942 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
944 _GL_CXXALIASWARN (getcwd
);
948 #if @GNULIB_GETDOMAINNAME@
949 /* Return the NIS domain name of the machine.
950 WARNING! The NIS domain name is unrelated to the fully qualified host name
951 of the machine. It is also unrelated to email addresses.
952 WARNING! The NIS domain name is usually the empty string or "(none)" when
955 Put up to LEN bytes of the NIS domain name into NAME.
956 Null terminate it if the name is shorter than LEN.
957 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
958 Return 0 if successful, otherwise set errno and return -1. */
959 # if @REPLACE_GETDOMAINNAME@
960 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
961 # undef getdomainname
962 # define getdomainname rpl_getdomainname
964 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
965 _GL_ARG_NONNULL ((1)));
966 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
968 # if !@HAVE_DECL_GETDOMAINNAME@
969 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
970 _GL_ARG_NONNULL ((1)));
972 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
974 _GL_CXXALIASWARN (getdomainname
);
975 #elif defined GNULIB_POSIXCHECK
976 # undef getdomainname
977 # if HAVE_RAW_DECL_GETDOMAINNAME
978 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
979 "use gnulib module getdomainname for portability");
984 #if @GNULIB_GETDTABLESIZE@
985 /* Return the maximum number of file descriptors in the current process.
986 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
987 # if @REPLACE_GETDTABLESIZE@
988 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
989 # undef getdtablesize
990 # define getdtablesize rpl_getdtablesize
992 _GL_FUNCDECL_RPL (getdtablesize
, int, (void));
993 _GL_CXXALIAS_RPL (getdtablesize
, int, (void));
995 # if !@HAVE_GETDTABLESIZE@
996 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
998 /* Need to cast, because on AIX, the parameter list is
1000 _GL_CXXALIAS_SYS_CAST (getdtablesize
, int, (void));
1002 _GL_CXXALIASWARN (getdtablesize
);
1003 #elif defined GNULIB_POSIXCHECK
1004 # undef getdtablesize
1005 # if HAVE_RAW_DECL_GETDTABLESIZE
1006 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
1007 "use gnulib module getdtablesize for portability");
1012 #if @GNULIB_GETENTROPY@
1013 /* Fill a buffer with random bytes. */
1014 # if !@HAVE_GETENTROPY@
1015 _GL_FUNCDECL_SYS (getentropy
, int, (void *buffer
, size_t length
));
1017 _GL_CXXALIAS_SYS (getentropy
, int, (void *buffer
, size_t length
));
1018 _GL_CXXALIASWARN (getentropy
);
1019 #elif defined GNULIB_POSIXCHECK
1021 # if HAVE_RAW_DECL_GETENTROPY
1022 _GL_WARN_ON_USE (getentropy
, "getentropy is unportable - "
1023 "use gnulib module getentropy for portability");
1028 #if @GNULIB_GETGROUPS@
1029 /* Return the supplemental groups that the current process belongs to.
1030 It is unspecified whether the effective group id is in the list.
1031 If N is 0, return the group count; otherwise, N describes how many
1032 entries are available in GROUPS. Return -1 and set errno if N is
1033 not 0 and not large enough. Fails with ENOSYS on some systems. */
1034 # if @REPLACE_GETGROUPS@
1035 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1037 # define getgroups rpl_getgroups
1039 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
1040 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
1042 # if !@HAVE_GETGROUPS@
1043 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
1045 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
1047 _GL_CXXALIASWARN (getgroups
);
1048 #elif defined GNULIB_POSIXCHECK
1050 # if HAVE_RAW_DECL_GETGROUPS
1051 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
1052 "use gnulib module getgroups for portability");
1057 #if @GNULIB_GETHOSTNAME@
1058 /* Return the standard host name of the machine.
1059 WARNING! The host name may or may not be fully qualified.
1061 Put up to LEN bytes of the host name into NAME.
1062 Null terminate it if the name is shorter than LEN.
1063 If the host name is longer than LEN, set errno = EINVAL and return -1.
1064 Return 0 if successful, otherwise set errno and return -1. */
1065 # if @UNISTD_H_HAVE_WINSOCK2_H@
1066 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1068 # define gethostname rpl_gethostname
1070 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
1071 _GL_ARG_NONNULL ((1)));
1072 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
1074 # if !@HAVE_GETHOSTNAME@
1075 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
1076 _GL_ARG_NONNULL ((1)));
1078 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
1081 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
1083 _GL_CXXALIASWARN (gethostname
);
1084 #elif @UNISTD_H_HAVE_WINSOCK2_H@
1086 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
1087 #elif defined GNULIB_POSIXCHECK
1089 # if HAVE_RAW_DECL_GETHOSTNAME
1090 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
1091 "use gnulib module gethostname for portability");
1096 #if @GNULIB_GETLOGIN@
1097 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
1098 returns NULL with errno set.
1100 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1102 Most programs don't need to use this function, because the information is
1103 available through environment variables:
1104 ${LOGNAME-$USER} on Unix platforms,
1105 $USERNAME on native Windows platforms.
1107 # if !@HAVE_DECL_GETLOGIN@
1108 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
1110 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
1111 _GL_CXXALIASWARN (getlogin
);
1112 #elif defined GNULIB_POSIXCHECK
1114 # if HAVE_RAW_DECL_GETLOGIN
1115 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
1116 "use gnulib module getlogin for portability");
1121 #if @GNULIB_GETLOGIN_R@
1122 /* Copies the user's login name to NAME.
1123 The array pointed to by NAME has room for SIZE bytes.
1125 Returns 0 if successful. Upon error, an error number is returned, or -1 in
1126 the case that the login name cannot be found but no specific error is
1127 provided (this case is hopefully rare but is left open by the POSIX spec).
1129 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1131 Most programs don't need to use this function, because the information is
1132 available through environment variables:
1133 ${LOGNAME-$USER} on Unix platforms,
1134 $USERNAME on native Windows platforms.
1136 # if @REPLACE_GETLOGIN_R@
1137 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1138 # define getlogin_r rpl_getlogin_r
1140 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
1141 _GL_ARG_NONNULL ((1)));
1142 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
1144 # if !@HAVE_DECL_GETLOGIN_R@
1145 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
1146 _GL_ARG_NONNULL ((1)));
1148 /* Need to cast, because on Solaris 10 systems, the second argument is
1150 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
1152 _GL_CXXALIASWARN (getlogin_r
);
1153 #elif defined GNULIB_POSIXCHECK
1155 # if HAVE_RAW_DECL_GETLOGIN_R
1156 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
1157 "use gnulib module getlogin_r for portability");
1162 #if @GNULIB_GETPAGESIZE@
1163 # if @REPLACE_GETPAGESIZE@
1164 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1165 # define getpagesize rpl_getpagesize
1167 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
1168 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
1170 /* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
1171 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */
1173 _GL_FUNCDECL_SYS (getpagesize
, int, (void));
1175 # if !@HAVE_GETPAGESIZE@
1176 # if !defined getpagesize
1177 /* This is for POSIX systems. */
1178 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
1179 # if ! (defined __VMS && __VMS_VER < 70000000)
1180 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
1183 /* This is for older VMS. */
1184 # if !defined _gl_getpagesize && defined __VMS
1186 # define _gl_getpagesize() 8192
1188 # define _gl_getpagesize() 512
1191 /* This is for BeOS. */
1192 # if !defined _gl_getpagesize && @HAVE_OS_H@
1194 # if defined B_PAGE_SIZE
1195 # define _gl_getpagesize() B_PAGE_SIZE
1198 /* This is for AmigaOS4.0. */
1199 # if !defined _gl_getpagesize && defined __amigaos4__
1200 # define _gl_getpagesize() 2048
1202 /* This is for older Unix systems. */
1203 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
1204 # include <sys/param.h>
1205 # ifdef EXEC_PAGESIZE
1206 # define _gl_getpagesize() EXEC_PAGESIZE
1212 # define _gl_getpagesize() (NBPG * CLSIZE)
1215 # define _gl_getpagesize() NBPC
1220 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1221 # define getpagesize() _gl_getpagesize ()
1223 # if !GNULIB_defined_getpagesize_function
1224 _GL_UNISTD_INLINE
int
1227 return _gl_getpagesize ();
1229 # define GNULIB_defined_getpagesize_function 1
1234 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
1235 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
1237 # if @HAVE_DECL_GETPAGESIZE@
1238 _GL_CXXALIASWARN (getpagesize
);
1240 #elif defined GNULIB_POSIXCHECK
1242 # if HAVE_RAW_DECL_GETPAGESIZE
1243 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
1244 "use gnulib module getpagesize for portability");
1249 #if @GNULIB_GETPASS@
1250 /* Function getpass() from module 'getpass':
1251 Read a password from /dev/tty or stdin.
1252 Function getpass() from module 'getpass-gnu':
1253 Read a password of arbitrary length from /dev/tty or stdin. */
1254 # if @REPLACE_GETPASS@
1255 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1257 # define getpass rpl_getpass
1259 _GL_FUNCDECL_RPL (getpass
, char *, (const char *prompt
)
1260 _GL_ARG_NONNULL ((1)));
1261 _GL_CXXALIAS_RPL (getpass
, char *, (const char *prompt
));
1263 # if !@HAVE_GETPASS@
1264 _GL_FUNCDECL_SYS (getpass
, char *, (const char *prompt
)
1265 _GL_ARG_NONNULL ((1)));
1267 _GL_CXXALIAS_SYS (getpass
, char *, (const char *prompt
));
1269 _GL_CXXALIASWARN (getpass
);
1270 #elif defined GNULIB_POSIXCHECK
1272 # if HAVE_RAW_DECL_GETPASS
1273 _GL_WARN_ON_USE (getpass
, "getpass is unportable - "
1274 "use gnulib module getpass or getpass-gnu for portability");
1279 /* On native Windows, map 'getpid' to '_getpid', so that -loldnames is not
1280 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1281 platforms by defining GNULIB_NAMESPACE::getpid always. */
1282 #if defined _WIN32 && !defined __CYGWIN__
1283 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1285 # define getpid _getpid
1287 _GL_CXXALIAS_MDA (getpid
, int, (void));
1289 _GL_CXXALIAS_SYS (getpid
, pid_t
, (void));
1291 _GL_CXXALIASWARN (getpid
);
1294 #if @GNULIB_GETUSERSHELL@
1295 /* Return the next valid login shell on the system, or NULL when the end of
1296 the list has been reached. */
1297 # if !@HAVE_DECL_GETUSERSHELL@
1298 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
1300 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
1301 _GL_CXXALIASWARN (getusershell
);
1302 #elif defined GNULIB_POSIXCHECK
1303 # undef getusershell
1304 # if HAVE_RAW_DECL_GETUSERSHELL
1305 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
1306 "use gnulib module getusershell for portability");
1310 #if @GNULIB_GETUSERSHELL@
1311 /* Rewind to pointer that is advanced at each getusershell() call. */
1312 # if !@HAVE_DECL_GETUSERSHELL@
1313 _GL_FUNCDECL_SYS (setusershell
, void, (void));
1315 _GL_CXXALIAS_SYS (setusershell
, void, (void));
1316 _GL_CXXALIASWARN (setusershell
);
1317 #elif defined GNULIB_POSIXCHECK
1318 # undef setusershell
1319 # if HAVE_RAW_DECL_SETUSERSHELL
1320 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
1321 "use gnulib module getusershell for portability");
1325 #if @GNULIB_GETUSERSHELL@
1326 /* Free the pointer that is advanced at each getusershell() call and
1327 associated resources. */
1328 # if !@HAVE_DECL_GETUSERSHELL@
1329 _GL_FUNCDECL_SYS (endusershell
, void, (void));
1331 _GL_CXXALIAS_SYS (endusershell
, void, (void));
1332 _GL_CXXALIASWARN (endusershell
);
1333 #elif defined GNULIB_POSIXCHECK
1334 # undef endusershell
1335 # if HAVE_RAW_DECL_ENDUSERSHELL
1336 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
1337 "use gnulib module getusershell for portability");
1342 #if @GNULIB_GROUP_MEMBER@
1343 /* Determine whether group id is in calling user's group list. */
1344 # if !@HAVE_GROUP_MEMBER@
1345 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
1347 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
1348 _GL_CXXALIASWARN (group_member
);
1349 #elif defined GNULIB_POSIXCHECK
1350 # undef group_member
1351 # if HAVE_RAW_DECL_GROUP_MEMBER
1352 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
1353 "use gnulib module group-member for portability");
1359 # if @REPLACE_ISATTY@
1360 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1362 # define isatty rpl_isatty
1364 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
1365 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
1366 # elif defined _WIN32 && !defined __CYGWIN__
1367 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1369 # define isatty _isatty
1371 _GL_CXXALIAS_MDA (isatty
, int, (int fd
));
1373 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
1375 _GL_CXXALIASWARN (isatty
);
1376 #elif defined GNULIB_POSIXCHECK
1378 # if HAVE_RAW_DECL_ISATTY
1379 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
1380 "use gnulib module isatty for portability");
1383 /* On native Windows, map 'isatty' to '_isatty', so that -loldnames is not
1384 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1385 platforms by defining GNULIB_NAMESPACE::isatty always. */
1386 # if defined _WIN32 && !defined __CYGWIN__
1387 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1389 # define isatty _isatty
1391 _GL_CXXALIAS_MDA (isatty
, int, (int fd
));
1393 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
1395 _GL_CXXALIASWARN (isatty
);
1400 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1401 to GID (if GID is not -1). Do not follow symbolic links.
1402 Return 0 if successful, otherwise -1 and errno set.
1403 See the POSIX:2008 specification
1404 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1405 # if @REPLACE_LCHOWN@
1406 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1408 # define lchown rpl_lchown
1410 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1411 _GL_ARG_NONNULL ((1)));
1412 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1415 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1416 _GL_ARG_NONNULL ((1)));
1418 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1420 _GL_CXXALIASWARN (lchown
);
1421 #elif defined GNULIB_POSIXCHECK
1423 # if HAVE_RAW_DECL_LCHOWN
1424 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1425 "use gnulib module lchown for portability");
1431 /* Create a new hard link for an existing file.
1432 Return 0 if successful, otherwise -1 and errno set.
1433 See POSIX:2008 specification
1434 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1436 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1437 # define link rpl_link
1439 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1440 _GL_ARG_NONNULL ((1, 2)));
1441 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1444 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1445 _GL_ARG_NONNULL ((1, 2)));
1447 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1449 _GL_CXXALIASWARN (link
);
1450 #elif defined GNULIB_POSIXCHECK
1452 # if HAVE_RAW_DECL_LINK
1453 _GL_WARN_ON_USE (link
, "link is unportable - "
1454 "use gnulib module link for portability");
1460 /* Create a new hard link for an existing file, relative to two
1461 directories. FLAG controls whether symlinks are followed.
1462 Return 0 if successful, otherwise -1 and errno set. */
1463 # if @REPLACE_LINKAT@
1464 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1466 # define linkat rpl_linkat
1468 _GL_FUNCDECL_RPL (linkat
, int,
1469 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1471 _GL_ARG_NONNULL ((2, 4)));
1472 _GL_CXXALIAS_RPL (linkat
, int,
1473 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1477 _GL_FUNCDECL_SYS (linkat
, int,
1478 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1480 _GL_ARG_NONNULL ((2, 4)));
1482 _GL_CXXALIAS_SYS (linkat
, int,
1483 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1486 _GL_CXXALIASWARN (linkat
);
1487 #elif defined GNULIB_POSIXCHECK
1489 # if HAVE_RAW_DECL_LINKAT
1490 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1491 "use gnulib module linkat for portability");
1497 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1498 Return the new offset if successful, otherwise -1 and errno set.
1499 See the POSIX:2008 specification
1500 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1501 # if @REPLACE_LSEEK@
1502 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1503 # define lseek rpl_lseek
1505 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1506 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1507 # elif defined _WIN32 && !defined __CYGWIN__
1508 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1510 # define lseek _lseek
1512 _GL_CXXALIAS_MDA (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1514 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1516 _GL_CXXALIASWARN (lseek
);
1517 #elif defined GNULIB_POSIXCHECK
1519 # if HAVE_RAW_DECL_LSEEK
1520 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1521 "systems - use gnulib module lseek for portability");
1524 /* On native Windows, map 'lseek' to '_lseek', so that -loldnames is not
1525 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1526 platforms by defining GNULIB_NAMESPACE::lseek always. */
1527 # if defined _WIN32 && !defined __CYGWIN__
1528 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1530 # define lseek _lseek
1532 _GL_CXXALIAS_MDA (lseek
, long, (int fd
, long offset
, int whence
));
1534 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1536 _GL_CXXALIASWARN (lseek
);
1541 /* Create a pipe, defaulting to O_BINARY mode.
1542 Store the read-end as fd[0] and the write-end as fd[1].
1543 Return 0 upon success, or -1 with errno set upon failure. */
1545 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1547 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1548 _GL_CXXALIASWARN (pipe
);
1549 #elif defined GNULIB_POSIXCHECK
1551 # if HAVE_RAW_DECL_PIPE
1552 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1553 "use gnulib module pipe-posix for portability");
1559 /* Create a pipe, applying the given flags when opening the read-end of the
1560 pipe and the write-end of the pipe.
1561 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1562 and O_TEXT, O_BINARY (defined in "binary-io.h").
1563 Store the read-end as fd[0] and the write-end as fd[1].
1564 Return 0 upon success, or -1 with errno set upon failure.
1565 See also the Linux man page at
1566 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1568 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1569 # define pipe2 rpl_pipe2
1571 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1572 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1574 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1575 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1577 _GL_CXXALIASWARN (pipe2
);
1578 #elif defined GNULIB_POSIXCHECK
1580 # if HAVE_RAW_DECL_PIPE2
1581 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1582 "use gnulib module pipe2 for portability");
1588 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1589 Return the number of bytes placed into BUF if successful, otherwise
1590 set errno and return -1. 0 indicates EOF.
1591 See the POSIX:2008 specification
1592 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1593 # if @REPLACE_PREAD@
1594 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1596 # define pread rpl_pread
1598 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1599 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1600 _GL_ARG_NONNULL ((2)));
1601 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1602 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1605 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1606 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1607 _GL_ARG_NONNULL ((2)));
1609 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1610 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1612 _GL_CXXALIASWARN (pread
);
1613 #elif defined GNULIB_POSIXCHECK
1615 # if HAVE_RAW_DECL_PREAD
1616 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1617 "use gnulib module pread for portability");
1623 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1624 Return the number of bytes written if successful, otherwise
1625 set errno and return -1. 0 indicates nothing written. See the
1626 POSIX:2008 specification
1627 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1628 # if @REPLACE_PWRITE@
1629 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1631 # define pwrite rpl_pwrite
1633 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1634 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1635 _GL_ARG_NONNULL ((2)));
1636 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1637 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1640 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1641 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1642 _GL_ARG_NONNULL ((2)));
1644 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1645 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1647 _GL_CXXALIASWARN (pwrite
);
1648 #elif defined GNULIB_POSIXCHECK
1650 # if HAVE_RAW_DECL_PWRITE
1651 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1652 "use gnulib module pwrite for portability");
1658 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1659 at BUF. See the POSIX:2008 specification
1660 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1662 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1664 # define read rpl_read
1666 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1667 _GL_ARG_NONNULL ((2)));
1668 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1669 # elif defined _WIN32 && !defined __CYGWIN__
1670 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1674 _GL_CXXALIAS_MDA (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1676 _GL_CXXALIAS_SYS (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1678 _GL_CXXALIASWARN (read
);
1680 /* On native Windows, map 'read' to '_read', so that -loldnames is not
1681 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1682 platforms by defining GNULIB_NAMESPACE::read always. */
1683 # if defined _WIN32 && !defined __CYGWIN__
1684 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1689 _GL_CXXALIAS_MDA (read
, int, (int fd
, void *buf
, unsigned int count
));
1691 _GL_CXXALIAS_MDA (read
, ssize_t
, (int fd
, void *buf
, unsigned int count
));
1694 _GL_CXXALIAS_SYS (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1696 _GL_CXXALIASWARN (read
);
1700 #if @GNULIB_READLINK@
1701 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1702 bytes of it into BUF. Return the number of bytes placed into BUF if
1703 successful, otherwise -1 and errno set.
1704 See the POSIX:2008 specification
1705 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1706 # if @REPLACE_READLINK@
1707 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1708 # define readlink rpl_readlink
1710 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1711 (const char *restrict file
,
1712 char *restrict buf
, size_t bufsize
)
1713 _GL_ARG_NONNULL ((1, 2)));
1714 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1715 (const char *restrict file
,
1716 char *restrict buf
, size_t bufsize
));
1718 # if !@HAVE_READLINK@
1719 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1720 (const char *restrict file
,
1721 char *restrict buf
, size_t bufsize
)
1722 _GL_ARG_NONNULL ((1, 2)));
1724 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1725 (const char *restrict file
,
1726 char *restrict buf
, size_t bufsize
));
1728 _GL_CXXALIASWARN (readlink
);
1729 #elif defined GNULIB_POSIXCHECK
1731 # if HAVE_RAW_DECL_READLINK
1732 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1733 "use gnulib module readlink for portability");
1738 #if @GNULIB_READLINKAT@
1739 # if @REPLACE_READLINKAT@
1740 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1741 # define readlinkat rpl_readlinkat
1743 _GL_FUNCDECL_RPL (readlinkat
, ssize_t
,
1744 (int fd
, char const *restrict file
,
1745 char *restrict buf
, size_t len
)
1746 _GL_ARG_NONNULL ((2, 3)));
1747 _GL_CXXALIAS_RPL (readlinkat
, ssize_t
,
1748 (int fd
, char const *restrict file
,
1749 char *restrict buf
, size_t len
));
1751 # if !@HAVE_READLINKAT@
1752 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1753 (int fd
, char const *restrict file
,
1754 char *restrict buf
, size_t len
)
1755 _GL_ARG_NONNULL ((2, 3)));
1757 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1758 (int fd
, char const *restrict file
,
1759 char *restrict buf
, size_t len
));
1761 _GL_CXXALIASWARN (readlinkat
);
1762 #elif defined GNULIB_POSIXCHECK
1764 # if HAVE_RAW_DECL_READLINKAT
1765 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1766 "use gnulib module readlinkat for portability");
1772 /* Remove the directory DIR. */
1773 # if @REPLACE_RMDIR@
1774 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1775 # define rmdir rpl_rmdir
1777 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1778 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1779 # elif defined _WIN32 && !defined __CYGWIN__
1780 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1782 # define rmdir _rmdir
1784 _GL_CXXALIAS_MDA (rmdir
, int, (char const *name
));
1786 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1788 _GL_CXXALIASWARN (rmdir
);
1789 #elif defined GNULIB_POSIXCHECK
1791 # if HAVE_RAW_DECL_RMDIR
1792 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1793 "use gnulib module rmdir for portability");
1796 /* On native Windows, map 'rmdir' to '_rmdir', so that -loldnames is not
1797 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1798 platforms by defining GNULIB_NAMESPACE::rmdir always. */
1799 # if defined _WIN32 && !defined __CYGWIN__
1800 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1802 # define rmdir _rmdir
1804 _GL_CXXALIAS_MDA (rmdir
, int, (char const *name
));
1806 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1808 _GL_CXXALIASWARN (rmdir
);
1812 #if @GNULIB_SETHOSTNAME@
1813 /* Set the host name of the machine.
1814 The host name may or may not be fully qualified.
1816 Put LEN bytes of NAME into the host name.
1817 Return 0 if successful, otherwise, set errno and return -1.
1819 Platforms with no ability to set the hostname return -1 and set
1821 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1822 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1823 _GL_ARG_NONNULL ((1)));
1825 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1826 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1827 2011-10, the first parameter is not const. */
1828 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1829 _GL_CXXALIASWARN (sethostname
);
1830 #elif defined GNULIB_POSIXCHECK
1832 # if HAVE_RAW_DECL_SETHOSTNAME
1833 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1834 "use gnulib module sethostname for portability");
1840 /* Pause the execution of the current thread for N seconds.
1841 Returns the number of seconds left to sleep.
1842 See the POSIX:2008 specification
1843 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1844 # if @REPLACE_SLEEP@
1845 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1847 # define sleep rpl_sleep
1849 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1850 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1853 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1855 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1857 _GL_CXXALIASWARN (sleep
);
1858 #elif defined GNULIB_POSIXCHECK
1860 # if HAVE_RAW_DECL_SLEEP
1861 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1862 "use gnulib module sleep for portability");
1867 /* On native Windows, map 'swab' to '_swab', so that -loldnames is not
1868 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1869 platforms by defining GNULIB_NAMESPACE::creat always. */
1870 #if defined _WIN32 && !defined __CYGWIN__
1871 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1875 _GL_CXXALIAS_MDA (swab
, void, (char *from
, char *to
, int n
));
1877 _GL_CXXALIAS_SYS (swab
, void, (const void *from
, void *to
, ssize_t n
));
1879 _GL_CXXALIASWARN (swab
);
1882 #if @GNULIB_SYMLINK@
1883 # if @REPLACE_SYMLINK@
1884 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1886 # define symlink rpl_symlink
1888 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1889 _GL_ARG_NONNULL ((1, 2)));
1890 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1892 # if !@HAVE_SYMLINK@
1893 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1894 _GL_ARG_NONNULL ((1, 2)));
1896 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1898 _GL_CXXALIASWARN (symlink
);
1899 #elif defined GNULIB_POSIXCHECK
1901 # if HAVE_RAW_DECL_SYMLINK
1902 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1903 "use gnulib module symlink for portability");
1908 #if @GNULIB_SYMLINKAT@
1909 # if @REPLACE_SYMLINKAT@
1910 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1912 # define symlinkat rpl_symlinkat
1914 _GL_FUNCDECL_RPL (symlinkat
, int,
1915 (char const *contents
, int fd
, char const *file
)
1916 _GL_ARG_NONNULL ((1, 3)));
1917 _GL_CXXALIAS_RPL (symlinkat
, int,
1918 (char const *contents
, int fd
, char const *file
));
1920 # if !@HAVE_SYMLINKAT@
1921 _GL_FUNCDECL_SYS (symlinkat
, int,
1922 (char const *contents
, int fd
, char const *file
)
1923 _GL_ARG_NONNULL ((1, 3)));
1925 _GL_CXXALIAS_SYS (symlinkat
, int,
1926 (char const *contents
, int fd
, char const *file
));
1928 _GL_CXXALIASWARN (symlinkat
);
1929 #elif defined GNULIB_POSIXCHECK
1931 # if HAVE_RAW_DECL_SYMLINKAT
1932 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1933 "use gnulib module symlinkat for portability");
1938 #if @GNULIB_TRUNCATE@
1939 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
1940 Return 0 if successful, otherwise -1 and errno set.
1941 See the POSIX:2008 specification
1942 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
1943 # if @REPLACE_TRUNCATE@
1944 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1946 # define truncate rpl_truncate
1948 _GL_FUNCDECL_RPL (truncate
, int, (const char *filename
, off_t length
)
1949 _GL_ARG_NONNULL ((1)));
1950 _GL_CXXALIAS_RPL (truncate
, int, (const char *filename
, off_t length
));
1952 # if !@HAVE_DECL_TRUNCATE@
1953 _GL_FUNCDECL_SYS (truncate
, int, (const char *filename
, off_t length
)
1954 _GL_ARG_NONNULL ((1)));
1956 _GL_CXXALIAS_SYS (truncate
, int, (const char *filename
, off_t length
));
1958 _GL_CXXALIASWARN (truncate
);
1959 #elif defined GNULIB_POSIXCHECK
1961 # if HAVE_RAW_DECL_TRUNCATE
1962 _GL_WARN_ON_USE (truncate
, "truncate is unportable - "
1963 "use gnulib module truncate for portability");
1968 #if @GNULIB_TTYNAME_R@
1969 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1970 open on in BUF. Return 0 on success, otherwise an error number. */
1971 # if @REPLACE_TTYNAME_R@
1972 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1974 # define ttyname_r rpl_ttyname_r
1976 _GL_FUNCDECL_RPL (ttyname_r
, int,
1977 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1978 _GL_CXXALIAS_RPL (ttyname_r
, int,
1979 (int fd
, char *buf
, size_t buflen
));
1981 # if !@HAVE_DECL_TTYNAME_R@
1982 _GL_FUNCDECL_SYS (ttyname_r
, int,
1983 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1985 _GL_CXXALIAS_SYS (ttyname_r
, int,
1986 (int fd
, char *buf
, size_t buflen
));
1988 _GL_CXXALIASWARN (ttyname_r
);
1989 #elif defined GNULIB_POSIXCHECK
1991 # if HAVE_RAW_DECL_TTYNAME_R
1992 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1993 "use gnulib module ttyname_r for portability");
1999 # if @REPLACE_UNLINK@
2000 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2002 # define unlink rpl_unlink
2004 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
2005 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
2006 # elif defined _WIN32 && !defined __CYGWIN__
2007 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2009 # define unlink _unlink
2011 _GL_CXXALIAS_MDA (unlink
, int, (char const *file
));
2013 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
2015 _GL_CXXALIASWARN (unlink
);
2016 #elif defined GNULIB_POSIXCHECK
2018 # if HAVE_RAW_DECL_UNLINK
2019 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
2020 "use gnulib module unlink for portability");
2023 /* On native Windows, map 'unlink' to '_unlink', so that -loldnames is not
2024 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2025 platforms by defining GNULIB_NAMESPACE::unlink always. */
2026 # if defined _WIN32 && !defined __CYGWIN__
2027 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2029 # define unlink _unlink
2031 _GL_CXXALIAS_MDA (unlink
, int, (char const *file
));
2033 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
2035 _GL_CXXALIASWARN (unlink
);
2039 #if @GNULIB_UNLINKAT@
2040 # if @REPLACE_UNLINKAT@
2041 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2043 # define unlinkat rpl_unlinkat
2045 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
2046 _GL_ARG_NONNULL ((2)));
2047 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
2049 # if !@HAVE_UNLINKAT@
2050 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
2051 _GL_ARG_NONNULL ((2)));
2053 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
2055 _GL_CXXALIASWARN (unlinkat
);
2056 #elif defined GNULIB_POSIXCHECK
2058 # if HAVE_RAW_DECL_UNLINKAT
2059 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
2060 "use gnulib module openat for portability");
2066 /* Pause the execution of the current thread for N microseconds.
2067 Returns 0 on completion, or -1 on range error.
2068 See the POSIX:2001 specification
2069 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
2070 # if @REPLACE_USLEEP@
2071 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2073 # define usleep rpl_usleep
2075 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
2076 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
2079 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
2081 /* Need to cast, because on Haiku, the first parameter is
2083 _GL_CXXALIAS_SYS_CAST (usleep
, int, (useconds_t n
));
2085 _GL_CXXALIASWARN (usleep
);
2086 #elif defined GNULIB_POSIXCHECK
2088 # if HAVE_RAW_DECL_USLEEP
2089 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
2090 "use gnulib module usleep for portability");
2096 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
2097 See the POSIX:2008 specification
2098 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
2099 # if @REPLACE_WRITE@
2100 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2102 # define write rpl_write
2104 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
2105 _GL_ARG_NONNULL ((2)));
2106 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2107 # elif defined _WIN32 && !defined __CYGWIN__
2108 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2110 # define write _write
2112 _GL_CXXALIAS_MDA (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2114 _GL_CXXALIAS_SYS (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2116 _GL_CXXALIASWARN (write
);
2118 /* On native Windows, map 'write' to '_write', so that -loldnames is not
2119 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2120 platforms by defining GNULIB_NAMESPACE::write always. */
2121 # if defined _WIN32 && !defined __CYGWIN__
2122 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2124 # define write _write
2127 _GL_CXXALIAS_MDA (write
, int, (int fd
, const void *buf
, unsigned int count
));
2129 _GL_CXXALIAS_MDA (write
, ssize_t
, (int fd
, const void *buf
, unsigned int count
));
2132 _GL_CXXALIAS_SYS (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2134 _GL_CXXALIASWARN (write
);
2137 _GL_INLINE_HEADER_END
2139 #endif /* _@GUARD_PREFIX@_UNISTD_H */
2140 #endif /* _GL_INCLUDING_UNISTD_H */
2141 #endif /* _@GUARD_PREFIX@_UNISTD_H */