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, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
79 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
80 /* But avoid namespace pollution on glibc systems. */
85 /* mingw declares getcwd in <io.h>, not in <unistd.h>. */
86 #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
87 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
88 # include <io.h> /* mingw32, mingw64 */
89 # include <direct.h> /* mingw64 */
92 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
93 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
94 /* But avoid namespace pollution on glibc systems. */
95 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
96 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
101 /* MSVC defines off_t in <sys/types.h>. */
104 # include <sys/types.h>
107 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
108 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
109 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
111 # include <sys/types.h>
114 /* Get getopt(), optarg, optind, opterr, optopt.
115 But avoid namespace pollution on glibc systems. */
116 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
120 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
122 /* The definition of _GL_ARG_NONNULL is copied here. */
124 /* The definition of _GL_WARN_ON_USE is copied here. */
127 /* Hide some function declarations from <winsock2.h>. */
129 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
130 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
131 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
133 # define socket socket_used_without_including_sys_socket_h
135 # define connect connect_used_without_including_sys_socket_h
137 # define accept accept_used_without_including_sys_socket_h
139 # define bind bind_used_without_including_sys_socket_h
141 # define getpeername getpeername_used_without_including_sys_socket_h
143 # define getsockname getsockname_used_without_including_sys_socket_h
145 # define getsockopt getsockopt_used_without_including_sys_socket_h
147 # define listen listen_used_without_including_sys_socket_h
149 # define recv recv_used_without_including_sys_socket_h
151 # define send send_used_without_including_sys_socket_h
153 # define recvfrom recvfrom_used_without_including_sys_socket_h
155 # define sendto sendto_used_without_including_sys_socket_h
157 # define setsockopt setsockopt_used_without_including_sys_socket_h
159 # define shutdown shutdown_used_without_including_sys_socket_h
161 _GL_WARN_ON_USE (socket,
162 "socket() used without including <sys/socket.h>");
163 _GL_WARN_ON_USE (connect,
164 "connect() used without including <sys/socket.h>");
165 _GL_WARN_ON_USE (accept,
166 "accept() used without including <sys/socket.h>");
167 _GL_WARN_ON_USE (bind,
168 "bind() used without including <sys/socket.h>");
169 _GL_WARN_ON_USE (getpeername,
170 "getpeername() used without including <sys/socket.h>");
171 _GL_WARN_ON_USE (getsockname,
172 "getsockname() used without including <sys/socket.h>");
173 _GL_WARN_ON_USE (getsockopt,
174 "getsockopt() used without including <sys/socket.h>");
175 _GL_WARN_ON_USE (listen,
176 "listen() used without including <sys/socket.h>");
177 _GL_WARN_ON_USE (recv,
178 "recv() used without including <sys/socket.h>");
179 _GL_WARN_ON_USE (send,
180 "send() used without including <sys/socket.h>");
181 _GL_WARN_ON_USE (recvfrom,
182 "recvfrom() used without including <sys/socket.h>");
183 _GL_WARN_ON_USE (sendto,
184 "sendto() used without including <sys/socket.h>");
185 _GL_WARN_ON_USE (setsockopt,
186 "setsockopt() used without including <sys/socket.h>");
187 _GL_WARN_ON_USE (shutdown,
188 "shutdown() used without including <sys/socket.h>");
191 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
192 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
194 # define select select_used_without_including_sys_select_h
196 _GL_WARN_ON_USE (select,
197 "select() used without including <sys/select.h>");
203 /* OS/2 EMX lacks these macros. */
205 # define STDIN_FILENO 0
207 #ifndef STDOUT_FILENO
208 # define STDOUT_FILENO 1
210 #ifndef STDERR_FILENO
211 # define STDERR_FILENO 2
214 /* Ensure *_OK macros exist. */
223 /* Declare overridden functions. */
226 #if defined GNULIB_POSIXCHECK
227 /* The access() function is a security risk. */
228 _GL_WARN_ON_USE (access, "the access function is a security risk - "
229 "use the gnulib module faccessat instead");
234 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
235 to GID (if GID is not -1). Follow symbolic links.
236 Return 0 if successful, otherwise -1 and errno set.
237 See the POSIX:2008 specification
238 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
240 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
242 # define chown rpl_chown
244 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
245 _GL_ARG_NONNULL ((1)));
246 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
249 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
250 _GL_ARG_NONNULL ((1)));
252 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
254 _GL_CXXALIASWARN (chown);
255 #elif defined GNULIB_POSIXCHECK
257 # if HAVE_RAW_DECL_CHOWN
258 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
259 "doesn't treat a uid or gid of -1 on some systems - "
260 "use gnulib module chown for portability");
267 /* Automatically included by modules that need a replacement for close. */
268 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
270 # define close rpl_close
272 _GL_FUNCDECL_RPL (close, int, (int fd));
273 _GL_CXXALIAS_RPL (close, int, (int fd));
275 _GL_CXXALIAS_SYS (close, int, (int fd));
277 _GL_CXXALIASWARN (close);
278 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
280 # define close close_used_without_requesting_gnulib_module_close
281 #elif defined GNULIB_POSIXCHECK
283 /* Assume close is always declared. */
284 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
285 "use gnulib module close for portability");
290 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
293 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
294 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
296 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
298 _GL_CXXALIASWARN (dup);
302 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
303 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
304 Return newfd if successful, otherwise -1 and errno set.
305 See the POSIX:2008 specification
306 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
308 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
309 # define dup2 rpl_dup2
311 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
312 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
315 _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
317 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
319 _GL_CXXALIASWARN (dup2);
320 #elif defined GNULIB_POSIXCHECK
322 # if HAVE_RAW_DECL_DUP2
323 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
324 "use gnulib module dup2 for portability");
330 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
332 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
333 and O_TEXT, O_BINARY (defined in "binary-io.h").
334 Close NEWFD first if it is open.
335 Return newfd if successful, otherwise -1 and errno set.
336 See the Linux man page at
337 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
339 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
340 # define dup3 rpl_dup3
342 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
343 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
345 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
346 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
348 _GL_CXXALIASWARN (dup3);
349 #elif defined GNULIB_POSIXCHECK
351 # if HAVE_RAW_DECL_DUP3
352 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
353 "use gnulib module dup3 for portability");
359 # if !@HAVE_DECL_ENVIRON@
360 /* Set of environment variables and values. An array of strings of the form
361 "VARIABLE=VALUE", terminated with a NULL. */
362 # if defined __APPLE__ && defined __MACH__
363 # include <crt_externs.h>
364 # define environ (*_NSGetEnviron ())
369 extern char **environ;
375 #elif defined GNULIB_POSIXCHECK
376 # if HAVE_RAW_DECL_ENVIRON
377 static inline char ***
382 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
383 "use gnulib module environ for portability");
385 # define environ (*rpl_environ ())
390 #if @GNULIB_EUIDACCESS@
391 /* Like access(), except that it uses the effective user id and group id of
392 the current process. */
393 # if !@HAVE_EUIDACCESS@
394 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
395 _GL_ARG_NONNULL ((1)));
397 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
398 _GL_CXXALIASWARN (euidaccess);
399 # if defined GNULIB_POSIXCHECK
400 /* Like access(), this function is a security risk. */
401 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
402 "use the gnulib module faccessat instead");
404 #elif defined GNULIB_POSIXCHECK
406 # if HAVE_RAW_DECL_EUIDACCESS
407 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
408 "use gnulib module euidaccess for portability");
413 #if @GNULIB_FACCESSAT@
414 # if !@HAVE_FACCESSAT@
415 _GL_FUNCDECL_SYS (faccessat, int,
416 (int fd, char const *file, int mode, int flag)
417 _GL_ARG_NONNULL ((2)));
419 _GL_CXXALIAS_SYS (faccessat, int,
420 (int fd, char const *file, int mode, int flag));
421 _GL_CXXALIASWARN (faccessat);
422 #elif defined GNULIB_POSIXCHECK
424 # if HAVE_RAW_DECL_FACCESSAT
425 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
426 "use gnulib module faccessat for portability");
432 /* Change the process' current working directory to the directory on which
433 the given file descriptor is open.
434 Return 0 if successful, otherwise -1 and errno set.
435 See the POSIX:2008 specification
436 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
438 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
440 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
441 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
442 _GL_ARG_NONNULL ((2));
443 _GL_EXTERN_C void _gl_unregister_fd (int fd);
444 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
445 _GL_EXTERN_C const char *_gl_directory_name (int fd);
448 # if !@HAVE_DECL_FCHDIR@
449 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
452 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
453 _GL_CXXALIASWARN (fchdir);
454 #elif defined GNULIB_POSIXCHECK
456 # if HAVE_RAW_DECL_FCHDIR
457 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
458 "use gnulib module fchdir for portability");
463 #if @GNULIB_FCHOWNAT@
464 # if @REPLACE_FCHOWNAT@
465 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
467 # define fchownat rpl_fchownat
469 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
470 uid_t owner, gid_t group, int flag)
471 _GL_ARG_NONNULL ((2)));
472 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
473 uid_t owner, gid_t group, int flag));
475 # if !@HAVE_FCHOWNAT@
476 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
477 uid_t owner, gid_t group, int flag)
478 _GL_ARG_NONNULL ((2)));
480 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
481 uid_t owner, gid_t group, int flag));
483 _GL_CXXALIASWARN (fchownat);
484 #elif defined GNULIB_POSIXCHECK
486 # if HAVE_RAW_DECL_FCHOWNAT
487 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
488 "use gnulib module openat for portability");
493 #if @GNULIB_FDATASYNC@
494 /* Synchronize changes to a file.
495 Return 0 if successful, otherwise -1 and errno set.
496 See POSIX:2008 specification
497 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
498 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
499 _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
501 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
502 _GL_CXXALIASWARN (fdatasync);
503 #elif defined GNULIB_POSIXCHECK
505 # if HAVE_RAW_DECL_FDATASYNC
506 _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
507 "use gnulib module fdatasync for portability");
513 /* Synchronize changes, including metadata, to a file.
514 Return 0 if successful, otherwise -1 and errno set.
515 See POSIX:2008 specification
516 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
518 _GL_FUNCDECL_SYS (fsync, int, (int fd));
520 _GL_CXXALIAS_SYS (fsync, int, (int fd));
521 _GL_CXXALIASWARN (fsync);
522 #elif defined GNULIB_POSIXCHECK
524 # if HAVE_RAW_DECL_FSYNC
525 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
526 "use gnulib module fsync for portability");
531 #if @GNULIB_FTRUNCATE@
532 /* Change the size of the file to which FD is opened to become equal to LENGTH.
533 Return 0 if successful, otherwise -1 and errno set.
534 See the POSIX:2008 specification
535 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
536 # if !@HAVE_FTRUNCATE@
537 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
539 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
540 _GL_CXXALIASWARN (ftruncate);
541 #elif defined GNULIB_POSIXCHECK
543 # if HAVE_RAW_DECL_FTRUNCATE
544 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
545 "use gnulib module ftruncate for portability");
551 /* Get the name of the current working directory, and put it in SIZE bytes
553 Return BUF if successful, or NULL if the directory couldn't be determined
554 or SIZE was too small.
555 See the POSIX:2008 specification
556 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
557 Additionally, the gnulib module 'getcwd' guarantees the following GNU
558 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
559 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
561 # if @REPLACE_GETCWD@
562 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
563 # define getcwd rpl_getcwd
565 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
566 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
568 /* Need to cast, because on mingw, the second parameter is
570 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
572 _GL_CXXALIASWARN (getcwd);
573 #elif defined GNULIB_POSIXCHECK
575 # if HAVE_RAW_DECL_GETCWD
576 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
577 "use gnulib module getcwd for portability");
582 #if @GNULIB_GETDOMAINNAME@
583 /* Return the NIS domain name of the machine.
584 WARNING! The NIS domain name is unrelated to the fully qualified host name
585 of the machine. It is also unrelated to email addresses.
586 WARNING! The NIS domain name is usually the empty string or "(none)" when
589 Put up to LEN bytes of the NIS domain name into NAME.
590 Null terminate it if the name is shorter than LEN.
591 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
592 Return 0 if successful, otherwise set errno and return -1. */
593 # if @REPLACE_GETDOMAINNAME@
594 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
595 # undef getdomainname
596 # define getdomainname rpl_getdomainname
598 _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
599 _GL_ARG_NONNULL ((1)));
600 _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
602 # if !@HAVE_DECL_GETDOMAINNAME@
603 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
604 _GL_ARG_NONNULL ((1)));
606 _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
608 _GL_CXXALIASWARN (getdomainname);
609 #elif defined GNULIB_POSIXCHECK
610 # undef getdomainname
611 # if HAVE_RAW_DECL_GETDOMAINNAME
612 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
613 "use gnulib module getdomainname for portability");
618 #if @GNULIB_GETDTABLESIZE@
619 /* Return the maximum number of file descriptors in the current process.
620 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
621 # if !@HAVE_GETDTABLESIZE@
622 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
624 _GL_CXXALIAS_SYS (getdtablesize, int, (void));
625 _GL_CXXALIASWARN (getdtablesize);
626 #elif defined GNULIB_POSIXCHECK
627 # undef getdtablesize
628 # if HAVE_RAW_DECL_GETDTABLESIZE
629 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
630 "use gnulib module getdtablesize for portability");
635 #if @GNULIB_GETGROUPS@
636 /* Return the supplemental groups that the current process belongs to.
637 It is unspecified whether the effective group id is in the list.
638 If N is 0, return the group count; otherwise, N describes how many
639 entries are available in GROUPS. Return -1 and set errno if N is
640 not 0 and not large enough. Fails with ENOSYS on some systems. */
641 # if @REPLACE_GETGROUPS@
642 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
644 # define getgroups rpl_getgroups
646 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
647 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
649 # if !@HAVE_GETGROUPS@
650 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
652 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
654 _GL_CXXALIASWARN (getgroups);
655 #elif defined GNULIB_POSIXCHECK
657 # if HAVE_RAW_DECL_GETGROUPS
658 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
659 "use gnulib module getgroups for portability");
664 #if @GNULIB_GETHOSTNAME@
665 /* Return the standard host name of the machine.
666 WARNING! The host name may or may not be fully qualified.
668 Put up to LEN bytes of the host name into NAME.
669 Null terminate it if the name is shorter than LEN.
670 If the host name is longer than LEN, set errno = EINVAL and return -1.
671 Return 0 if successful, otherwise set errno and return -1. */
672 # if @UNISTD_H_HAVE_WINSOCK2_H@
673 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
675 # define gethostname rpl_gethostname
677 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
678 _GL_ARG_NONNULL ((1)));
679 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
681 # if !@HAVE_GETHOSTNAME@
682 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
683 _GL_ARG_NONNULL ((1)));
685 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
688 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
690 _GL_CXXALIASWARN (gethostname);
691 #elif @UNISTD_H_HAVE_WINSOCK2_H@
693 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
694 #elif defined GNULIB_POSIXCHECK
696 # if HAVE_RAW_DECL_GETHOSTNAME
697 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
698 "use gnulib module gethostname for portability");
703 #if @GNULIB_GETLOGIN@
704 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
705 returns NULL with errno set.
707 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
709 Most programs don't need to use this function, because the information is
710 available through environment variables:
711 ${LOGNAME-$USER} on Unix platforms,
712 $USERNAME on native Windows platforms.
714 # if !@HAVE_GETLOGIN@
715 _GL_FUNCDECL_SYS (getlogin, char *, (void));
717 _GL_CXXALIAS_SYS (getlogin, char *, (void));
718 _GL_CXXALIASWARN (getlogin);
719 #elif defined GNULIB_POSIXCHECK
721 # if HAVE_RAW_DECL_GETLOGIN
722 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
723 "use gnulib module getlogin for portability");
728 #if @GNULIB_GETLOGIN_R@
729 /* Copies the user's login name to NAME.
730 The array pointed to by NAME has room for SIZE bytes.
732 Returns 0 if successful. Upon error, an error number is returned, or -1 in
733 the case that the login name cannot be found but no specific error is
734 provided (this case is hopefully rare but is left open by the POSIX spec).
736 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
738 Most programs don't need to use this function, because the information is
739 available through environment variables:
740 ${LOGNAME-$USER} on Unix platforms,
741 $USERNAME on native Windows platforms.
743 # if @REPLACE_GETLOGIN_R@
744 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
745 # define getlogin_r rpl_getlogin_r
747 _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
748 _GL_ARG_NONNULL ((1)));
749 _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
751 # if !@HAVE_DECL_GETLOGIN_R@
752 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
753 _GL_ARG_NONNULL ((1)));
755 /* Need to cast, because on Solaris 10 systems, the second argument is
757 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
759 _GL_CXXALIASWARN (getlogin_r);
760 #elif defined GNULIB_POSIXCHECK
762 # if HAVE_RAW_DECL_GETLOGIN_R
763 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
764 "use gnulib module getlogin_r for portability");
769 #if @GNULIB_GETPAGESIZE@
770 # if @REPLACE_GETPAGESIZE@
771 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
772 # define getpagesize rpl_getpagesize
774 _GL_FUNCDECL_RPL (getpagesize, int, (void));
775 _GL_CXXALIAS_RPL (getpagesize, int, (void));
777 # if !@HAVE_GETPAGESIZE@
778 # if !defined getpagesize
779 /* This is for POSIX systems. */
780 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
781 # if ! (defined __VMS && __VMS_VER < 70000000)
782 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
785 /* This is for older VMS. */
786 # if !defined _gl_getpagesize && defined __VMS
788 # define _gl_getpagesize() 8192
790 # define _gl_getpagesize() 512
793 /* This is for BeOS. */
794 # if !defined _gl_getpagesize && @HAVE_OS_H@
796 # if defined B_PAGE_SIZE
797 # define _gl_getpagesize() B_PAGE_SIZE
800 /* This is for AmigaOS4.0. */
801 # if !defined _gl_getpagesize && defined __amigaos4__
802 # define _gl_getpagesize() 2048
804 /* This is for older Unix systems. */
805 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
806 # include <sys/param.h>
807 # ifdef EXEC_PAGESIZE
808 # define _gl_getpagesize() EXEC_PAGESIZE
814 # define _gl_getpagesize() (NBPG * CLSIZE)
817 # define _gl_getpagesize() NBPC
822 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
823 # define getpagesize() _gl_getpagesize ()
825 # if !GNULIB_defined_getpagesize_function
829 return _gl_getpagesize ();
831 # define GNULIB_defined_getpagesize_function 1
836 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
837 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
839 # if @HAVE_DECL_GETPAGESIZE@
840 _GL_CXXALIASWARN (getpagesize);
842 #elif defined GNULIB_POSIXCHECK
844 # if HAVE_RAW_DECL_GETPAGESIZE
845 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
846 "use gnulib module getpagesize for portability");
851 #if @GNULIB_GETUSERSHELL@
852 /* Return the next valid login shell on the system, or NULL when the end of
853 the list has been reached. */
854 # if !@HAVE_DECL_GETUSERSHELL@
855 _GL_FUNCDECL_SYS (getusershell, char *, (void));
857 _GL_CXXALIAS_SYS (getusershell, char *, (void));
858 _GL_CXXALIASWARN (getusershell);
859 #elif defined GNULIB_POSIXCHECK
861 # if HAVE_RAW_DECL_GETUSERSHELL
862 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
863 "use gnulib module getusershell for portability");
867 #if @GNULIB_GETUSERSHELL@
868 /* Rewind to pointer that is advanced at each getusershell() call. */
869 # if !@HAVE_DECL_GETUSERSHELL@
870 _GL_FUNCDECL_SYS (setusershell, void, (void));
872 _GL_CXXALIAS_SYS (setusershell, void, (void));
873 _GL_CXXALIASWARN (setusershell);
874 #elif defined GNULIB_POSIXCHECK
876 # if HAVE_RAW_DECL_SETUSERSHELL
877 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
878 "use gnulib module getusershell for portability");
882 #if @GNULIB_GETUSERSHELL@
883 /* Free the pointer that is advanced at each getusershell() call and
884 associated resources. */
885 # if !@HAVE_DECL_GETUSERSHELL@
886 _GL_FUNCDECL_SYS (endusershell, void, (void));
888 _GL_CXXALIAS_SYS (endusershell, void, (void));
889 _GL_CXXALIASWARN (endusershell);
890 #elif defined GNULIB_POSIXCHECK
892 # if HAVE_RAW_DECL_ENDUSERSHELL
893 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
894 "use gnulib module getusershell for portability");
899 #if @GNULIB_GROUP_MEMBER@
900 /* Determine whether group id is in calling user's group list. */
901 # if !@HAVE_GROUP_MEMBER@
902 _GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
904 _GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
905 _GL_CXXALIASWARN (group_member);
906 #elif defined GNULIB_POSIXCHECK
908 # if HAVE_RAW_DECL_GROUP_MEMBER
909 _GL_WARN_ON_USE (group_member, "group_member is unportable - "
910 "use gnulib module group-member for portability");
916 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
917 to GID (if GID is not -1). Do not follow symbolic links.
918 Return 0 if successful, otherwise -1 and errno set.
919 See the POSIX:2008 specification
920 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
921 # if @REPLACE_LCHOWN@
922 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
924 # define lchown rpl_lchown
926 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
927 _GL_ARG_NONNULL ((1)));
928 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
931 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
932 _GL_ARG_NONNULL ((1)));
934 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
936 _GL_CXXALIASWARN (lchown);
937 #elif defined GNULIB_POSIXCHECK
939 # if HAVE_RAW_DECL_LCHOWN
940 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
941 "use gnulib module lchown for portability");
947 /* Create a new hard link for an existing file.
948 Return 0 if successful, otherwise -1 and errno set.
949 See POSIX:2008 specification
950 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
952 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
953 # define link rpl_link
955 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
956 _GL_ARG_NONNULL ((1, 2)));
957 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
960 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
961 _GL_ARG_NONNULL ((1, 2)));
963 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
965 _GL_CXXALIASWARN (link);
966 #elif defined GNULIB_POSIXCHECK
968 # if HAVE_RAW_DECL_LINK
969 _GL_WARN_ON_USE (link, "link is unportable - "
970 "use gnulib module link for portability");
976 /* Create a new hard link for an existing file, relative to two
977 directories. FLAG controls whether symlinks are followed.
978 Return 0 if successful, otherwise -1 and errno set. */
979 # if @REPLACE_LINKAT@
980 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
982 # define linkat rpl_linkat
984 _GL_FUNCDECL_RPL (linkat, int,
985 (int fd1, const char *path1, int fd2, const char *path2,
987 _GL_ARG_NONNULL ((2, 4)));
988 _GL_CXXALIAS_RPL (linkat, int,
989 (int fd1, const char *path1, int fd2, const char *path2,
993 _GL_FUNCDECL_SYS (linkat, int,
994 (int fd1, const char *path1, int fd2, const char *path2,
996 _GL_ARG_NONNULL ((2, 4)));
998 _GL_CXXALIAS_SYS (linkat, int,
999 (int fd1, const char *path1, int fd2, const char *path2,
1002 _GL_CXXALIASWARN (linkat);
1003 #elif defined GNULIB_POSIXCHECK
1005 # if HAVE_RAW_DECL_LINKAT
1006 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1007 "use gnulib module linkat for portability");
1013 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1014 Return the new offset if successful, otherwise -1 and errno set.
1015 See the POSIX:2008 specification
1016 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1017 # if @REPLACE_LSEEK@
1018 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1019 # define lseek rpl_lseek
1021 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1022 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1024 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1026 _GL_CXXALIASWARN (lseek);
1027 #elif defined GNULIB_POSIXCHECK
1029 # if HAVE_RAW_DECL_LSEEK
1030 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1031 "systems - use gnulib module lseek for portability");
1037 /* Create a pipe, defaulting to O_BINARY mode.
1038 Store the read-end as fd[0] and the write-end as fd[1].
1039 Return 0 upon success, or -1 with errno set upon failure. */
1041 _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1043 _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1044 _GL_CXXALIASWARN (pipe);
1045 #elif defined GNULIB_POSIXCHECK
1047 # if HAVE_RAW_DECL_PIPE
1048 _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1049 "use gnulib module pipe-posix for portability");
1055 /* Create a pipe, applying the given flags when opening the read-end of the
1056 pipe and the write-end of the pipe.
1057 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1058 and O_TEXT, O_BINARY (defined in "binary-io.h").
1059 Store the read-end as fd[0] and the write-end as fd[1].
1060 Return 0 upon success, or -1 with errno set upon failure.
1061 See also the Linux man page at
1062 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1064 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1065 # define pipe2 rpl_pipe2
1067 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1068 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1070 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1071 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1073 _GL_CXXALIASWARN (pipe2);
1074 #elif defined GNULIB_POSIXCHECK
1076 # if HAVE_RAW_DECL_PIPE2
1077 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1078 "use gnulib module pipe2 for portability");
1084 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1085 Return the number of bytes placed into BUF if successful, otherwise
1086 set errno and return -1. 0 indicates EOF.
1087 See the POSIX:2008 specification
1088 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1089 # if @REPLACE_PREAD@
1090 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1092 # define pread rpl_pread
1094 _GL_FUNCDECL_RPL (pread, ssize_t,
1095 (int fd, void *buf, size_t bufsize, off_t offset)
1096 _GL_ARG_NONNULL ((2)));
1097 _GL_CXXALIAS_RPL (pread, ssize_t,
1098 (int fd, void *buf, size_t bufsize, off_t offset));
1101 _GL_FUNCDECL_SYS (pread, ssize_t,
1102 (int fd, void *buf, size_t bufsize, off_t offset)
1103 _GL_ARG_NONNULL ((2)));
1105 _GL_CXXALIAS_SYS (pread, ssize_t,
1106 (int fd, void *buf, size_t bufsize, off_t offset));
1108 _GL_CXXALIASWARN (pread);
1109 #elif defined GNULIB_POSIXCHECK
1111 # if HAVE_RAW_DECL_PREAD
1112 _GL_WARN_ON_USE (pread, "pread is unportable - "
1113 "use gnulib module pread for portability");
1119 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1120 Return the number of bytes written if successful, otherwise
1121 set errno and return -1. 0 indicates nothing written. See the
1122 POSIX:2008 specification
1123 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1124 # if @REPLACE_PWRITE@
1125 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1127 # define pwrite rpl_pwrite
1129 _GL_FUNCDECL_RPL (pwrite, ssize_t,
1130 (int fd, const void *buf, size_t bufsize, off_t offset)
1131 _GL_ARG_NONNULL ((2)));
1132 _GL_CXXALIAS_RPL (pwrite, ssize_t,
1133 (int fd, const void *buf, size_t bufsize, off_t offset));
1136 _GL_FUNCDECL_SYS (pwrite, ssize_t,
1137 (int fd, const void *buf, size_t bufsize, off_t offset)
1138 _GL_ARG_NONNULL ((2)));
1140 _GL_CXXALIAS_SYS (pwrite, ssize_t,
1141 (int fd, const void *buf, size_t bufsize, off_t offset));
1143 _GL_CXXALIASWARN (pwrite);
1144 #elif defined GNULIB_POSIXCHECK
1146 # if HAVE_RAW_DECL_PWRITE
1147 _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1148 "use gnulib module pwrite for portability");
1154 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1155 at BUF. See the POSIX:2008 specification
1156 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1157 # if @REPLACE_READ@ && @GNULIB_UNISTD_H_NONBLOCKING@
1158 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1160 # define read rpl_read
1162 _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1163 _GL_ARG_NONNULL ((2)));
1164 _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1166 /* Need to cast, because on mingw, the third parameter is
1168 and the return type is 'int'. */
1169 _GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1171 _GL_CXXALIASWARN (read);
1175 #if @GNULIB_READLINK@
1176 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1177 bytes of it into BUF. Return the number of bytes placed into BUF if
1178 successful, otherwise -1 and errno set.
1179 See the POSIX:2008 specification
1180 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1181 # if @REPLACE_READLINK@
1182 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1183 # define readlink rpl_readlink
1185 _GL_FUNCDECL_RPL (readlink, ssize_t,
1186 (const char *file, char *buf, size_t bufsize)
1187 _GL_ARG_NONNULL ((1, 2)));
1188 _GL_CXXALIAS_RPL (readlink, ssize_t,
1189 (const char *file, char *buf, size_t bufsize));
1191 # if !@HAVE_READLINK@
1192 _GL_FUNCDECL_SYS (readlink, ssize_t,
1193 (const char *file, char *buf, size_t bufsize)
1194 _GL_ARG_NONNULL ((1, 2)));
1196 _GL_CXXALIAS_SYS (readlink, ssize_t,
1197 (const char *file, char *buf, size_t bufsize));
1199 _GL_CXXALIASWARN (readlink);
1200 #elif defined GNULIB_POSIXCHECK
1202 # if HAVE_RAW_DECL_READLINK
1203 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1204 "use gnulib module readlink for portability");
1209 #if @GNULIB_READLINKAT@
1210 # if !@HAVE_READLINKAT@
1211 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
1212 (int fd, char const *file, char *buf, size_t len)
1213 _GL_ARG_NONNULL ((2, 3)));
1215 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1216 (int fd, char const *file, char *buf, size_t len));
1217 _GL_CXXALIASWARN (readlinkat);
1218 #elif defined GNULIB_POSIXCHECK
1220 # if HAVE_RAW_DECL_READLINKAT
1221 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1222 "use gnulib module readlinkat for portability");
1228 /* Remove the directory DIR. */
1229 # if @REPLACE_RMDIR@
1230 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1231 # define rmdir rpl_rmdir
1233 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1234 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1236 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1238 _GL_CXXALIASWARN (rmdir);
1239 #elif defined GNULIB_POSIXCHECK
1241 # if HAVE_RAW_DECL_RMDIR
1242 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1243 "use gnulib module rmdir for portability");
1249 /* Pause the execution of the current thread for N seconds.
1250 Returns the number of seconds left to sleep.
1251 See the POSIX:2008 specification
1252 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1253 # if @REPLACE_SLEEP@
1254 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1256 # define sleep rpl_sleep
1258 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1259 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1262 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1264 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1266 _GL_CXXALIASWARN (sleep);
1267 #elif defined GNULIB_POSIXCHECK
1269 # if HAVE_RAW_DECL_SLEEP
1270 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1271 "use gnulib module sleep for portability");
1276 #if @GNULIB_SYMLINK@
1277 # if @REPLACE_SYMLINK@
1278 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1280 # define symlink rpl_symlink
1282 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1283 _GL_ARG_NONNULL ((1, 2)));
1284 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1286 # if !@HAVE_SYMLINK@
1287 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1288 _GL_ARG_NONNULL ((1, 2)));
1290 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1292 _GL_CXXALIASWARN (symlink);
1293 #elif defined GNULIB_POSIXCHECK
1295 # if HAVE_RAW_DECL_SYMLINK
1296 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1297 "use gnulib module symlink for portability");
1302 #if @GNULIB_SYMLINKAT@
1303 # if !@HAVE_SYMLINKAT@
1304 _GL_FUNCDECL_SYS (symlinkat, int,
1305 (char const *contents, int fd, char const *file)
1306 _GL_ARG_NONNULL ((1, 3)));
1308 _GL_CXXALIAS_SYS (symlinkat, int,
1309 (char const *contents, int fd, char const *file));
1310 _GL_CXXALIASWARN (symlinkat);
1311 #elif defined GNULIB_POSIXCHECK
1313 # if HAVE_RAW_DECL_SYMLINKAT
1314 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1315 "use gnulib module symlinkat for portability");
1320 #if @GNULIB_TTYNAME_R@
1321 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1322 open on in BUF. Return 0 on success, otherwise an error number. */
1323 # if @REPLACE_TTYNAME_R@
1324 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1326 # define ttyname_r rpl_ttyname_r
1328 _GL_FUNCDECL_RPL (ttyname_r, int,
1329 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1330 _GL_CXXALIAS_RPL (ttyname_r, int,
1331 (int fd, char *buf, size_t buflen));
1333 # if !@HAVE_DECL_TTYNAME_R@
1334 _GL_FUNCDECL_SYS (ttyname_r, int,
1335 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1337 _GL_CXXALIAS_SYS (ttyname_r, int,
1338 (int fd, char *buf, size_t buflen));
1340 _GL_CXXALIASWARN (ttyname_r);
1341 #elif defined GNULIB_POSIXCHECK
1343 # if HAVE_RAW_DECL_TTYNAME_R
1344 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1345 "use gnulib module ttyname_r for portability");
1351 # if @REPLACE_UNLINK@
1352 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1354 # define unlink rpl_unlink
1356 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1357 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
1359 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
1361 _GL_CXXALIASWARN (unlink);
1362 #elif defined GNULIB_POSIXCHECK
1364 # if HAVE_RAW_DECL_UNLINK
1365 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
1366 "use gnulib module unlink for portability");
1371 #if @GNULIB_UNLINKAT@
1372 # if @REPLACE_UNLINKAT@
1373 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1375 # define unlinkat rpl_unlinkat
1377 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1378 _GL_ARG_NONNULL ((2)));
1379 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1381 # if !@HAVE_UNLINKAT@
1382 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1383 _GL_ARG_NONNULL ((2)));
1385 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1387 _GL_CXXALIASWARN (unlinkat);
1388 #elif defined GNULIB_POSIXCHECK
1390 # if HAVE_RAW_DECL_UNLINKAT
1391 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1392 "use gnulib module openat for portability");
1398 /* Pause the execution of the current thread for N microseconds.
1399 Returns 0 on completion, or -1 on range error.
1400 See the POSIX:2001 specification
1401 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1402 # if @REPLACE_USLEEP@
1403 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1405 # define usleep rpl_usleep
1407 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1408 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1411 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1413 _GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1415 _GL_CXXALIASWARN (usleep);
1416 #elif defined GNULIB_POSIXCHECK
1418 # if HAVE_RAW_DECL_USLEEP
1419 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1420 "use gnulib module usleep for portability");
1426 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1427 See the POSIX:2008 specification
1428 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1429 # if @REPLACE_WRITE@ && (@GNULIB_UNISTD_H_NONBLOCKING@ || @GNULIB_UNISTD_H_SIGPIPE@)
1430 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1432 # define write rpl_write
1434 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1435 _GL_ARG_NONNULL ((2)));
1436 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1438 /* Need to cast, because on mingw, the third parameter is
1440 and the return type is 'int'. */
1441 _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1443 _GL_CXXALIASWARN (write);
1447 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1448 #endif /* _@GUARD_PREFIX@_UNISTD_H */