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_R@
480 /* Copies the user's login name to NAME.
481 The array pointed to by NAME has room for SIZE bytes.
483 Returns 0 if successful. Upon error, an error number is returned, or -1 in
484 the case that the login name cannot be found but no specific error is
485 provided (this case is hopefully rare but is left open by the POSIX spec).
487 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
489 Most programs don't need to use this function, because the information is
490 available through environment variables:
491 ${LOGNAME-$USER} on Unix platforms,
492 $USERNAME on native Windows platforms.
494 # if !@HAVE_DECL_GETLOGIN_R@
495 extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
497 #elif defined GNULIB_POSIXCHECK
499 # define getlogin_r(n,s) \
500 (GL_LINK_WARNING ("getlogin_r is unportable - " \
501 "use gnulib module getlogin_r for portability"), \
506 #if @GNULIB_GETPAGESIZE@
507 # if @REPLACE_GETPAGESIZE@
508 # define getpagesize rpl_getpagesize
509 extern int getpagesize (void);
510 # elif !@HAVE_GETPAGESIZE@
511 /* This is for POSIX systems. */
512 # if !defined getpagesize && defined _SC_PAGESIZE
513 # if ! (defined __VMS && __VMS_VER < 70000000)
514 # define getpagesize() sysconf (_SC_PAGESIZE)
517 /* This is for older VMS. */
518 # if !defined getpagesize && defined __VMS
520 # define getpagesize() 8192
522 # define getpagesize() 512
525 /* This is for BeOS. */
526 # if !defined getpagesize && @HAVE_OS_H@
528 # if defined B_PAGE_SIZE
529 # define getpagesize() B_PAGE_SIZE
532 /* This is for AmigaOS4.0. */
533 # if !defined getpagesize && defined __amigaos4__
534 # define getpagesize() 2048
536 /* This is for older Unix systems. */
537 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
538 # include <sys/param.h>
539 # ifdef EXEC_PAGESIZE
540 # define getpagesize() EXEC_PAGESIZE
546 # define getpagesize() (NBPG * CLSIZE)
549 # define getpagesize() NBPC
555 #elif defined GNULIB_POSIXCHECK
557 # define getpagesize() \
558 (GL_LINK_WARNING ("getpagesize is unportable - " \
559 "use gnulib module getpagesize for portability"), \
564 #if @GNULIB_GETUSERSHELL@
565 # if !@HAVE_GETUSERSHELL@
566 /* Return the next valid login shell on the system, or NULL when the end of
567 the list has been reached. */
568 extern char *getusershell (void);
569 /* Rewind to pointer that is advanced at each getusershell() call. */
570 extern void setusershell (void);
571 /* Free the pointer that is advanced at each getusershell() call and
572 associated resources. */
573 extern void endusershell (void);
575 #elif defined GNULIB_POSIXCHECK
577 # define getusershell() \
578 (GL_LINK_WARNING ("getusershell is unportable - " \
579 "use gnulib module getusershell for portability"), \
582 # define setusershell() \
583 (GL_LINK_WARNING ("setusershell is unportable - " \
584 "use gnulib module getusershell for portability"), \
587 # define endusershell() \
588 (GL_LINK_WARNING ("endusershell is unportable - " \
589 "use gnulib module getusershell for portability"), \
595 # if @REPLACE_LCHOWN@
597 # define lchown rpl_lchown
599 # if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
600 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
601 to GID (if GID is not -1). Do not follow symbolic links.
602 Return 0 if successful, otherwise -1 and errno set.
603 See the POSIX:2001 specification
604 <http://www.opengroup.org/susv3xsh/lchown.html>. */
605 extern int lchown (char const *file, uid_t owner, gid_t group)
606 _GL_ARG_NONNULL ((1));
608 #elif defined GNULIB_POSIXCHECK
610 # define lchown(f,u,g) \
611 (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
612 "systems - use gnulib module lchown for portability"), \
619 # define link rpl_link
621 /* Create a new hard link for an existing file.
622 Return 0 if successful, otherwise -1 and errno set.
623 See POSIX:2001 specification
624 <http://www.opengroup.org/susv3xsh/link.html>. */
625 # if !@HAVE_LINK@ || @REPLACE_LINK@
626 extern int link (const char *path1, const char *path2)
627 _GL_ARG_NONNULL ((1, 2));
629 #elif defined GNULIB_POSIXCHECK
631 # define link(path1,path2) \
632 (GL_LINK_WARNING ("link is unportable - " \
633 "use gnulib module link for portability"), \
638 # if @REPLACE_LINKAT@
640 # define linkat rpl_linkat
642 /* Create a new hard link for an existing file, relative to two
643 directories. FLAG controls whether symlinks are followed.
644 Return 0 if successful, otherwise -1 and errno set. */
645 # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
646 extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
648 _GL_ARG_NONNULL ((2, 4));
650 #elif defined GNULIB_POSIXCHECK
652 # define linkat(f1,path1,f2,path2,f) \
653 (GL_LINK_WARNING ("linkat is unportable - " \
654 "use gnulib module linkat for portability"), \
655 linkat (f1, path1, f2, path2,f))
660 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
661 Return the new offset if successful, otherwise -1 and errno set.
662 See the POSIX:2001 specification
663 <http://www.opengroup.org/susv3xsh/lseek.html>. */
664 # define lseek rpl_lseek
665 extern off_t lseek (int fd, off_t offset, int whence);
667 #elif defined GNULIB_POSIXCHECK
669 # define lseek(f,o,w) \
670 (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
671 "systems - use gnulib module lseek for portability"), \
677 /* Create a pipe, applying the given flags when opening the read-end of the
678 pipe and the write-end of the pipe.
679 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
680 and O_TEXT, O_BINARY (defined in "binary-io.h").
681 Store the read-end as fd[0] and the write-end as fd[1].
682 Return 0 upon success, or -1 with errno set upon failure.
683 See also the Linux man page at
684 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
686 # define pipe2 rpl_pipe2
688 extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
689 #elif defined GNULIB_POSIXCHECK
691 # define pipe2(f,o) \
692 (GL_LINK_WARNING ("pipe2 is unportable - " \
693 "use gnulib module pipe2 for portability"), \
700 # define pread rpl_pread
702 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
703 Return the number of bytes placed into BUF if successful, otherwise
704 set errno and return -1. 0 indicates EOF. See the POSIX:2001
705 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
706 # if !@HAVE_PREAD@ || @REPLACE_PREAD@
707 extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
708 _GL_ARG_NONNULL ((2));
710 #elif defined GNULIB_POSIXCHECK
712 # define pread(f,b,s,o) \
713 (GL_LINK_WARNING ("pread is unportable - " \
714 "use gnulib module pread for portability"), \
719 #if @GNULIB_READLINK@
720 # if @REPLACE_READLINK@
721 # define readlink rpl_readlink
723 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
724 bytes of it into BUF. Return the number of bytes placed into BUF if
725 successful, otherwise -1 and errno set.
726 See the POSIX:2001 specification
727 <http://www.opengroup.org/susv3xsh/readlink.html>. */
728 # if !@HAVE_READLINK@ || @REPLACE_READLINK@
729 extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
730 _GL_ARG_NONNULL ((1, 2));
732 #elif defined GNULIB_POSIXCHECK
734 # define readlink(f,b,s) \
735 (GL_LINK_WARNING ("readlink is unportable - " \
736 "use gnulib module readlink for portability"), \
741 #if @GNULIB_READLINKAT@
742 # if !@HAVE_READLINKAT@
743 extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
744 _GL_ARG_NONNULL ((2, 3));
746 #elif defined GNULIB_POSIXCHECK
748 # define readlinkat(d,n,b,l) \
749 (GL_LINK_WARNING ("readlinkat is not portable - " \
750 "use gnulib module symlinkat for portability"), \
751 readlinkat (d, n, b, l))
757 # define rmdir rpl_rmdir
758 /* Remove the directory DIR. */
759 extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
761 #elif defined GNULIB_POSIXCHECK
764 (GL_LINK_WARNING ("rmdir is unportable - " \
765 "use gnulib module rmdir for portability"), \
773 # define sleep rpl_sleep
775 /* Pause the execution of the current thread for N seconds.
776 Returns the number of seconds left to sleep.
777 See the POSIX:2001 specification
778 <http://www.opengroup.org/susv3xsh/sleep.html>. */
779 # if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
780 extern unsigned int sleep (unsigned int n);
782 #elif defined GNULIB_POSIXCHECK
785 (GL_LINK_WARNING ("sleep is unportable - " \
786 "use gnulib module sleep for portability"), \
792 # if @REPLACE_SYMLINK@
794 # define symlink rpl_symlink
796 # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
797 extern int symlink (char const *contents, char const *file)
798 _GL_ARG_NONNULL ((1, 2));
800 #elif defined GNULIB_POSIXCHECK
802 # define symlink(c,n) \
803 (GL_LINK_WARNING ("symlink is not portable - " \
804 "use gnulib module symlink for portability"), \
809 #if @GNULIB_SYMLINKAT@
810 # if !@HAVE_SYMLINKAT@
811 extern int symlinkat (char const *contents, int fd, char const *file)
812 _GL_ARG_NONNULL ((1, 3));
814 #elif defined GNULIB_POSIXCHECK
816 # define symlinkat(c,d,n) \
817 (GL_LINK_WARNING ("symlinkat is not portable - " \
818 "use gnulib module symlinkat for portability"), \
824 # if @REPLACE_UNLINK@
826 # define unlink rpl_unlink
827 extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
829 #elif defined GNULIB_POSIXCHECK
832 (GL_LINK_WARNING ("unlink is not portable - " \
833 "use gnulib module unlink for portability"), \
838 #if @GNULIB_UNLINKAT@
839 # if @REPLACE_UNLINKAT@
841 # define unlinkat rpl_unlinkat
843 # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
844 extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
846 #elif defined GNULIB_POSIXCHECK
848 # define unlinkat(d,n,f) \
849 (GL_LINK_WARNING ("unlinkat is not portable - " \
850 "use gnulib module openat for portability"), \
856 # if @REPLACE_USLEEP@
858 # define usleep rpl_usleep
860 # if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
861 /* Pause the execution of the current thread for N microseconds.
862 Returns 0 on completion, or -1 on range error.
863 See the POSIX:2001 specification
864 <http://www.opengroup.org/susv3xsh/sleep.html>. */
865 extern int usleep (useconds_t n);
867 #elif defined GNULIB_POSIXCHECK
870 (GL_LINK_WARNING ("usleep is unportable - " \
871 "use gnulib module usleep for portability"), \
876 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
877 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
878 See the POSIX:2001 specification
879 <http://www.opengroup.org/susv3xsh/write.html>. */
881 # define write rpl_write
882 extern ssize_t write (int fd, const void *buf, size_t count)
883 _GL_ARG_NONNULL ((2));
892 #endif /* _GL_UNISTD_H */
893 #endif /* _GL_UNISTD_H */