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 /* mingw declares getcwd in <io.h>, not in <unistd.h>. */
87 #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
88 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
89 # include <io.h> /* mingw32, mingw64 */
90 # include <direct.h> /* mingw64 */
93 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
94 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
95 /* But avoid namespace pollution on glibc systems. */
96 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
97 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
102 /* MSVC defines off_t in <sys/types.h>. */
105 # include <sys/types.h>
108 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
109 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
110 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
112 # include <sys/types.h>
115 /* Get getopt(), optarg, optind, opterr, optopt.
116 But avoid namespace pollution on glibc systems. */
117 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
121 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
123 /* The definition of _GL_ARG_NONNULL is copied here. */
125 /* The definition of _GL_WARN_ON_USE is copied here. */
128 /* Hide some function declarations from <winsock2.h>. */
130 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
131 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
132 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
134 # define socket socket_used_without_including_sys_socket_h
136 # define connect connect_used_without_including_sys_socket_h
138 # define accept accept_used_without_including_sys_socket_h
140 # define bind bind_used_without_including_sys_socket_h
142 # define getpeername getpeername_used_without_including_sys_socket_h
144 # define getsockname getsockname_used_without_including_sys_socket_h
146 # define getsockopt getsockopt_used_without_including_sys_socket_h
148 # define listen listen_used_without_including_sys_socket_h
150 # define recv recv_used_without_including_sys_socket_h
152 # define send send_used_without_including_sys_socket_h
154 # define recvfrom recvfrom_used_without_including_sys_socket_h
156 # define sendto sendto_used_without_including_sys_socket_h
158 # define setsockopt setsockopt_used_without_including_sys_socket_h
160 # define shutdown shutdown_used_without_including_sys_socket_h
162 _GL_WARN_ON_USE (socket,
163 "socket() used without including <sys/socket.h>");
164 _GL_WARN_ON_USE (connect,
165 "connect() used without including <sys/socket.h>");
166 _GL_WARN_ON_USE (accept,
167 "accept() used without including <sys/socket.h>");
168 _GL_WARN_ON_USE (bind,
169 "bind() used without including <sys/socket.h>");
170 _GL_WARN_ON_USE (getpeername,
171 "getpeername() used without including <sys/socket.h>");
172 _GL_WARN_ON_USE (getsockname,
173 "getsockname() used without including <sys/socket.h>");
174 _GL_WARN_ON_USE (getsockopt,
175 "getsockopt() used without including <sys/socket.h>");
176 _GL_WARN_ON_USE (listen,
177 "listen() used without including <sys/socket.h>");
178 _GL_WARN_ON_USE (recv,
179 "recv() used without including <sys/socket.h>");
180 _GL_WARN_ON_USE (send,
181 "send() used without including <sys/socket.h>");
182 _GL_WARN_ON_USE (recvfrom,
183 "recvfrom() used without including <sys/socket.h>");
184 _GL_WARN_ON_USE (sendto,
185 "sendto() used without including <sys/socket.h>");
186 _GL_WARN_ON_USE (setsockopt,
187 "setsockopt() used without including <sys/socket.h>");
188 _GL_WARN_ON_USE (shutdown,
189 "shutdown() used without including <sys/socket.h>");
192 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
193 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
195 # define select select_used_without_including_sys_select_h
197 _GL_WARN_ON_USE (select,
198 "select() used without including <sys/select.h>");
204 /* OS/2 EMX lacks these macros. */
206 # define STDIN_FILENO 0
208 #ifndef STDOUT_FILENO
209 # define STDOUT_FILENO 1
211 #ifndef STDERR_FILENO
212 # define STDERR_FILENO 2
215 /* Ensure *_OK macros exist. */
224 /* Declare overridden functions. */
227 #if defined GNULIB_POSIXCHECK
228 /* The access() function is a security risk. */
229 _GL_WARN_ON_USE (access, "the access function is a security risk - "
230 "use the gnulib module faccessat instead");
235 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
236 to GID (if GID is not -1). Follow symbolic links.
237 Return 0 if successful, otherwise -1 and errno set.
238 See the POSIX:2008 specification
239 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
241 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
243 # define chown rpl_chown
245 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
246 _GL_ARG_NONNULL ((1)));
247 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
250 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
251 _GL_ARG_NONNULL ((1)));
253 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
255 _GL_CXXALIASWARN (chown);
256 #elif defined GNULIB_POSIXCHECK
258 # if HAVE_RAW_DECL_CHOWN
259 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
260 "doesn't treat a uid or gid of -1 on some systems - "
261 "use gnulib module chown for portability");
268 /* Automatically included by modules that need a replacement for close. */
269 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
271 # define close rpl_close
273 _GL_FUNCDECL_RPL (close, int, (int fd));
274 _GL_CXXALIAS_RPL (close, int, (int fd));
276 _GL_CXXALIAS_SYS (close, int, (int fd));
278 _GL_CXXALIASWARN (close);
279 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
281 # define close close_used_without_requesting_gnulib_module_close
282 #elif defined GNULIB_POSIXCHECK
284 /* Assume close is always declared. */
285 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
286 "use gnulib module close for portability");
291 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
294 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
295 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
297 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
299 _GL_CXXALIASWARN (dup);
303 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
304 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
305 Return newfd if successful, otherwise -1 and errno set.
306 See the POSIX:2008 specification
307 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
309 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
310 # define dup2 rpl_dup2
312 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
313 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
316 _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
318 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
320 _GL_CXXALIASWARN (dup2);
321 #elif defined GNULIB_POSIXCHECK
323 # if HAVE_RAW_DECL_DUP2
324 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
325 "use gnulib module dup2 for portability");
331 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
333 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
334 and O_TEXT, O_BINARY (defined in "binary-io.h").
335 Close NEWFD first if it is open.
336 Return newfd if successful, otherwise -1 and errno set.
337 See the Linux man page at
338 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
340 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
341 # define dup3 rpl_dup3
343 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
344 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
346 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
347 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
349 _GL_CXXALIASWARN (dup3);
350 #elif defined GNULIB_POSIXCHECK
352 # if HAVE_RAW_DECL_DUP3
353 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
354 "use gnulib module dup3 for portability");
360 # if !@HAVE_DECL_ENVIRON@
361 /* Set of environment variables and values. An array of strings of the form
362 "VARIABLE=VALUE", terminated with a NULL. */
363 # if defined __APPLE__ && defined __MACH__
364 # include <crt_externs.h>
365 # define environ (*_NSGetEnviron ())
370 extern char **environ;
376 #elif defined GNULIB_POSIXCHECK
377 # if HAVE_RAW_DECL_ENVIRON
378 static inline char ***
383 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
384 "use gnulib module environ for portability");
386 # define environ (*rpl_environ ())
391 #if @GNULIB_EUIDACCESS@
392 /* Like access(), except that it uses the effective user id and group id of
393 the current process. */
394 # if !@HAVE_EUIDACCESS@
395 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
396 _GL_ARG_NONNULL ((1)));
398 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
399 _GL_CXXALIASWARN (euidaccess);
400 # if defined GNULIB_POSIXCHECK
401 /* Like access(), this function is a security risk. */
402 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
403 "use the gnulib module faccessat instead");
405 #elif defined GNULIB_POSIXCHECK
407 # if HAVE_RAW_DECL_EUIDACCESS
408 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
409 "use gnulib module euidaccess for portability");
414 #if @GNULIB_FACCESSAT@
415 # if !@HAVE_FACCESSAT@
416 _GL_FUNCDECL_SYS (faccessat, int,
417 (int fd, char const *file, int mode, int flag)
418 _GL_ARG_NONNULL ((2)));
420 _GL_CXXALIAS_SYS (faccessat, int,
421 (int fd, char const *file, int mode, int flag));
422 _GL_CXXALIASWARN (faccessat);
423 #elif defined GNULIB_POSIXCHECK
425 # if HAVE_RAW_DECL_FACCESSAT
426 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
427 "use gnulib module faccessat for portability");
433 /* Change the process' current working directory to the directory on which
434 the given file descriptor is open.
435 Return 0 if successful, otherwise -1 and errno set.
436 See the POSIX:2008 specification
437 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
439 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
441 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
442 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
443 _GL_ARG_NONNULL ((2));
444 _GL_EXTERN_C void _gl_unregister_fd (int fd);
445 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
446 _GL_EXTERN_C const char *_gl_directory_name (int fd);
449 # if !@HAVE_DECL_FCHDIR@
450 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
453 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
454 _GL_CXXALIASWARN (fchdir);
455 #elif defined GNULIB_POSIXCHECK
457 # if HAVE_RAW_DECL_FCHDIR
458 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
459 "use gnulib module fchdir for portability");
464 #if @GNULIB_FCHOWNAT@
465 # if @REPLACE_FCHOWNAT@
466 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
468 # define fchownat rpl_fchownat
470 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
471 uid_t owner, gid_t group, int flag)
472 _GL_ARG_NONNULL ((2)));
473 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
474 uid_t owner, gid_t group, int flag));
476 # if !@HAVE_FCHOWNAT@
477 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
478 uid_t owner, gid_t group, int flag)
479 _GL_ARG_NONNULL ((2)));
481 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
482 uid_t owner, gid_t group, int flag));
484 _GL_CXXALIASWARN (fchownat);
485 #elif defined GNULIB_POSIXCHECK
487 # if HAVE_RAW_DECL_FCHOWNAT
488 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
489 "use gnulib module openat for portability");
494 #if @GNULIB_FDATASYNC@
495 /* Synchronize changes to a file.
496 Return 0 if successful, otherwise -1 and errno set.
497 See POSIX:2008 specification
498 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
499 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
500 _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
502 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
503 _GL_CXXALIASWARN (fdatasync);
504 #elif defined GNULIB_POSIXCHECK
506 # if HAVE_RAW_DECL_FDATASYNC
507 _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
508 "use gnulib module fdatasync for portability");
514 /* Synchronize changes, including metadata, to a file.
515 Return 0 if successful, otherwise -1 and errno set.
516 See POSIX:2008 specification
517 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
519 _GL_FUNCDECL_SYS (fsync, int, (int fd));
521 _GL_CXXALIAS_SYS (fsync, int, (int fd));
522 _GL_CXXALIASWARN (fsync);
523 #elif defined GNULIB_POSIXCHECK
525 # if HAVE_RAW_DECL_FSYNC
526 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
527 "use gnulib module fsync for portability");
532 #if @GNULIB_FTRUNCATE@
533 /* Change the size of the file to which FD is opened to become equal to LENGTH.
534 Return 0 if successful, otherwise -1 and errno set.
535 See the POSIX:2008 specification
536 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
537 # if !@HAVE_FTRUNCATE@
538 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
540 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
541 _GL_CXXALIASWARN (ftruncate);
542 #elif defined GNULIB_POSIXCHECK
544 # if HAVE_RAW_DECL_FTRUNCATE
545 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
546 "use gnulib module ftruncate for portability");
552 /* Get the name of the current working directory, and put it in SIZE bytes
554 Return BUF if successful, or NULL if the directory couldn't be determined
555 or SIZE was too small.
556 See the POSIX:2008 specification
557 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
558 Additionally, the gnulib module 'getcwd' guarantees the following GNU
559 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
560 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
562 # if @REPLACE_GETCWD@
563 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
564 # define getcwd rpl_getcwd
566 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
567 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
569 /* Need to cast, because on mingw, the second parameter is
571 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
573 _GL_CXXALIASWARN (getcwd);
574 #elif defined GNULIB_POSIXCHECK
576 # if HAVE_RAW_DECL_GETCWD
577 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
578 "use gnulib module getcwd for portability");
583 #if @GNULIB_GETDOMAINNAME@
584 /* Return the NIS domain name of the machine.
585 WARNING! The NIS domain name is unrelated to the fully qualified host name
586 of the machine. It is also unrelated to email addresses.
587 WARNING! The NIS domain name is usually the empty string or "(none)" when
590 Put up to LEN bytes of the NIS domain name into NAME.
591 Null terminate it if the name is shorter than LEN.
592 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
593 Return 0 if successful, otherwise set errno and return -1. */
594 # if @REPLACE_GETDOMAINNAME@
595 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
596 # undef getdomainname
597 # define getdomainname rpl_getdomainname
599 _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
600 _GL_ARG_NONNULL ((1)));
601 _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
603 # if !@HAVE_DECL_GETDOMAINNAME@
604 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
605 _GL_ARG_NONNULL ((1)));
607 _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
609 _GL_CXXALIASWARN (getdomainname);
610 #elif defined GNULIB_POSIXCHECK
611 # undef getdomainname
612 # if HAVE_RAW_DECL_GETDOMAINNAME
613 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
614 "use gnulib module getdomainname for portability");
619 #if @GNULIB_GETDTABLESIZE@
620 /* Return the maximum number of file descriptors in the current process.
621 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
622 # if !@HAVE_GETDTABLESIZE@
623 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
625 _GL_CXXALIAS_SYS (getdtablesize, int, (void));
626 _GL_CXXALIASWARN (getdtablesize);
627 #elif defined GNULIB_POSIXCHECK
628 # undef getdtablesize
629 # if HAVE_RAW_DECL_GETDTABLESIZE
630 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
631 "use gnulib module getdtablesize for portability");
636 #if @GNULIB_GETGROUPS@
637 /* Return the supplemental groups that the current process belongs to.
638 It is unspecified whether the effective group id is in the list.
639 If N is 0, return the group count; otherwise, N describes how many
640 entries are available in GROUPS. Return -1 and set errno if N is
641 not 0 and not large enough. Fails with ENOSYS on some systems. */
642 # if @REPLACE_GETGROUPS@
643 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
645 # define getgroups rpl_getgroups
647 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
648 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
650 # if !@HAVE_GETGROUPS@
651 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
653 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
655 _GL_CXXALIASWARN (getgroups);
656 #elif defined GNULIB_POSIXCHECK
658 # if HAVE_RAW_DECL_GETGROUPS
659 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
660 "use gnulib module getgroups for portability");
665 #if @GNULIB_GETHOSTNAME@
666 /* Return the standard host name of the machine.
667 WARNING! The host name may or may not be fully qualified.
669 Put up to LEN bytes of the host name into NAME.
670 Null terminate it if the name is shorter than LEN.
671 If the host name is longer than LEN, set errno = EINVAL and return -1.
672 Return 0 if successful, otherwise set errno and return -1. */
673 # if @UNISTD_H_HAVE_WINSOCK2_H@
674 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
676 # define gethostname rpl_gethostname
678 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
679 _GL_ARG_NONNULL ((1)));
680 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
682 # if !@HAVE_GETHOSTNAME@
683 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
684 _GL_ARG_NONNULL ((1)));
686 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
689 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
691 _GL_CXXALIASWARN (gethostname);
692 #elif @UNISTD_H_HAVE_WINSOCK2_H@
694 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
695 #elif defined GNULIB_POSIXCHECK
697 # if HAVE_RAW_DECL_GETHOSTNAME
698 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
699 "use gnulib module gethostname for portability");
704 #if @GNULIB_GETLOGIN@
705 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
706 returns NULL with errno set.
708 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
710 Most programs don't need to use this function, because the information is
711 available through environment variables:
712 ${LOGNAME-$USER} on Unix platforms,
713 $USERNAME on native Windows platforms.
715 # if !@HAVE_GETLOGIN@
716 _GL_FUNCDECL_SYS (getlogin, char *, (void));
718 _GL_CXXALIAS_SYS (getlogin, char *, (void));
719 _GL_CXXALIASWARN (getlogin);
720 #elif defined GNULIB_POSIXCHECK
722 # if HAVE_RAW_DECL_GETLOGIN
723 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
724 "use gnulib module getlogin for portability");
729 #if @GNULIB_GETLOGIN_R@
730 /* Copies the user's login name to NAME.
731 The array pointed to by NAME has room for SIZE bytes.
733 Returns 0 if successful. Upon error, an error number is returned, or -1 in
734 the case that the login name cannot be found but no specific error is
735 provided (this case is hopefully rare but is left open by the POSIX spec).
737 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
739 Most programs don't need to use this function, because the information is
740 available through environment variables:
741 ${LOGNAME-$USER} on Unix platforms,
742 $USERNAME on native Windows platforms.
744 # if @REPLACE_GETLOGIN_R@
745 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
746 # define getlogin_r rpl_getlogin_r
748 _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
749 _GL_ARG_NONNULL ((1)));
750 _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
752 # if !@HAVE_DECL_GETLOGIN_R@
753 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
754 _GL_ARG_NONNULL ((1)));
756 /* Need to cast, because on Solaris 10 systems, the second argument is
758 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
760 _GL_CXXALIASWARN (getlogin_r);
761 #elif defined GNULIB_POSIXCHECK
763 # if HAVE_RAW_DECL_GETLOGIN_R
764 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
765 "use gnulib module getlogin_r for portability");
770 #if @GNULIB_GETPAGESIZE@
771 # if @REPLACE_GETPAGESIZE@
772 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
773 # define getpagesize rpl_getpagesize
775 _GL_FUNCDECL_RPL (getpagesize, int, (void));
776 _GL_CXXALIAS_RPL (getpagesize, int, (void));
778 # if !@HAVE_GETPAGESIZE@
779 # if !defined getpagesize
780 /* This is for POSIX systems. */
781 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
782 # if ! (defined __VMS && __VMS_VER < 70000000)
783 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
786 /* This is for older VMS. */
787 # if !defined _gl_getpagesize && defined __VMS
789 # define _gl_getpagesize() 8192
791 # define _gl_getpagesize() 512
794 /* This is for BeOS. */
795 # if !defined _gl_getpagesize && @HAVE_OS_H@
797 # if defined B_PAGE_SIZE
798 # define _gl_getpagesize() B_PAGE_SIZE
801 /* This is for AmigaOS4.0. */
802 # if !defined _gl_getpagesize && defined __amigaos4__
803 # define _gl_getpagesize() 2048
805 /* This is for older Unix systems. */
806 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
807 # include <sys/param.h>
808 # ifdef EXEC_PAGESIZE
809 # define _gl_getpagesize() EXEC_PAGESIZE
815 # define _gl_getpagesize() (NBPG * CLSIZE)
818 # define _gl_getpagesize() NBPC
823 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
824 # define getpagesize() _gl_getpagesize ()
826 # if !GNULIB_defined_getpagesize_function
830 return _gl_getpagesize ();
832 # define GNULIB_defined_getpagesize_function 1
837 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
838 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
840 # if @HAVE_DECL_GETPAGESIZE@
841 _GL_CXXALIASWARN (getpagesize);
843 #elif defined GNULIB_POSIXCHECK
845 # if HAVE_RAW_DECL_GETPAGESIZE
846 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
847 "use gnulib module getpagesize for portability");
852 #if @GNULIB_GETUSERSHELL@
853 /* Return the next valid login shell on the system, or NULL when the end of
854 the list has been reached. */
855 # if !@HAVE_DECL_GETUSERSHELL@
856 _GL_FUNCDECL_SYS (getusershell, char *, (void));
858 _GL_CXXALIAS_SYS (getusershell, char *, (void));
859 _GL_CXXALIASWARN (getusershell);
860 #elif defined GNULIB_POSIXCHECK
862 # if HAVE_RAW_DECL_GETUSERSHELL
863 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
864 "use gnulib module getusershell for portability");
868 #if @GNULIB_GETUSERSHELL@
869 /* Rewind to pointer that is advanced at each getusershell() call. */
870 # if !@HAVE_DECL_GETUSERSHELL@
871 _GL_FUNCDECL_SYS (setusershell, void, (void));
873 _GL_CXXALIAS_SYS (setusershell, void, (void));
874 _GL_CXXALIASWARN (setusershell);
875 #elif defined GNULIB_POSIXCHECK
877 # if HAVE_RAW_DECL_SETUSERSHELL
878 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
879 "use gnulib module getusershell for portability");
883 #if @GNULIB_GETUSERSHELL@
884 /* Free the pointer that is advanced at each getusershell() call and
885 associated resources. */
886 # if !@HAVE_DECL_GETUSERSHELL@
887 _GL_FUNCDECL_SYS (endusershell, void, (void));
889 _GL_CXXALIAS_SYS (endusershell, void, (void));
890 _GL_CXXALIASWARN (endusershell);
891 #elif defined GNULIB_POSIXCHECK
893 # if HAVE_RAW_DECL_ENDUSERSHELL
894 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
895 "use gnulib module getusershell for portability");
900 #if @GNULIB_GROUP_MEMBER@
901 /* Determine whether group id is in calling user's group list. */
902 # if !@HAVE_GROUP_MEMBER@
903 _GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
905 _GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
906 _GL_CXXALIASWARN (group_member);
907 #elif defined GNULIB_POSIXCHECK
909 # if HAVE_RAW_DECL_GROUP_MEMBER
910 _GL_WARN_ON_USE (group_member, "group_member is unportable - "
911 "use gnulib module group-member for portability");
917 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
918 to GID (if GID is not -1). Do not follow symbolic links.
919 Return 0 if successful, otherwise -1 and errno set.
920 See the POSIX:2008 specification
921 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
922 # if @REPLACE_LCHOWN@
923 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
925 # define lchown rpl_lchown
927 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
928 _GL_ARG_NONNULL ((1)));
929 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
932 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
933 _GL_ARG_NONNULL ((1)));
935 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
937 _GL_CXXALIASWARN (lchown);
938 #elif defined GNULIB_POSIXCHECK
940 # if HAVE_RAW_DECL_LCHOWN
941 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
942 "use gnulib module lchown for portability");
948 /* Create a new hard link for an existing file.
949 Return 0 if successful, otherwise -1 and errno set.
950 See POSIX:2008 specification
951 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
953 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
954 # define link rpl_link
956 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
957 _GL_ARG_NONNULL ((1, 2)));
958 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
961 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
962 _GL_ARG_NONNULL ((1, 2)));
964 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
966 _GL_CXXALIASWARN (link);
967 #elif defined GNULIB_POSIXCHECK
969 # if HAVE_RAW_DECL_LINK
970 _GL_WARN_ON_USE (link, "link is unportable - "
971 "use gnulib module link for portability");
977 /* Create a new hard link for an existing file, relative to two
978 directories. FLAG controls whether symlinks are followed.
979 Return 0 if successful, otherwise -1 and errno set. */
980 # if @REPLACE_LINKAT@
981 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
983 # define linkat rpl_linkat
985 _GL_FUNCDECL_RPL (linkat, int,
986 (int fd1, const char *path1, int fd2, const char *path2,
988 _GL_ARG_NONNULL ((2, 4)));
989 _GL_CXXALIAS_RPL (linkat, int,
990 (int fd1, const char *path1, int fd2, const char *path2,
994 _GL_FUNCDECL_SYS (linkat, int,
995 (int fd1, const char *path1, int fd2, const char *path2,
997 _GL_ARG_NONNULL ((2, 4)));
999 _GL_CXXALIAS_SYS (linkat, int,
1000 (int fd1, const char *path1, int fd2, const char *path2,
1003 _GL_CXXALIASWARN (linkat);
1004 #elif defined GNULIB_POSIXCHECK
1006 # if HAVE_RAW_DECL_LINKAT
1007 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1008 "use gnulib module linkat for portability");
1014 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1015 Return the new offset if successful, otherwise -1 and errno set.
1016 See the POSIX:2008 specification
1017 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1018 # if @REPLACE_LSEEK@
1019 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1020 # define lseek rpl_lseek
1022 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1023 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1025 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1027 _GL_CXXALIASWARN (lseek);
1028 #elif defined GNULIB_POSIXCHECK
1030 # if HAVE_RAW_DECL_LSEEK
1031 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1032 "systems - use gnulib module lseek for portability");
1038 /* Create a pipe, defaulting to O_BINARY mode.
1039 Store the read-end as fd[0] and the write-end as fd[1].
1040 Return 0 upon success, or -1 with errno set upon failure. */
1042 _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1044 _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1045 _GL_CXXALIASWARN (pipe);
1046 #elif defined GNULIB_POSIXCHECK
1048 # if HAVE_RAW_DECL_PIPE
1049 _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1050 "use gnulib module pipe-posix for portability");
1056 /* Create a pipe, applying the given flags when opening the read-end of the
1057 pipe and the write-end of the pipe.
1058 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1059 and O_TEXT, O_BINARY (defined in "binary-io.h").
1060 Store the read-end as fd[0] and the write-end as fd[1].
1061 Return 0 upon success, or -1 with errno set upon failure.
1062 See also the Linux man page at
1063 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1065 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1066 # define pipe2 rpl_pipe2
1068 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1069 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1071 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1072 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1074 _GL_CXXALIASWARN (pipe2);
1075 #elif defined GNULIB_POSIXCHECK
1077 # if HAVE_RAW_DECL_PIPE2
1078 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1079 "use gnulib module pipe2 for portability");
1085 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1086 Return the number of bytes placed into BUF if successful, otherwise
1087 set errno and return -1. 0 indicates EOF.
1088 See the POSIX:2008 specification
1089 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1090 # if @REPLACE_PREAD@
1091 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1093 # define pread rpl_pread
1095 _GL_FUNCDECL_RPL (pread, ssize_t,
1096 (int fd, void *buf, size_t bufsize, off_t offset)
1097 _GL_ARG_NONNULL ((2)));
1098 _GL_CXXALIAS_RPL (pread, ssize_t,
1099 (int fd, void *buf, size_t bufsize, off_t offset));
1102 _GL_FUNCDECL_SYS (pread, ssize_t,
1103 (int fd, void *buf, size_t bufsize, off_t offset)
1104 _GL_ARG_NONNULL ((2)));
1106 _GL_CXXALIAS_SYS (pread, ssize_t,
1107 (int fd, void *buf, size_t bufsize, off_t offset));
1109 _GL_CXXALIASWARN (pread);
1110 #elif defined GNULIB_POSIXCHECK
1112 # if HAVE_RAW_DECL_PREAD
1113 _GL_WARN_ON_USE (pread, "pread is unportable - "
1114 "use gnulib module pread for portability");
1120 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1121 Return the number of bytes written if successful, otherwise
1122 set errno and return -1. 0 indicates nothing written. See the
1123 POSIX:2008 specification
1124 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1125 # if @REPLACE_PWRITE@
1126 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1128 # define pwrite rpl_pwrite
1130 _GL_FUNCDECL_RPL (pwrite, ssize_t,
1131 (int fd, const void *buf, size_t bufsize, off_t offset)
1132 _GL_ARG_NONNULL ((2)));
1133 _GL_CXXALIAS_RPL (pwrite, ssize_t,
1134 (int fd, const void *buf, size_t bufsize, off_t offset));
1137 _GL_FUNCDECL_SYS (pwrite, ssize_t,
1138 (int fd, const void *buf, size_t bufsize, off_t offset)
1139 _GL_ARG_NONNULL ((2)));
1141 _GL_CXXALIAS_SYS (pwrite, ssize_t,
1142 (int fd, const void *buf, size_t bufsize, off_t offset));
1144 _GL_CXXALIASWARN (pwrite);
1145 #elif defined GNULIB_POSIXCHECK
1147 # if HAVE_RAW_DECL_PWRITE
1148 _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1149 "use gnulib module pwrite for portability");
1155 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1156 at BUF. See the POSIX:2008 specification
1157 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1158 # if @REPLACE_READ@ && @GNULIB_UNISTD_H_NONBLOCKING@
1159 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1161 # define read rpl_read
1163 _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1164 _GL_ARG_NONNULL ((2)));
1165 _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1167 /* Need to cast, because on mingw, the third parameter is
1169 and the return type is 'int'. */
1170 _GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1172 _GL_CXXALIASWARN (read);
1176 #if @GNULIB_READLINK@
1177 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1178 bytes of it into BUF. Return the number of bytes placed into BUF if
1179 successful, otherwise -1 and errno set.
1180 See the POSIX:2008 specification
1181 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1182 # if @REPLACE_READLINK@
1183 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1184 # define readlink rpl_readlink
1186 _GL_FUNCDECL_RPL (readlink, ssize_t,
1187 (const char *file, char *buf, size_t bufsize)
1188 _GL_ARG_NONNULL ((1, 2)));
1189 _GL_CXXALIAS_RPL (readlink, ssize_t,
1190 (const char *file, char *buf, size_t bufsize));
1192 # if !@HAVE_READLINK@
1193 _GL_FUNCDECL_SYS (readlink, ssize_t,
1194 (const char *file, char *buf, size_t bufsize)
1195 _GL_ARG_NONNULL ((1, 2)));
1197 _GL_CXXALIAS_SYS (readlink, ssize_t,
1198 (const char *file, char *buf, size_t bufsize));
1200 _GL_CXXALIASWARN (readlink);
1201 #elif defined GNULIB_POSIXCHECK
1203 # if HAVE_RAW_DECL_READLINK
1204 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1205 "use gnulib module readlink for portability");
1210 #if @GNULIB_READLINKAT@
1211 # if !@HAVE_READLINKAT@
1212 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
1213 (int fd, char const *file, char *buf, size_t len)
1214 _GL_ARG_NONNULL ((2, 3)));
1216 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1217 (int fd, char const *file, char *buf, size_t len));
1218 _GL_CXXALIASWARN (readlinkat);
1219 #elif defined GNULIB_POSIXCHECK
1221 # if HAVE_RAW_DECL_READLINKAT
1222 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1223 "use gnulib module readlinkat for portability");
1229 /* Remove the directory DIR. */
1230 # if @REPLACE_RMDIR@
1231 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1232 # define rmdir rpl_rmdir
1234 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1235 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1237 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1239 _GL_CXXALIASWARN (rmdir);
1240 #elif defined GNULIB_POSIXCHECK
1242 # if HAVE_RAW_DECL_RMDIR
1243 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1244 "use gnulib module rmdir for portability");
1250 /* Pause the execution of the current thread for N seconds.
1251 Returns the number of seconds left to sleep.
1252 See the POSIX:2008 specification
1253 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1254 # if @REPLACE_SLEEP@
1255 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1257 # define sleep rpl_sleep
1259 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1260 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1263 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1265 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1267 _GL_CXXALIASWARN (sleep);
1268 #elif defined GNULIB_POSIXCHECK
1270 # if HAVE_RAW_DECL_SLEEP
1271 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1272 "use gnulib module sleep for portability");
1277 #if @GNULIB_SYMLINK@
1278 # if @REPLACE_SYMLINK@
1279 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1281 # define symlink rpl_symlink
1283 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1284 _GL_ARG_NONNULL ((1, 2)));
1285 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1287 # if !@HAVE_SYMLINK@
1288 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1289 _GL_ARG_NONNULL ((1, 2)));
1291 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1293 _GL_CXXALIASWARN (symlink);
1294 #elif defined GNULIB_POSIXCHECK
1296 # if HAVE_RAW_DECL_SYMLINK
1297 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1298 "use gnulib module symlink for portability");
1303 #if @GNULIB_SYMLINKAT@
1304 # if !@HAVE_SYMLINKAT@
1305 _GL_FUNCDECL_SYS (symlinkat, int,
1306 (char const *contents, int fd, char const *file)
1307 _GL_ARG_NONNULL ((1, 3)));
1309 _GL_CXXALIAS_SYS (symlinkat, int,
1310 (char const *contents, int fd, char const *file));
1311 _GL_CXXALIASWARN (symlinkat);
1312 #elif defined GNULIB_POSIXCHECK
1314 # if HAVE_RAW_DECL_SYMLINKAT
1315 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1316 "use gnulib module symlinkat for portability");
1321 #if @GNULIB_TTYNAME_R@
1322 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1323 open on in BUF. Return 0 on success, otherwise an error number. */
1324 # if @REPLACE_TTYNAME_R@
1325 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1327 # define ttyname_r rpl_ttyname_r
1329 _GL_FUNCDECL_RPL (ttyname_r, int,
1330 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1331 _GL_CXXALIAS_RPL (ttyname_r, int,
1332 (int fd, char *buf, size_t buflen));
1334 # if !@HAVE_DECL_TTYNAME_R@
1335 _GL_FUNCDECL_SYS (ttyname_r, int,
1336 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1338 _GL_CXXALIAS_SYS (ttyname_r, int,
1339 (int fd, char *buf, size_t buflen));
1341 _GL_CXXALIASWARN (ttyname_r);
1342 #elif defined GNULIB_POSIXCHECK
1344 # if HAVE_RAW_DECL_TTYNAME_R
1345 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1346 "use gnulib module ttyname_r for portability");
1352 # if @REPLACE_UNLINK@
1353 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1355 # define unlink rpl_unlink
1357 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1358 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
1360 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
1362 _GL_CXXALIASWARN (unlink);
1363 #elif defined GNULIB_POSIXCHECK
1365 # if HAVE_RAW_DECL_UNLINK
1366 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
1367 "use gnulib module unlink for portability");
1372 #if @GNULIB_UNLINKAT@
1373 # if @REPLACE_UNLINKAT@
1374 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1376 # define unlinkat rpl_unlinkat
1378 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1379 _GL_ARG_NONNULL ((2)));
1380 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1382 # if !@HAVE_UNLINKAT@
1383 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1384 _GL_ARG_NONNULL ((2)));
1386 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1388 _GL_CXXALIASWARN (unlinkat);
1389 #elif defined GNULIB_POSIXCHECK
1391 # if HAVE_RAW_DECL_UNLINKAT
1392 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1393 "use gnulib module openat for portability");
1399 /* Pause the execution of the current thread for N microseconds.
1400 Returns 0 on completion, or -1 on range error.
1401 See the POSIX:2001 specification
1402 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1403 # if @REPLACE_USLEEP@
1404 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1406 # define usleep rpl_usleep
1408 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1409 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1412 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1414 _GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1416 _GL_CXXALIASWARN (usleep);
1417 #elif defined GNULIB_POSIXCHECK
1419 # if HAVE_RAW_DECL_USLEEP
1420 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1421 "use gnulib module usleep for portability");
1427 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1428 See the POSIX:2008 specification
1429 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1430 # if @REPLACE_WRITE@ && (@GNULIB_UNISTD_H_NONBLOCKING@ || @GNULIB_UNISTD_H_SIGPIPE@)
1431 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1433 # define write rpl_write
1435 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1436 _GL_ARG_NONNULL ((2)));
1437 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1439 /* Need to cast, because on mingw, the third parameter is
1441 and the return type is 'int'. */
1442 _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1444 _GL_CXXALIASWARN (write);
1448 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1449 #endif /* _@GUARD_PREFIX@_UNISTD_H */