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 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
38 || @GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)
42 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
43 #if @GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK
47 /* mingw fails to declare _exit in <unistd.h>. */
48 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
49 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
52 /* mingw declares getcwd in <io.h>, not in <unistd.h>. */
53 #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
54 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
58 #if ((@GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@) \
59 || (@GNULIB_READLINK@ && (!@HAVE_READLINK@ || @REPLACE_READLINK@)) \
60 || (@GNULIB_READLINKAT@ && !@HAVE_READLINKAT@) \
61 || defined GNULIB_POSIXCHECK)
63 # include <sys/types.h>
66 /* Get getopt(), optarg, optind, opterr, optopt. */
67 #if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
71 #if @GNULIB_GETHOSTNAME@
72 /* Get all possible declarations of gethostname(). */
73 # if @UNISTD_H_HAVE_WINSOCK2_H@
74 # include <winsock2.h>
75 # if !defined _GL_SYS_SOCKET_H
77 # define socket socket_used_without_including_sys_socket_h
79 # define connect connect_used_without_including_sys_socket_h
81 # define accept accept_used_without_including_sys_socket_h
83 # define bind bind_used_without_including_sys_socket_h
85 # define getpeername getpeername_used_without_including_sys_socket_h
87 # define getsockname getsockname_used_without_including_sys_socket_h
89 # define getsockopt getsockopt_used_without_including_sys_socket_h
91 # define listen listen_used_without_including_sys_socket_h
93 # define recv recv_used_without_including_sys_socket_h
95 # define send send_used_without_including_sys_socket_h
97 # define recvfrom recvfrom_used_without_including_sys_socket_h
99 # define sendto sendto_used_without_including_sys_socket_h
101 # define setsockopt setsockopt_used_without_including_sys_socket_h
103 # define shutdown shutdown_used_without_including_sys_socket_h
105 # if !defined _GL_SYS_SELECT_H
107 # define select select_used_without_including_sys_select_h
112 /* The definition of GL_LINK_WARNING is copied here. */
114 /* The definition of _GL_ARG_NONNULL is copied here. */
117 /* OS/2 EMX lacks these macros. */
119 # define STDIN_FILENO 0
121 #ifndef STDOUT_FILENO
122 # define STDOUT_FILENO 1
124 #ifndef STDERR_FILENO
125 # define STDERR_FILENO 2
128 /* Ensure *_OK macros exist. */
137 /* Declare overridden functions. */
147 # define chown rpl_chown
149 # if !@HAVE_CHOWN@ || @REPLACE_CHOWN@
150 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
151 to GID (if GID is not -1). Follow symbolic links.
152 Return 0 if successful, otherwise -1 and errno set.
153 See the POSIX:2001 specification
154 <http://www.opengroup.org/susv3xsh/chown.html>. */
155 extern int chown (const char *file, uid_t uid, gid_t gid)
156 _GL_ARG_NONNULL ((1));
158 #elif defined GNULIB_POSIXCHECK
160 # define chown(f,u,g) \
161 (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
162 "doesn't treat a uid or gid of -1 on some systems - " \
163 "use gnulib module chown for portability"), \
170 /* Automatically included by modules that need a replacement for close. */
172 # define close rpl_close
173 extern int close (int);
175 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
177 # define close close_used_without_requesting_gnulib_module_close
178 #elif defined GNULIB_POSIXCHECK
181 (GL_LINK_WARNING ("close does not portably work on sockets - " \
182 "use gnulib module close for portability"), \
189 extern int dup (int);
195 # define dup2 rpl_dup2
197 # if !@HAVE_DUP2@ || @REPLACE_DUP2@
198 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
199 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
200 Return newfd if successful, otherwise -1 and errno set.
201 See the POSIX:2001 specification
202 <http://www.opengroup.org/susv3xsh/dup2.html>. */
203 extern int dup2 (int oldfd, int newfd);
205 #elif defined GNULIB_POSIXCHECK
208 (GL_LINK_WARNING ("dup2 is unportable - " \
209 "use gnulib module dup2 for portability"), \
215 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
217 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
218 and O_TEXT, O_BINARY (defined in "binary-io.h").
219 Close NEWFD first if it is open.
220 Return newfd if successful, otherwise -1 and errno set.
221 See the Linux man page at
222 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
224 # define dup3 rpl_dup3
226 extern int dup3 (int oldfd, int newfd, int flags);
227 #elif defined GNULIB_POSIXCHECK
229 # define dup3(o,n,f) \
230 (GL_LINK_WARNING ("dup3 is unportable - " \
231 "use gnulib module dup3 for portability"), \
237 # if !@HAVE_DECL_ENVIRON@
238 /* Set of environment variables and values. An array of strings of the form
239 "VARIABLE=VALUE", terminated with a NULL. */
240 # if defined __APPLE__ && defined __MACH__
241 # include <crt_externs.h>
242 # define environ (*_NSGetEnviron ())
244 extern char **environ;
247 #elif defined GNULIB_POSIXCHECK
250 (GL_LINK_WARNING ("environ is unportable - " \
251 "use gnulib module environ for portability"), \
256 #if @GNULIB_EUIDACCESS@
257 # if !@HAVE_EUIDACCESS@
258 /* Like access(), except that it uses the effective user id and group id of
259 the current process. */
260 extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
262 #elif defined GNULIB_POSIXCHECK
264 # define euidaccess(f,m) \
265 (GL_LINK_WARNING ("euidaccess is unportable - " \
266 "use gnulib module euidaccess for portability"), \
271 #if @GNULIB_FACCESSAT@
272 # if !@HAVE_FACCESSAT@
273 extern int faccessat (int fd, char const *file, int mode, int flag)
274 _GL_ARG_NONNULL ((2));
276 #elif defined GNULIB_POSIXCHECK
278 # define faccessat(d,n,m,f) \
279 (GL_LINK_WARNING ("faccessat is not portable - " \
280 "use gnulib module faccessat for portability"), \
281 faccessat (d, n, m, f))
286 # if @REPLACE_FCHDIR@
287 /* Change the process' current working directory to the directory on which
288 the given file descriptor is open.
289 Return 0 if successful, otherwise -1 and errno set.
290 See the POSIX:2001 specification
291 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
292 extern int fchdir (int /*fd*/);
294 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
295 extern int _gl_register_fd (int fd, const char *filename)
296 _GL_ARG_NONNULL ((2));
297 extern void _gl_unregister_fd (int fd);
298 extern int _gl_register_dup (int oldfd, int newfd);
299 extern const char *_gl_directory_name (int fd);
302 #elif defined GNULIB_POSIXCHECK
305 (GL_LINK_WARNING ("fchdir is unportable - " \
306 "use gnulib module fchdir for portability"), \
311 #if @GNULIB_FCHOWNAT@
312 # if @REPLACE_FCHOWNAT@
314 # define fchownat rpl_fchownat
316 # if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
317 extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
318 _GL_ARG_NONNULL ((2));
320 #elif defined GNULIB_POSIXCHECK
322 # define fchownat(d,n,o,g,f) \
323 (GL_LINK_WARNING ("fchownat is not portable - " \
324 "use gnulib module openat for portability"), \
325 fchownat (d, n, o, g, f))
330 /* Synchronize changes to a file.
331 Return 0 if successful, otherwise -1 and errno set.
332 See POSIX:2001 specification
333 <http://www.opengroup.org/susv3xsh/fsync.html>. */
335 extern int fsync (int fd);
337 #elif defined GNULIB_POSIXCHECK
340 (GL_LINK_WARNING ("fsync is unportable - " \
341 "use gnulib module fsync for portability"), \
346 #if @GNULIB_FTRUNCATE@
347 # if !@HAVE_FTRUNCATE@
348 /* Change the size of the file to which FD is opened to become equal to LENGTH.
349 Return 0 if successful, otherwise -1 and errno set.
350 See the POSIX:2001 specification
351 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
352 extern int ftruncate (int fd, off_t length);
354 #elif defined GNULIB_POSIXCHECK
356 # define ftruncate(f,l) \
357 (GL_LINK_WARNING ("ftruncate is unportable - " \
358 "use gnulib module ftruncate for portability"), \
364 # if @REPLACE_GETCWD@
365 /* Get the name of the current working directory, and put it in SIZE bytes
367 Return BUF if successful, or NULL if the directory couldn't be determined
368 or SIZE was too small.
369 See the POSIX:2001 specification
370 <http://www.opengroup.org/susv3xsh/getcwd.html>.
371 Additionally, the gnulib module 'getcwd' guarantees the following GNU
372 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
373 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
375 # define getcwd rpl_getcwd
376 extern char * getcwd (char *buf, size_t size);
378 #elif defined GNULIB_POSIXCHECK
380 # define getcwd(b,s) \
381 (GL_LINK_WARNING ("getcwd is unportable - " \
382 "use gnulib module getcwd for portability"), \
387 #if @GNULIB_GETDOMAINNAME@
388 /* Return the NIS domain name of the machine.
389 WARNING! The NIS domain name is unrelated to the fully qualified host name
390 of the machine. It is also unrelated to email addresses.
391 WARNING! The NIS domain name is usually the empty string or "(none)" when
394 Put up to LEN bytes of the NIS domain name into NAME.
395 Null terminate it if the name is shorter than LEN.
396 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
397 Return 0 if successful, otherwise set errno and return -1. */
398 # if !@HAVE_GETDOMAINNAME@
399 extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
401 #elif defined GNULIB_POSIXCHECK
402 # undef getdomainname
403 # define getdomainname(n,l) \
404 (GL_LINK_WARNING ("getdomainname is unportable - " \
405 "use gnulib module getdomainname for portability"), \
406 getdomainname (n, l))
410 #if @GNULIB_GETDTABLESIZE@
411 # if !@HAVE_GETDTABLESIZE@
412 /* Return the maximum number of file descriptors in the current process.
413 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
414 extern int getdtablesize (void);
416 #elif defined GNULIB_POSIXCHECK
417 # undef getdtablesize
418 # define getdtablesize() \
419 (GL_LINK_WARNING ("getdtablesize is unportable - " \
420 "use gnulib module getdtablesize for portability"), \
425 #if @GNULIB_GETGROUPS@
426 # if @REPLACE_GETGROUPS@
428 # define getgroups rpl_getgroups
430 # if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@
431 /* Return the supplemental groups that the current process belongs to.
432 It is unspecified whether the effective group id is in the list.
433 If N is 0, return the group count; otherwise, N describes how many
434 entries are available in GROUPS. Return -1 and set errno if N is
435 not 0 and not large enough. Fails with ENOSYS on some systems. */
436 int getgroups (int n, gid_t *groups);
438 #elif defined GNULIB_POSIXCHECK
440 # define getgroups(n,g) \
441 (GL_LINK_WARNING ("getgroups is unportable - " \
442 "use gnulib module getgroups for portability"), \
447 #if @GNULIB_GETHOSTNAME@
448 /* Return the standard host name of the machine.
449 WARNING! The host name may or may not be fully qualified.
451 Put up to LEN bytes of the host name into NAME.
452 Null terminate it if the name is shorter than LEN.
453 If the host name is longer than LEN, set errno = EINVAL and return -1.
454 Return 0 if successful, otherwise set errno and return -1. */
455 # if @UNISTD_H_HAVE_WINSOCK2_H@
457 # define gethostname rpl_gethostname
459 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
460 extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
462 #elif @UNISTD_H_HAVE_WINSOCK2_H@
464 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
465 #elif defined GNULIB_POSIXCHECK
467 # define gethostname(n,l) \
468 (GL_LINK_WARNING ("gethostname is unportable - " \
469 "use gnulib module gethostname for portability"), \
474 #if @GNULIB_GETLOGIN_R@
475 /* Copies the user's login name to NAME.
476 The array pointed to by NAME has room for SIZE bytes.
478 Returns 0 if successful. Upon error, an error number is returned, or -1 in
479 the case that the login name cannot be found but no specific error is
480 provided (this case is hopefully rare but is left open by the POSIX spec).
482 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
484 # if !@HAVE_DECL_GETLOGIN_R@
485 extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
487 #elif defined GNULIB_POSIXCHECK
489 # define getlogin_r(n,s) \
490 (GL_LINK_WARNING ("getlogin_r is unportable - " \
491 "use gnulib module getlogin_r for portability"), \
496 #if @GNULIB_GETPAGESIZE@
497 # if @REPLACE_GETPAGESIZE@
498 # define getpagesize rpl_getpagesize
499 extern int getpagesize (void);
500 # elif !@HAVE_GETPAGESIZE@
501 /* This is for POSIX systems. */
502 # if !defined getpagesize && defined _SC_PAGESIZE
503 # if ! (defined __VMS && __VMS_VER < 70000000)
504 # define getpagesize() sysconf (_SC_PAGESIZE)
507 /* This is for older VMS. */
508 # if !defined getpagesize && defined __VMS
510 # define getpagesize() 8192
512 # define getpagesize() 512
515 /* This is for BeOS. */
516 # if !defined getpagesize && @HAVE_OS_H@
518 # if defined B_PAGE_SIZE
519 # define getpagesize() B_PAGE_SIZE
522 /* This is for AmigaOS4.0. */
523 # if !defined getpagesize && defined __amigaos4__
524 # define getpagesize() 2048
526 /* This is for older Unix systems. */
527 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
528 # include <sys/param.h>
529 # ifdef EXEC_PAGESIZE
530 # define getpagesize() EXEC_PAGESIZE
536 # define getpagesize() (NBPG * CLSIZE)
539 # define getpagesize() NBPC
545 #elif defined GNULIB_POSIXCHECK
547 # define getpagesize() \
548 (GL_LINK_WARNING ("getpagesize is unportable - " \
549 "use gnulib module getpagesize for portability"), \
554 #if @GNULIB_GETUSERSHELL@
555 # if !@HAVE_GETUSERSHELL@
556 /* Return the next valid login shell on the system, or NULL when the end of
557 the list has been reached. */
558 extern char *getusershell (void);
559 /* Rewind to pointer that is advanced at each getusershell() call. */
560 extern void setusershell (void);
561 /* Free the pointer that is advanced at each getusershell() call and
562 associated resources. */
563 extern void endusershell (void);
565 #elif defined GNULIB_POSIXCHECK
567 # define getusershell() \
568 (GL_LINK_WARNING ("getusershell is unportable - " \
569 "use gnulib module getusershell for portability"), \
572 # define setusershell() \
573 (GL_LINK_WARNING ("setusershell is unportable - " \
574 "use gnulib module getusershell for portability"), \
577 # define endusershell() \
578 (GL_LINK_WARNING ("endusershell is unportable - " \
579 "use gnulib module getusershell for portability"), \
585 # if @REPLACE_LCHOWN@
587 # define lchown rpl_lchown
589 # if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
590 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
591 to GID (if GID is not -1). Do not follow symbolic links.
592 Return 0 if successful, otherwise -1 and errno set.
593 See the POSIX:2001 specification
594 <http://www.opengroup.org/susv3xsh/lchown.html>. */
595 extern int lchown (char const *file, uid_t owner, gid_t group)
596 _GL_ARG_NONNULL ((1));
598 #elif defined GNULIB_POSIXCHECK
600 # define lchown(f,u,g) \
601 (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
602 "systems - use gnulib module lchown for portability"), \
609 # define link rpl_link
611 /* Create a new hard link for an existing file.
612 Return 0 if successful, otherwise -1 and errno set.
613 See POSIX:2001 specification
614 <http://www.opengroup.org/susv3xsh/link.html>. */
615 # if !@HAVE_LINK@ || @REPLACE_LINK@
616 extern int link (const char *path1, const char *path2)
617 _GL_ARG_NONNULL ((1, 2));
619 #elif defined GNULIB_POSIXCHECK
621 # define link(path1,path2) \
622 (GL_LINK_WARNING ("link is unportable - " \
623 "use gnulib module link for portability"), \
628 # if @REPLACE_LINKAT@
630 # define linkat rpl_linkat
632 /* Create a new hard link for an existing file, relative to two
633 directories. FLAG controls whether symlinks are followed.
634 Return 0 if successful, otherwise -1 and errno set. */
635 # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
636 extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
638 _GL_ARG_NONNULL ((2, 4));
640 #elif defined GNULIB_POSIXCHECK
642 # define link(f1,path1,f2,path2,f) \
643 (GL_LINK_WARNING ("linkat is unportable - " \
644 "use gnulib module linkat for portability"), \
645 linkat (f1, path1, f2, path2,f))
650 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
651 Return the new offset if successful, otherwise -1 and errno set.
652 See the POSIX:2001 specification
653 <http://www.opengroup.org/susv3xsh/lseek.html>. */
654 # define lseek rpl_lseek
655 extern off_t lseek (int fd, off_t offset, int whence);
657 #elif defined GNULIB_POSIXCHECK
659 # define lseek(f,o,w) \
660 (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
661 "systems - use gnulib module lseek for portability"), \
667 /* Create a pipe, applying the given flags when opening the read-end of the
668 pipe and the write-end of the pipe.
669 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
670 and O_TEXT, O_BINARY (defined in "binary-io.h").
671 Store the read-end as fd[0] and the write-end as fd[1].
672 Return 0 upon success, or -1 with errno set upon failure.
673 See also the Linux man page at
674 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
676 # define pipe2 rpl_pipe2
678 extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
679 #elif defined GNULIB_POSIXCHECK
681 # define pipe2(f,o) \
682 (GL_LINK_WARNING ("pipe2 is unportable - " \
683 "use gnulib module pipe2 for portability"), \
690 # define pread rpl_pread
692 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
693 Return the number of bytes placed into BUF if successful, otherwise
694 set errno and return -1. 0 indicates EOF. See the POSIX:2001
695 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
696 # if !@HAVE_PREAD@ || @REPLACE_PREAD@
697 extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
698 _GL_ARG_NONNULL ((2));
700 #elif defined GNULIB_POSIXCHECK
702 # define pread(f,b,s,o) \
703 (GL_LINK_WARNING ("pread is unportable - " \
704 "use gnulib module pread for portability"), \
709 #if @GNULIB_READLINK@
710 # if @REPLACE_READLINK@
711 # define readlink rpl_readlink
713 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
714 bytes of it into BUF. Return the number of bytes placed into BUF if
715 successful, otherwise -1 and errno set.
716 See the POSIX:2001 specification
717 <http://www.opengroup.org/susv3xsh/readlink.html>. */
718 # if !@HAVE_READLINK@ || @REPLACE_READLINK@
719 extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
720 _GL_ARG_NONNULL ((1, 2));
722 #elif defined GNULIB_POSIXCHECK
724 # define readlink(f,b,s) \
725 (GL_LINK_WARNING ("readlink is unportable - " \
726 "use gnulib module readlink for portability"), \
731 #if @GNULIB_READLINKAT@
732 # if !@HAVE_READLINKAT@
733 extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
734 _GL_ARG_NONNULL ((2, 3));
736 #elif defined GNULIB_POSIXCHECK
738 # define readlinkat(d,n,b,l) \
739 (GL_LINK_WARNING ("readlinkat is not portable - " \
740 "use gnulib module symlinkat for portability"), \
741 readlinkat (d, n, b, l))
747 # define rmdir rpl_rmdir
748 /* Remove the directory DIR. */
749 extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
751 #elif defined GNULIB_POSIXCHECK
754 (GL_LINK_WARNING ("rmdir is unportable - " \
755 "use gnulib module rmdir for portability"), \
763 # define sleep rpl_sleep
765 /* Pause the execution of the current thread for N seconds.
766 Returns the number of seconds left to sleep.
767 See the POSIX:2001 specification
768 <http://www.opengroup.org/susv3xsh/sleep.html>. */
769 # if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
770 extern unsigned int sleep (unsigned int n);
772 #elif defined GNULIB_POSIXCHECK
775 (GL_LINK_WARNING ("sleep is unportable - " \
776 "use gnulib module sleep for portability"), \
782 # if @REPLACE_SYMLINK@
784 # define symlink rpl_symlink
786 # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
787 extern int symlink (char const *contents, char const *file)
788 _GL_ARG_NONNULL ((1, 2));
790 #elif defined GNULIB_POSIXCHECK
792 # define symlink(c,n) \
793 (GL_LINK_WARNING ("symlink is not portable - " \
794 "use gnulib module symlink for portability"), \
799 #if @GNULIB_SYMLINKAT@
800 # if !@HAVE_SYMLINKAT@
801 extern int symlinkat (char const *contents, int fd, char const *file)
802 _GL_ARG_NONNULL ((1, 3));
804 #elif defined GNULIB_POSIXCHECK
806 # define symlinkat(c,d,n) \
807 (GL_LINK_WARNING ("symlinkat is not portable - " \
808 "use gnulib module symlinkat for portability"), \
814 # if @REPLACE_UNLINK@
816 # define unlink rpl_unlink
817 extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
819 #elif defined GNULIB_POSIXCHECK
822 (GL_LINK_WARNING ("unlink is not portable - " \
823 "use gnulib module unlink for portability"), \
828 #if @GNULIB_UNLINKAT@
829 # if @REPLACE_UNLINKAT@
831 # define unlinkat rpl_unlinkat
833 # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
834 extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
836 #elif defined GNULIB_POSIXCHECK
838 # define unlinkat(d,n,f) \
839 (GL_LINK_WARNING ("unlinkat is not portable - " \
840 "use gnulib module openat for portability"), \
846 # if @REPLACE_USLEEP@
848 # define usleep rpl_usleep
850 # if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
851 /* Pause the execution of the current thread for N microseconds.
852 Returns 0 on completion, or -1 on range error.
853 See the POSIX:2001 specification
854 <http://www.opengroup.org/susv3xsh/sleep.html>. */
855 extern int usleep (useconds_t n);
857 #elif defined GNULIB_POSIXCHECK
860 (GL_LINK_WARNING ("usleep is unportable - " \
861 "use gnulib module usleep for portability"), \
866 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
867 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
868 See the POSIX:2001 specification
869 <http://www.opengroup.org/susv3xsh/write.html>. */
871 # define write rpl_write
872 extern ssize_t write (int fd, const void *buf, size_t count)
873 _GL_ARG_NONNULL ((2));
882 #endif /* _GL_UNISTD_H */
883 #endif /* _GL_UNISTD_H */