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. */
122 /* OS/2 EMX lacks these macros. */
124 # define STDIN_FILENO 0
126 #ifndef STDOUT_FILENO
127 # define STDOUT_FILENO 1
129 #ifndef STDERR_FILENO
130 # define STDERR_FILENO 2
133 /* Ensure *_OK macros exist. */
142 /* Declare overridden functions. */
152 # define chown rpl_chown
154 # if !@HAVE_CHOWN@ || @REPLACE_CHOWN@
155 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
156 to GID (if GID is not -1). Follow symbolic links.
157 Return 0 if successful, otherwise -1 and errno set.
158 See the POSIX:2001 specification
159 <http://www.opengroup.org/susv3xsh/chown.html>. */
160 extern int chown (const char *file, uid_t uid, gid_t gid)
161 _GL_ARG_NONNULL ((1));
163 #elif defined GNULIB_POSIXCHECK
165 # define chown(f,u,g) \
166 (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
167 "doesn't treat a uid or gid of -1 on some systems - " \
168 "use gnulib module chown for portability"), \
175 /* Automatically included by modules that need a replacement for close. */
177 # define close rpl_close
178 extern int close (int);
180 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
182 # define close close_used_without_requesting_gnulib_module_close
183 #elif defined GNULIB_POSIXCHECK
186 (GL_LINK_WARNING ("close does not portably work on sockets - " \
187 "use gnulib module close for portability"), \
194 extern int dup (int);
200 # define dup2 rpl_dup2
202 # if !@HAVE_DUP2@ || @REPLACE_DUP2@
203 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
204 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
205 Return newfd if successful, otherwise -1 and errno set.
206 See the POSIX:2001 specification
207 <http://www.opengroup.org/susv3xsh/dup2.html>. */
208 extern int dup2 (int oldfd, int newfd);
210 #elif defined GNULIB_POSIXCHECK
213 (GL_LINK_WARNING ("dup2 is unportable - " \
214 "use gnulib module dup2 for portability"), \
220 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
222 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
223 and O_TEXT, O_BINARY (defined in "binary-io.h").
224 Close NEWFD first if it is open.
225 Return newfd if successful, otherwise -1 and errno set.
226 See the Linux man page at
227 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
229 # define dup3 rpl_dup3
231 extern int dup3 (int oldfd, int newfd, int flags);
232 #elif defined GNULIB_POSIXCHECK
234 # define dup3(o,n,f) \
235 (GL_LINK_WARNING ("dup3 is unportable - " \
236 "use gnulib module dup3 for portability"), \
242 # if !@HAVE_DECL_ENVIRON@
243 /* Set of environment variables and values. An array of strings of the form
244 "VARIABLE=VALUE", terminated with a NULL. */
245 # if defined __APPLE__ && defined __MACH__
246 # include <crt_externs.h>
247 # define environ (*_NSGetEnviron ())
249 extern char **environ;
252 #elif defined GNULIB_POSIXCHECK
255 (GL_LINK_WARNING ("environ is unportable - " \
256 "use gnulib module environ for portability"), \
261 #if @GNULIB_EUIDACCESS@
262 # if !@HAVE_EUIDACCESS@
263 /* Like access(), except that it uses the effective user id and group id of
264 the current process. */
265 extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
267 #elif defined GNULIB_POSIXCHECK
269 # define euidaccess(f,m) \
270 (GL_LINK_WARNING ("euidaccess is unportable - " \
271 "use gnulib module euidaccess for portability"), \
276 #if @GNULIB_FACCESSAT@
277 # if !@HAVE_FACCESSAT@
278 extern int faccessat (int fd, char const *file, int mode, int flag)
279 _GL_ARG_NONNULL ((2));
281 #elif defined GNULIB_POSIXCHECK
283 # define faccessat(d,n,m,f) \
284 (GL_LINK_WARNING ("faccessat is not portable - " \
285 "use gnulib module faccessat for portability"), \
286 faccessat (d, n, m, f))
291 # if @REPLACE_FCHDIR@
292 /* Change the process' current working directory to the directory on which
293 the given file descriptor is open.
294 Return 0 if successful, otherwise -1 and errno set.
295 See the POSIX:2001 specification
296 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
297 extern int fchdir (int /*fd*/);
299 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
300 extern int _gl_register_fd (int fd, const char *filename)
301 _GL_ARG_NONNULL ((2));
302 extern void _gl_unregister_fd (int fd);
303 extern int _gl_register_dup (int oldfd, int newfd);
304 extern const char *_gl_directory_name (int fd);
307 #elif defined GNULIB_POSIXCHECK
310 (GL_LINK_WARNING ("fchdir is unportable - " \
311 "use gnulib module fchdir for portability"), \
316 #if @GNULIB_FCHOWNAT@
317 # if @REPLACE_FCHOWNAT@
319 # define fchownat rpl_fchownat
321 # if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
322 extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
323 _GL_ARG_NONNULL ((2));
325 #elif defined GNULIB_POSIXCHECK
327 # define fchownat(d,n,o,g,f) \
328 (GL_LINK_WARNING ("fchownat is not portable - " \
329 "use gnulib module openat for portability"), \
330 fchownat (d, n, o, g, f))
335 /* Synchronize changes to a file.
336 Return 0 if successful, otherwise -1 and errno set.
337 See POSIX:2001 specification
338 <http://www.opengroup.org/susv3xsh/fsync.html>. */
340 extern int fsync (int fd);
342 #elif defined GNULIB_POSIXCHECK
345 (GL_LINK_WARNING ("fsync is unportable - " \
346 "use gnulib module fsync for portability"), \
351 #if @GNULIB_FTRUNCATE@
352 # if !@HAVE_FTRUNCATE@
353 /* Change the size of the file to which FD is opened to become equal to LENGTH.
354 Return 0 if successful, otherwise -1 and errno set.
355 See the POSIX:2001 specification
356 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
357 extern int ftruncate (int fd, off_t length);
359 #elif defined GNULIB_POSIXCHECK
361 # define ftruncate(f,l) \
362 (GL_LINK_WARNING ("ftruncate is unportable - " \
363 "use gnulib module ftruncate for portability"), \
369 # if @REPLACE_GETCWD@
370 /* Get the name of the current working directory, and put it in SIZE bytes
372 Return BUF if successful, or NULL if the directory couldn't be determined
373 or SIZE was too small.
374 See the POSIX:2001 specification
375 <http://www.opengroup.org/susv3xsh/getcwd.html>.
376 Additionally, the gnulib module 'getcwd' guarantees the following GNU
377 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
378 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
380 # define getcwd rpl_getcwd
381 extern char * getcwd (char *buf, size_t size);
383 #elif defined GNULIB_POSIXCHECK
385 # define getcwd(b,s) \
386 (GL_LINK_WARNING ("getcwd is unportable - " \
387 "use gnulib module getcwd for portability"), \
392 #if @GNULIB_GETDOMAINNAME@
393 /* Return the NIS domain name of the machine.
394 WARNING! The NIS domain name is unrelated to the fully qualified host name
395 of the machine. It is also unrelated to email addresses.
396 WARNING! The NIS domain name is usually the empty string or "(none)" when
399 Put up to LEN bytes of the NIS domain name into NAME.
400 Null terminate it if the name is shorter than LEN.
401 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
402 Return 0 if successful, otherwise set errno and return -1. */
403 # if !@HAVE_GETDOMAINNAME@
404 extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
406 #elif defined GNULIB_POSIXCHECK
407 # undef getdomainname
408 # define getdomainname(n,l) \
409 (GL_LINK_WARNING ("getdomainname is unportable - " \
410 "use gnulib module getdomainname for portability"), \
411 getdomainname (n, l))
415 #if @GNULIB_GETDTABLESIZE@
416 # if !@HAVE_GETDTABLESIZE@
417 /* Return the maximum number of file descriptors in the current process.
418 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
419 extern int getdtablesize (void);
421 #elif defined GNULIB_POSIXCHECK
422 # undef getdtablesize
423 # define getdtablesize() \
424 (GL_LINK_WARNING ("getdtablesize is unportable - " \
425 "use gnulib module getdtablesize for portability"), \
430 #if @GNULIB_GETGROUPS@
431 # if @REPLACE_GETGROUPS@
433 # define getgroups rpl_getgroups
435 # if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@
436 /* Return the supplemental groups that the current process belongs to.
437 It is unspecified whether the effective group id is in the list.
438 If N is 0, return the group count; otherwise, N describes how many
439 entries are available in GROUPS. Return -1 and set errno if N is
440 not 0 and not large enough. Fails with ENOSYS on some systems. */
441 int getgroups (int n, gid_t *groups);
443 #elif defined GNULIB_POSIXCHECK
445 # define getgroups(n,g) \
446 (GL_LINK_WARNING ("getgroups is unportable - " \
447 "use gnulib module getgroups for portability"), \
452 #if @GNULIB_GETHOSTNAME@
453 /* Return the standard host name of the machine.
454 WARNING! The host name may or may not be fully qualified.
456 Put up to LEN bytes of the host name into NAME.
457 Null terminate it if the name is shorter than LEN.
458 If the host name is longer than LEN, set errno = EINVAL and return -1.
459 Return 0 if successful, otherwise set errno and return -1. */
460 # if @UNISTD_H_HAVE_WINSOCK2_H@
462 # define gethostname rpl_gethostname
464 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
465 extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
467 #elif @UNISTD_H_HAVE_WINSOCK2_H@
469 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
470 #elif defined GNULIB_POSIXCHECK
472 # define gethostname(n,l) \
473 (GL_LINK_WARNING ("gethostname is unportable - " \
474 "use gnulib module gethostname for portability"), \
479 #if @GNULIB_GETLOGIN@
480 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
481 returns NULL with errno set.
483 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
485 Most programs don't need to use this function, because the information is
486 available through environment variables:
487 ${LOGNAME-$USER} on Unix platforms,
488 $USERNAME on native Windows platforms.
490 # if !@HAVE_GETLOGIN@
491 extern char *getlogin (void);
493 #elif defined GNULIB_POSIXCHECK
495 # define getlogin() \
496 (GL_LINK_WARNING ("getlogin is unportable - " \
497 "use gnulib module getlogin for portability"), \
502 #if @GNULIB_GETLOGIN_R@
503 /* Copies the user's login name to NAME.
504 The array pointed to by NAME has room for SIZE bytes.
506 Returns 0 if successful. Upon error, an error number is returned, or -1 in
507 the case that the login name cannot be found but no specific error is
508 provided (this case is hopefully rare but is left open by the POSIX spec).
510 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
512 Most programs don't need to use this function, because the information is
513 available through environment variables:
514 ${LOGNAME-$USER} on Unix platforms,
515 $USERNAME on native Windows platforms.
517 # if !@HAVE_DECL_GETLOGIN_R@
518 extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
520 #elif defined GNULIB_POSIXCHECK
522 # define getlogin_r(n,s) \
523 (GL_LINK_WARNING ("getlogin_r is unportable - " \
524 "use gnulib module getlogin_r for portability"), \
529 #if @GNULIB_GETPAGESIZE@
530 # if @REPLACE_GETPAGESIZE@
531 # define getpagesize rpl_getpagesize
532 extern int getpagesize (void);
533 # elif !@HAVE_GETPAGESIZE@
534 /* This is for POSIX systems. */
535 # if !defined getpagesize && defined _SC_PAGESIZE
536 # if ! (defined __VMS && __VMS_VER < 70000000)
537 # define getpagesize() sysconf (_SC_PAGESIZE)
540 /* This is for older VMS. */
541 # if !defined getpagesize && defined __VMS
543 # define getpagesize() 8192
545 # define getpagesize() 512
548 /* This is for BeOS. */
549 # if !defined getpagesize && @HAVE_OS_H@
551 # if defined B_PAGE_SIZE
552 # define getpagesize() B_PAGE_SIZE
555 /* This is for AmigaOS4.0. */
556 # if !defined getpagesize && defined __amigaos4__
557 # define getpagesize() 2048
559 /* This is for older Unix systems. */
560 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
561 # include <sys/param.h>
562 # ifdef EXEC_PAGESIZE
563 # define getpagesize() EXEC_PAGESIZE
569 # define getpagesize() (NBPG * CLSIZE)
572 # define getpagesize() NBPC
578 #elif defined GNULIB_POSIXCHECK
580 # define getpagesize() \
581 (GL_LINK_WARNING ("getpagesize is unportable - " \
582 "use gnulib module getpagesize for portability"), \
587 #if @GNULIB_GETUSERSHELL@
588 # if !@HAVE_GETUSERSHELL@
589 /* Return the next valid login shell on the system, or NULL when the end of
590 the list has been reached. */
591 extern char *getusershell (void);
592 /* Rewind to pointer that is advanced at each getusershell() call. */
593 extern void setusershell (void);
594 /* Free the pointer that is advanced at each getusershell() call and
595 associated resources. */
596 extern void endusershell (void);
598 #elif defined GNULIB_POSIXCHECK
600 # define getusershell() \
601 (GL_LINK_WARNING ("getusershell is unportable - " \
602 "use gnulib module getusershell for portability"), \
605 # define setusershell() \
606 (GL_LINK_WARNING ("setusershell is unportable - " \
607 "use gnulib module getusershell for portability"), \
610 # define endusershell() \
611 (GL_LINK_WARNING ("endusershell is unportable - " \
612 "use gnulib module getusershell for portability"), \
618 # if @REPLACE_LCHOWN@
620 # define lchown rpl_lchown
622 # if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
623 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
624 to GID (if GID is not -1). Do not follow symbolic links.
625 Return 0 if successful, otherwise -1 and errno set.
626 See the POSIX:2001 specification
627 <http://www.opengroup.org/susv3xsh/lchown.html>. */
628 extern int lchown (char const *file, uid_t owner, gid_t group)
629 _GL_ARG_NONNULL ((1));
631 #elif defined GNULIB_POSIXCHECK
633 # define lchown(f,u,g) \
634 (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
635 "systems - use gnulib module lchown for portability"), \
642 # define link rpl_link
644 /* Create a new hard link for an existing file.
645 Return 0 if successful, otherwise -1 and errno set.
646 See POSIX:2001 specification
647 <http://www.opengroup.org/susv3xsh/link.html>. */
648 # if !@HAVE_LINK@ || @REPLACE_LINK@
649 extern int link (const char *path1, const char *path2)
650 _GL_ARG_NONNULL ((1, 2));
652 #elif defined GNULIB_POSIXCHECK
654 # define link(path1,path2) \
655 (GL_LINK_WARNING ("link is unportable - " \
656 "use gnulib module link for portability"), \
661 # if @REPLACE_LINKAT@
663 # define linkat rpl_linkat
665 /* Create a new hard link for an existing file, relative to two
666 directories. FLAG controls whether symlinks are followed.
667 Return 0 if successful, otherwise -1 and errno set. */
668 # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
669 extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
671 _GL_ARG_NONNULL ((2, 4));
673 #elif defined GNULIB_POSIXCHECK
675 # define linkat(f1,path1,f2,path2,f) \
676 (GL_LINK_WARNING ("linkat is unportable - " \
677 "use gnulib module linkat for portability"), \
678 linkat (f1, path1, f2, path2,f))
683 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
684 Return the new offset if successful, otherwise -1 and errno set.
685 See the POSIX:2001 specification
686 <http://www.opengroup.org/susv3xsh/lseek.html>. */
687 # define lseek rpl_lseek
688 extern off_t lseek (int fd, off_t offset, int whence);
690 #elif defined GNULIB_POSIXCHECK
692 # define lseek(f,o,w) \
693 (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
694 "systems - use gnulib module lseek for portability"), \
700 /* Create a pipe, applying the given flags when opening the read-end of the
701 pipe and the write-end of the pipe.
702 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
703 and O_TEXT, O_BINARY (defined in "binary-io.h").
704 Store the read-end as fd[0] and the write-end as fd[1].
705 Return 0 upon success, or -1 with errno set upon failure.
706 See also the Linux man page at
707 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
709 # define pipe2 rpl_pipe2
711 extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
712 #elif defined GNULIB_POSIXCHECK
714 # define pipe2(f,o) \
715 (GL_LINK_WARNING ("pipe2 is unportable - " \
716 "use gnulib module pipe2 for portability"), \
723 # define pread rpl_pread
725 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
726 Return the number of bytes placed into BUF if successful, otherwise
727 set errno and return -1. 0 indicates EOF. See the POSIX:2001
728 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
729 # if !@HAVE_PREAD@ || @REPLACE_PREAD@
730 extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
731 _GL_ARG_NONNULL ((2));
733 #elif defined GNULIB_POSIXCHECK
735 # define pread(f,b,s,o) \
736 (GL_LINK_WARNING ("pread is unportable - " \
737 "use gnulib module pread for portability"), \
742 #if @GNULIB_READLINK@
743 # if @REPLACE_READLINK@
744 # define readlink rpl_readlink
746 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
747 bytes of it into BUF. Return the number of bytes placed into BUF if
748 successful, otherwise -1 and errno set.
749 See the POSIX:2001 specification
750 <http://www.opengroup.org/susv3xsh/readlink.html>. */
751 # if !@HAVE_READLINK@ || @REPLACE_READLINK@
752 extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
753 _GL_ARG_NONNULL ((1, 2));
755 #elif defined GNULIB_POSIXCHECK
757 # define readlink(f,b,s) \
758 (GL_LINK_WARNING ("readlink is unportable - " \
759 "use gnulib module readlink for portability"), \
764 #if @GNULIB_READLINKAT@
765 # if !@HAVE_READLINKAT@
766 extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
767 _GL_ARG_NONNULL ((2, 3));
769 #elif defined GNULIB_POSIXCHECK
771 # define readlinkat(d,n,b,l) \
772 (GL_LINK_WARNING ("readlinkat is not portable - " \
773 "use gnulib module symlinkat for portability"), \
774 readlinkat (d, n, b, l))
780 # define rmdir rpl_rmdir
781 /* Remove the directory DIR. */
782 extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
784 #elif defined GNULIB_POSIXCHECK
787 (GL_LINK_WARNING ("rmdir is unportable - " \
788 "use gnulib module rmdir for portability"), \
796 # define sleep rpl_sleep
798 /* Pause the execution of the current thread for N seconds.
799 Returns the number of seconds left to sleep.
800 See the POSIX:2001 specification
801 <http://www.opengroup.org/susv3xsh/sleep.html>. */
802 # if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
803 extern unsigned int sleep (unsigned int n);
805 #elif defined GNULIB_POSIXCHECK
808 (GL_LINK_WARNING ("sleep is unportable - " \
809 "use gnulib module sleep for portability"), \
815 # if @REPLACE_SYMLINK@
817 # define symlink rpl_symlink
819 # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
820 extern int symlink (char const *contents, char const *file)
821 _GL_ARG_NONNULL ((1, 2));
823 #elif defined GNULIB_POSIXCHECK
825 # define symlink(c,n) \
826 (GL_LINK_WARNING ("symlink is not portable - " \
827 "use gnulib module symlink for portability"), \
832 #if @GNULIB_SYMLINKAT@
833 # if !@HAVE_SYMLINKAT@
834 extern int symlinkat (char const *contents, int fd, char const *file)
835 _GL_ARG_NONNULL ((1, 3));
837 #elif defined GNULIB_POSIXCHECK
839 # define symlinkat(c,d,n) \
840 (GL_LINK_WARNING ("symlinkat is not portable - " \
841 "use gnulib module symlinkat for portability"), \
847 # if @REPLACE_UNLINK@
849 # define unlink rpl_unlink
850 extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
852 #elif defined GNULIB_POSIXCHECK
855 (GL_LINK_WARNING ("unlink is not portable - " \
856 "use gnulib module unlink for portability"), \
861 #if @GNULIB_UNLINKAT@
862 # if @REPLACE_UNLINKAT@
864 # define unlinkat rpl_unlinkat
866 # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
867 extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
869 #elif defined GNULIB_POSIXCHECK
871 # define unlinkat(d,n,f) \
872 (GL_LINK_WARNING ("unlinkat is not portable - " \
873 "use gnulib module openat for portability"), \
879 # if @REPLACE_USLEEP@
881 # define usleep rpl_usleep
883 # if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
884 /* Pause the execution of the current thread for N microseconds.
885 Returns 0 on completion, or -1 on range error.
886 See the POSIX:2001 specification
887 <http://www.opengroup.org/susv3xsh/sleep.html>. */
888 extern int usleep (useconds_t n);
890 #elif defined GNULIB_POSIXCHECK
893 (GL_LINK_WARNING ("usleep is unportable - " \
894 "use gnulib module usleep for portability"), \
899 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
900 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
901 See the POSIX:2001 specification
902 <http://www.opengroup.org/susv3xsh/write.html>. */
904 # define write rpl_write
905 extern ssize_t write (int fd, const void *buf, size_t count)
906 _GL_ARG_NONNULL ((2));
915 #endif /* _GL_UNISTD_H */
916 #endif /* _GL_UNISTD_H */