1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2010 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. */
21 @PRAGMA_SYSTEM_HEADER@
24 /* The include_next requires a split double-inclusion guard. */
26 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
32 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
35 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
36 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
37 /* But avoid namespace pollution on glibc systems. */
38 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
39 || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \
40 && ! defined __GLIBC__
44 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
45 /* But avoid namespace pollution on glibc systems. */
46 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
50 /* mingw fails to declare _exit in <unistd.h>. */
51 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
52 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
53 /* But avoid namespace pollution on glibc systems. */
58 /* mingw declares getcwd in <io.h>, not in <unistd.h>. */
59 #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
60 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
64 #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
65 || @GNULIB_PREAD@ || defined GNULIB_POSIXCHECK)
67 # include <sys/types.h>
70 /* Get getopt(), optarg, optind, opterr, optopt.
71 But avoid namespace pollution on glibc systems. */
72 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
76 #if @GNULIB_GETHOSTNAME@
77 /* Get all possible declarations of gethostname(). */
78 # if @UNISTD_H_HAVE_WINSOCK2_H@
79 # include <winsock2.h>
80 # if !defined _GL_SYS_SOCKET_H
82 # define socket socket_used_without_including_sys_socket_h
84 # define connect connect_used_without_including_sys_socket_h
86 # define accept accept_used_without_including_sys_socket_h
88 # define bind bind_used_without_including_sys_socket_h
90 # define getpeername getpeername_used_without_including_sys_socket_h
92 # define getsockname getsockname_used_without_including_sys_socket_h
94 # define getsockopt getsockopt_used_without_including_sys_socket_h
96 # define listen listen_used_without_including_sys_socket_h
98 # define recv recv_used_without_including_sys_socket_h
100 # define send send_used_without_including_sys_socket_h
102 # define recvfrom recvfrom_used_without_including_sys_socket_h
104 # define sendto sendto_used_without_including_sys_socket_h
106 # define setsockopt setsockopt_used_without_including_sys_socket_h
108 # define shutdown shutdown_used_without_including_sys_socket_h
110 # if !defined _GL_SYS_SELECT_H
112 # define select select_used_without_including_sys_select_h
117 /* The definition of GL_LINK_WARNING is copied here. */
119 /* The definition of _GL_ARG_NONNULL is copied here. */
121 /* The definition of _GL_WARN_ON_USE is copied here. */
124 /* OS/2 EMX lacks these macros. */
126 # define STDIN_FILENO 0
128 #ifndef STDOUT_FILENO
129 # define STDOUT_FILENO 1
131 #ifndef STDERR_FILENO
132 # define STDERR_FILENO 2
135 /* Ensure *_OK macros exist. */
144 /* Declare overridden functions. */
154 # define chown rpl_chown
156 # if !@HAVE_CHOWN@ || @REPLACE_CHOWN@
157 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
158 to GID (if GID is not -1). Follow symbolic links.
159 Return 0 if successful, otherwise -1 and errno set.
160 See the POSIX:2001 specification
161 <http://www.opengroup.org/susv3xsh/chown.html>. */
162 extern int chown (const char *file, uid_t uid, gid_t gid)
163 _GL_ARG_NONNULL ((1));
165 #elif defined GNULIB_POSIXCHECK
167 # define chown(f,u,g) \
168 (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
169 "doesn't treat a uid or gid of -1 on some systems - " \
170 "use gnulib module chown for portability"), \
177 /* Automatically included by modules that need a replacement for close. */
179 # define close rpl_close
180 extern int close (int);
182 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
184 # define close close_used_without_requesting_gnulib_module_close
185 #elif defined GNULIB_POSIXCHECK
188 (GL_LINK_WARNING ("close does not portably work on sockets - " \
189 "use gnulib module close for portability"), \
196 extern int dup (int);
202 # define dup2 rpl_dup2
204 # if !@HAVE_DUP2@ || @REPLACE_DUP2@
205 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
206 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
207 Return newfd if successful, otherwise -1 and errno set.
208 See the POSIX:2001 specification
209 <http://www.opengroup.org/susv3xsh/dup2.html>. */
210 extern int dup2 (int oldfd, int newfd);
212 #elif defined GNULIB_POSIXCHECK
215 (GL_LINK_WARNING ("dup2 is unportable - " \
216 "use gnulib module dup2 for portability"), \
222 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
224 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
225 and O_TEXT, O_BINARY (defined in "binary-io.h").
226 Close NEWFD first if it is open.
227 Return newfd if successful, otherwise -1 and errno set.
228 See the Linux man page at
229 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
231 # define dup3 rpl_dup3
233 extern int dup3 (int oldfd, int newfd, int flags);
234 #elif defined GNULIB_POSIXCHECK
236 # define dup3(o,n,f) \
237 (GL_LINK_WARNING ("dup3 is unportable - " \
238 "use gnulib module dup3 for portability"), \
244 # if !@HAVE_DECL_ENVIRON@
245 /* Set of environment variables and values. An array of strings of the form
246 "VARIABLE=VALUE", terminated with a NULL. */
247 # if defined __APPLE__ && defined __MACH__
248 # include <crt_externs.h>
249 # define environ (*_NSGetEnviron ())
251 extern char **environ;
254 #elif defined GNULIB_POSIXCHECK
255 # if HAVE_RAW_DECL_ENVIRON
256 static inline char ***
261 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
262 "use gnulib module environ for portability");
264 # define environ (*rpl_environ ())
269 #if @GNULIB_EUIDACCESS@
270 # if !@HAVE_EUIDACCESS@
271 /* Like access(), except that it uses the effective user id and group id of
272 the current process. */
273 extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
275 #elif defined GNULIB_POSIXCHECK
277 # define euidaccess(f,m) \
278 (GL_LINK_WARNING ("euidaccess is unportable - " \
279 "use gnulib module euidaccess for portability"), \
284 #if @GNULIB_FACCESSAT@
285 # if !@HAVE_FACCESSAT@
286 extern int faccessat (int fd, char const *file, int mode, int flag)
287 _GL_ARG_NONNULL ((2));
289 #elif defined GNULIB_POSIXCHECK
291 # define faccessat(d,n,m,f) \
292 (GL_LINK_WARNING ("faccessat is not portable - " \
293 "use gnulib module faccessat for portability"), \
294 faccessat (d, n, m, f))
299 # if @REPLACE_FCHDIR@
300 /* Change the process' current working directory to the directory on which
301 the given file descriptor is open.
302 Return 0 if successful, otherwise -1 and errno set.
303 See the POSIX:2001 specification
304 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
305 extern int fchdir (int /*fd*/);
307 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
308 extern int _gl_register_fd (int fd, const char *filename)
309 _GL_ARG_NONNULL ((2));
310 extern void _gl_unregister_fd (int fd);
311 extern int _gl_register_dup (int oldfd, int newfd);
312 extern const char *_gl_directory_name (int fd);
315 #elif defined GNULIB_POSIXCHECK
318 (GL_LINK_WARNING ("fchdir is unportable - " \
319 "use gnulib module fchdir for portability"), \
324 #if @GNULIB_FCHOWNAT@
325 # if @REPLACE_FCHOWNAT@
327 # define fchownat rpl_fchownat
329 # if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
330 extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
331 _GL_ARG_NONNULL ((2));
333 #elif defined GNULIB_POSIXCHECK
335 # define fchownat(d,n,o,g,f) \
336 (GL_LINK_WARNING ("fchownat is not portable - " \
337 "use gnulib module openat for portability"), \
338 fchownat (d, n, o, g, f))
343 /* Synchronize changes to a file.
344 Return 0 if successful, otherwise -1 and errno set.
345 See POSIX:2001 specification
346 <http://www.opengroup.org/susv3xsh/fsync.html>. */
348 extern int fsync (int fd);
350 #elif defined GNULIB_POSIXCHECK
353 (GL_LINK_WARNING ("fsync is unportable - " \
354 "use gnulib module fsync for portability"), \
359 #if @GNULIB_FTRUNCATE@
360 # if !@HAVE_FTRUNCATE@
361 /* Change the size of the file to which FD is opened to become equal to LENGTH.
362 Return 0 if successful, otherwise -1 and errno set.
363 See the POSIX:2001 specification
364 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
365 extern int ftruncate (int fd, off_t length);
367 #elif defined GNULIB_POSIXCHECK
369 # define ftruncate(f,l) \
370 (GL_LINK_WARNING ("ftruncate is unportable - " \
371 "use gnulib module ftruncate for portability"), \
377 # if @REPLACE_GETCWD@
378 /* Get the name of the current working directory, and put it in SIZE bytes
380 Return BUF if successful, or NULL if the directory couldn't be determined
381 or SIZE was too small.
382 See the POSIX:2001 specification
383 <http://www.opengroup.org/susv3xsh/getcwd.html>.
384 Additionally, the gnulib module 'getcwd' guarantees the following GNU
385 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
386 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
388 # define getcwd rpl_getcwd
389 extern char * getcwd (char *buf, size_t size);
391 #elif defined GNULIB_POSIXCHECK
393 # define getcwd(b,s) \
394 (GL_LINK_WARNING ("getcwd is unportable - " \
395 "use gnulib module getcwd for portability"), \
400 #if @GNULIB_GETDOMAINNAME@
401 /* Return the NIS domain name of the machine.
402 WARNING! The NIS domain name is unrelated to the fully qualified host name
403 of the machine. It is also unrelated to email addresses.
404 WARNING! The NIS domain name is usually the empty string or "(none)" when
407 Put up to LEN bytes of the NIS domain name into NAME.
408 Null terminate it if the name is shorter than LEN.
409 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
410 Return 0 if successful, otherwise set errno and return -1. */
411 # if !@HAVE_GETDOMAINNAME@
412 extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
414 #elif defined GNULIB_POSIXCHECK
415 # undef getdomainname
416 # define getdomainname(n,l) \
417 (GL_LINK_WARNING ("getdomainname is unportable - " \
418 "use gnulib module getdomainname for portability"), \
419 getdomainname (n, l))
423 #if @GNULIB_GETDTABLESIZE@
424 # if !@HAVE_GETDTABLESIZE@
425 /* Return the maximum number of file descriptors in the current process.
426 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
427 extern int getdtablesize (void);
429 #elif defined GNULIB_POSIXCHECK
430 # undef getdtablesize
431 # define getdtablesize() \
432 (GL_LINK_WARNING ("getdtablesize is unportable - " \
433 "use gnulib module getdtablesize for portability"), \
438 #if @GNULIB_GETGROUPS@
439 # if @REPLACE_GETGROUPS@
441 # define getgroups rpl_getgroups
443 # if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@
444 /* Return the supplemental groups that the current process belongs to.
445 It is unspecified whether the effective group id is in the list.
446 If N is 0, return the group count; otherwise, N describes how many
447 entries are available in GROUPS. Return -1 and set errno if N is
448 not 0 and not large enough. Fails with ENOSYS on some systems. */
449 int getgroups (int n, gid_t *groups);
451 #elif defined GNULIB_POSIXCHECK
453 # define getgroups(n,g) \
454 (GL_LINK_WARNING ("getgroups is unportable - " \
455 "use gnulib module getgroups for portability"), \
460 #if @GNULIB_GETHOSTNAME@
461 /* Return the standard host name of the machine.
462 WARNING! The host name may or may not be fully qualified.
464 Put up to LEN bytes of the host name into NAME.
465 Null terminate it if the name is shorter than LEN.
466 If the host name is longer than LEN, set errno = EINVAL and return -1.
467 Return 0 if successful, otherwise set errno and return -1. */
468 # if @UNISTD_H_HAVE_WINSOCK2_H@
470 # define gethostname rpl_gethostname
472 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
473 extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
475 #elif @UNISTD_H_HAVE_WINSOCK2_H@
477 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
478 #elif defined GNULIB_POSIXCHECK
480 # define gethostname(n,l) \
481 (GL_LINK_WARNING ("gethostname is unportable - " \
482 "use gnulib module gethostname for portability"), \
487 #if @GNULIB_GETLOGIN@
488 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
489 returns NULL with errno set.
491 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
493 Most programs don't need to use this function, because the information is
494 available through environment variables:
495 ${LOGNAME-$USER} on Unix platforms,
496 $USERNAME on native Windows platforms.
498 # if !@HAVE_GETLOGIN@
499 extern char *getlogin (void);
501 #elif defined GNULIB_POSIXCHECK
503 # define getlogin() \
504 (GL_LINK_WARNING ("getlogin is unportable - " \
505 "use gnulib module getlogin for portability"), \
510 #if @GNULIB_GETLOGIN_R@
511 /* Copies the user's login name to NAME.
512 The array pointed to by NAME has room for SIZE bytes.
514 Returns 0 if successful. Upon error, an error number is returned, or -1 in
515 the case that the login name cannot be found but no specific error is
516 provided (this case is hopefully rare but is left open by the POSIX spec).
518 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
520 Most programs don't need to use this function, because the information is
521 available through environment variables:
522 ${LOGNAME-$USER} on Unix platforms,
523 $USERNAME on native Windows platforms.
525 # if !@HAVE_DECL_GETLOGIN_R@
526 extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
528 #elif defined GNULIB_POSIXCHECK
530 # define getlogin_r(n,s) \
531 (GL_LINK_WARNING ("getlogin_r is unportable - " \
532 "use gnulib module getlogin_r for portability"), \
537 #if @GNULIB_GETPAGESIZE@
538 # if @REPLACE_GETPAGESIZE@
539 # define getpagesize rpl_getpagesize
540 extern int getpagesize (void);
541 # elif !@HAVE_GETPAGESIZE@
542 /* This is for POSIX systems. */
543 # if !defined getpagesize && defined _SC_PAGESIZE
544 # if ! (defined __VMS && __VMS_VER < 70000000)
545 # define getpagesize() sysconf (_SC_PAGESIZE)
548 /* This is for older VMS. */
549 # if !defined getpagesize && defined __VMS
551 # define getpagesize() 8192
553 # define getpagesize() 512
556 /* This is for BeOS. */
557 # if !defined getpagesize && @HAVE_OS_H@
559 # if defined B_PAGE_SIZE
560 # define getpagesize() B_PAGE_SIZE
563 /* This is for AmigaOS4.0. */
564 # if !defined getpagesize && defined __amigaos4__
565 # define getpagesize() 2048
567 /* This is for older Unix systems. */
568 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
569 # include <sys/param.h>
570 # ifdef EXEC_PAGESIZE
571 # define getpagesize() EXEC_PAGESIZE
577 # define getpagesize() (NBPG * CLSIZE)
580 # define getpagesize() NBPC
586 #elif defined GNULIB_POSIXCHECK
588 # define getpagesize() \
589 (GL_LINK_WARNING ("getpagesize is unportable - " \
590 "use gnulib module getpagesize for portability"), \
595 #if @GNULIB_GETUSERSHELL@
596 # if !@HAVE_GETUSERSHELL@
597 /* Return the next valid login shell on the system, or NULL when the end of
598 the list has been reached. */
599 extern char *getusershell (void);
600 /* Rewind to pointer that is advanced at each getusershell() call. */
601 extern void setusershell (void);
602 /* Free the pointer that is advanced at each getusershell() call and
603 associated resources. */
604 extern void endusershell (void);
606 #elif defined GNULIB_POSIXCHECK
608 # define getusershell() \
609 (GL_LINK_WARNING ("getusershell is unportable - " \
610 "use gnulib module getusershell for portability"), \
613 # define setusershell() \
614 (GL_LINK_WARNING ("setusershell is unportable - " \
615 "use gnulib module getusershell for portability"), \
618 # define endusershell() \
619 (GL_LINK_WARNING ("endusershell is unportable - " \
620 "use gnulib module getusershell for portability"), \
626 # if @REPLACE_LCHOWN@
628 # define lchown rpl_lchown
630 # if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
631 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
632 to GID (if GID is not -1). Do not follow symbolic links.
633 Return 0 if successful, otherwise -1 and errno set.
634 See the POSIX:2001 specification
635 <http://www.opengroup.org/susv3xsh/lchown.html>. */
636 extern int lchown (char const *file, uid_t owner, gid_t group)
637 _GL_ARG_NONNULL ((1));
639 #elif defined GNULIB_POSIXCHECK
641 # define lchown(f,u,g) \
642 (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
643 "systems - use gnulib module lchown for portability"), \
650 # define link rpl_link
652 /* Create a new hard link for an existing file.
653 Return 0 if successful, otherwise -1 and errno set.
654 See POSIX:2001 specification
655 <http://www.opengroup.org/susv3xsh/link.html>. */
656 # if !@HAVE_LINK@ || @REPLACE_LINK@
657 extern int link (const char *path1, const char *path2)
658 _GL_ARG_NONNULL ((1, 2));
660 #elif defined GNULIB_POSIXCHECK
662 # define link(path1,path2) \
663 (GL_LINK_WARNING ("link is unportable - " \
664 "use gnulib module link for portability"), \
669 # if @REPLACE_LINKAT@
671 # define linkat rpl_linkat
673 /* Create a new hard link for an existing file, relative to two
674 directories. FLAG controls whether symlinks are followed.
675 Return 0 if successful, otherwise -1 and errno set. */
676 # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
677 extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
679 _GL_ARG_NONNULL ((2, 4));
681 #elif defined GNULIB_POSIXCHECK
683 # define linkat(f1,path1,f2,path2,f) \
684 (GL_LINK_WARNING ("linkat is unportable - " \
685 "use gnulib module linkat for portability"), \
686 linkat (f1, path1, f2, path2,f))
691 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
692 Return the new offset if successful, otherwise -1 and errno set.
693 See the POSIX:2001 specification
694 <http://www.opengroup.org/susv3xsh/lseek.html>. */
695 # define lseek rpl_lseek
696 extern off_t lseek (int fd, off_t offset, int whence);
698 #elif defined GNULIB_POSIXCHECK
700 # define lseek(f,o,w) \
701 (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
702 "systems - use gnulib module lseek for portability"), \
708 /* Create a pipe, applying the given flags when opening the read-end of the
709 pipe and the write-end of the pipe.
710 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
711 and O_TEXT, O_BINARY (defined in "binary-io.h").
712 Store the read-end as fd[0] and the write-end as fd[1].
713 Return 0 upon success, or -1 with errno set upon failure.
714 See also the Linux man page at
715 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
717 # define pipe2 rpl_pipe2
719 extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
720 #elif defined GNULIB_POSIXCHECK
722 # define pipe2(f,o) \
723 (GL_LINK_WARNING ("pipe2 is unportable - " \
724 "use gnulib module pipe2 for portability"), \
731 # define pread rpl_pread
733 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
734 Return the number of bytes placed into BUF if successful, otherwise
735 set errno and return -1. 0 indicates EOF. See the POSIX:2001
736 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
737 # if !@HAVE_PREAD@ || @REPLACE_PREAD@
738 extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
739 _GL_ARG_NONNULL ((2));
741 #elif defined GNULIB_POSIXCHECK
743 # define pread(f,b,s,o) \
744 (GL_LINK_WARNING ("pread is unportable - " \
745 "use gnulib module pread for portability"), \
750 #if @GNULIB_READLINK@
751 # if @REPLACE_READLINK@
752 # define readlink rpl_readlink
754 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
755 bytes of it into BUF. Return the number of bytes placed into BUF if
756 successful, otherwise -1 and errno set.
757 See the POSIX:2001 specification
758 <http://www.opengroup.org/susv3xsh/readlink.html>. */
759 # if !@HAVE_READLINK@ || @REPLACE_READLINK@
760 extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
761 _GL_ARG_NONNULL ((1, 2));
763 #elif defined GNULIB_POSIXCHECK
765 # define readlink(f,b,s) \
766 (GL_LINK_WARNING ("readlink is unportable - " \
767 "use gnulib module readlink for portability"), \
772 #if @GNULIB_READLINKAT@
773 # if !@HAVE_READLINKAT@
774 extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
775 _GL_ARG_NONNULL ((2, 3));
777 #elif defined GNULIB_POSIXCHECK
779 # define readlinkat(d,n,b,l) \
780 (GL_LINK_WARNING ("readlinkat is not portable - " \
781 "use gnulib module symlinkat for portability"), \
782 readlinkat (d, n, b, l))
788 # define rmdir rpl_rmdir
789 /* Remove the directory DIR. */
790 extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
792 #elif defined GNULIB_POSIXCHECK
795 (GL_LINK_WARNING ("rmdir is unportable - " \
796 "use gnulib module rmdir for portability"), \
804 # define sleep rpl_sleep
806 /* Pause the execution of the current thread for N seconds.
807 Returns the number of seconds left to sleep.
808 See the POSIX:2001 specification
809 <http://www.opengroup.org/susv3xsh/sleep.html>. */
810 # if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
811 extern unsigned int sleep (unsigned int n);
813 #elif defined GNULIB_POSIXCHECK
816 (GL_LINK_WARNING ("sleep is unportable - " \
817 "use gnulib module sleep for portability"), \
823 # if @REPLACE_SYMLINK@
825 # define symlink rpl_symlink
827 # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
828 extern int symlink (char const *contents, char const *file)
829 _GL_ARG_NONNULL ((1, 2));
831 #elif defined GNULIB_POSIXCHECK
833 # define symlink(c,n) \
834 (GL_LINK_WARNING ("symlink is not portable - " \
835 "use gnulib module symlink for portability"), \
840 #if @GNULIB_SYMLINKAT@
841 # if !@HAVE_SYMLINKAT@
842 extern int symlinkat (char const *contents, int fd, char const *file)
843 _GL_ARG_NONNULL ((1, 3));
845 #elif defined GNULIB_POSIXCHECK
847 # define symlinkat(c,d,n) \
848 (GL_LINK_WARNING ("symlinkat is not portable - " \
849 "use gnulib module symlinkat for portability"), \
855 # if @REPLACE_UNLINK@
857 # define unlink rpl_unlink
858 extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
860 #elif defined GNULIB_POSIXCHECK
863 (GL_LINK_WARNING ("unlink is not portable - " \
864 "use gnulib module unlink for portability"), \
869 #if @GNULIB_UNLINKAT@
870 # if @REPLACE_UNLINKAT@
872 # define unlinkat rpl_unlinkat
874 # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
875 extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
877 #elif defined GNULIB_POSIXCHECK
879 # define unlinkat(d,n,f) \
880 (GL_LINK_WARNING ("unlinkat is not portable - " \
881 "use gnulib module openat for portability"), \
887 # if @REPLACE_USLEEP@
889 # define usleep rpl_usleep
891 # if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
892 /* Pause the execution of the current thread for N microseconds.
893 Returns 0 on completion, or -1 on range error.
894 See the POSIX:2001 specification
895 <http://www.opengroup.org/susv3xsh/sleep.html>. */
896 extern int usleep (useconds_t n);
898 #elif defined GNULIB_POSIXCHECK
901 (GL_LINK_WARNING ("usleep is unportable - " \
902 "use gnulib module usleep for portability"), \
907 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
908 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
909 See the POSIX:2001 specification
910 <http://www.opengroup.org/susv3xsh/write.html>. */
912 # define write rpl_write
913 extern ssize_t write (int fd, const void *buf, size_t count)
914 _GL_ARG_NONNULL ((2));
923 #endif /* _GL_UNISTD_H */
924 #endif /* _GL_UNISTD_H */