1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2011 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, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 @PRAGMA_SYSTEM_HEADER@
23 /* Special invocation convention:
24 - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
25 but we need to ensure that both the system <unistd.h> and <winsock2.h>
26 are completely included before we replace gethostname. */
27 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
28 && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
29 /* <unistd.h> is being indirectly included for the first time from
30 <winsock2.h>; avoid declaring any overrides. */
32 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
34 # error unexpected; report this to bug-gnulib@gnu.org
36 # define _GL_WINSOCK2_H_WITNESS
38 /* Normal invocation. */
39 #elif !defined _@GUARD_PREFIX@_UNISTD_H
41 /* The include_next requires a split double-inclusion guard. */
43 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
46 /* Get all possible declarations of gethostname(). */
47 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
48 && !defined _GL_INCLUDING_WINSOCK2_H
49 # define _GL_INCLUDING_WINSOCK2_H
50 # include <winsock2.h>
51 # undef _GL_INCLUDING_WINSOCK2_H
54 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
55 #define _@GUARD_PREFIX@_UNISTD_H
57 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
60 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
61 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
62 /* But avoid namespace pollution on glibc systems. */
63 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
64 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
65 && defined __CYGWIN__)) \
66 && ! defined __GLIBC__
70 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
71 /* But avoid namespace pollution on glibc systems. */
72 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
73 && ! defined __GLIBC__
77 /* mingw fails to declare _exit in <unistd.h>. */
78 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
80 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
81 /* But avoid namespace pollution on glibc systems. */
86 /* Native Windows platforms declare chdir, getcwd, rmdir in
87 <io.h> and/or <direct.h>, not in <unistd.h>. */
88 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
89 || defined GNULIB_POSIXCHECK) \
90 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
91 # include <io.h> /* mingw32, mingw64 */
92 # include <direct.h> /* mingw64, MSVC 9 */
95 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
96 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
97 /* But avoid namespace pollution on glibc systems. */
98 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
99 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
100 && !defined __GLIBC__
104 /* MSVC defines off_t in <sys/types.h>. */
107 # include <sys/types.h>
110 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
111 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
112 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
114 # include <sys/types.h>
117 /* Get getopt(), optarg, optind, opterr, optopt.
118 But avoid namespace pollution on glibc systems. */
119 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
123 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
125 /* The definition of _GL_ARG_NONNULL is copied here. */
127 /* The definition of _GL_WARN_ON_USE is copied here. */
130 /* Hide some function declarations from <winsock2.h>. */
132 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
133 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
134 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
136 # define socket socket_used_without_including_sys_socket_h
138 # define connect connect_used_without_including_sys_socket_h
140 # define accept accept_used_without_including_sys_socket_h
142 # define bind bind_used_without_including_sys_socket_h
144 # define getpeername getpeername_used_without_including_sys_socket_h
146 # define getsockname getsockname_used_without_including_sys_socket_h
148 # define getsockopt getsockopt_used_without_including_sys_socket_h
150 # define listen listen_used_without_including_sys_socket_h
152 # define recv recv_used_without_including_sys_socket_h
154 # define send send_used_without_including_sys_socket_h
156 # define recvfrom recvfrom_used_without_including_sys_socket_h
158 # define sendto sendto_used_without_including_sys_socket_h
160 # define setsockopt setsockopt_used_without_including_sys_socket_h
162 # define shutdown shutdown_used_without_including_sys_socket_h
164 _GL_WARN_ON_USE (socket,
165 "socket() used without including <sys/socket.h>");
166 _GL_WARN_ON_USE (connect,
167 "connect() used without including <sys/socket.h>");
168 _GL_WARN_ON_USE (accept,
169 "accept() used without including <sys/socket.h>");
170 _GL_WARN_ON_USE (bind,
171 "bind() used without including <sys/socket.h>");
172 _GL_WARN_ON_USE (getpeername,
173 "getpeername() used without including <sys/socket.h>");
174 _GL_WARN_ON_USE (getsockname,
175 "getsockname() used without including <sys/socket.h>");
176 _GL_WARN_ON_USE (getsockopt,
177 "getsockopt() used without including <sys/socket.h>");
178 _GL_WARN_ON_USE (listen,
179 "listen() used without including <sys/socket.h>");
180 _GL_WARN_ON_USE (recv,
181 "recv() used without including <sys/socket.h>");
182 _GL_WARN_ON_USE (send,
183 "send() used without including <sys/socket.h>");
184 _GL_WARN_ON_USE (recvfrom,
185 "recvfrom() used without including <sys/socket.h>");
186 _GL_WARN_ON_USE (sendto,
187 "sendto() used without including <sys/socket.h>");
188 _GL_WARN_ON_USE (setsockopt,
189 "setsockopt() used without including <sys/socket.h>");
190 _GL_WARN_ON_USE (shutdown,
191 "shutdown() used without including <sys/socket.h>");
194 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
195 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
197 # define select select_used_without_including_sys_select_h
199 _GL_WARN_ON_USE (select,
200 "select() used without including <sys/select.h>");
206 /* OS/2 EMX lacks these macros. */
208 # define STDIN_FILENO 0
210 #ifndef STDOUT_FILENO
211 # define STDOUT_FILENO 1
213 #ifndef STDERR_FILENO
214 # define STDERR_FILENO 2
217 /* Ensure *_OK macros exist. */
226 /* Declare overridden functions. */
229 #if defined GNULIB_POSIXCHECK
230 /* The access() function is a security risk. */
231 _GL_WARN_ON_USE (access, "the access function is a security risk - "
232 "use the gnulib module faccessat instead");
237 _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
238 _GL_CXXALIASWARN (chdir);
239 #elif defined GNULIB_POSIXCHECK
241 # if HAVE_RAW_DECL_CHDIR
242 _GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
243 "use gnulib module chdir for portability");
249 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
250 to GID (if GID is not -1). Follow symbolic links.
251 Return 0 if successful, otherwise -1 and errno set.
252 See the POSIX:2008 specification
253 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
255 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
257 # define chown rpl_chown
259 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
260 _GL_ARG_NONNULL ((1)));
261 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
264 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
265 _GL_ARG_NONNULL ((1)));
267 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
269 _GL_CXXALIASWARN (chown);
270 #elif defined GNULIB_POSIXCHECK
272 # if HAVE_RAW_DECL_CHOWN
273 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
274 "doesn't treat a uid or gid of -1 on some systems - "
275 "use gnulib module chown for portability");
282 /* Automatically included by modules that need a replacement for close. */
283 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
285 # define close rpl_close
287 _GL_FUNCDECL_RPL (close, int, (int fd));
288 _GL_CXXALIAS_RPL (close, int, (int fd));
290 _GL_CXXALIAS_SYS (close, int, (int fd));
292 _GL_CXXALIASWARN (close);
293 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
295 # define close close_used_without_requesting_gnulib_module_close
296 #elif defined GNULIB_POSIXCHECK
298 /* Assume close is always declared. */
299 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
300 "use gnulib module close for portability");
306 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
309 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
310 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
312 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
314 _GL_CXXALIASWARN (dup);
315 #elif defined GNULIB_POSIXCHECK
317 # if HAVE_RAW_DECL_DUP
318 _GL_WARN_ON_USE (dup, "dup is unportable - "
319 "use gnulib module dup for portability");
325 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
326 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
327 Return newfd if successful, otherwise -1 and errno set.
328 See the POSIX:2008 specification
329 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
331 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
332 # define dup2 rpl_dup2
334 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
335 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
338 _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
340 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
342 _GL_CXXALIASWARN (dup2);
343 #elif defined GNULIB_POSIXCHECK
345 # if HAVE_RAW_DECL_DUP2
346 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
347 "use gnulib module dup2 for portability");
353 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
355 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
356 and O_TEXT, O_BINARY (defined in "binary-io.h").
357 Close NEWFD first if it is open.
358 Return newfd if successful, otherwise -1 and errno set.
359 See the Linux man page at
360 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
362 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
363 # define dup3 rpl_dup3
365 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
366 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
368 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
369 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
371 _GL_CXXALIASWARN (dup3);
372 #elif defined GNULIB_POSIXCHECK
374 # if HAVE_RAW_DECL_DUP3
375 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
376 "use gnulib module dup3 for portability");
382 # if !@HAVE_DECL_ENVIRON@
383 /* Set of environment variables and values. An array of strings of the form
384 "VARIABLE=VALUE", terminated with a NULL. */
385 # if defined __APPLE__ && defined __MACH__
386 # include <crt_externs.h>
387 # define environ (*_NSGetEnviron ())
392 extern char **environ;
398 #elif defined GNULIB_POSIXCHECK
399 # if HAVE_RAW_DECL_ENVIRON
400 static inline char ***
405 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
406 "use gnulib module environ for portability");
408 # define environ (*rpl_environ ())
413 #if @GNULIB_EUIDACCESS@
414 /* Like access(), except that it uses the effective user id and group id of
415 the current process. */
416 # if !@HAVE_EUIDACCESS@
417 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
418 _GL_ARG_NONNULL ((1)));
420 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
421 _GL_CXXALIASWARN (euidaccess);
422 # if defined GNULIB_POSIXCHECK
423 /* Like access(), this function is a security risk. */
424 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
425 "use the gnulib module faccessat instead");
427 #elif defined GNULIB_POSIXCHECK
429 # if HAVE_RAW_DECL_EUIDACCESS
430 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
431 "use gnulib module euidaccess for portability");
436 #if @GNULIB_FACCESSAT@
437 # if !@HAVE_FACCESSAT@
438 _GL_FUNCDECL_SYS (faccessat, int,
439 (int fd, char const *file, int mode, int flag)
440 _GL_ARG_NONNULL ((2)));
442 _GL_CXXALIAS_SYS (faccessat, int,
443 (int fd, char const *file, int mode, int flag));
444 _GL_CXXALIASWARN (faccessat);
445 #elif defined GNULIB_POSIXCHECK
447 # if HAVE_RAW_DECL_FACCESSAT
448 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
449 "use gnulib module faccessat for portability");
455 /* Change the process' current working directory to the directory on which
456 the given file descriptor is open.
457 Return 0 if successful, otherwise -1 and errno set.
458 See the POSIX:2008 specification
459 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
461 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
463 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
464 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
465 _GL_ARG_NONNULL ((2));
466 _GL_EXTERN_C void _gl_unregister_fd (int fd);
467 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
468 _GL_EXTERN_C const char *_gl_directory_name (int fd);
471 # if !@HAVE_DECL_FCHDIR@
472 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
475 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
476 _GL_CXXALIASWARN (fchdir);
477 #elif defined GNULIB_POSIXCHECK
479 # if HAVE_RAW_DECL_FCHDIR
480 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
481 "use gnulib module fchdir for portability");
486 #if @GNULIB_FCHOWNAT@
487 # if @REPLACE_FCHOWNAT@
488 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
490 # define fchownat rpl_fchownat
492 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
493 uid_t owner, gid_t group, int flag)
494 _GL_ARG_NONNULL ((2)));
495 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
496 uid_t owner, gid_t group, int flag));
498 # if !@HAVE_FCHOWNAT@
499 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
500 uid_t owner, gid_t group, int flag)
501 _GL_ARG_NONNULL ((2)));
503 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
504 uid_t owner, gid_t group, int flag));
506 _GL_CXXALIASWARN (fchownat);
507 #elif defined GNULIB_POSIXCHECK
509 # if HAVE_RAW_DECL_FCHOWNAT
510 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
511 "use gnulib module openat for portability");
516 #if @GNULIB_FDATASYNC@
517 /* Synchronize changes to a file.
518 Return 0 if successful, otherwise -1 and errno set.
519 See POSIX:2008 specification
520 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
521 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
522 _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
524 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
525 _GL_CXXALIASWARN (fdatasync);
526 #elif defined GNULIB_POSIXCHECK
528 # if HAVE_RAW_DECL_FDATASYNC
529 _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
530 "use gnulib module fdatasync for portability");
536 /* Synchronize changes, including metadata, to a file.
537 Return 0 if successful, otherwise -1 and errno set.
538 See POSIX:2008 specification
539 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
541 _GL_FUNCDECL_SYS (fsync, int, (int fd));
543 _GL_CXXALIAS_SYS (fsync, int, (int fd));
544 _GL_CXXALIASWARN (fsync);
545 #elif defined GNULIB_POSIXCHECK
547 # if HAVE_RAW_DECL_FSYNC
548 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
549 "use gnulib module fsync for portability");
554 #if @GNULIB_FTRUNCATE@
555 /* Change the size of the file to which FD is opened to become equal to LENGTH.
556 Return 0 if successful, otherwise -1 and errno set.
557 See the POSIX:2008 specification
558 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
559 # if !@HAVE_FTRUNCATE@
560 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
562 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
563 _GL_CXXALIASWARN (ftruncate);
564 #elif defined GNULIB_POSIXCHECK
566 # if HAVE_RAW_DECL_FTRUNCATE
567 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
568 "use gnulib module ftruncate for portability");
574 /* Get the name of the current working directory, and put it in SIZE bytes
576 Return BUF if successful, or NULL if the directory couldn't be determined
577 or SIZE was too small.
578 See the POSIX:2008 specification
579 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
580 Additionally, the gnulib module 'getcwd' guarantees the following GNU
581 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
582 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
584 # if @REPLACE_GETCWD@
585 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
586 # define getcwd rpl_getcwd
588 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
589 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
591 /* Need to cast, because on mingw, the second parameter is
593 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
595 _GL_CXXALIASWARN (getcwd);
596 #elif defined GNULIB_POSIXCHECK
598 # if HAVE_RAW_DECL_GETCWD
599 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
600 "use gnulib module getcwd for portability");
605 #if @GNULIB_GETDOMAINNAME@
606 /* Return the NIS domain name of the machine.
607 WARNING! The NIS domain name is unrelated to the fully qualified host name
608 of the machine. It is also unrelated to email addresses.
609 WARNING! The NIS domain name is usually the empty string or "(none)" when
612 Put up to LEN bytes of the NIS domain name into NAME.
613 Null terminate it if the name is shorter than LEN.
614 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
615 Return 0 if successful, otherwise set errno and return -1. */
616 # if @REPLACE_GETDOMAINNAME@
617 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
618 # undef getdomainname
619 # define getdomainname rpl_getdomainname
621 _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
622 _GL_ARG_NONNULL ((1)));
623 _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
625 # if !@HAVE_DECL_GETDOMAINNAME@
626 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
627 _GL_ARG_NONNULL ((1)));
629 _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
631 _GL_CXXALIASWARN (getdomainname);
632 #elif defined GNULIB_POSIXCHECK
633 # undef getdomainname
634 # if HAVE_RAW_DECL_GETDOMAINNAME
635 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
636 "use gnulib module getdomainname for portability");
641 #if @GNULIB_GETDTABLESIZE@
642 /* Return the maximum number of file descriptors in the current process.
643 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
644 # if !@HAVE_GETDTABLESIZE@
645 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
647 _GL_CXXALIAS_SYS (getdtablesize, int, (void));
648 _GL_CXXALIASWARN (getdtablesize);
649 #elif defined GNULIB_POSIXCHECK
650 # undef getdtablesize
651 # if HAVE_RAW_DECL_GETDTABLESIZE
652 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
653 "use gnulib module getdtablesize for portability");
658 #if @GNULIB_GETGROUPS@
659 /* Return the supplemental groups that the current process belongs to.
660 It is unspecified whether the effective group id is in the list.
661 If N is 0, return the group count; otherwise, N describes how many
662 entries are available in GROUPS. Return -1 and set errno if N is
663 not 0 and not large enough. Fails with ENOSYS on some systems. */
664 # if @REPLACE_GETGROUPS@
665 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
667 # define getgroups rpl_getgroups
669 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
670 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
672 # if !@HAVE_GETGROUPS@
673 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
675 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
677 _GL_CXXALIASWARN (getgroups);
678 #elif defined GNULIB_POSIXCHECK
680 # if HAVE_RAW_DECL_GETGROUPS
681 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
682 "use gnulib module getgroups for portability");
686 #if @GNULIB_SETHOSTNAME@
687 /* Set the host name of the machine.
688 The host name may or may not be fully qualified.
690 Put LEN bytes of NAME into the host name.
691 Return 0 if successful, otherwise, set errno and return -1
693 Platforms with no ability to set the hostname return -1 and set
695 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
696 _GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
697 _GL_ARG_NONNULL ((1)));
699 /* Need to cast, because on Solaris 11 2011-10, MacOS X 10.5, IRIX 6.5
700 and FreeBSD 6.4 the second parameter is int. On Solaris 11
701 2011-10, the first parameter is not const. */
702 _GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
703 _GL_CXXALIASWARN (sethostname);
704 #elif defined GNULIB_POSIXCHECK
706 # if HAVE_RAW_DECL_GETHOSTNAME
707 _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
708 "use gnulib module sethostname for portability");
712 #if @GNULIB_GETHOSTNAME@
713 /* Return the standard host name of the machine.
714 WARNING! The host name may or may not be fully qualified.
716 Put up to LEN bytes of the host name into NAME.
717 Null terminate it if the name is shorter than LEN.
718 If the host name is longer than LEN, set errno = EINVAL and return -1.
719 Return 0 if successful, otherwise set errno and return -1. */
720 # if @UNISTD_H_HAVE_WINSOCK2_H@
721 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
723 # define gethostname rpl_gethostname
725 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
726 _GL_ARG_NONNULL ((1)));
727 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
729 # if !@HAVE_GETHOSTNAME@
730 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
731 _GL_ARG_NONNULL ((1)));
733 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
736 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
738 _GL_CXXALIASWARN (gethostname);
739 #elif @UNISTD_H_HAVE_WINSOCK2_H@
741 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
742 #elif defined GNULIB_POSIXCHECK
744 # if HAVE_RAW_DECL_GETHOSTNAME
745 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
746 "use gnulib module gethostname for portability");
751 #if @GNULIB_GETLOGIN@
752 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
753 returns NULL with errno set.
755 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
757 Most programs don't need to use this function, because the information is
758 available through environment variables:
759 ${LOGNAME-$USER} on Unix platforms,
760 $USERNAME on native Windows platforms.
762 # if !@HAVE_GETLOGIN@
763 _GL_FUNCDECL_SYS (getlogin, char *, (void));
765 _GL_CXXALIAS_SYS (getlogin, char *, (void));
766 _GL_CXXALIASWARN (getlogin);
767 #elif defined GNULIB_POSIXCHECK
769 # if HAVE_RAW_DECL_GETLOGIN
770 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
771 "use gnulib module getlogin for portability");
776 #if @GNULIB_GETLOGIN_R@
777 /* Copies the user's login name to NAME.
778 The array pointed to by NAME has room for SIZE bytes.
780 Returns 0 if successful. Upon error, an error number is returned, or -1 in
781 the case that the login name cannot be found but no specific error is
782 provided (this case is hopefully rare but is left open by the POSIX spec).
784 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
786 Most programs don't need to use this function, because the information is
787 available through environment variables:
788 ${LOGNAME-$USER} on Unix platforms,
789 $USERNAME on native Windows platforms.
791 # if @REPLACE_GETLOGIN_R@
792 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
793 # define getlogin_r rpl_getlogin_r
795 _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
796 _GL_ARG_NONNULL ((1)));
797 _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
799 # if !@HAVE_DECL_GETLOGIN_R@
800 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
801 _GL_ARG_NONNULL ((1)));
803 /* Need to cast, because on Solaris 10 systems, the second argument is
805 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
807 _GL_CXXALIASWARN (getlogin_r);
808 #elif defined GNULIB_POSIXCHECK
810 # if HAVE_RAW_DECL_GETLOGIN_R
811 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
812 "use gnulib module getlogin_r for portability");
817 #if @GNULIB_GETPAGESIZE@
818 # if @REPLACE_GETPAGESIZE@
819 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
820 # define getpagesize rpl_getpagesize
822 _GL_FUNCDECL_RPL (getpagesize, int, (void));
823 _GL_CXXALIAS_RPL (getpagesize, int, (void));
825 # if !@HAVE_GETPAGESIZE@
826 # if !defined getpagesize
827 /* This is for POSIX systems. */
828 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
829 # if ! (defined __VMS && __VMS_VER < 70000000)
830 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
833 /* This is for older VMS. */
834 # if !defined _gl_getpagesize && defined __VMS
836 # define _gl_getpagesize() 8192
838 # define _gl_getpagesize() 512
841 /* This is for BeOS. */
842 # if !defined _gl_getpagesize && @HAVE_OS_H@
844 # if defined B_PAGE_SIZE
845 # define _gl_getpagesize() B_PAGE_SIZE
848 /* This is for AmigaOS4.0. */
849 # if !defined _gl_getpagesize && defined __amigaos4__
850 # define _gl_getpagesize() 2048
852 /* This is for older Unix systems. */
853 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
854 # include <sys/param.h>
855 # ifdef EXEC_PAGESIZE
856 # define _gl_getpagesize() EXEC_PAGESIZE
862 # define _gl_getpagesize() (NBPG * CLSIZE)
865 # define _gl_getpagesize() NBPC
870 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
871 # define getpagesize() _gl_getpagesize ()
873 # if !GNULIB_defined_getpagesize_function
877 return _gl_getpagesize ();
879 # define GNULIB_defined_getpagesize_function 1
884 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
885 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
887 # if @HAVE_DECL_GETPAGESIZE@
888 _GL_CXXALIASWARN (getpagesize);
890 #elif defined GNULIB_POSIXCHECK
892 # if HAVE_RAW_DECL_GETPAGESIZE
893 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
894 "use gnulib module getpagesize for portability");
899 #if @GNULIB_GETUSERSHELL@
900 /* Return the next valid login shell on the system, or NULL when the end of
901 the list has been reached. */
902 # if !@HAVE_DECL_GETUSERSHELL@
903 _GL_FUNCDECL_SYS (getusershell, char *, (void));
905 _GL_CXXALIAS_SYS (getusershell, char *, (void));
906 _GL_CXXALIASWARN (getusershell);
907 #elif defined GNULIB_POSIXCHECK
909 # if HAVE_RAW_DECL_GETUSERSHELL
910 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
911 "use gnulib module getusershell for portability");
915 #if @GNULIB_GETUSERSHELL@
916 /* Rewind to pointer that is advanced at each getusershell() call. */
917 # if !@HAVE_DECL_GETUSERSHELL@
918 _GL_FUNCDECL_SYS (setusershell, void, (void));
920 _GL_CXXALIAS_SYS (setusershell, void, (void));
921 _GL_CXXALIASWARN (setusershell);
922 #elif defined GNULIB_POSIXCHECK
924 # if HAVE_RAW_DECL_SETUSERSHELL
925 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
926 "use gnulib module getusershell for portability");
930 #if @GNULIB_GETUSERSHELL@
931 /* Free the pointer that is advanced at each getusershell() call and
932 associated resources. */
933 # if !@HAVE_DECL_GETUSERSHELL@
934 _GL_FUNCDECL_SYS (endusershell, void, (void));
936 _GL_CXXALIAS_SYS (endusershell, void, (void));
937 _GL_CXXALIASWARN (endusershell);
938 #elif defined GNULIB_POSIXCHECK
940 # if HAVE_RAW_DECL_ENDUSERSHELL
941 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
942 "use gnulib module getusershell for portability");
947 #if @GNULIB_GROUP_MEMBER@
948 /* Determine whether group id is in calling user's group list. */
949 # if !@HAVE_GROUP_MEMBER@
950 _GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
952 _GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
953 _GL_CXXALIASWARN (group_member);
954 #elif defined GNULIB_POSIXCHECK
956 # if HAVE_RAW_DECL_GROUP_MEMBER
957 _GL_WARN_ON_USE (group_member, "group_member is unportable - "
958 "use gnulib module group-member for portability");
964 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
965 to GID (if GID is not -1). Do not follow symbolic links.
966 Return 0 if successful, otherwise -1 and errno set.
967 See the POSIX:2008 specification
968 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
969 # if @REPLACE_LCHOWN@
970 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
972 # define lchown rpl_lchown
974 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
975 _GL_ARG_NONNULL ((1)));
976 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
979 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
980 _GL_ARG_NONNULL ((1)));
982 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
984 _GL_CXXALIASWARN (lchown);
985 #elif defined GNULIB_POSIXCHECK
987 # if HAVE_RAW_DECL_LCHOWN
988 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
989 "use gnulib module lchown for portability");
995 /* Create a new hard link for an existing file.
996 Return 0 if successful, otherwise -1 and errno set.
997 See POSIX:2008 specification
998 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1000 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1001 # define link rpl_link
1003 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
1004 _GL_ARG_NONNULL ((1, 2)));
1005 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
1008 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
1009 _GL_ARG_NONNULL ((1, 2)));
1011 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
1013 _GL_CXXALIASWARN (link);
1014 #elif defined GNULIB_POSIXCHECK
1016 # if HAVE_RAW_DECL_LINK
1017 _GL_WARN_ON_USE (link, "link is unportable - "
1018 "use gnulib module link for portability");
1024 /* Create a new hard link for an existing file, relative to two
1025 directories. FLAG controls whether symlinks are followed.
1026 Return 0 if successful, otherwise -1 and errno set. */
1027 # if @REPLACE_LINKAT@
1028 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1030 # define linkat rpl_linkat
1032 _GL_FUNCDECL_RPL (linkat, int,
1033 (int fd1, const char *path1, int fd2, const char *path2,
1035 _GL_ARG_NONNULL ((2, 4)));
1036 _GL_CXXALIAS_RPL (linkat, int,
1037 (int fd1, const char *path1, int fd2, const char *path2,
1041 _GL_FUNCDECL_SYS (linkat, int,
1042 (int fd1, const char *path1, int fd2, const char *path2,
1044 _GL_ARG_NONNULL ((2, 4)));
1046 _GL_CXXALIAS_SYS (linkat, int,
1047 (int fd1, const char *path1, int fd2, const char *path2,
1050 _GL_CXXALIASWARN (linkat);
1051 #elif defined GNULIB_POSIXCHECK
1053 # if HAVE_RAW_DECL_LINKAT
1054 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1055 "use gnulib module linkat for portability");
1061 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1062 Return the new offset if successful, otherwise -1 and errno set.
1063 See the POSIX:2008 specification
1064 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1065 # if @REPLACE_LSEEK@
1066 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1067 # define lseek rpl_lseek
1069 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1070 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1072 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1074 _GL_CXXALIASWARN (lseek);
1075 #elif defined GNULIB_POSIXCHECK
1077 # if HAVE_RAW_DECL_LSEEK
1078 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1079 "systems - use gnulib module lseek for portability");
1085 /* Create a pipe, defaulting to O_BINARY mode.
1086 Store the read-end as fd[0] and the write-end as fd[1].
1087 Return 0 upon success, or -1 with errno set upon failure. */
1089 _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1091 _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1092 _GL_CXXALIASWARN (pipe);
1093 #elif defined GNULIB_POSIXCHECK
1095 # if HAVE_RAW_DECL_PIPE
1096 _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1097 "use gnulib module pipe-posix for portability");
1103 /* Create a pipe, applying the given flags when opening the read-end of the
1104 pipe and the write-end of the pipe.
1105 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1106 and O_TEXT, O_BINARY (defined in "binary-io.h").
1107 Store the read-end as fd[0] and the write-end as fd[1].
1108 Return 0 upon success, or -1 with errno set upon failure.
1109 See also the Linux man page at
1110 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1112 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1113 # define pipe2 rpl_pipe2
1115 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1116 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1118 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1119 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1121 _GL_CXXALIASWARN (pipe2);
1122 #elif defined GNULIB_POSIXCHECK
1124 # if HAVE_RAW_DECL_PIPE2
1125 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1126 "use gnulib module pipe2 for portability");
1132 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1133 Return the number of bytes placed into BUF if successful, otherwise
1134 set errno and return -1. 0 indicates EOF.
1135 See the POSIX:2008 specification
1136 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1137 # if @REPLACE_PREAD@
1138 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1140 # define pread rpl_pread
1142 _GL_FUNCDECL_RPL (pread, ssize_t,
1143 (int fd, void *buf, size_t bufsize, off_t offset)
1144 _GL_ARG_NONNULL ((2)));
1145 _GL_CXXALIAS_RPL (pread, ssize_t,
1146 (int fd, void *buf, size_t bufsize, off_t offset));
1149 _GL_FUNCDECL_SYS (pread, ssize_t,
1150 (int fd, void *buf, size_t bufsize, off_t offset)
1151 _GL_ARG_NONNULL ((2)));
1153 _GL_CXXALIAS_SYS (pread, ssize_t,
1154 (int fd, void *buf, size_t bufsize, off_t offset));
1156 _GL_CXXALIASWARN (pread);
1157 #elif defined GNULIB_POSIXCHECK
1159 # if HAVE_RAW_DECL_PREAD
1160 _GL_WARN_ON_USE (pread, "pread is unportable - "
1161 "use gnulib module pread for portability");
1167 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1168 Return the number of bytes written if successful, otherwise
1169 set errno and return -1. 0 indicates nothing written. See the
1170 POSIX:2008 specification
1171 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1172 # if @REPLACE_PWRITE@
1173 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1175 # define pwrite rpl_pwrite
1177 _GL_FUNCDECL_RPL (pwrite, ssize_t,
1178 (int fd, const void *buf, size_t bufsize, off_t offset)
1179 _GL_ARG_NONNULL ((2)));
1180 _GL_CXXALIAS_RPL (pwrite, ssize_t,
1181 (int fd, const void *buf, size_t bufsize, off_t offset));
1184 _GL_FUNCDECL_SYS (pwrite, ssize_t,
1185 (int fd, const void *buf, size_t bufsize, off_t offset)
1186 _GL_ARG_NONNULL ((2)));
1188 _GL_CXXALIAS_SYS (pwrite, ssize_t,
1189 (int fd, const void *buf, size_t bufsize, off_t offset));
1191 _GL_CXXALIASWARN (pwrite);
1192 #elif defined GNULIB_POSIXCHECK
1194 # if HAVE_RAW_DECL_PWRITE
1195 _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1196 "use gnulib module pwrite for portability");
1202 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1203 at BUF. See the POSIX:2008 specification
1204 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1206 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1208 # define read rpl_read
1210 _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1211 _GL_ARG_NONNULL ((2)));
1212 _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1214 /* Need to cast, because on mingw, the third parameter is
1216 and the return type is 'int'. */
1217 _GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1219 _GL_CXXALIASWARN (read);
1223 #if @GNULIB_READLINK@
1224 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1225 bytes of it into BUF. Return the number of bytes placed into BUF if
1226 successful, otherwise -1 and errno set.
1227 See the POSIX:2008 specification
1228 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1229 # if @REPLACE_READLINK@
1230 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1231 # define readlink rpl_readlink
1233 _GL_FUNCDECL_RPL (readlink, ssize_t,
1234 (const char *file, char *buf, size_t bufsize)
1235 _GL_ARG_NONNULL ((1, 2)));
1236 _GL_CXXALIAS_RPL (readlink, ssize_t,
1237 (const char *file, char *buf, size_t bufsize));
1239 # if !@HAVE_READLINK@
1240 _GL_FUNCDECL_SYS (readlink, ssize_t,
1241 (const char *file, char *buf, size_t bufsize)
1242 _GL_ARG_NONNULL ((1, 2)));
1244 _GL_CXXALIAS_SYS (readlink, ssize_t,
1245 (const char *file, char *buf, size_t bufsize));
1247 _GL_CXXALIASWARN (readlink);
1248 #elif defined GNULIB_POSIXCHECK
1250 # if HAVE_RAW_DECL_READLINK
1251 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1252 "use gnulib module readlink for portability");
1257 #if @GNULIB_READLINKAT@
1258 # if !@HAVE_READLINKAT@
1259 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
1260 (int fd, char const *file, char *buf, size_t len)
1261 _GL_ARG_NONNULL ((2, 3)));
1263 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1264 (int fd, char const *file, char *buf, size_t len));
1265 _GL_CXXALIASWARN (readlinkat);
1266 #elif defined GNULIB_POSIXCHECK
1268 # if HAVE_RAW_DECL_READLINKAT
1269 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1270 "use gnulib module readlinkat for portability");
1276 /* Remove the directory DIR. */
1277 # if @REPLACE_RMDIR@
1278 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1279 # define rmdir rpl_rmdir
1281 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1282 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1284 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1286 _GL_CXXALIASWARN (rmdir);
1287 #elif defined GNULIB_POSIXCHECK
1289 # if HAVE_RAW_DECL_RMDIR
1290 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1291 "use gnulib module rmdir for portability");
1297 /* Pause the execution of the current thread for N seconds.
1298 Returns the number of seconds left to sleep.
1299 See the POSIX:2008 specification
1300 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1301 # if @REPLACE_SLEEP@
1302 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1304 # define sleep rpl_sleep
1306 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1307 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1310 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1312 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1314 _GL_CXXALIASWARN (sleep);
1315 #elif defined GNULIB_POSIXCHECK
1317 # if HAVE_RAW_DECL_SLEEP
1318 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1319 "use gnulib module sleep for portability");
1324 #if @GNULIB_SYMLINK@
1325 # if @REPLACE_SYMLINK@
1326 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1328 # define symlink rpl_symlink
1330 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1331 _GL_ARG_NONNULL ((1, 2)));
1332 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1334 # if !@HAVE_SYMLINK@
1335 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1336 _GL_ARG_NONNULL ((1, 2)));
1338 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1340 _GL_CXXALIASWARN (symlink);
1341 #elif defined GNULIB_POSIXCHECK
1343 # if HAVE_RAW_DECL_SYMLINK
1344 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1345 "use gnulib module symlink for portability");
1350 #if @GNULIB_SYMLINKAT@
1351 # if !@HAVE_SYMLINKAT@
1352 _GL_FUNCDECL_SYS (symlinkat, int,
1353 (char const *contents, int fd, char const *file)
1354 _GL_ARG_NONNULL ((1, 3)));
1356 _GL_CXXALIAS_SYS (symlinkat, int,
1357 (char const *contents, int fd, char const *file));
1358 _GL_CXXALIASWARN (symlinkat);
1359 #elif defined GNULIB_POSIXCHECK
1361 # if HAVE_RAW_DECL_SYMLINKAT
1362 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1363 "use gnulib module symlinkat for portability");
1368 #if @GNULIB_TTYNAME_R@
1369 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1370 open on in BUF. Return 0 on success, otherwise an error number. */
1371 # if @REPLACE_TTYNAME_R@
1372 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1374 # define ttyname_r rpl_ttyname_r
1376 _GL_FUNCDECL_RPL (ttyname_r, int,
1377 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1378 _GL_CXXALIAS_RPL (ttyname_r, int,
1379 (int fd, char *buf, size_t buflen));
1381 # if !@HAVE_DECL_TTYNAME_R@
1382 _GL_FUNCDECL_SYS (ttyname_r, int,
1383 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1385 _GL_CXXALIAS_SYS (ttyname_r, int,
1386 (int fd, char *buf, size_t buflen));
1388 _GL_CXXALIASWARN (ttyname_r);
1389 #elif defined GNULIB_POSIXCHECK
1391 # if HAVE_RAW_DECL_TTYNAME_R
1392 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1393 "use gnulib module ttyname_r for portability");
1399 # if @REPLACE_UNLINK@
1400 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1402 # define unlink rpl_unlink
1404 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1405 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
1407 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
1409 _GL_CXXALIASWARN (unlink);
1410 #elif defined GNULIB_POSIXCHECK
1412 # if HAVE_RAW_DECL_UNLINK
1413 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
1414 "use gnulib module unlink for portability");
1419 #if @GNULIB_UNLINKAT@
1420 # if @REPLACE_UNLINKAT@
1421 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1423 # define unlinkat rpl_unlinkat
1425 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1426 _GL_ARG_NONNULL ((2)));
1427 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1429 # if !@HAVE_UNLINKAT@
1430 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1431 _GL_ARG_NONNULL ((2)));
1433 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1435 _GL_CXXALIASWARN (unlinkat);
1436 #elif defined GNULIB_POSIXCHECK
1438 # if HAVE_RAW_DECL_UNLINKAT
1439 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1440 "use gnulib module openat for portability");
1446 /* Pause the execution of the current thread for N microseconds.
1447 Returns 0 on completion, or -1 on range error.
1448 See the POSIX:2001 specification
1449 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1450 # if @REPLACE_USLEEP@
1451 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1453 # define usleep rpl_usleep
1455 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1456 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1459 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1461 _GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1463 _GL_CXXALIASWARN (usleep);
1464 #elif defined GNULIB_POSIXCHECK
1466 # if HAVE_RAW_DECL_USLEEP
1467 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1468 "use gnulib module usleep for portability");
1474 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1475 See the POSIX:2008 specification
1476 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1477 # if @REPLACE_WRITE@
1478 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1480 # define write rpl_write
1482 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1483 _GL_ARG_NONNULL ((2)));
1484 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1486 /* Need to cast, because on mingw, the third parameter is
1488 and the return type is 'int'. */
1489 _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1491 _GL_CXXALIASWARN (write);
1495 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1496 #endif /* _@GUARD_PREFIX@_UNISTD_H */