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 getcwd in
87 <io.h> and/or <direct.h>, not in <unistd.h>. */
88 #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
89 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
90 # include <io.h> /* mingw32, mingw64 */
91 # include <direct.h> /* mingw64, MSVC 9 */
94 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
95 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
96 /* But avoid namespace pollution on glibc systems. */
97 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
98 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
103 /* MSVC defines off_t in <sys/types.h>. */
106 # include <sys/types.h>
109 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
110 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
111 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
113 # include <sys/types.h>
116 /* Get getopt(), optarg, optind, opterr, optopt.
117 But avoid namespace pollution on glibc systems. */
118 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
122 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
124 /* The definition of _GL_ARG_NONNULL is copied here. */
126 /* The definition of _GL_WARN_ON_USE is copied here. */
129 /* Hide some function declarations from <winsock2.h>. */
131 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
132 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
133 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
135 # define socket socket_used_without_including_sys_socket_h
137 # define connect connect_used_without_including_sys_socket_h
139 # define accept accept_used_without_including_sys_socket_h
141 # define bind bind_used_without_including_sys_socket_h
143 # define getpeername getpeername_used_without_including_sys_socket_h
145 # define getsockname getsockname_used_without_including_sys_socket_h
147 # define getsockopt getsockopt_used_without_including_sys_socket_h
149 # define listen listen_used_without_including_sys_socket_h
151 # define recv recv_used_without_including_sys_socket_h
153 # define send send_used_without_including_sys_socket_h
155 # define recvfrom recvfrom_used_without_including_sys_socket_h
157 # define sendto sendto_used_without_including_sys_socket_h
159 # define setsockopt setsockopt_used_without_including_sys_socket_h
161 # define shutdown shutdown_used_without_including_sys_socket_h
163 _GL_WARN_ON_USE (socket,
164 "socket() used without including <sys/socket.h>");
165 _GL_WARN_ON_USE (connect,
166 "connect() used without including <sys/socket.h>");
167 _GL_WARN_ON_USE (accept,
168 "accept() used without including <sys/socket.h>");
169 _GL_WARN_ON_USE (bind,
170 "bind() used without including <sys/socket.h>");
171 _GL_WARN_ON_USE (getpeername,
172 "getpeername() used without including <sys/socket.h>");
173 _GL_WARN_ON_USE (getsockname,
174 "getsockname() used without including <sys/socket.h>");
175 _GL_WARN_ON_USE (getsockopt,
176 "getsockopt() used without including <sys/socket.h>");
177 _GL_WARN_ON_USE (listen,
178 "listen() used without including <sys/socket.h>");
179 _GL_WARN_ON_USE (recv,
180 "recv() used without including <sys/socket.h>");
181 _GL_WARN_ON_USE (send,
182 "send() used without including <sys/socket.h>");
183 _GL_WARN_ON_USE (recvfrom,
184 "recvfrom() used without including <sys/socket.h>");
185 _GL_WARN_ON_USE (sendto,
186 "sendto() used without including <sys/socket.h>");
187 _GL_WARN_ON_USE (setsockopt,
188 "setsockopt() used without including <sys/socket.h>");
189 _GL_WARN_ON_USE (shutdown,
190 "shutdown() used without including <sys/socket.h>");
193 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
194 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
196 # define select select_used_without_including_sys_select_h
198 _GL_WARN_ON_USE (select,
199 "select() used without including <sys/select.h>");
205 /* OS/2 EMX lacks these macros. */
207 # define STDIN_FILENO 0
209 #ifndef STDOUT_FILENO
210 # define STDOUT_FILENO 1
212 #ifndef STDERR_FILENO
213 # define STDERR_FILENO 2
216 /* Ensure *_OK macros exist. */
225 /* Declare overridden functions. */
228 #if defined GNULIB_POSIXCHECK
229 /* The access() function is a security risk. */
230 _GL_WARN_ON_USE (access, "the access function is a security risk - "
231 "use the gnulib module faccessat instead");
236 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
237 to GID (if GID is not -1). Follow symbolic links.
238 Return 0 if successful, otherwise -1 and errno set.
239 See the POSIX:2008 specification
240 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
242 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
244 # define chown rpl_chown
246 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
247 _GL_ARG_NONNULL ((1)));
248 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
251 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
252 _GL_ARG_NONNULL ((1)));
254 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
256 _GL_CXXALIASWARN (chown);
257 #elif defined GNULIB_POSIXCHECK
259 # if HAVE_RAW_DECL_CHOWN
260 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
261 "doesn't treat a uid or gid of -1 on some systems - "
262 "use gnulib module chown for portability");
269 /* Automatically included by modules that need a replacement for close. */
270 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
272 # define close rpl_close
274 _GL_FUNCDECL_RPL (close, int, (int fd));
275 _GL_CXXALIAS_RPL (close, int, (int fd));
277 _GL_CXXALIAS_SYS (close, int, (int fd));
279 _GL_CXXALIASWARN (close);
280 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
282 # define close close_used_without_requesting_gnulib_module_close
283 #elif defined GNULIB_POSIXCHECK
285 /* Assume close is always declared. */
286 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
287 "use gnulib module close for portability");
292 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
295 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
296 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
298 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
300 _GL_CXXALIASWARN (dup);
304 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
305 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
306 Return newfd if successful, otherwise -1 and errno set.
307 See the POSIX:2008 specification
308 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
310 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
311 # define dup2 rpl_dup2
313 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
314 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
317 _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
319 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
321 _GL_CXXALIASWARN (dup2);
322 #elif defined GNULIB_POSIXCHECK
324 # if HAVE_RAW_DECL_DUP2
325 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
326 "use gnulib module dup2 for portability");
332 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
334 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
335 and O_TEXT, O_BINARY (defined in "binary-io.h").
336 Close NEWFD first if it is open.
337 Return newfd if successful, otherwise -1 and errno set.
338 See the Linux man page at
339 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
341 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
342 # define dup3 rpl_dup3
344 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
345 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
347 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
348 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
350 _GL_CXXALIASWARN (dup3);
351 #elif defined GNULIB_POSIXCHECK
353 # if HAVE_RAW_DECL_DUP3
354 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
355 "use gnulib module dup3 for portability");
361 # if !@HAVE_DECL_ENVIRON@
362 /* Set of environment variables and values. An array of strings of the form
363 "VARIABLE=VALUE", terminated with a NULL. */
364 # if defined __APPLE__ && defined __MACH__
365 # include <crt_externs.h>
366 # define environ (*_NSGetEnviron ())
371 extern char **environ;
377 #elif defined GNULIB_POSIXCHECK
378 # if HAVE_RAW_DECL_ENVIRON
379 static inline char ***
384 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
385 "use gnulib module environ for portability");
387 # define environ (*rpl_environ ())
392 #if @GNULIB_EUIDACCESS@
393 /* Like access(), except that it uses the effective user id and group id of
394 the current process. */
395 # if !@HAVE_EUIDACCESS@
396 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
397 _GL_ARG_NONNULL ((1)));
399 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
400 _GL_CXXALIASWARN (euidaccess);
401 # if defined GNULIB_POSIXCHECK
402 /* Like access(), this function is a security risk. */
403 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
404 "use the gnulib module faccessat instead");
406 #elif defined GNULIB_POSIXCHECK
408 # if HAVE_RAW_DECL_EUIDACCESS
409 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
410 "use gnulib module euidaccess for portability");
415 #if @GNULIB_FACCESSAT@
416 # if !@HAVE_FACCESSAT@
417 _GL_FUNCDECL_SYS (faccessat, int,
418 (int fd, char const *file, int mode, int flag)
419 _GL_ARG_NONNULL ((2)));
421 _GL_CXXALIAS_SYS (faccessat, int,
422 (int fd, char const *file, int mode, int flag));
423 _GL_CXXALIASWARN (faccessat);
424 #elif defined GNULIB_POSIXCHECK
426 # if HAVE_RAW_DECL_FACCESSAT
427 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
428 "use gnulib module faccessat for portability");
434 /* Change the process' current working directory to the directory on which
435 the given file descriptor is open.
436 Return 0 if successful, otherwise -1 and errno set.
437 See the POSIX:2008 specification
438 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
440 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
442 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
443 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
444 _GL_ARG_NONNULL ((2));
445 _GL_EXTERN_C void _gl_unregister_fd (int fd);
446 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
447 _GL_EXTERN_C const char *_gl_directory_name (int fd);
450 # if !@HAVE_DECL_FCHDIR@
451 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
454 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
455 _GL_CXXALIASWARN (fchdir);
456 #elif defined GNULIB_POSIXCHECK
458 # if HAVE_RAW_DECL_FCHDIR
459 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
460 "use gnulib module fchdir for portability");
465 #if @GNULIB_FCHOWNAT@
466 # if @REPLACE_FCHOWNAT@
467 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
469 # define fchownat rpl_fchownat
471 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
472 uid_t owner, gid_t group, int flag)
473 _GL_ARG_NONNULL ((2)));
474 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
475 uid_t owner, gid_t group, int flag));
477 # if !@HAVE_FCHOWNAT@
478 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
479 uid_t owner, gid_t group, int flag)
480 _GL_ARG_NONNULL ((2)));
482 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
483 uid_t owner, gid_t group, int flag));
485 _GL_CXXALIASWARN (fchownat);
486 #elif defined GNULIB_POSIXCHECK
488 # if HAVE_RAW_DECL_FCHOWNAT
489 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
490 "use gnulib module openat for portability");
495 #if @GNULIB_FDATASYNC@
496 /* Synchronize changes to a file.
497 Return 0 if successful, otherwise -1 and errno set.
498 See POSIX:2008 specification
499 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
500 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
501 _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
503 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
504 _GL_CXXALIASWARN (fdatasync);
505 #elif defined GNULIB_POSIXCHECK
507 # if HAVE_RAW_DECL_FDATASYNC
508 _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
509 "use gnulib module fdatasync for portability");
515 /* Synchronize changes, including metadata, to a file.
516 Return 0 if successful, otherwise -1 and errno set.
517 See POSIX:2008 specification
518 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
520 _GL_FUNCDECL_SYS (fsync, int, (int fd));
522 _GL_CXXALIAS_SYS (fsync, int, (int fd));
523 _GL_CXXALIASWARN (fsync);
524 #elif defined GNULIB_POSIXCHECK
526 # if HAVE_RAW_DECL_FSYNC
527 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
528 "use gnulib module fsync for portability");
533 #if @GNULIB_FTRUNCATE@
534 /* Change the size of the file to which FD is opened to become equal to LENGTH.
535 Return 0 if successful, otherwise -1 and errno set.
536 See the POSIX:2008 specification
537 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
538 # if !@HAVE_FTRUNCATE@
539 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
541 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
542 _GL_CXXALIASWARN (ftruncate);
543 #elif defined GNULIB_POSIXCHECK
545 # if HAVE_RAW_DECL_FTRUNCATE
546 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
547 "use gnulib module ftruncate for portability");
553 /* Get the name of the current working directory, and put it in SIZE bytes
555 Return BUF if successful, or NULL if the directory couldn't be determined
556 or SIZE was too small.
557 See the POSIX:2008 specification
558 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
559 Additionally, the gnulib module 'getcwd' guarantees the following GNU
560 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
561 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
563 # if @REPLACE_GETCWD@
564 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
565 # define getcwd rpl_getcwd
567 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
568 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
570 /* Need to cast, because on mingw, the second parameter is
572 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
574 _GL_CXXALIASWARN (getcwd);
575 #elif defined GNULIB_POSIXCHECK
577 # if HAVE_RAW_DECL_GETCWD
578 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
579 "use gnulib module getcwd for portability");
584 #if @GNULIB_GETDOMAINNAME@
585 /* Return the NIS domain name of the machine.
586 WARNING! The NIS domain name is unrelated to the fully qualified host name
587 of the machine. It is also unrelated to email addresses.
588 WARNING! The NIS domain name is usually the empty string or "(none)" when
591 Put up to LEN bytes of the NIS domain name into NAME.
592 Null terminate it if the name is shorter than LEN.
593 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
594 Return 0 if successful, otherwise set errno and return -1. */
595 # if @REPLACE_GETDOMAINNAME@
596 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
597 # undef getdomainname
598 # define getdomainname rpl_getdomainname
600 _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
601 _GL_ARG_NONNULL ((1)));
602 _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
604 # if !@HAVE_DECL_GETDOMAINNAME@
605 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
606 _GL_ARG_NONNULL ((1)));
608 _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
610 _GL_CXXALIASWARN (getdomainname);
611 #elif defined GNULIB_POSIXCHECK
612 # undef getdomainname
613 # if HAVE_RAW_DECL_GETDOMAINNAME
614 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
615 "use gnulib module getdomainname for portability");
620 #if @GNULIB_GETDTABLESIZE@
621 /* Return the maximum number of file descriptors in the current process.
622 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
623 # if !@HAVE_GETDTABLESIZE@
624 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
626 _GL_CXXALIAS_SYS (getdtablesize, int, (void));
627 _GL_CXXALIASWARN (getdtablesize);
628 #elif defined GNULIB_POSIXCHECK
629 # undef getdtablesize
630 # if HAVE_RAW_DECL_GETDTABLESIZE
631 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
632 "use gnulib module getdtablesize for portability");
637 #if @GNULIB_GETGROUPS@
638 /* Return the supplemental groups that the current process belongs to.
639 It is unspecified whether the effective group id is in the list.
640 If N is 0, return the group count; otherwise, N describes how many
641 entries are available in GROUPS. Return -1 and set errno if N is
642 not 0 and not large enough. Fails with ENOSYS on some systems. */
643 # if @REPLACE_GETGROUPS@
644 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
646 # define getgroups rpl_getgroups
648 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
649 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
651 # if !@HAVE_GETGROUPS@
652 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
654 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
656 _GL_CXXALIASWARN (getgroups);
657 #elif defined GNULIB_POSIXCHECK
659 # if HAVE_RAW_DECL_GETGROUPS
660 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
661 "use gnulib module getgroups for portability");
666 #if @GNULIB_GETHOSTNAME@
667 /* Return the standard host name of the machine.
668 WARNING! The host name may or may not be fully qualified.
670 Put up to LEN bytes of the host name into NAME.
671 Null terminate it if the name is shorter than LEN.
672 If the host name is longer than LEN, set errno = EINVAL and return -1.
673 Return 0 if successful, otherwise set errno and return -1. */
674 # if @UNISTD_H_HAVE_WINSOCK2_H@
675 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
677 # define gethostname rpl_gethostname
679 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
680 _GL_ARG_NONNULL ((1)));
681 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
683 # if !@HAVE_GETHOSTNAME@
684 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
685 _GL_ARG_NONNULL ((1)));
687 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
690 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
692 _GL_CXXALIASWARN (gethostname);
693 #elif @UNISTD_H_HAVE_WINSOCK2_H@
695 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
696 #elif defined GNULIB_POSIXCHECK
698 # if HAVE_RAW_DECL_GETHOSTNAME
699 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
700 "use gnulib module gethostname for portability");
705 #if @GNULIB_GETLOGIN@
706 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
707 returns NULL with errno set.
709 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
711 Most programs don't need to use this function, because the information is
712 available through environment variables:
713 ${LOGNAME-$USER} on Unix platforms,
714 $USERNAME on native Windows platforms.
716 # if !@HAVE_GETLOGIN@
717 _GL_FUNCDECL_SYS (getlogin, char *, (void));
719 _GL_CXXALIAS_SYS (getlogin, char *, (void));
720 _GL_CXXALIASWARN (getlogin);
721 #elif defined GNULIB_POSIXCHECK
723 # if HAVE_RAW_DECL_GETLOGIN
724 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
725 "use gnulib module getlogin for portability");
730 #if @GNULIB_GETLOGIN_R@
731 /* Copies the user's login name to NAME.
732 The array pointed to by NAME has room for SIZE bytes.
734 Returns 0 if successful. Upon error, an error number is returned, or -1 in
735 the case that the login name cannot be found but no specific error is
736 provided (this case is hopefully rare but is left open by the POSIX spec).
738 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
740 Most programs don't need to use this function, because the information is
741 available through environment variables:
742 ${LOGNAME-$USER} on Unix platforms,
743 $USERNAME on native Windows platforms.
745 # if @REPLACE_GETLOGIN_R@
746 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
747 # define getlogin_r rpl_getlogin_r
749 _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
750 _GL_ARG_NONNULL ((1)));
751 _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
753 # if !@HAVE_DECL_GETLOGIN_R@
754 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
755 _GL_ARG_NONNULL ((1)));
757 /* Need to cast, because on Solaris 10 systems, the second argument is
759 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
761 _GL_CXXALIASWARN (getlogin_r);
762 #elif defined GNULIB_POSIXCHECK
764 # if HAVE_RAW_DECL_GETLOGIN_R
765 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
766 "use gnulib module getlogin_r for portability");
771 #if @GNULIB_GETPAGESIZE@
772 # if @REPLACE_GETPAGESIZE@
773 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
774 # define getpagesize rpl_getpagesize
776 _GL_FUNCDECL_RPL (getpagesize, int, (void));
777 _GL_CXXALIAS_RPL (getpagesize, int, (void));
779 # if !@HAVE_GETPAGESIZE@
780 # if !defined getpagesize
781 /* This is for POSIX systems. */
782 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
783 # if ! (defined __VMS && __VMS_VER < 70000000)
784 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
787 /* This is for older VMS. */
788 # if !defined _gl_getpagesize && defined __VMS
790 # define _gl_getpagesize() 8192
792 # define _gl_getpagesize() 512
795 /* This is for BeOS. */
796 # if !defined _gl_getpagesize && @HAVE_OS_H@
798 # if defined B_PAGE_SIZE
799 # define _gl_getpagesize() B_PAGE_SIZE
802 /* This is for AmigaOS4.0. */
803 # if !defined _gl_getpagesize && defined __amigaos4__
804 # define _gl_getpagesize() 2048
806 /* This is for older Unix systems. */
807 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
808 # include <sys/param.h>
809 # ifdef EXEC_PAGESIZE
810 # define _gl_getpagesize() EXEC_PAGESIZE
816 # define _gl_getpagesize() (NBPG * CLSIZE)
819 # define _gl_getpagesize() NBPC
824 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
825 # define getpagesize() _gl_getpagesize ()
827 # if !GNULIB_defined_getpagesize_function
831 return _gl_getpagesize ();
833 # define GNULIB_defined_getpagesize_function 1
838 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
839 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
841 # if @HAVE_DECL_GETPAGESIZE@
842 _GL_CXXALIASWARN (getpagesize);
844 #elif defined GNULIB_POSIXCHECK
846 # if HAVE_RAW_DECL_GETPAGESIZE
847 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
848 "use gnulib module getpagesize for portability");
853 #if @GNULIB_GETUSERSHELL@
854 /* Return the next valid login shell on the system, or NULL when the end of
855 the list has been reached. */
856 # if !@HAVE_DECL_GETUSERSHELL@
857 _GL_FUNCDECL_SYS (getusershell, char *, (void));
859 _GL_CXXALIAS_SYS (getusershell, char *, (void));
860 _GL_CXXALIASWARN (getusershell);
861 #elif defined GNULIB_POSIXCHECK
863 # if HAVE_RAW_DECL_GETUSERSHELL
864 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
865 "use gnulib module getusershell for portability");
869 #if @GNULIB_GETUSERSHELL@
870 /* Rewind to pointer that is advanced at each getusershell() call. */
871 # if !@HAVE_DECL_GETUSERSHELL@
872 _GL_FUNCDECL_SYS (setusershell, void, (void));
874 _GL_CXXALIAS_SYS (setusershell, void, (void));
875 _GL_CXXALIASWARN (setusershell);
876 #elif defined GNULIB_POSIXCHECK
878 # if HAVE_RAW_DECL_SETUSERSHELL
879 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
880 "use gnulib module getusershell for portability");
884 #if @GNULIB_GETUSERSHELL@
885 /* Free the pointer that is advanced at each getusershell() call and
886 associated resources. */
887 # if !@HAVE_DECL_GETUSERSHELL@
888 _GL_FUNCDECL_SYS (endusershell, void, (void));
890 _GL_CXXALIAS_SYS (endusershell, void, (void));
891 _GL_CXXALIASWARN (endusershell);
892 #elif defined GNULIB_POSIXCHECK
894 # if HAVE_RAW_DECL_ENDUSERSHELL
895 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
896 "use gnulib module getusershell for portability");
901 #if @GNULIB_GROUP_MEMBER@
902 /* Determine whether group id is in calling user's group list. */
903 # if !@HAVE_GROUP_MEMBER@
904 _GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
906 _GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
907 _GL_CXXALIASWARN (group_member);
908 #elif defined GNULIB_POSIXCHECK
910 # if HAVE_RAW_DECL_GROUP_MEMBER
911 _GL_WARN_ON_USE (group_member, "group_member is unportable - "
912 "use gnulib module group-member for portability");
918 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
919 to GID (if GID is not -1). Do not follow symbolic links.
920 Return 0 if successful, otherwise -1 and errno set.
921 See the POSIX:2008 specification
922 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
923 # if @REPLACE_LCHOWN@
924 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
926 # define lchown rpl_lchown
928 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
929 _GL_ARG_NONNULL ((1)));
930 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
933 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
934 _GL_ARG_NONNULL ((1)));
936 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
938 _GL_CXXALIASWARN (lchown);
939 #elif defined GNULIB_POSIXCHECK
941 # if HAVE_RAW_DECL_LCHOWN
942 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
943 "use gnulib module lchown for portability");
949 /* Create a new hard link for an existing file.
950 Return 0 if successful, otherwise -1 and errno set.
951 See POSIX:2008 specification
952 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
954 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
955 # define link rpl_link
957 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
958 _GL_ARG_NONNULL ((1, 2)));
959 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
962 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
963 _GL_ARG_NONNULL ((1, 2)));
965 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
967 _GL_CXXALIASWARN (link);
968 #elif defined GNULIB_POSIXCHECK
970 # if HAVE_RAW_DECL_LINK
971 _GL_WARN_ON_USE (link, "link is unportable - "
972 "use gnulib module link for portability");
978 /* Create a new hard link for an existing file, relative to two
979 directories. FLAG controls whether symlinks are followed.
980 Return 0 if successful, otherwise -1 and errno set. */
981 # if @REPLACE_LINKAT@
982 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
984 # define linkat rpl_linkat
986 _GL_FUNCDECL_RPL (linkat, int,
987 (int fd1, const char *path1, int fd2, const char *path2,
989 _GL_ARG_NONNULL ((2, 4)));
990 _GL_CXXALIAS_RPL (linkat, int,
991 (int fd1, const char *path1, int fd2, const char *path2,
995 _GL_FUNCDECL_SYS (linkat, int,
996 (int fd1, const char *path1, int fd2, const char *path2,
998 _GL_ARG_NONNULL ((2, 4)));
1000 _GL_CXXALIAS_SYS (linkat, int,
1001 (int fd1, const char *path1, int fd2, const char *path2,
1004 _GL_CXXALIASWARN (linkat);
1005 #elif defined GNULIB_POSIXCHECK
1007 # if HAVE_RAW_DECL_LINKAT
1008 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1009 "use gnulib module linkat for portability");
1015 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1016 Return the new offset if successful, otherwise -1 and errno set.
1017 See the POSIX:2008 specification
1018 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1019 # if @REPLACE_LSEEK@
1020 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1021 # define lseek rpl_lseek
1023 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1024 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1026 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1028 _GL_CXXALIASWARN (lseek);
1029 #elif defined GNULIB_POSIXCHECK
1031 # if HAVE_RAW_DECL_LSEEK
1032 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1033 "systems - use gnulib module lseek for portability");
1039 /* Create a pipe, defaulting to O_BINARY mode.
1040 Store the read-end as fd[0] and the write-end as fd[1].
1041 Return 0 upon success, or -1 with errno set upon failure. */
1043 _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1045 _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1046 _GL_CXXALIASWARN (pipe);
1047 #elif defined GNULIB_POSIXCHECK
1049 # if HAVE_RAW_DECL_PIPE
1050 _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1051 "use gnulib module pipe-posix for portability");
1057 /* Create a pipe, applying the given flags when opening the read-end of the
1058 pipe and the write-end of the pipe.
1059 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1060 and O_TEXT, O_BINARY (defined in "binary-io.h").
1061 Store the read-end as fd[0] and the write-end as fd[1].
1062 Return 0 upon success, or -1 with errno set upon failure.
1063 See also the Linux man page at
1064 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1066 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1067 # define pipe2 rpl_pipe2
1069 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1070 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1072 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1073 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1075 _GL_CXXALIASWARN (pipe2);
1076 #elif defined GNULIB_POSIXCHECK
1078 # if HAVE_RAW_DECL_PIPE2
1079 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1080 "use gnulib module pipe2 for portability");
1086 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1087 Return the number of bytes placed into BUF if successful, otherwise
1088 set errno and return -1. 0 indicates EOF.
1089 See the POSIX:2008 specification
1090 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1091 # if @REPLACE_PREAD@
1092 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1094 # define pread rpl_pread
1096 _GL_FUNCDECL_RPL (pread, ssize_t,
1097 (int fd, void *buf, size_t bufsize, off_t offset)
1098 _GL_ARG_NONNULL ((2)));
1099 _GL_CXXALIAS_RPL (pread, ssize_t,
1100 (int fd, void *buf, size_t bufsize, off_t offset));
1103 _GL_FUNCDECL_SYS (pread, ssize_t,
1104 (int fd, void *buf, size_t bufsize, off_t offset)
1105 _GL_ARG_NONNULL ((2)));
1107 _GL_CXXALIAS_SYS (pread, ssize_t,
1108 (int fd, void *buf, size_t bufsize, off_t offset));
1110 _GL_CXXALIASWARN (pread);
1111 #elif defined GNULIB_POSIXCHECK
1113 # if HAVE_RAW_DECL_PREAD
1114 _GL_WARN_ON_USE (pread, "pread is unportable - "
1115 "use gnulib module pread for portability");
1121 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1122 Return the number of bytes written if successful, otherwise
1123 set errno and return -1. 0 indicates nothing written. See the
1124 POSIX:2008 specification
1125 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1126 # if @REPLACE_PWRITE@
1127 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1129 # define pwrite rpl_pwrite
1131 _GL_FUNCDECL_RPL (pwrite, ssize_t,
1132 (int fd, const void *buf, size_t bufsize, off_t offset)
1133 _GL_ARG_NONNULL ((2)));
1134 _GL_CXXALIAS_RPL (pwrite, ssize_t,
1135 (int fd, const void *buf, size_t bufsize, off_t offset));
1138 _GL_FUNCDECL_SYS (pwrite, ssize_t,
1139 (int fd, const void *buf, size_t bufsize, off_t offset)
1140 _GL_ARG_NONNULL ((2)));
1142 _GL_CXXALIAS_SYS (pwrite, ssize_t,
1143 (int fd, const void *buf, size_t bufsize, off_t offset));
1145 _GL_CXXALIASWARN (pwrite);
1146 #elif defined GNULIB_POSIXCHECK
1148 # if HAVE_RAW_DECL_PWRITE
1149 _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1150 "use gnulib module pwrite for portability");
1156 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1157 at BUF. See the POSIX:2008 specification
1158 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1159 # if @REPLACE_READ@ && @GNULIB_UNISTD_H_NONBLOCKING@
1160 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1162 # define read rpl_read
1164 _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1165 _GL_ARG_NONNULL ((2)));
1166 _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1168 /* Need to cast, because on mingw, the third parameter is
1170 and the return type is 'int'. */
1171 _GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1173 _GL_CXXALIASWARN (read);
1177 #if @GNULIB_READLINK@
1178 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1179 bytes of it into BUF. Return the number of bytes placed into BUF if
1180 successful, otherwise -1 and errno set.
1181 See the POSIX:2008 specification
1182 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1183 # if @REPLACE_READLINK@
1184 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1185 # define readlink rpl_readlink
1187 _GL_FUNCDECL_RPL (readlink, ssize_t,
1188 (const char *file, char *buf, size_t bufsize)
1189 _GL_ARG_NONNULL ((1, 2)));
1190 _GL_CXXALIAS_RPL (readlink, ssize_t,
1191 (const char *file, char *buf, size_t bufsize));
1193 # if !@HAVE_READLINK@
1194 _GL_FUNCDECL_SYS (readlink, ssize_t,
1195 (const char *file, char *buf, size_t bufsize)
1196 _GL_ARG_NONNULL ((1, 2)));
1198 _GL_CXXALIAS_SYS (readlink, ssize_t,
1199 (const char *file, char *buf, size_t bufsize));
1201 _GL_CXXALIASWARN (readlink);
1202 #elif defined GNULIB_POSIXCHECK
1204 # if HAVE_RAW_DECL_READLINK
1205 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1206 "use gnulib module readlink for portability");
1211 #if @GNULIB_READLINKAT@
1212 # if !@HAVE_READLINKAT@
1213 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
1214 (int fd, char const *file, char *buf, size_t len)
1215 _GL_ARG_NONNULL ((2, 3)));
1217 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1218 (int fd, char const *file, char *buf, size_t len));
1219 _GL_CXXALIASWARN (readlinkat);
1220 #elif defined GNULIB_POSIXCHECK
1222 # if HAVE_RAW_DECL_READLINKAT
1223 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1224 "use gnulib module readlinkat for portability");
1230 /* Remove the directory DIR. */
1231 # if @REPLACE_RMDIR@
1232 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1233 # define rmdir rpl_rmdir
1235 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1236 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1238 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1240 _GL_CXXALIASWARN (rmdir);
1241 #elif defined GNULIB_POSIXCHECK
1243 # if HAVE_RAW_DECL_RMDIR
1244 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1245 "use gnulib module rmdir for portability");
1251 /* Pause the execution of the current thread for N seconds.
1252 Returns the number of seconds left to sleep.
1253 See the POSIX:2008 specification
1254 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1255 # if @REPLACE_SLEEP@
1256 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1258 # define sleep rpl_sleep
1260 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1261 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1264 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1266 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1268 _GL_CXXALIASWARN (sleep);
1269 #elif defined GNULIB_POSIXCHECK
1271 # if HAVE_RAW_DECL_SLEEP
1272 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1273 "use gnulib module sleep for portability");
1278 #if @GNULIB_SYMLINK@
1279 # if @REPLACE_SYMLINK@
1280 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1282 # define symlink rpl_symlink
1284 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1285 _GL_ARG_NONNULL ((1, 2)));
1286 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1288 # if !@HAVE_SYMLINK@
1289 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1290 _GL_ARG_NONNULL ((1, 2)));
1292 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1294 _GL_CXXALIASWARN (symlink);
1295 #elif defined GNULIB_POSIXCHECK
1297 # if HAVE_RAW_DECL_SYMLINK
1298 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1299 "use gnulib module symlink for portability");
1304 #if @GNULIB_SYMLINKAT@
1305 # if !@HAVE_SYMLINKAT@
1306 _GL_FUNCDECL_SYS (symlinkat, int,
1307 (char const *contents, int fd, char const *file)
1308 _GL_ARG_NONNULL ((1, 3)));
1310 _GL_CXXALIAS_SYS (symlinkat, int,
1311 (char const *contents, int fd, char const *file));
1312 _GL_CXXALIASWARN (symlinkat);
1313 #elif defined GNULIB_POSIXCHECK
1315 # if HAVE_RAW_DECL_SYMLINKAT
1316 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1317 "use gnulib module symlinkat for portability");
1322 #if @GNULIB_TTYNAME_R@
1323 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1324 open on in BUF. Return 0 on success, otherwise an error number. */
1325 # if @REPLACE_TTYNAME_R@
1326 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1328 # define ttyname_r rpl_ttyname_r
1330 _GL_FUNCDECL_RPL (ttyname_r, int,
1331 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1332 _GL_CXXALIAS_RPL (ttyname_r, int,
1333 (int fd, char *buf, size_t buflen));
1335 # if !@HAVE_DECL_TTYNAME_R@
1336 _GL_FUNCDECL_SYS (ttyname_r, int,
1337 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1339 _GL_CXXALIAS_SYS (ttyname_r, int,
1340 (int fd, char *buf, size_t buflen));
1342 _GL_CXXALIASWARN (ttyname_r);
1343 #elif defined GNULIB_POSIXCHECK
1345 # if HAVE_RAW_DECL_TTYNAME_R
1346 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1347 "use gnulib module ttyname_r for portability");
1353 # if @REPLACE_UNLINK@
1354 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1356 # define unlink rpl_unlink
1358 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1359 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
1361 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
1363 _GL_CXXALIASWARN (unlink);
1364 #elif defined GNULIB_POSIXCHECK
1366 # if HAVE_RAW_DECL_UNLINK
1367 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
1368 "use gnulib module unlink for portability");
1373 #if @GNULIB_UNLINKAT@
1374 # if @REPLACE_UNLINKAT@
1375 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1377 # define unlinkat rpl_unlinkat
1379 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1380 _GL_ARG_NONNULL ((2)));
1381 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1383 # if !@HAVE_UNLINKAT@
1384 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1385 _GL_ARG_NONNULL ((2)));
1387 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1389 _GL_CXXALIASWARN (unlinkat);
1390 #elif defined GNULIB_POSIXCHECK
1392 # if HAVE_RAW_DECL_UNLINKAT
1393 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1394 "use gnulib module openat for portability");
1400 /* Pause the execution of the current thread for N microseconds.
1401 Returns 0 on completion, or -1 on range error.
1402 See the POSIX:2001 specification
1403 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1404 # if @REPLACE_USLEEP@
1405 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1407 # define usleep rpl_usleep
1409 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1410 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1413 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1415 _GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1417 _GL_CXXALIASWARN (usleep);
1418 #elif defined GNULIB_POSIXCHECK
1420 # if HAVE_RAW_DECL_USLEEP
1421 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1422 "use gnulib module usleep for portability");
1428 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1429 See the POSIX:2008 specification
1430 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1431 # if @REPLACE_WRITE@ && (@GNULIB_UNISTD_H_NONBLOCKING@ || @GNULIB_UNISTD_H_SIGPIPE@)
1432 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1434 # define write rpl_write
1436 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1437 _GL_ARG_NONNULL ((2)));
1438 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1440 /* Need to cast, because on mingw, the third parameter is
1442 and the return type is 'int'. */
1443 _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1445 _GL_CXXALIASWARN (write);
1449 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1450 #endif /* _@GUARD_PREFIX@_UNISTD_H */