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@)
42 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
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 _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
57 #if ((@GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@) \
58 || (@GNULIB_READLINK@ && (!@HAVE_READLINK@ || @REPLACE_READLINK@)) \
59 || (@GNULIB_READLINKAT@ && !@HAVE_READLINKAT@))
61 # include <sys/types.h>
64 /* Get getopt(), optarg, optind, opterr, optopt. */
65 #if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
69 #if @GNULIB_GETHOSTNAME@
70 /* Get all possible declarations of gethostname(). */
71 # if @UNISTD_H_HAVE_WINSOCK2_H@
72 # include <winsock2.h>
73 # if !defined _GL_SYS_SOCKET_H
75 # define socket socket_used_without_including_sys_socket_h
77 # define connect connect_used_without_including_sys_socket_h
79 # define accept accept_used_without_including_sys_socket_h
81 # define bind bind_used_without_including_sys_socket_h
83 # define getpeername getpeername_used_without_including_sys_socket_h
85 # define getsockname getsockname_used_without_including_sys_socket_h
87 # define getsockopt getsockopt_used_without_including_sys_socket_h
89 # define listen listen_used_without_including_sys_socket_h
91 # define recv recv_used_without_including_sys_socket_h
93 # define send send_used_without_including_sys_socket_h
95 # define recvfrom recvfrom_used_without_including_sys_socket_h
97 # define sendto sendto_used_without_including_sys_socket_h
99 # define setsockopt setsockopt_used_without_including_sys_socket_h
101 # define shutdown shutdown_used_without_including_sys_socket_h
103 # if !defined _GL_SYS_SELECT_H
105 # define select select_used_without_including_sys_select_h
110 /* The definition of GL_LINK_WARNING is copied here. */
112 /* The definition of _GL_ARG_NONNULL is copied here. */
115 /* OS/2 EMX lacks these macros. */
117 # define STDIN_FILENO 0
119 #ifndef STDOUT_FILENO
120 # define STDOUT_FILENO 1
122 #ifndef STDERR_FILENO
123 # define STDERR_FILENO 2
126 /* Ensure *_OK macros exist. */
135 /* Declare overridden functions. */
145 # define chown rpl_chown
147 # if !@HAVE_CHOWN@ || @REPLACE_CHOWN@
148 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
149 to GID (if GID is not -1). Follow symbolic links.
150 Return 0 if successful, otherwise -1 and errno set.
151 See the POSIX:2001 specification
152 <http://www.opengroup.org/susv3xsh/chown.html>. */
153 extern int chown (const char *file, uid_t uid, gid_t gid)
154 _GL_ARG_NONNULL ((1));
156 #elif defined GNULIB_POSIXCHECK
158 # define chown(f,u,g) \
159 (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
160 "doesn't treat a uid or gid of -1 on some systems - " \
161 "use gnulib module chown for portability"), \
168 /* Automatically included by modules that need a replacement for close. */
170 # define close rpl_close
171 extern int close (int);
173 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
175 # define close close_used_without_requesting_gnulib_module_close
176 #elif defined GNULIB_POSIXCHECK
179 (GL_LINK_WARNING ("close does not portably work on sockets - " \
180 "use gnulib module close for portability"), \
187 extern int dup (int);
193 # define dup2 rpl_dup2
195 # if !@HAVE_DUP2@ || @REPLACE_DUP2@
196 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
197 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
198 Return newfd if successful, otherwise -1 and errno set.
199 See the POSIX:2001 specification
200 <http://www.opengroup.org/susv3xsh/dup2.html>. */
201 extern int dup2 (int oldfd, int newfd);
203 #elif defined GNULIB_POSIXCHECK
206 (GL_LINK_WARNING ("dup2 is unportable - " \
207 "use gnulib module dup2 for portability"), \
213 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
215 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
216 and O_TEXT, O_BINARY (defined in "binary-io.h").
217 Close NEWFD first if it is open.
218 Return newfd if successful, otherwise -1 and errno set.
219 See the Linux man page at
220 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
222 # define dup3 rpl_dup3
224 extern int dup3 (int oldfd, int newfd, int flags);
225 #elif defined GNULIB_POSIXCHECK
227 # define dup3(o,n,f) \
228 (GL_LINK_WARNING ("dup3 is unportable - " \
229 "use gnulib module dup3 for portability"), \
235 # if !@HAVE_DECL_ENVIRON@
236 /* Set of environment variables and values. An array of strings of the form
237 "VARIABLE=VALUE", terminated with a NULL. */
238 # if defined __APPLE__ && defined __MACH__
239 # include <crt_externs.h>
240 # define environ (*_NSGetEnviron ())
242 extern char **environ;
245 #elif defined GNULIB_POSIXCHECK
248 (GL_LINK_WARNING ("environ is unportable - " \
249 "use gnulib module environ for portability"), \
254 #if @GNULIB_EUIDACCESS@
255 # if !@HAVE_EUIDACCESS@
256 /* Like access(), except that it uses the effective user id and group id of
257 the current process. */
258 extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
260 #elif defined GNULIB_POSIXCHECK
262 # define euidaccess(f,m) \
263 (GL_LINK_WARNING ("euidaccess is unportable - " \
264 "use gnulib module euidaccess for portability"), \
269 #if @GNULIB_FACCESSAT@
270 # if !@HAVE_FACCESSAT@
271 extern int faccessat (int fd, char const *file, int mode, int flag)
272 _GL_ARG_NONNULL ((2));
274 #elif defined GNULIB_POSIXCHECK
276 # define faccessat(d,n,m,f) \
277 (GL_LINK_WARNING ("faccessat is not portable - " \
278 "use gnulib module faccessat for portability"), \
279 faccessat (d, n, m, f))
284 # if @REPLACE_FCHDIR@
285 /* Change the process' current working directory to the directory on which
286 the given file descriptor is open.
287 Return 0 if successful, otherwise -1 and errno set.
288 See the POSIX:2001 specification
289 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
290 extern int fchdir (int /*fd*/);
292 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
293 extern int _gl_register_fd (int fd, const char *filename)
294 _GL_ARG_NONNULL ((2));
295 extern void _gl_unregister_fd (int fd);
296 extern int _gl_register_dup (int oldfd, int newfd);
297 extern const char *_gl_directory_name (int fd);
300 #elif defined GNULIB_POSIXCHECK
303 (GL_LINK_WARNING ("fchdir is unportable - " \
304 "use gnulib module fchdir for portability"), \
309 #if @GNULIB_FCHOWNAT@
310 # if @REPLACE_FCHOWNAT@
312 # define fchownat rpl_fchownat
314 # if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
315 extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
316 _GL_ARG_NONNULL ((2));
318 #elif defined GNULIB_POSIXCHECK
320 # define fchownat(d,n,o,g,f) \
321 (GL_LINK_WARNING ("fchownat is not portable - " \
322 "use gnulib module openat for portability"), \
323 fchownat (d, n, o, g, f))
328 /* Synchronize changes to a file.
329 Return 0 if successful, otherwise -1 and errno set.
330 See POSIX:2001 specification
331 <http://www.opengroup.org/susv3xsh/fsync.html>. */
333 extern int fsync (int fd);
335 #elif defined GNULIB_POSIXCHECK
338 (GL_LINK_WARNING ("fsync is unportable - " \
339 "use gnulib module fsync for portability"), \
344 #if @GNULIB_FTRUNCATE@
345 # if !@HAVE_FTRUNCATE@
346 /* Change the size of the file to which FD is opened to become equal to LENGTH.
347 Return 0 if successful, otherwise -1 and errno set.
348 See the POSIX:2001 specification
349 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
350 extern int ftruncate (int fd, off_t length);
352 #elif defined GNULIB_POSIXCHECK
354 # define ftruncate(f,l) \
355 (GL_LINK_WARNING ("ftruncate is unportable - " \
356 "use gnulib module ftruncate for portability"), \
362 # if @REPLACE_GETCWD@
363 /* Get the name of the current working directory, and put it in SIZE bytes
365 Return BUF if successful, or NULL if the directory couldn't be determined
366 or SIZE was too small.
367 See the POSIX:2001 specification
368 <http://www.opengroup.org/susv3xsh/getcwd.html>.
369 Additionally, the gnulib module 'getcwd' guarantees the following GNU
370 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
371 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
373 # define getcwd rpl_getcwd
374 extern char * getcwd (char *buf, size_t size);
376 #elif defined GNULIB_POSIXCHECK
378 # define getcwd(b,s) \
379 (GL_LINK_WARNING ("getcwd is unportable - " \
380 "use gnulib module getcwd for portability"), \
385 #if @GNULIB_GETDOMAINNAME@
386 /* Return the NIS domain name of the machine.
387 WARNING! The NIS domain name is unrelated to the fully qualified host name
388 of the machine. It is also unrelated to email addresses.
389 WARNING! The NIS domain name is usually the empty string or "(none)" when
392 Put up to LEN bytes of the NIS domain name into NAME.
393 Null terminate it if the name is shorter than LEN.
394 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
395 Return 0 if successful, otherwise set errno and return -1. */
396 # if !@HAVE_GETDOMAINNAME@
397 extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
399 #elif defined GNULIB_POSIXCHECK
400 # undef getdomainname
401 # define getdomainname(n,l) \
402 (GL_LINK_WARNING ("getdomainname is unportable - " \
403 "use gnulib module getdomainname for portability"), \
404 getdomainname (n, l))
408 #if @GNULIB_GETDTABLESIZE@
409 # if !@HAVE_GETDTABLESIZE@
410 /* Return the maximum number of file descriptors in the current process.
411 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
412 extern int getdtablesize (void);
414 #elif defined GNULIB_POSIXCHECK
415 # undef getdtablesize
416 # define getdtablesize() \
417 (GL_LINK_WARNING ("getdtablesize is unportable - " \
418 "use gnulib module getdtablesize for portability"), \
423 #if @GNULIB_GETGROUPS@
424 # if @REPLACE_GETGROUPS@
426 # define getgroups rpl_getgroups
428 # if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@
429 /* Return the supplemental groups that the current process belongs to.
430 It is unspecified whether the effective group id is in the list.
431 If N is 0, return the group count; otherwise, N describes how many
432 entries are available in GROUPS. Return -1 and set errno if N is
433 not 0 and not large enough. Fails with ENOSYS on some systems. */
434 int getgroups (int n, gid_t *groups);
436 #elif defined GNULIB_POSIXCHECK
438 # define getgroups(n,g) \
439 (GL_LINK_WARNING ("getgroups is unportable - " \
440 "use gnulib module getgroups for portability"), \
445 #if @GNULIB_GETHOSTNAME@
446 /* Return the standard host name of the machine.
447 WARNING! The host name may or may not be fully qualified.
449 Put up to LEN bytes of the host name into NAME.
450 Null terminate it if the name is shorter than LEN.
451 If the host name is longer than LEN, set errno = EINVAL and return -1.
452 Return 0 if successful, otherwise set errno and return -1. */
453 # if @UNISTD_H_HAVE_WINSOCK2_H@
455 # define gethostname rpl_gethostname
457 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
458 extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
460 #elif @UNISTD_H_HAVE_WINSOCK2_H@
462 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
463 #elif defined GNULIB_POSIXCHECK
465 # define gethostname(n,l) \
466 (GL_LINK_WARNING ("gethostname is unportable - " \
467 "use gnulib module gethostname for portability"), \
472 #if @GNULIB_GETLOGIN_R@
473 /* Copies the user's login name to NAME.
474 The array pointed to by NAME has room for SIZE bytes.
476 Returns 0 if successful. Upon error, an error number is returned, or -1 in
477 the case that the login name cannot be found but no specific error is
478 provided (this case is hopefully rare but is left open by the POSIX spec).
480 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
482 # if !@HAVE_DECL_GETLOGIN_R@
483 extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
485 #elif defined GNULIB_POSIXCHECK
487 # define getlogin_r(n,s) \
488 (GL_LINK_WARNING ("getlogin_r is unportable - " \
489 "use gnulib module getlogin_r for portability"), \
494 #if @GNULIB_GETPAGESIZE@
495 # if @REPLACE_GETPAGESIZE@
496 # define getpagesize rpl_getpagesize
497 extern int getpagesize (void);
498 # elif !@HAVE_GETPAGESIZE@
499 /* This is for POSIX systems. */
500 # if !defined getpagesize && defined _SC_PAGESIZE
501 # if ! (defined __VMS && __VMS_VER < 70000000)
502 # define getpagesize() sysconf (_SC_PAGESIZE)
505 /* This is for older VMS. */
506 # if !defined getpagesize && defined __VMS
508 # define getpagesize() 8192
510 # define getpagesize() 512
513 /* This is for BeOS. */
514 # if !defined getpagesize && @HAVE_OS_H@
516 # if defined B_PAGE_SIZE
517 # define getpagesize() B_PAGE_SIZE
520 /* This is for AmigaOS4.0. */
521 # if !defined getpagesize && defined __amigaos4__
522 # define getpagesize() 2048
524 /* This is for older Unix systems. */
525 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
526 # include <sys/param.h>
527 # ifdef EXEC_PAGESIZE
528 # define getpagesize() EXEC_PAGESIZE
534 # define getpagesize() (NBPG * CLSIZE)
537 # define getpagesize() NBPC
543 #elif defined GNULIB_POSIXCHECK
545 # define getpagesize() \
546 (GL_LINK_WARNING ("getpagesize is unportable - " \
547 "use gnulib module getpagesize for portability"), \
552 #if @GNULIB_GETUSERSHELL@
553 # if !@HAVE_GETUSERSHELL@
554 /* Return the next valid login shell on the system, or NULL when the end of
555 the list has been reached. */
556 extern char *getusershell (void);
557 /* Rewind to pointer that is advanced at each getusershell() call. */
558 extern void setusershell (void);
559 /* Free the pointer that is advanced at each getusershell() call and
560 associated resources. */
561 extern void endusershell (void);
563 #elif defined GNULIB_POSIXCHECK
565 # define getusershell() \
566 (GL_LINK_WARNING ("getusershell is unportable - " \
567 "use gnulib module getusershell for portability"), \
570 # define setusershell() \
571 (GL_LINK_WARNING ("setusershell is unportable - " \
572 "use gnulib module getusershell for portability"), \
575 # define endusershell() \
576 (GL_LINK_WARNING ("endusershell is unportable - " \
577 "use gnulib module getusershell for portability"), \
583 # if @REPLACE_LCHOWN@
585 # define lchown rpl_lchown
587 # if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
588 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
589 to GID (if GID is not -1). Do not follow symbolic links.
590 Return 0 if successful, otherwise -1 and errno set.
591 See the POSIX:2001 specification
592 <http://www.opengroup.org/susv3xsh/lchown.html>. */
593 extern int lchown (char const *file, uid_t owner, gid_t group)
594 _GL_ARG_NONNULL ((1));
596 #elif defined GNULIB_POSIXCHECK
598 # define lchown(f,u,g) \
599 (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
600 "systems - use gnulib module lchown for portability"), \
607 # define link rpl_link
609 /* Create a new hard link for an existing file.
610 Return 0 if successful, otherwise -1 and errno set.
611 See POSIX:2001 specification
612 <http://www.opengroup.org/susv3xsh/link.html>. */
613 # if !@HAVE_LINK@ || @REPLACE_LINK@
614 extern int link (const char *path1, const char *path2)
615 _GL_ARG_NONNULL ((1, 2));
617 #elif defined GNULIB_POSIXCHECK
619 # define link(path1,path2) \
620 (GL_LINK_WARNING ("link is unportable - " \
621 "use gnulib module link for portability"), \
626 # if @REPLACE_LINKAT@
628 # define linkat rpl_linkat
630 /* Create a new hard link for an existing file, relative to two
631 directories. FLAG controls whether symlinks are followed.
632 Return 0 if successful, otherwise -1 and errno set. */
633 # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
634 extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
636 _GL_ARG_NONNULL ((2, 4));
638 #elif defined GNULIB_POSIXCHECK
640 # define link(f1,path1,f2,path2,f) \
641 (GL_LINK_WARNING ("linkat is unportable - " \
642 "use gnulib module linkat for portability"), \
643 linkat (f1, path1, f2, path2,f))
648 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
649 Return the new offset if successful, otherwise -1 and errno set.
650 See the POSIX:2001 specification
651 <http://www.opengroup.org/susv3xsh/lseek.html>. */
652 # define lseek rpl_lseek
653 extern off_t lseek (int fd, off_t offset, int whence);
655 #elif defined GNULIB_POSIXCHECK
657 # define lseek(f,o,w) \
658 (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
659 "systems - use gnulib module lseek for portability"), \
665 /* Create a pipe, applying the given flags when opening the read-end of the
666 pipe and the write-end of the pipe.
667 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
668 and O_TEXT, O_BINARY (defined in "binary-io.h").
669 Store the read-end as fd[0] and the write-end as fd[1].
670 Return 0 upon success, or -1 with errno set upon failure.
671 See also the Linux man page at
672 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
674 # define pipe2 rpl_pipe2
676 extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
677 #elif defined GNULIB_POSIXCHECK
679 # define pipe2(f,o) \
680 (GL_LINK_WARNING ("pipe2 is unportable - " \
681 "use gnulib module pipe2 for portability"), \
688 # define pread rpl_pread
690 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
691 Return the number of bytes placed into BUF if successful, otherwise
692 set errno and return -1. 0 indicates EOF. See the POSIX:2001
693 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
694 # if !@HAVE_PREAD@ || @REPLACE_PREAD@
695 extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
696 _GL_ARG_NONNULL ((2));
698 #elif defined GNULIB_POSIXCHECK
700 # define pread(f,b,s,o) \
701 (GL_LINK_WARNING ("pread is unportable - " \
702 "use gnulib module pread for portability"), \
707 #if @GNULIB_READLINK@
708 # if @REPLACE_READLINK@
709 # define readlink rpl_readlink
711 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
712 bytes of it into BUF. Return the number of bytes placed into BUF if
713 successful, otherwise -1 and errno set.
714 See the POSIX:2001 specification
715 <http://www.opengroup.org/susv3xsh/readlink.html>. */
716 # if !@HAVE_READLINK@ || @REPLACE_READLINK@
717 extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
718 _GL_ARG_NONNULL ((1, 2));
720 #elif defined GNULIB_POSIXCHECK
722 # define readlink(f,b,s) \
723 (GL_LINK_WARNING ("readlink is unportable - " \
724 "use gnulib module readlink for portability"), \
729 #if @GNULIB_READLINKAT@
730 # if !@HAVE_READLINKAT@
731 extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
732 _GL_ARG_NONNULL ((2, 3));
734 #elif defined GNULIB_POSIXCHECK
736 # define readlinkat(d,n,b,l) \
737 (GL_LINK_WARNING ("readlinkat is not portable - " \
738 "use gnulib module symlinkat for portability"), \
739 readlinkat (d, n, b, l))
745 # define rmdir rpl_rmdir
746 /* Remove the directory DIR. */
747 extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
749 #elif defined GNULIB_POSIXCHECK
752 (GL_LINK_WARNING ("rmdir is unportable - " \
753 "use gnulib module rmdir for portability"), \
761 # define sleep rpl_sleep
763 /* Pause the execution of the current thread for N seconds.
764 Returns the number of seconds left to sleep.
765 See the POSIX:2001 specification
766 <http://www.opengroup.org/susv3xsh/sleep.html>. */
767 # if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
768 extern unsigned int sleep (unsigned int n);
770 #elif defined GNULIB_POSIXCHECK
773 (GL_LINK_WARNING ("sleep is unportable - " \
774 "use gnulib module sleep for portability"), \
780 # if @REPLACE_SYMLINK@
782 # define symlink rpl_symlink
784 # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
785 extern int symlink (char const *contents, char const *file)
786 _GL_ARG_NONNULL ((1, 2));
788 #elif defined GNULIB_POSIXCHECK
790 # define symlink(c,n) \
791 (GL_LINK_WARNING ("symlink is not portable - " \
792 "use gnulib module symlink for portability"), \
797 #if @GNULIB_SYMLINKAT@
798 # if !@HAVE_SYMLINKAT@
799 extern int symlinkat (char const *contents, int fd, char const *file)
800 _GL_ARG_NONNULL ((1, 3));
802 #elif defined GNULIB_POSIXCHECK
804 # define symlinkat(c,d,n) \
805 (GL_LINK_WARNING ("symlinkat is not portable - " \
806 "use gnulib module symlinkat for portability"), \
812 # if @REPLACE_UNLINK@
814 # define unlink rpl_unlink
815 extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
817 #elif defined GNULIB_POSIXCHECK
820 (GL_LINK_WARNING ("unlink is not portable - " \
821 "use gnulib module unlink for portability"), \
826 #if @GNULIB_UNLINKAT@
827 # if @REPLACE_UNLINKAT@
829 # define unlinkat rpl_unlinkat
831 # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
832 extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
834 #elif defined GNULIB_POSIXCHECK
836 # define unlinkat(d,n,f) \
837 (GL_LINK_WARNING ("unlinkat is not portable - " \
838 "use gnulib module openat for portability"), \
844 # if @REPLACE_USLEEP@
846 # define usleep rpl_usleep
848 # if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
849 /* Pause the execution of the current thread for N microseconds.
850 Returns 0 on completion, or -1 on range error.
851 See the POSIX:2001 specification
852 <http://www.opengroup.org/susv3xsh/sleep.html>. */
853 extern int usleep (useconds_t n);
855 #elif defined GNULIB_POSIXCHECK
858 (GL_LINK_WARNING ("usleep is unportable - " \
859 "use gnulib module usleep for portability"), \
864 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
865 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
866 See the POSIX:2001 specification
867 <http://www.opengroup.org/susv3xsh/write.html>. */
869 # define write rpl_write
870 extern ssize_t write (int fd, const void *buf, size_t count)
871 _GL_ARG_NONNULL ((2));
880 #endif /* _GL_UNISTD_H */
881 #endif /* _GL_UNISTD_H */