1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2009 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@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@) \
65 || (@GNULIB_READLINK@ && (!@HAVE_READLINK@ || @REPLACE_READLINK@)) \
66 || (@GNULIB_READLINKAT@ && !@HAVE_READLINKAT@) \
67 || defined GNULIB_POSIXCHECK)
69 # include <sys/types.h>
72 /* Get getopt(), optarg, optind, opterr, optopt.
73 But avoid namespace pollution on glibc systems. */
74 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
78 #if @GNULIB_GETHOSTNAME@
79 /* Get all possible declarations of gethostname(). */
80 # if @UNISTD_H_HAVE_WINSOCK2_H@
81 # include <winsock2.h>
82 # if !defined _GL_SYS_SOCKET_H
84 # define socket socket_used_without_including_sys_socket_h
86 # define connect connect_used_without_including_sys_socket_h
88 # define accept accept_used_without_including_sys_socket_h
90 # define bind bind_used_without_including_sys_socket_h
92 # define getpeername getpeername_used_without_including_sys_socket_h
94 # define getsockname getsockname_used_without_including_sys_socket_h
96 # define getsockopt getsockopt_used_without_including_sys_socket_h
98 # define listen listen_used_without_including_sys_socket_h
100 # define recv recv_used_without_including_sys_socket_h
102 # define send send_used_without_including_sys_socket_h
104 # define recvfrom recvfrom_used_without_including_sys_socket_h
106 # define sendto sendto_used_without_including_sys_socket_h
108 # define setsockopt setsockopt_used_without_including_sys_socket_h
110 # define shutdown shutdown_used_without_including_sys_socket_h
112 # if !defined _GL_SYS_SELECT_H
114 # define select select_used_without_including_sys_select_h
119 /* The definition of GL_LINK_WARNING is copied here. */
121 /* The definition of _GL_ARG_NONNULL 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
257 (GL_LINK_WARNING ("environ is unportable - " \
258 "use gnulib module environ for portability"), \
263 #if @GNULIB_EUIDACCESS@
264 # if !@HAVE_EUIDACCESS@
265 /* Like access(), except that it uses the effective user id and group id of
266 the current process. */
267 extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
269 #elif defined GNULIB_POSIXCHECK
271 # define euidaccess(f,m) \
272 (GL_LINK_WARNING ("euidaccess is unportable - " \
273 "use gnulib module euidaccess for portability"), \
278 #if @GNULIB_FACCESSAT@
279 # if !@HAVE_FACCESSAT@
280 extern int faccessat (int fd, char const *file, int mode, int flag)
281 _GL_ARG_NONNULL ((2));
283 #elif defined GNULIB_POSIXCHECK
285 # define faccessat(d,n,m,f) \
286 (GL_LINK_WARNING ("faccessat is not portable - " \
287 "use gnulib module faccessat for portability"), \
288 faccessat (d, n, m, f))
293 # if @REPLACE_FCHDIR@
294 /* Change the process' current working directory to the directory on which
295 the given file descriptor is open.
296 Return 0 if successful, otherwise -1 and errno set.
297 See the POSIX:2001 specification
298 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
299 extern int fchdir (int /*fd*/);
301 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
302 extern int _gl_register_fd (int fd, const char *filename)
303 _GL_ARG_NONNULL ((2));
304 extern void _gl_unregister_fd (int fd);
305 extern int _gl_register_dup (int oldfd, int newfd);
306 extern const char *_gl_directory_name (int fd);
309 #elif defined GNULIB_POSIXCHECK
312 (GL_LINK_WARNING ("fchdir is unportable - " \
313 "use gnulib module fchdir for portability"), \
318 #if @GNULIB_FCHOWNAT@
319 # if @REPLACE_FCHOWNAT@
321 # define fchownat rpl_fchownat
323 # if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
324 extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
325 _GL_ARG_NONNULL ((2));
327 #elif defined GNULIB_POSIXCHECK
329 # define fchownat(d,n,o,g,f) \
330 (GL_LINK_WARNING ("fchownat is not portable - " \
331 "use gnulib module openat for portability"), \
332 fchownat (d, n, o, g, f))
337 /* Synchronize changes to a file.
338 Return 0 if successful, otherwise -1 and errno set.
339 See POSIX:2001 specification
340 <http://www.opengroup.org/susv3xsh/fsync.html>. */
342 extern int fsync (int fd);
344 #elif defined GNULIB_POSIXCHECK
347 (GL_LINK_WARNING ("fsync is unportable - " \
348 "use gnulib module fsync for portability"), \
353 #if @GNULIB_FTRUNCATE@
354 # if !@HAVE_FTRUNCATE@
355 /* Change the size of the file to which FD is opened to become equal to LENGTH.
356 Return 0 if successful, otherwise -1 and errno set.
357 See the POSIX:2001 specification
358 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
359 extern int ftruncate (int fd, off_t length);
361 #elif defined GNULIB_POSIXCHECK
363 # define ftruncate(f,l) \
364 (GL_LINK_WARNING ("ftruncate is unportable - " \
365 "use gnulib module ftruncate for portability"), \
371 # if @REPLACE_GETCWD@
372 /* Get the name of the current working directory, and put it in SIZE bytes
374 Return BUF if successful, or NULL if the directory couldn't be determined
375 or SIZE was too small.
376 See the POSIX:2001 specification
377 <http://www.opengroup.org/susv3xsh/getcwd.html>.
378 Additionally, the gnulib module 'getcwd' guarantees the following GNU
379 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
380 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
382 # define getcwd rpl_getcwd
383 extern char * getcwd (char *buf, size_t size);
385 #elif defined GNULIB_POSIXCHECK
387 # define getcwd(b,s) \
388 (GL_LINK_WARNING ("getcwd is unportable - " \
389 "use gnulib module getcwd for portability"), \
394 #if @GNULIB_GETDOMAINNAME@
395 /* Return the NIS domain name of the machine.
396 WARNING! The NIS domain name is unrelated to the fully qualified host name
397 of the machine. It is also unrelated to email addresses.
398 WARNING! The NIS domain name is usually the empty string or "(none)" when
401 Put up to LEN bytes of the NIS domain name into NAME.
402 Null terminate it if the name is shorter than LEN.
403 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
404 Return 0 if successful, otherwise set errno and return -1. */
405 # if !@HAVE_GETDOMAINNAME@
406 extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
408 #elif defined GNULIB_POSIXCHECK
409 # undef getdomainname
410 # define getdomainname(n,l) \
411 (GL_LINK_WARNING ("getdomainname is unportable - " \
412 "use gnulib module getdomainname for portability"), \
413 getdomainname (n, l))
417 #if @GNULIB_GETDTABLESIZE@
418 # if !@HAVE_GETDTABLESIZE@
419 /* Return the maximum number of file descriptors in the current process.
420 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
421 extern int getdtablesize (void);
423 #elif defined GNULIB_POSIXCHECK
424 # undef getdtablesize
425 # define getdtablesize() \
426 (GL_LINK_WARNING ("getdtablesize is unportable - " \
427 "use gnulib module getdtablesize for portability"), \
432 #if @GNULIB_GETGROUPS@
433 # if @REPLACE_GETGROUPS@
435 # define getgroups rpl_getgroups
437 # if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@
438 /* Return the supplemental groups that the current process belongs to.
439 It is unspecified whether the effective group id is in the list.
440 If N is 0, return the group count; otherwise, N describes how many
441 entries are available in GROUPS. Return -1 and set errno if N is
442 not 0 and not large enough. Fails with ENOSYS on some systems. */
443 int getgroups (int n, gid_t *groups);
445 #elif defined GNULIB_POSIXCHECK
447 # define getgroups(n,g) \
448 (GL_LINK_WARNING ("getgroups is unportable - " \
449 "use gnulib module getgroups for portability"), \
454 #if @GNULIB_GETHOSTNAME@
455 /* Return the standard host name of the machine.
456 WARNING! The host name may or may not be fully qualified.
458 Put up to LEN bytes of the host name into NAME.
459 Null terminate it if the name is shorter than LEN.
460 If the host name is longer than LEN, set errno = EINVAL and return -1.
461 Return 0 if successful, otherwise set errno and return -1. */
462 # if @UNISTD_H_HAVE_WINSOCK2_H@
464 # define gethostname rpl_gethostname
466 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
467 extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
469 #elif @UNISTD_H_HAVE_WINSOCK2_H@
471 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
472 #elif defined GNULIB_POSIXCHECK
474 # define gethostname(n,l) \
475 (GL_LINK_WARNING ("gethostname is unportable - " \
476 "use gnulib module gethostname for portability"), \
481 #if @GNULIB_GETLOGIN_R@
482 /* Copies the user's login name to NAME.
483 The array pointed to by NAME has room for SIZE bytes.
485 Returns 0 if successful. Upon error, an error number is returned, or -1 in
486 the case that the login name cannot be found but no specific error is
487 provided (this case is hopefully rare but is left open by the POSIX spec).
489 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
491 # if !@HAVE_DECL_GETLOGIN_R@
492 extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
494 #elif defined GNULIB_POSIXCHECK
496 # define getlogin_r(n,s) \
497 (GL_LINK_WARNING ("getlogin_r is unportable - " \
498 "use gnulib module getlogin_r for portability"), \
503 #if @GNULIB_GETPAGESIZE@
504 # if @REPLACE_GETPAGESIZE@
505 # define getpagesize rpl_getpagesize
506 extern int getpagesize (void);
507 # elif !@HAVE_GETPAGESIZE@
508 /* This is for POSIX systems. */
509 # if !defined getpagesize && defined _SC_PAGESIZE
510 # if ! (defined __VMS && __VMS_VER < 70000000)
511 # define getpagesize() sysconf (_SC_PAGESIZE)
514 /* This is for older VMS. */
515 # if !defined getpagesize && defined __VMS
517 # define getpagesize() 8192
519 # define getpagesize() 512
522 /* This is for BeOS. */
523 # if !defined getpagesize && @HAVE_OS_H@
525 # if defined B_PAGE_SIZE
526 # define getpagesize() B_PAGE_SIZE
529 /* This is for AmigaOS4.0. */
530 # if !defined getpagesize && defined __amigaos4__
531 # define getpagesize() 2048
533 /* This is for older Unix systems. */
534 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
535 # include <sys/param.h>
536 # ifdef EXEC_PAGESIZE
537 # define getpagesize() EXEC_PAGESIZE
543 # define getpagesize() (NBPG * CLSIZE)
546 # define getpagesize() NBPC
552 #elif defined GNULIB_POSIXCHECK
554 # define getpagesize() \
555 (GL_LINK_WARNING ("getpagesize is unportable - " \
556 "use gnulib module getpagesize for portability"), \
561 #if @GNULIB_GETUSERSHELL@
562 # if !@HAVE_GETUSERSHELL@
563 /* Return the next valid login shell on the system, or NULL when the end of
564 the list has been reached. */
565 extern char *getusershell (void);
566 /* Rewind to pointer that is advanced at each getusershell() call. */
567 extern void setusershell (void);
568 /* Free the pointer that is advanced at each getusershell() call and
569 associated resources. */
570 extern void endusershell (void);
572 #elif defined GNULIB_POSIXCHECK
574 # define getusershell() \
575 (GL_LINK_WARNING ("getusershell is unportable - " \
576 "use gnulib module getusershell for portability"), \
579 # define setusershell() \
580 (GL_LINK_WARNING ("setusershell is unportable - " \
581 "use gnulib module getusershell for portability"), \
584 # define endusershell() \
585 (GL_LINK_WARNING ("endusershell is unportable - " \
586 "use gnulib module getusershell for portability"), \
592 # if @REPLACE_LCHOWN@
594 # define lchown rpl_lchown
596 # if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
597 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
598 to GID (if GID is not -1). Do not follow symbolic links.
599 Return 0 if successful, otherwise -1 and errno set.
600 See the POSIX:2001 specification
601 <http://www.opengroup.org/susv3xsh/lchown.html>. */
602 extern int lchown (char const *file, uid_t owner, gid_t group)
603 _GL_ARG_NONNULL ((1));
605 #elif defined GNULIB_POSIXCHECK
607 # define lchown(f,u,g) \
608 (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
609 "systems - use gnulib module lchown for portability"), \
616 # define link rpl_link
618 /* Create a new hard link for an existing file.
619 Return 0 if successful, otherwise -1 and errno set.
620 See POSIX:2001 specification
621 <http://www.opengroup.org/susv3xsh/link.html>. */
622 # if !@HAVE_LINK@ || @REPLACE_LINK@
623 extern int link (const char *path1, const char *path2)
624 _GL_ARG_NONNULL ((1, 2));
626 #elif defined GNULIB_POSIXCHECK
628 # define link(path1,path2) \
629 (GL_LINK_WARNING ("link is unportable - " \
630 "use gnulib module link for portability"), \
635 # if @REPLACE_LINKAT@
637 # define linkat rpl_linkat
639 /* Create a new hard link for an existing file, relative to two
640 directories. FLAG controls whether symlinks are followed.
641 Return 0 if successful, otherwise -1 and errno set. */
642 # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
643 extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
645 _GL_ARG_NONNULL ((2, 4));
647 #elif defined GNULIB_POSIXCHECK
649 # define link(f1,path1,f2,path2,f) \
650 (GL_LINK_WARNING ("linkat is unportable - " \
651 "use gnulib module linkat for portability"), \
652 linkat (f1, path1, f2, path2,f))
657 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
658 Return the new offset if successful, otherwise -1 and errno set.
659 See the POSIX:2001 specification
660 <http://www.opengroup.org/susv3xsh/lseek.html>. */
661 # define lseek rpl_lseek
662 extern off_t lseek (int fd, off_t offset, int whence);
664 #elif defined GNULIB_POSIXCHECK
666 # define lseek(f,o,w) \
667 (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
668 "systems - use gnulib module lseek for portability"), \
674 /* Create a pipe, applying the given flags when opening the read-end of the
675 pipe and the write-end of the pipe.
676 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
677 and O_TEXT, O_BINARY (defined in "binary-io.h").
678 Store the read-end as fd[0] and the write-end as fd[1].
679 Return 0 upon success, or -1 with errno set upon failure.
680 See also the Linux man page at
681 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
683 # define pipe2 rpl_pipe2
685 extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
686 #elif defined GNULIB_POSIXCHECK
688 # define pipe2(f,o) \
689 (GL_LINK_WARNING ("pipe2 is unportable - " \
690 "use gnulib module pipe2 for portability"), \
697 # define pread rpl_pread
699 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
700 Return the number of bytes placed into BUF if successful, otherwise
701 set errno and return -1. 0 indicates EOF. See the POSIX:2001
702 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
703 # if !@HAVE_PREAD@ || @REPLACE_PREAD@
704 extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
705 _GL_ARG_NONNULL ((2));
707 #elif defined GNULIB_POSIXCHECK
709 # define pread(f,b,s,o) \
710 (GL_LINK_WARNING ("pread is unportable - " \
711 "use gnulib module pread for portability"), \
716 #if @GNULIB_READLINK@
717 # if @REPLACE_READLINK@
718 # define readlink rpl_readlink
720 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
721 bytes of it into BUF. Return the number of bytes placed into BUF if
722 successful, otherwise -1 and errno set.
723 See the POSIX:2001 specification
724 <http://www.opengroup.org/susv3xsh/readlink.html>. */
725 # if !@HAVE_READLINK@ || @REPLACE_READLINK@
726 extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
727 _GL_ARG_NONNULL ((1, 2));
729 #elif defined GNULIB_POSIXCHECK
731 # define readlink(f,b,s) \
732 (GL_LINK_WARNING ("readlink is unportable - " \
733 "use gnulib module readlink for portability"), \
738 #if @GNULIB_READLINKAT@
739 # if !@HAVE_READLINKAT@
740 extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
741 _GL_ARG_NONNULL ((2, 3));
743 #elif defined GNULIB_POSIXCHECK
745 # define readlinkat(d,n,b,l) \
746 (GL_LINK_WARNING ("readlinkat is not portable - " \
747 "use gnulib module symlinkat for portability"), \
748 readlinkat (d, n, b, l))
754 # define rmdir rpl_rmdir
755 /* Remove the directory DIR. */
756 extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
758 #elif defined GNULIB_POSIXCHECK
761 (GL_LINK_WARNING ("rmdir is unportable - " \
762 "use gnulib module rmdir for portability"), \
770 # define sleep rpl_sleep
772 /* Pause the execution of the current thread for N seconds.
773 Returns the number of seconds left to sleep.
774 See the POSIX:2001 specification
775 <http://www.opengroup.org/susv3xsh/sleep.html>. */
776 # if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
777 extern unsigned int sleep (unsigned int n);
779 #elif defined GNULIB_POSIXCHECK
782 (GL_LINK_WARNING ("sleep is unportable - " \
783 "use gnulib module sleep for portability"), \
789 # if @REPLACE_SYMLINK@
791 # define symlink rpl_symlink
793 # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
794 extern int symlink (char const *contents, char const *file)
795 _GL_ARG_NONNULL ((1, 2));
797 #elif defined GNULIB_POSIXCHECK
799 # define symlink(c,n) \
800 (GL_LINK_WARNING ("symlink is not portable - " \
801 "use gnulib module symlink for portability"), \
806 #if @GNULIB_SYMLINKAT@
807 # if !@HAVE_SYMLINKAT@
808 extern int symlinkat (char const *contents, int fd, char const *file)
809 _GL_ARG_NONNULL ((1, 3));
811 #elif defined GNULIB_POSIXCHECK
813 # define symlinkat(c,d,n) \
814 (GL_LINK_WARNING ("symlinkat is not portable - " \
815 "use gnulib module symlinkat for portability"), \
821 # if @REPLACE_UNLINK@
823 # define unlink rpl_unlink
824 extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
826 #elif defined GNULIB_POSIXCHECK
829 (GL_LINK_WARNING ("unlink is not portable - " \
830 "use gnulib module unlink for portability"), \
835 #if @GNULIB_UNLINKAT@
836 # if @REPLACE_UNLINKAT@
838 # define unlinkat rpl_unlinkat
840 # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
841 extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
843 #elif defined GNULIB_POSIXCHECK
845 # define unlinkat(d,n,f) \
846 (GL_LINK_WARNING ("unlinkat is not portable - " \
847 "use gnulib module openat for portability"), \
853 # if @REPLACE_USLEEP@
855 # define usleep rpl_usleep
857 # if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
858 /* Pause the execution of the current thread for N microseconds.
859 Returns 0 on completion, or -1 on range error.
860 See the POSIX:2001 specification
861 <http://www.opengroup.org/susv3xsh/sleep.html>. */
862 extern int usleep (useconds_t n);
864 #elif defined GNULIB_POSIXCHECK
867 (GL_LINK_WARNING ("usleep is unportable - " \
868 "use gnulib module usleep for portability"), \
873 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
874 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
875 See the POSIX:2001 specification
876 <http://www.opengroup.org/susv3xsh/write.html>. */
878 # define write rpl_write
879 extern ssize_t write (int fd, const void *buf, size_t count)
880 _GL_ARG_NONNULL ((2));
889 #endif /* _GL_UNISTD_H */
890 #endif /* _GL_UNISTD_H */