1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2013 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 3, 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 <http://www.gnu.org/licenses/>. */
17 #ifndef _@GUARD_PREFIX@_UNISTD_H
20 @PRAGMA_SYSTEM_HEADER@
24 /* The include_next requires a split double-inclusion guard. */
26 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
29 /* Get all possible declarations of gethostname(). */
30 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
31 && !defined _GL_INCLUDING_WINSOCK2_H
32 # define _GL_INCLUDING_WINSOCK2_H
33 # include <winsock2.h>
34 # undef _GL_INCLUDING_WINSOCK2_H
37 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
38 #define _@GUARD_PREFIX@_UNISTD_H
40 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
43 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
44 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
45 /* But avoid namespace pollution on glibc systems. */
46 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
47 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
48 && defined __CYGWIN__)) \
49 && ! defined __GLIBC__
53 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
54 /* But avoid namespace pollution on glibc systems. */
55 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
56 && ! defined __GLIBC__
60 /* mingw fails to declare _exit in <unistd.h>. */
61 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
63 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
64 /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
66 /* But avoid namespace pollution on glibc systems. */
67 #if !defined __GLIBC__ && !defined __osf__
68 # define __need_system_stdlib_h
70 # undef __need_system_stdlib_h
73 /* Native Windows platforms declare chdir, getcwd, rmdir in
74 <io.h> and/or <direct.h>, not in <unistd.h>.
75 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
76 lseek(), read(), unlink(), write() in <io.h>. */
77 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
78 || defined GNULIB_POSIXCHECK) \
79 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
80 # include <io.h> /* mingw32, mingw64 */
81 # include <direct.h> /* mingw64, MSVC 9 */
82 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
83 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
84 || defined GNULIB_POSIXCHECK) \
85 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
89 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
90 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
91 /* But avoid namespace pollution on glibc systems. */
92 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
93 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
98 /* MSVC defines off_t in <sys/types.h>.
99 May also define off_t to a 64-bit type on native Windows. */
100 #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
102 # include <sys/types.h>
105 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
106 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
107 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
109 # include <sys/types.h>
112 /* Get getopt(), optarg, optind, opterr, optopt.
113 But avoid namespace pollution on glibc systems. */
114 /* Also, don't include <getopt.h> inside libgettextpo, because we use
115 the getopt module only in gettext-tools/gnulib-lib/, not in
116 gettext-tools/libgettextpo/, but there is only a single
117 GNULIB_UNISTD_H_GETOPT variable for both. */
118 #if @GNULIB_UNISTD_H_GETOPT@ && !defined GTPO_CONFIG_H && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
119 # define __need_getopt
123 _GL_INLINE_HEADER_BEGIN
124 #ifndef _GL_UNISTD_INLINE
125 # define _GL_UNISTD_INLINE _GL_INLINE
128 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
130 /* The definition of _GL_ARG_NONNULL is copied here. */
132 /* The definition of _GL_WARN_ON_USE is copied here. */
135 /* Hide some function declarations from <winsock2.h>. */
137 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
138 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
139 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
141 # define socket socket_used_without_including_sys_socket_h
143 # define connect connect_used_without_including_sys_socket_h
145 # define accept accept_used_without_including_sys_socket_h
147 # define bind bind_used_without_including_sys_socket_h
149 # define getpeername getpeername_used_without_including_sys_socket_h
151 # define getsockname getsockname_used_without_including_sys_socket_h
153 # define getsockopt getsockopt_used_without_including_sys_socket_h
155 # define listen listen_used_without_including_sys_socket_h
157 # define recv recv_used_without_including_sys_socket_h
159 # define send send_used_without_including_sys_socket_h
161 # define recvfrom recvfrom_used_without_including_sys_socket_h
163 # define sendto sendto_used_without_including_sys_socket_h
165 # define setsockopt setsockopt_used_without_including_sys_socket_h
167 # define shutdown shutdown_used_without_including_sys_socket_h
169 _GL_WARN_ON_USE (socket,
170 "socket() used without including <sys/socket.h>");
171 _GL_WARN_ON_USE (connect,
172 "connect() used without including <sys/socket.h>");
173 _GL_WARN_ON_USE (accept,
174 "accept() used without including <sys/socket.h>");
175 _GL_WARN_ON_USE (bind,
176 "bind() used without including <sys/socket.h>");
177 _GL_WARN_ON_USE (getpeername,
178 "getpeername() used without including <sys/socket.h>");
179 _GL_WARN_ON_USE (getsockname,
180 "getsockname() used without including <sys/socket.h>");
181 _GL_WARN_ON_USE (getsockopt,
182 "getsockopt() used without including <sys/socket.h>");
183 _GL_WARN_ON_USE (listen,
184 "listen() used without including <sys/socket.h>");
185 _GL_WARN_ON_USE (recv,
186 "recv() used without including <sys/socket.h>");
187 _GL_WARN_ON_USE (send,
188 "send() used without including <sys/socket.h>");
189 _GL_WARN_ON_USE (recvfrom,
190 "recvfrom() used without including <sys/socket.h>");
191 _GL_WARN_ON_USE (sendto,
192 "sendto() used without including <sys/socket.h>");
193 _GL_WARN_ON_USE (setsockopt,
194 "setsockopt() used without including <sys/socket.h>");
195 _GL_WARN_ON_USE (shutdown,
196 "shutdown() used without including <sys/socket.h>");
199 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
200 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
202 # define select select_used_without_including_sys_select_h
204 _GL_WARN_ON_USE (select,
205 "select() used without including <sys/select.h>");
211 /* OS/2 EMX lacks these macros. */
213 # define STDIN_FILENO 0
215 #ifndef STDOUT_FILENO
216 # define STDOUT_FILENO 1
218 #ifndef STDERR_FILENO
219 # define STDERR_FILENO 2
222 /* Ensure *_OK macros exist. */
231 /* Declare overridden functions. */
234 #if defined GNULIB_POSIXCHECK
235 /* The access() function is a security risk. */
236 _GL_WARN_ON_USE (access, "the access function is a security risk - "
237 "use the gnulib module faccessat instead");
242 _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
243 _GL_CXXALIASWARN (chdir);
244 #elif defined GNULIB_POSIXCHECK
246 # if HAVE_RAW_DECL_CHDIR
247 _GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
248 "use gnulib module chdir for portability");
254 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
255 to GID (if GID is not -1). Follow symbolic links.
256 Return 0 if successful, otherwise -1 and errno set.
257 See the POSIX:2008 specification
258 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
260 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
262 # define chown rpl_chown
264 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
265 _GL_ARG_NONNULL ((1)));
266 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
269 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
270 _GL_ARG_NONNULL ((1)));
272 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
274 _GL_CXXALIASWARN (chown);
275 #elif defined GNULIB_POSIXCHECK
277 # if HAVE_RAW_DECL_CHOWN
278 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
279 "doesn't treat a uid or gid of -1 on some systems - "
280 "use gnulib module chown for portability");
287 /* Automatically included by modules that need a replacement for close. */
288 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
290 # define close rpl_close
292 _GL_FUNCDECL_RPL (close, int, (int fd));
293 _GL_CXXALIAS_RPL (close, int, (int fd));
295 _GL_CXXALIAS_SYS (close, int, (int fd));
297 _GL_CXXALIASWARN (close);
298 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
300 # define close close_used_without_requesting_gnulib_module_close
301 #elif defined GNULIB_POSIXCHECK
303 /* Assume close is always declared. */
304 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
305 "use gnulib module close for portability");
311 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
314 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
315 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
317 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
319 _GL_CXXALIASWARN (dup);
320 #elif defined GNULIB_POSIXCHECK
322 # if HAVE_RAW_DECL_DUP
323 _GL_WARN_ON_USE (dup, "dup is unportable - "
324 "use gnulib module dup for portability");
330 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
331 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
332 Return newfd if successful, otherwise -1 and errno set.
333 See the POSIX:2008 specification
334 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
336 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
337 # define dup2 rpl_dup2
339 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
340 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
343 _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
345 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
347 _GL_CXXALIASWARN (dup2);
348 #elif defined GNULIB_POSIXCHECK
350 # if HAVE_RAW_DECL_DUP2
351 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
352 "use gnulib module dup2 for portability");
358 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
360 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
361 and O_TEXT, O_BINARY (defined in "binary-io.h").
362 Close NEWFD first if it is open.
363 Return newfd if successful, otherwise -1 and errno set.
364 See the Linux man page at
365 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
367 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
368 # define dup3 rpl_dup3
370 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
371 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
373 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
374 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
376 _GL_CXXALIASWARN (dup3);
377 #elif defined GNULIB_POSIXCHECK
379 # if HAVE_RAW_DECL_DUP3
380 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
381 "use gnulib module dup3 for portability");
387 # if !@HAVE_DECL_ENVIRON@
388 /* Set of environment variables and values. An array of strings of the form
389 "VARIABLE=VALUE", terminated with a NULL. */
390 # if defined __APPLE__ && defined __MACH__
391 # include <crt_externs.h>
392 # define environ (*_NSGetEnviron ())
397 extern char **environ;
403 #elif defined GNULIB_POSIXCHECK
404 # if HAVE_RAW_DECL_ENVIRON
405 _GL_UNISTD_INLINE char ***
410 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
411 "use gnulib module environ for portability");
413 # define environ (*rpl_environ ())
418 #if @GNULIB_EUIDACCESS@
419 /* Like access(), except that it uses the effective user id and group id of
420 the current process. */
421 # if !@HAVE_EUIDACCESS@
422 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
423 _GL_ARG_NONNULL ((1)));
425 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
426 _GL_CXXALIASWARN (euidaccess);
427 # if defined GNULIB_POSIXCHECK
428 /* Like access(), this function is a security risk. */
429 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
430 "use the gnulib module faccessat instead");
432 #elif defined GNULIB_POSIXCHECK
434 # if HAVE_RAW_DECL_EUIDACCESS
435 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
436 "use gnulib module euidaccess for portability");
441 #if @GNULIB_FACCESSAT@
442 # if !@HAVE_FACCESSAT@
443 _GL_FUNCDECL_SYS (faccessat, int,
444 (int fd, char const *file, int mode, int flag)
445 _GL_ARG_NONNULL ((2)));
447 _GL_CXXALIAS_SYS (faccessat, int,
448 (int fd, char const *file, int mode, int flag));
449 _GL_CXXALIASWARN (faccessat);
450 #elif defined GNULIB_POSIXCHECK
452 # if HAVE_RAW_DECL_FACCESSAT
453 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
454 "use gnulib module faccessat for portability");
460 /* Change the process' current working directory to the directory on which
461 the given file descriptor is open.
462 Return 0 if successful, otherwise -1 and errno set.
463 See the POSIX:2008 specification
464 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
466 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
468 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
469 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
470 _GL_ARG_NONNULL ((2));
471 _GL_EXTERN_C void _gl_unregister_fd (int fd);
472 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
473 _GL_EXTERN_C const char *_gl_directory_name (int fd);
476 # if !@HAVE_DECL_FCHDIR@
477 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
480 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
481 _GL_CXXALIASWARN (fchdir);
482 #elif defined GNULIB_POSIXCHECK
484 # if HAVE_RAW_DECL_FCHDIR
485 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
486 "use gnulib module fchdir for portability");
491 #if @GNULIB_FCHOWNAT@
492 # if @REPLACE_FCHOWNAT@
493 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
495 # define fchownat rpl_fchownat
497 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
498 uid_t owner, gid_t group, int flag)
499 _GL_ARG_NONNULL ((2)));
500 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
501 uid_t owner, gid_t group, int flag));
503 # if !@HAVE_FCHOWNAT@
504 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
505 uid_t owner, gid_t group, int flag)
506 _GL_ARG_NONNULL ((2)));
508 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
509 uid_t owner, gid_t group, int flag));
511 _GL_CXXALIASWARN (fchownat);
512 #elif defined GNULIB_POSIXCHECK
514 # if HAVE_RAW_DECL_FCHOWNAT
515 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
516 "use gnulib module openat for portability");
521 #if @GNULIB_FDATASYNC@
522 /* Synchronize changes to a file.
523 Return 0 if successful, otherwise -1 and errno set.
524 See POSIX:2008 specification
525 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
526 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
527 _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
529 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
530 _GL_CXXALIASWARN (fdatasync);
531 #elif defined GNULIB_POSIXCHECK
533 # if HAVE_RAW_DECL_FDATASYNC
534 _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
535 "use gnulib module fdatasync for portability");
541 /* Synchronize changes, including metadata, to a file.
542 Return 0 if successful, otherwise -1 and errno set.
543 See POSIX:2008 specification
544 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
546 _GL_FUNCDECL_SYS (fsync, int, (int fd));
548 _GL_CXXALIAS_SYS (fsync, int, (int fd));
549 _GL_CXXALIASWARN (fsync);
550 #elif defined GNULIB_POSIXCHECK
552 # if HAVE_RAW_DECL_FSYNC
553 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
554 "use gnulib module fsync for portability");
559 #if @GNULIB_FTRUNCATE@
560 /* Change the size of the file to which FD is opened to become equal to LENGTH.
561 Return 0 if successful, otherwise -1 and errno set.
562 See the POSIX:2008 specification
563 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
564 # if @REPLACE_FTRUNCATE@
565 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
567 # define ftruncate rpl_ftruncate
569 _GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
570 _GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
572 # if !@HAVE_FTRUNCATE@
573 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
575 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
577 _GL_CXXALIASWARN (ftruncate);
578 #elif defined GNULIB_POSIXCHECK
580 # if HAVE_RAW_DECL_FTRUNCATE
581 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
582 "use gnulib module ftruncate for portability");
588 /* Get the name of the current working directory, and put it in SIZE bytes
590 Return BUF if successful, or NULL if the directory couldn't be determined
591 or SIZE was too small.
592 See the POSIX:2008 specification
593 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
594 Additionally, the gnulib module 'getcwd' guarantees the following GNU
595 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
596 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
598 # if @REPLACE_GETCWD@
599 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
600 # define getcwd rpl_getcwd
602 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
603 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
605 /* Need to cast, because on mingw, the second parameter is
607 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
609 _GL_CXXALIASWARN (getcwd);
610 #elif defined GNULIB_POSIXCHECK
612 # if HAVE_RAW_DECL_GETCWD
613 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
614 "use gnulib module getcwd for portability");
619 #if @GNULIB_GETDOMAINNAME@
620 /* Return the NIS domain name of the machine.
621 WARNING! The NIS domain name is unrelated to the fully qualified host name
622 of the machine. It is also unrelated to email addresses.
623 WARNING! The NIS domain name is usually the empty string or "(none)" when
626 Put up to LEN bytes of the NIS domain name into NAME.
627 Null terminate it if the name is shorter than LEN.
628 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
629 Return 0 if successful, otherwise set errno and return -1. */
630 # if @REPLACE_GETDOMAINNAME@
631 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
632 # undef getdomainname
633 # define getdomainname rpl_getdomainname
635 _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
636 _GL_ARG_NONNULL ((1)));
637 _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
639 # if !@HAVE_DECL_GETDOMAINNAME@
640 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
641 _GL_ARG_NONNULL ((1)));
643 _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
645 _GL_CXXALIASWARN (getdomainname);
646 #elif defined GNULIB_POSIXCHECK
647 # undef getdomainname
648 # if HAVE_RAW_DECL_GETDOMAINNAME
649 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
650 "use gnulib module getdomainname for portability");
655 #if @GNULIB_GETDTABLESIZE@
656 /* Return the maximum number of file descriptors in the current process.
657 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
658 # if !@HAVE_GETDTABLESIZE@
659 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
661 _GL_CXXALIAS_SYS (getdtablesize, int, (void));
662 _GL_CXXALIASWARN (getdtablesize);
663 #elif defined GNULIB_POSIXCHECK
664 # undef getdtablesize
665 # if HAVE_RAW_DECL_GETDTABLESIZE
666 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
667 "use gnulib module getdtablesize for portability");
672 #if @GNULIB_GETGROUPS@
673 /* Return the supplemental groups that the current process belongs to.
674 It is unspecified whether the effective group id is in the list.
675 If N is 0, return the group count; otherwise, N describes how many
676 entries are available in GROUPS. Return -1 and set errno if N is
677 not 0 and not large enough. Fails with ENOSYS on some systems. */
678 # if @REPLACE_GETGROUPS@
679 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
681 # define getgroups rpl_getgroups
683 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
684 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
686 # if !@HAVE_GETGROUPS@
687 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
689 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
691 _GL_CXXALIASWARN (getgroups);
692 #elif defined GNULIB_POSIXCHECK
694 # if HAVE_RAW_DECL_GETGROUPS
695 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
696 "use gnulib module getgroups for portability");
701 #if @GNULIB_GETHOSTNAME@
702 /* Return the standard host name of the machine.
703 WARNING! The host name may or may not be fully qualified.
705 Put up to LEN bytes of the host name into NAME.
706 Null terminate it if the name is shorter than LEN.
707 If the host name is longer than LEN, set errno = EINVAL and return -1.
708 Return 0 if successful, otherwise set errno and return -1. */
709 # if @UNISTD_H_HAVE_WINSOCK2_H@
710 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
712 # define gethostname rpl_gethostname
714 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
715 _GL_ARG_NONNULL ((1)));
716 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
718 # if !@HAVE_GETHOSTNAME@
719 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
720 _GL_ARG_NONNULL ((1)));
722 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
725 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
727 _GL_CXXALIASWARN (gethostname);
728 #elif @UNISTD_H_HAVE_WINSOCK2_H@
730 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
731 #elif defined GNULIB_POSIXCHECK
733 # if HAVE_RAW_DECL_GETHOSTNAME
734 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
735 "use gnulib module gethostname for portability");
740 #if @GNULIB_GETLOGIN@
741 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
742 returns NULL with errno set.
744 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
746 Most programs don't need to use this function, because the information is
747 available through environment variables:
748 ${LOGNAME-$USER} on Unix platforms,
749 $USERNAME on native Windows platforms.
751 # if !@HAVE_GETLOGIN@
752 _GL_FUNCDECL_SYS (getlogin, char *, (void));
754 _GL_CXXALIAS_SYS (getlogin, char *, (void));
755 _GL_CXXALIASWARN (getlogin);
756 #elif defined GNULIB_POSIXCHECK
758 # if HAVE_RAW_DECL_GETLOGIN
759 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
760 "use gnulib module getlogin for portability");
765 #if @GNULIB_GETLOGIN_R@
766 /* Copies the user's login name to NAME.
767 The array pointed to by NAME has room for SIZE bytes.
769 Returns 0 if successful. Upon error, an error number is returned, or -1 in
770 the case that the login name cannot be found but no specific error is
771 provided (this case is hopefully rare but is left open by the POSIX spec).
773 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
775 Most programs don't need to use this function, because the information is
776 available through environment variables:
777 ${LOGNAME-$USER} on Unix platforms,
778 $USERNAME on native Windows platforms.
780 # if @REPLACE_GETLOGIN_R@
781 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
782 # define getlogin_r rpl_getlogin_r
784 _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
785 _GL_ARG_NONNULL ((1)));
786 _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
788 # if !@HAVE_DECL_GETLOGIN_R@
789 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
790 _GL_ARG_NONNULL ((1)));
792 /* Need to cast, because on Solaris 10 systems, the second argument is
794 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
796 _GL_CXXALIASWARN (getlogin_r);
797 #elif defined GNULIB_POSIXCHECK
799 # if HAVE_RAW_DECL_GETLOGIN_R
800 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
801 "use gnulib module getlogin_r for portability");
806 #if @GNULIB_GETPAGESIZE@
807 # if @REPLACE_GETPAGESIZE@
808 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
809 # define getpagesize rpl_getpagesize
811 _GL_FUNCDECL_RPL (getpagesize, int, (void));
812 _GL_CXXALIAS_RPL (getpagesize, int, (void));
814 # if !@HAVE_GETPAGESIZE@
815 # if !defined getpagesize
816 /* This is for POSIX systems. */
817 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
818 # if ! (defined __VMS && __VMS_VER < 70000000)
819 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
822 /* This is for older VMS. */
823 # if !defined _gl_getpagesize && defined __VMS
825 # define _gl_getpagesize() 8192
827 # define _gl_getpagesize() 512
830 /* This is for BeOS. */
831 # if !defined _gl_getpagesize && @HAVE_OS_H@
833 # if defined B_PAGE_SIZE
834 # define _gl_getpagesize() B_PAGE_SIZE
837 /* This is for AmigaOS4.0. */
838 # if !defined _gl_getpagesize && defined __amigaos4__
839 # define _gl_getpagesize() 2048
841 /* This is for older Unix systems. */
842 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
843 # include <sys/param.h>
844 # ifdef EXEC_PAGESIZE
845 # define _gl_getpagesize() EXEC_PAGESIZE
851 # define _gl_getpagesize() (NBPG * CLSIZE)
854 # define _gl_getpagesize() NBPC
859 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
860 # define getpagesize() _gl_getpagesize ()
862 # if !GNULIB_defined_getpagesize_function
863 _GL_UNISTD_INLINE int
866 return _gl_getpagesize ();
868 # define GNULIB_defined_getpagesize_function 1
873 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
874 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
876 # if @HAVE_DECL_GETPAGESIZE@
877 _GL_CXXALIASWARN (getpagesize);
879 #elif defined GNULIB_POSIXCHECK
881 # if HAVE_RAW_DECL_GETPAGESIZE
882 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
883 "use gnulib module getpagesize for portability");
888 #if @GNULIB_GETUSERSHELL@
889 /* Return the next valid login shell on the system, or NULL when the end of
890 the list has been reached. */
891 # if !@HAVE_DECL_GETUSERSHELL@
892 _GL_FUNCDECL_SYS (getusershell, char *, (void));
894 _GL_CXXALIAS_SYS (getusershell, char *, (void));
895 _GL_CXXALIASWARN (getusershell);
896 #elif defined GNULIB_POSIXCHECK
898 # if HAVE_RAW_DECL_GETUSERSHELL
899 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
900 "use gnulib module getusershell for portability");
904 #if @GNULIB_GETUSERSHELL@
905 /* Rewind to pointer that is advanced at each getusershell() call. */
906 # if !@HAVE_DECL_GETUSERSHELL@
907 _GL_FUNCDECL_SYS (setusershell, void, (void));
909 _GL_CXXALIAS_SYS (setusershell, void, (void));
910 _GL_CXXALIASWARN (setusershell);
911 #elif defined GNULIB_POSIXCHECK
913 # if HAVE_RAW_DECL_SETUSERSHELL
914 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
915 "use gnulib module getusershell for portability");
919 #if @GNULIB_GETUSERSHELL@
920 /* Free the pointer that is advanced at each getusershell() call and
921 associated resources. */
922 # if !@HAVE_DECL_GETUSERSHELL@
923 _GL_FUNCDECL_SYS (endusershell, void, (void));
925 _GL_CXXALIAS_SYS (endusershell, void, (void));
926 _GL_CXXALIASWARN (endusershell);
927 #elif defined GNULIB_POSIXCHECK
929 # if HAVE_RAW_DECL_ENDUSERSHELL
930 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
931 "use gnulib module getusershell for portability");
936 #if @GNULIB_GROUP_MEMBER@
937 /* Determine whether group id is in calling user's group list. */
938 # if !@HAVE_GROUP_MEMBER@
939 _GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
941 _GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
942 _GL_CXXALIASWARN (group_member);
943 #elif defined GNULIB_POSIXCHECK
945 # if HAVE_RAW_DECL_GROUP_MEMBER
946 _GL_WARN_ON_USE (group_member, "group_member is unportable - "
947 "use gnulib module group-member for portability");
953 # if @REPLACE_ISATTY@
954 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
956 # define isatty rpl_isatty
958 _GL_FUNCDECL_RPL (isatty, int, (int fd));
959 _GL_CXXALIAS_RPL (isatty, int, (int fd));
961 _GL_CXXALIAS_SYS (isatty, int, (int fd));
963 _GL_CXXALIASWARN (isatty);
964 #elif defined GNULIB_POSIXCHECK
966 # if HAVE_RAW_DECL_ISATTY
967 _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
968 "use gnulib module isatty for portability");
974 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
975 to GID (if GID is not -1). Do not follow symbolic links.
976 Return 0 if successful, otherwise -1 and errno set.
977 See the POSIX:2008 specification
978 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
979 # if @REPLACE_LCHOWN@
980 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
982 # define lchown rpl_lchown
984 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
985 _GL_ARG_NONNULL ((1)));
986 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
989 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
990 _GL_ARG_NONNULL ((1)));
992 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
994 _GL_CXXALIASWARN (lchown);
995 #elif defined GNULIB_POSIXCHECK
997 # if HAVE_RAW_DECL_LCHOWN
998 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
999 "use gnulib module lchown for portability");
1005 /* Create a new hard link for an existing file.
1006 Return 0 if successful, otherwise -1 and errno set.
1007 See POSIX:2008 specification
1008 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1010 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1011 # define link rpl_link
1013 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
1014 _GL_ARG_NONNULL ((1, 2)));
1015 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
1018 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
1019 _GL_ARG_NONNULL ((1, 2)));
1021 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
1023 _GL_CXXALIASWARN (link);
1024 #elif defined GNULIB_POSIXCHECK
1026 # if HAVE_RAW_DECL_LINK
1027 _GL_WARN_ON_USE (link, "link is unportable - "
1028 "use gnulib module link for portability");
1034 /* Create a new hard link for an existing file, relative to two
1035 directories. FLAG controls whether symlinks are followed.
1036 Return 0 if successful, otherwise -1 and errno set. */
1037 # if @REPLACE_LINKAT@
1038 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1040 # define linkat rpl_linkat
1042 _GL_FUNCDECL_RPL (linkat, int,
1043 (int fd1, const char *path1, int fd2, const char *path2,
1045 _GL_ARG_NONNULL ((2, 4)));
1046 _GL_CXXALIAS_RPL (linkat, int,
1047 (int fd1, const char *path1, int fd2, const char *path2,
1051 _GL_FUNCDECL_SYS (linkat, int,
1052 (int fd1, const char *path1, int fd2, const char *path2,
1054 _GL_ARG_NONNULL ((2, 4)));
1056 _GL_CXXALIAS_SYS (linkat, int,
1057 (int fd1, const char *path1, int fd2, const char *path2,
1060 _GL_CXXALIASWARN (linkat);
1061 #elif defined GNULIB_POSIXCHECK
1063 # if HAVE_RAW_DECL_LINKAT
1064 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1065 "use gnulib module linkat for portability");
1071 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1072 Return the new offset if successful, otherwise -1 and errno set.
1073 See the POSIX:2008 specification
1074 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1075 # if @REPLACE_LSEEK@
1076 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1077 # define lseek rpl_lseek
1079 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1080 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1082 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1084 _GL_CXXALIASWARN (lseek);
1085 #elif defined GNULIB_POSIXCHECK
1087 # if HAVE_RAW_DECL_LSEEK
1088 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1089 "systems - use gnulib module lseek for portability");
1095 /* Create a pipe, defaulting to O_BINARY mode.
1096 Store the read-end as fd[0] and the write-end as fd[1].
1097 Return 0 upon success, or -1 with errno set upon failure. */
1099 _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1101 _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1102 _GL_CXXALIASWARN (pipe);
1103 #elif defined GNULIB_POSIXCHECK
1105 # if HAVE_RAW_DECL_PIPE
1106 _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1107 "use gnulib module pipe-posix for portability");
1113 /* Create a pipe, applying the given flags when opening the read-end of the
1114 pipe and the write-end of the pipe.
1115 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1116 and O_TEXT, O_BINARY (defined in "binary-io.h").
1117 Store the read-end as fd[0] and the write-end as fd[1].
1118 Return 0 upon success, or -1 with errno set upon failure.
1119 See also the Linux man page at
1120 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1122 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1123 # define pipe2 rpl_pipe2
1125 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1126 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1128 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1129 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1131 _GL_CXXALIASWARN (pipe2);
1132 #elif defined GNULIB_POSIXCHECK
1134 # if HAVE_RAW_DECL_PIPE2
1135 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1136 "use gnulib module pipe2 for portability");
1142 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1143 Return the number of bytes placed into BUF if successful, otherwise
1144 set errno and return -1. 0 indicates EOF.
1145 See the POSIX:2008 specification
1146 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1147 # if @REPLACE_PREAD@
1148 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1150 # define pread rpl_pread
1152 _GL_FUNCDECL_RPL (pread, ssize_t,
1153 (int fd, void *buf, size_t bufsize, off_t offset)
1154 _GL_ARG_NONNULL ((2)));
1155 _GL_CXXALIAS_RPL (pread, ssize_t,
1156 (int fd, void *buf, size_t bufsize, off_t offset));
1159 _GL_FUNCDECL_SYS (pread, ssize_t,
1160 (int fd, void *buf, size_t bufsize, off_t offset)
1161 _GL_ARG_NONNULL ((2)));
1163 _GL_CXXALIAS_SYS (pread, ssize_t,
1164 (int fd, void *buf, size_t bufsize, off_t offset));
1166 _GL_CXXALIASWARN (pread);
1167 #elif defined GNULIB_POSIXCHECK
1169 # if HAVE_RAW_DECL_PREAD
1170 _GL_WARN_ON_USE (pread, "pread is unportable - "
1171 "use gnulib module pread for portability");
1177 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1178 Return the number of bytes written if successful, otherwise
1179 set errno and return -1. 0 indicates nothing written. See the
1180 POSIX:2008 specification
1181 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1182 # if @REPLACE_PWRITE@
1183 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1185 # define pwrite rpl_pwrite
1187 _GL_FUNCDECL_RPL (pwrite, ssize_t,
1188 (int fd, const void *buf, size_t bufsize, off_t offset)
1189 _GL_ARG_NONNULL ((2)));
1190 _GL_CXXALIAS_RPL (pwrite, ssize_t,
1191 (int fd, const void *buf, size_t bufsize, off_t offset));
1194 _GL_FUNCDECL_SYS (pwrite, ssize_t,
1195 (int fd, const void *buf, size_t bufsize, off_t offset)
1196 _GL_ARG_NONNULL ((2)));
1198 _GL_CXXALIAS_SYS (pwrite, ssize_t,
1199 (int fd, const void *buf, size_t bufsize, off_t offset));
1201 _GL_CXXALIASWARN (pwrite);
1202 #elif defined GNULIB_POSIXCHECK
1204 # if HAVE_RAW_DECL_PWRITE
1205 _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1206 "use gnulib module pwrite for portability");
1212 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1213 at BUF. See the POSIX:2008 specification
1214 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1216 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1218 # define read rpl_read
1220 _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1221 _GL_ARG_NONNULL ((2)));
1222 _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1224 /* Need to cast, because on mingw, the third parameter is
1226 and the return type is 'int'. */
1227 _GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1229 _GL_CXXALIASWARN (read);
1233 #if @GNULIB_READLINK@
1234 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1235 bytes of it into BUF. Return the number of bytes placed into BUF if
1236 successful, otherwise -1 and errno set.
1237 See the POSIX:2008 specification
1238 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1239 # if @REPLACE_READLINK@
1240 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1241 # define readlink rpl_readlink
1243 _GL_FUNCDECL_RPL (readlink, ssize_t,
1244 (const char *file, char *buf, size_t bufsize)
1245 _GL_ARG_NONNULL ((1, 2)));
1246 _GL_CXXALIAS_RPL (readlink, ssize_t,
1247 (const char *file, char *buf, size_t bufsize));
1249 # if !@HAVE_READLINK@
1250 _GL_FUNCDECL_SYS (readlink, ssize_t,
1251 (const char *file, char *buf, size_t bufsize)
1252 _GL_ARG_NONNULL ((1, 2)));
1254 _GL_CXXALIAS_SYS (readlink, ssize_t,
1255 (const char *file, char *buf, size_t bufsize));
1257 _GL_CXXALIASWARN (readlink);
1258 #elif defined GNULIB_POSIXCHECK
1260 # if HAVE_RAW_DECL_READLINK
1261 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1262 "use gnulib module readlink for portability");
1267 #if @GNULIB_READLINKAT@
1268 # if !@HAVE_READLINKAT@
1269 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
1270 (int fd, char const *file, char *buf, size_t len)
1271 _GL_ARG_NONNULL ((2, 3)));
1273 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1274 (int fd, char const *file, char *buf, size_t len));
1275 _GL_CXXALIASWARN (readlinkat);
1276 #elif defined GNULIB_POSIXCHECK
1278 # if HAVE_RAW_DECL_READLINKAT
1279 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1280 "use gnulib module readlinkat for portability");
1286 /* Remove the directory DIR. */
1287 # if @REPLACE_RMDIR@
1288 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1289 # define rmdir rpl_rmdir
1291 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1292 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1294 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1296 _GL_CXXALIASWARN (rmdir);
1297 #elif defined GNULIB_POSIXCHECK
1299 # if HAVE_RAW_DECL_RMDIR
1300 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1301 "use gnulib module rmdir for portability");
1306 #if @GNULIB_SETHOSTNAME@
1307 /* Set the host name of the machine.
1308 The host name may or may not be fully qualified.
1310 Put LEN bytes of NAME into the host name.
1311 Return 0 if successful, otherwise, set errno and return -1.
1313 Platforms with no ability to set the hostname return -1 and set
1315 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1316 _GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
1317 _GL_ARG_NONNULL ((1)));
1319 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1320 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1321 2011-10, the first parameter is not const. */
1322 _GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
1323 _GL_CXXALIASWARN (sethostname);
1324 #elif defined GNULIB_POSIXCHECK
1326 # if HAVE_RAW_DECL_SETHOSTNAME
1327 _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1328 "use gnulib module sethostname for portability");
1334 /* Pause the execution of the current thread for N seconds.
1335 Returns the number of seconds left to sleep.
1336 See the POSIX:2008 specification
1337 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1338 # if @REPLACE_SLEEP@
1339 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1341 # define sleep rpl_sleep
1343 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1344 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1347 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1349 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1351 _GL_CXXALIASWARN (sleep);
1352 #elif defined GNULIB_POSIXCHECK
1354 # if HAVE_RAW_DECL_SLEEP
1355 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1356 "use gnulib module sleep for portability");
1361 #if @GNULIB_SYMLINK@
1362 # if @REPLACE_SYMLINK@
1363 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1365 # define symlink rpl_symlink
1367 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1368 _GL_ARG_NONNULL ((1, 2)));
1369 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1371 # if !@HAVE_SYMLINK@
1372 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1373 _GL_ARG_NONNULL ((1, 2)));
1375 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1377 _GL_CXXALIASWARN (symlink);
1378 #elif defined GNULIB_POSIXCHECK
1380 # if HAVE_RAW_DECL_SYMLINK
1381 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1382 "use gnulib module symlink for portability");
1387 #if @GNULIB_SYMLINKAT@
1388 # if !@HAVE_SYMLINKAT@
1389 _GL_FUNCDECL_SYS (symlinkat, int,
1390 (char const *contents, int fd, char const *file)
1391 _GL_ARG_NONNULL ((1, 3)));
1393 _GL_CXXALIAS_SYS (symlinkat, int,
1394 (char const *contents, int fd, char const *file));
1395 _GL_CXXALIASWARN (symlinkat);
1396 #elif defined GNULIB_POSIXCHECK
1398 # if HAVE_RAW_DECL_SYMLINKAT
1399 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1400 "use gnulib module symlinkat for portability");
1405 #if @GNULIB_TTYNAME_R@
1406 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1407 open on in BUF. Return 0 on success, otherwise an error number. */
1408 # if @REPLACE_TTYNAME_R@
1409 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1411 # define ttyname_r rpl_ttyname_r
1413 _GL_FUNCDECL_RPL (ttyname_r, int,
1414 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1415 _GL_CXXALIAS_RPL (ttyname_r, int,
1416 (int fd, char *buf, size_t buflen));
1418 # if !@HAVE_DECL_TTYNAME_R@
1419 _GL_FUNCDECL_SYS (ttyname_r, int,
1420 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1422 _GL_CXXALIAS_SYS (ttyname_r, int,
1423 (int fd, char *buf, size_t buflen));
1425 _GL_CXXALIASWARN (ttyname_r);
1426 #elif defined GNULIB_POSIXCHECK
1428 # if HAVE_RAW_DECL_TTYNAME_R
1429 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1430 "use gnulib module ttyname_r for portability");
1436 # if @REPLACE_UNLINK@
1437 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1439 # define unlink rpl_unlink
1441 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1442 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
1444 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
1446 _GL_CXXALIASWARN (unlink);
1447 #elif defined GNULIB_POSIXCHECK
1449 # if HAVE_RAW_DECL_UNLINK
1450 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
1451 "use gnulib module unlink for portability");
1456 #if @GNULIB_UNLINKAT@
1457 # if @REPLACE_UNLINKAT@
1458 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1460 # define unlinkat rpl_unlinkat
1462 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1463 _GL_ARG_NONNULL ((2)));
1464 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1466 # if !@HAVE_UNLINKAT@
1467 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1468 _GL_ARG_NONNULL ((2)));
1470 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1472 _GL_CXXALIASWARN (unlinkat);
1473 #elif defined GNULIB_POSIXCHECK
1475 # if HAVE_RAW_DECL_UNLINKAT
1476 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1477 "use gnulib module openat for portability");
1483 /* Pause the execution of the current thread for N microseconds.
1484 Returns 0 on completion, or -1 on range error.
1485 See the POSIX:2001 specification
1486 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1487 # if @REPLACE_USLEEP@
1488 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1490 # define usleep rpl_usleep
1492 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1493 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1496 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1498 _GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1500 _GL_CXXALIASWARN (usleep);
1501 #elif defined GNULIB_POSIXCHECK
1503 # if HAVE_RAW_DECL_USLEEP
1504 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1505 "use gnulib module usleep for portability");
1511 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1512 See the POSIX:2008 specification
1513 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1514 # if @REPLACE_WRITE@
1515 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1517 # define write rpl_write
1519 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1520 _GL_ARG_NONNULL ((2)));
1521 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1523 /* Need to cast, because on mingw, the third parameter is
1525 and the return type is 'int'. */
1526 _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1528 _GL_CXXALIASWARN (write);
1531 _GL_INLINE_HEADER_END
1533 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1534 #endif /* _@GUARD_PREFIX@_UNISTD_H */