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 #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
40 /* mingw fails to declare _exit in <unistd.h>. */
41 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
44 #if ((@GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@) \
45 || (@GNULIB_READLINK@ && (!@HAVE_READLINK@ || @REPLACE_READLINK@)) \
46 || (@GNULIB_READLINKAT@ && !@HAVE_READLINKAT@))
48 # include <sys/types.h>
51 /* Get getopt(), optarg, optind, opterr, optopt. */
52 #if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
56 #if @GNULIB_GETHOSTNAME@
57 /* Get all possible declarations of gethostname(). */
58 # if @UNISTD_H_HAVE_WINSOCK2_H@
59 # include <winsock2.h>
60 # if !defined _GL_SYS_SOCKET_H
62 # define socket socket_used_without_including_sys_socket_h
64 # define connect connect_used_without_including_sys_socket_h
66 # define accept accept_used_without_including_sys_socket_h
68 # define bind bind_used_without_including_sys_socket_h
70 # define getpeername getpeername_used_without_including_sys_socket_h
72 # define getsockname getsockname_used_without_including_sys_socket_h
74 # define getsockopt getsockopt_used_without_including_sys_socket_h
76 # define listen listen_used_without_including_sys_socket_h
78 # define recv recv_used_without_including_sys_socket_h
80 # define send send_used_without_including_sys_socket_h
82 # define recvfrom recvfrom_used_without_including_sys_socket_h
84 # define sendto sendto_used_without_including_sys_socket_h
86 # define setsockopt setsockopt_used_without_including_sys_socket_h
88 # define shutdown shutdown_used_without_including_sys_socket_h
90 # if !defined _GL_SYS_SELECT_H
92 # define select select_used_without_including_sys_select_h
97 /* The definition of GL_LINK_WARNING is copied here. */
99 /* The definition of _GL_ARG_NONNULL is copied here. */
102 /* OS/2 EMX lacks these macros. */
104 # define STDIN_FILENO 0
106 #ifndef STDOUT_FILENO
107 # define STDOUT_FILENO 1
109 #ifndef STDERR_FILENO
110 # define STDERR_FILENO 2
113 /* Ensure *_OK macros exist. */
122 /* Declare overridden functions. */
132 # define chown rpl_chown
134 # if !@HAVE_CHOWN@ || @REPLACE_CHOWN@
135 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
136 to GID (if GID is not -1). Follow symbolic links.
137 Return 0 if successful, otherwise -1 and errno set.
138 See the POSIX:2001 specification
139 <http://www.opengroup.org/susv3xsh/chown.html>. */
140 extern int chown (const char *file, uid_t uid, gid_t gid)
141 _GL_ARG_NONNULL ((1));
143 #elif defined GNULIB_POSIXCHECK
145 # define chown(f,u,g) \
146 (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
147 "doesn't treat a uid or gid of -1 on some systems - " \
148 "use gnulib module chown for portability"), \
155 /* Automatically included by modules that need a replacement for close. */
157 # define close rpl_close
158 extern int close (int);
160 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
162 # define close close_used_without_requesting_gnulib_module_close
163 #elif defined GNULIB_POSIXCHECK
166 (GL_LINK_WARNING ("close does not portably work on sockets - " \
167 "use gnulib module close for portability"), \
174 extern int dup (int);
180 # define dup2 rpl_dup2
182 # if !@HAVE_DUP2@ || @REPLACE_DUP2@
183 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
184 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
185 Return newfd if successful, otherwise -1 and errno set.
186 See the POSIX:2001 specification
187 <http://www.opengroup.org/susv3xsh/dup2.html>. */
188 extern int dup2 (int oldfd, int newfd);
190 #elif defined GNULIB_POSIXCHECK
193 (GL_LINK_WARNING ("dup2 is unportable - " \
194 "use gnulib module dup2 for portability"), \
200 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
202 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
203 and O_TEXT, O_BINARY (defined in "binary-io.h").
204 Close NEWFD first if it is open.
205 Return newfd if successful, otherwise -1 and errno set.
206 See the Linux man page at
207 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
209 # define dup3 rpl_dup3
211 extern int dup3 (int oldfd, int newfd, int flags);
212 #elif defined GNULIB_POSIXCHECK
214 # define dup3(o,n,f) \
215 (GL_LINK_WARNING ("dup3 is unportable - " \
216 "use gnulib module dup3 for portability"), \
222 # if !@HAVE_DECL_ENVIRON@
223 /* Set of environment variables and values. An array of strings of the form
224 "VARIABLE=VALUE", terminated with a NULL. */
225 # if defined __APPLE__ && defined __MACH__
226 # include <crt_externs.h>
227 # define environ (*_NSGetEnviron ())
229 extern char **environ;
232 #elif defined GNULIB_POSIXCHECK
235 (GL_LINK_WARNING ("environ is unportable - " \
236 "use gnulib module environ for portability"), \
241 #if @GNULIB_EUIDACCESS@
242 # if !@HAVE_EUIDACCESS@
243 /* Like access(), except that it uses the effective user id and group id of
244 the current process. */
245 extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
247 #elif defined GNULIB_POSIXCHECK
249 # define euidaccess(f,m) \
250 (GL_LINK_WARNING ("euidaccess is unportable - " \
251 "use gnulib module euidaccess for portability"), \
256 #if @GNULIB_FACCESSAT@
257 # if !@HAVE_FACCESSAT@
258 extern int faccessat (int fd, char const *file, int mode, int flag)
259 _GL_ARG_NONNULL ((2));
261 #elif defined GNULIB_POSIXCHECK
263 # define faccessat(d,n,m,f) \
264 (GL_LINK_WARNING ("faccessat is not portable - " \
265 "use gnulib module faccessat for portability"), \
266 faccessat (d, n, m, f))
271 # if @REPLACE_FCHDIR@
272 /* Change the process' current working directory to the directory on which
273 the given file descriptor is open.
274 Return 0 if successful, otherwise -1 and errno set.
275 See the POSIX:2001 specification
276 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
277 extern int fchdir (int /*fd*/);
279 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
280 extern int _gl_register_fd (int fd, const char *filename)
281 _GL_ARG_NONNULL ((2));
282 extern void _gl_unregister_fd (int fd);
283 extern int _gl_register_dup (int oldfd, int newfd);
284 extern const char *_gl_directory_name (int fd);
287 #elif defined GNULIB_POSIXCHECK
290 (GL_LINK_WARNING ("fchdir is unportable - " \
291 "use gnulib module fchdir for portability"), \
296 #if @GNULIB_FCHOWNAT@
297 # if @REPLACE_FCHOWNAT@
299 # define fchownat rpl_fchownat
301 # if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
302 extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
303 _GL_ARG_NONNULL ((2));
305 #elif defined GNULIB_POSIXCHECK
307 # define fchownat(d,n,o,g,f) \
308 (GL_LINK_WARNING ("fchownat is not portable - " \
309 "use gnulib module openat for portability"), \
310 fchownat (d, n, o, g, f))
315 /* Synchronize changes to a file.
316 Return 0 if successful, otherwise -1 and errno set.
317 See POSIX:2001 specification
318 <http://www.opengroup.org/susv3xsh/fsync.html>. */
320 extern int fsync (int fd);
322 #elif defined GNULIB_POSIXCHECK
325 (GL_LINK_WARNING ("fsync is unportable - " \
326 "use gnulib module fsync for portability"), \
331 #if @GNULIB_FTRUNCATE@
332 # if !@HAVE_FTRUNCATE@
333 /* Change the size of the file to which FD is opened to become equal to LENGTH.
334 Return 0 if successful, otherwise -1 and errno set.
335 See the POSIX:2001 specification
336 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
337 extern int ftruncate (int fd, off_t length);
339 #elif defined GNULIB_POSIXCHECK
341 # define ftruncate(f,l) \
342 (GL_LINK_WARNING ("ftruncate is unportable - " \
343 "use gnulib module ftruncate for portability"), \
349 # if @REPLACE_GETCWD@
350 /* Get the name of the current working directory, and put it in SIZE bytes
352 Return BUF if successful, or NULL if the directory couldn't be determined
353 or SIZE was too small.
354 See the POSIX:2001 specification
355 <http://www.opengroup.org/susv3xsh/getcwd.html>.
356 Additionally, the gnulib module 'getcwd' guarantees the following GNU
357 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
358 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
360 # define getcwd rpl_getcwd
361 extern char * getcwd (char *buf, size_t size);
363 #elif defined GNULIB_POSIXCHECK
365 # define getcwd(b,s) \
366 (GL_LINK_WARNING ("getcwd is unportable - " \
367 "use gnulib module getcwd for portability"), \
372 #if @GNULIB_GETDOMAINNAME@
373 /* Return the NIS domain name of the machine.
374 WARNING! The NIS domain name is unrelated to the fully qualified host name
375 of the machine. It is also unrelated to email addresses.
376 WARNING! The NIS domain name is usually the empty string or "(none)" when
379 Put up to LEN bytes of the NIS domain name into NAME.
380 Null terminate it if the name is shorter than LEN.
381 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
382 Return 0 if successful, otherwise set errno and return -1. */
383 # if !@HAVE_GETDOMAINNAME@
384 extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
386 #elif defined GNULIB_POSIXCHECK
387 # undef getdomainname
388 # define getdomainname(n,l) \
389 (GL_LINK_WARNING ("getdomainname is unportable - " \
390 "use gnulib module getdomainname for portability"), \
391 getdomainname (n, l))
395 #if @GNULIB_GETDTABLESIZE@
396 # if !@HAVE_GETDTABLESIZE@
397 /* Return the maximum number of file descriptors in the current process.
398 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
399 extern int getdtablesize (void);
401 #elif defined GNULIB_POSIXCHECK
402 # undef getdtablesize
403 # define getdtablesize() \
404 (GL_LINK_WARNING ("getdtablesize is unportable - " \
405 "use gnulib module getdtablesize for portability"), \
410 #if @GNULIB_GETGROUPS@
411 # if @REPLACE_GETGROUPS@
413 # define getgroups rpl_getgroups
415 # if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@
416 /* Return the supplemental groups that the current process belongs to.
417 It is unspecified whether the effective group id is in the list.
418 If N is 0, return the group count; otherwise, N describes how many
419 entries are available in GROUPS. Return -1 and set errno if N is
420 not 0 and not large enough. Fails with ENOSYS on some systems. */
421 int getgroups (int n, gid_t *groups);
423 #elif defined GNULIB_POSIXCHECK
425 # define getgroups(n,g) \
426 (GL_LINK_WARNING ("getgroups is unportable - " \
427 "use gnulib module getgroups for portability"), \
432 #if @GNULIB_GETHOSTNAME@
433 /* Return the standard host name of the machine.
434 WARNING! The host name may or may not be fully qualified.
436 Put up to LEN bytes of the host name into NAME.
437 Null terminate it if the name is shorter than LEN.
438 If the host name is longer than LEN, set errno = EINVAL and return -1.
439 Return 0 if successful, otherwise set errno and return -1. */
440 # if @UNISTD_H_HAVE_WINSOCK2_H@
442 # define gethostname rpl_gethostname
444 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
445 extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
447 #elif @UNISTD_H_HAVE_WINSOCK2_H@
449 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
450 #elif defined GNULIB_POSIXCHECK
452 # define gethostname(n,l) \
453 (GL_LINK_WARNING ("gethostname is unportable - " \
454 "use gnulib module gethostname for portability"), \
459 #if @GNULIB_GETLOGIN_R@
460 /* Copies the user's login name to NAME.
461 The array pointed to by NAME has room for SIZE bytes.
463 Returns 0 if successful. Upon error, an error number is returned, or -1 in
464 the case that the login name cannot be found but no specific error is
465 provided (this case is hopefully rare but is left open by the POSIX spec).
467 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
469 # if !@HAVE_DECL_GETLOGIN_R@
470 extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
472 #elif defined GNULIB_POSIXCHECK
474 # define getlogin_r(n,s) \
475 (GL_LINK_WARNING ("getlogin_r is unportable - " \
476 "use gnulib module getlogin_r for portability"), \
481 #if @GNULIB_GETPAGESIZE@
482 # if @REPLACE_GETPAGESIZE@
483 # define getpagesize rpl_getpagesize
484 extern int getpagesize (void);
485 # elif !@HAVE_GETPAGESIZE@
486 /* This is for POSIX systems. */
487 # if !defined getpagesize && defined _SC_PAGESIZE
488 # if ! (defined __VMS && __VMS_VER < 70000000)
489 # define getpagesize() sysconf (_SC_PAGESIZE)
492 /* This is for older VMS. */
493 # if !defined getpagesize && defined __VMS
495 # define getpagesize() 8192
497 # define getpagesize() 512
500 /* This is for BeOS. */
501 # if !defined getpagesize && @HAVE_OS_H@
503 # if defined B_PAGE_SIZE
504 # define getpagesize() B_PAGE_SIZE
507 /* This is for AmigaOS4.0. */
508 # if !defined getpagesize && defined __amigaos4__
509 # define getpagesize() 2048
511 /* This is for older Unix systems. */
512 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
513 # include <sys/param.h>
514 # ifdef EXEC_PAGESIZE
515 # define getpagesize() EXEC_PAGESIZE
521 # define getpagesize() (NBPG * CLSIZE)
524 # define getpagesize() NBPC
530 #elif defined GNULIB_POSIXCHECK
532 # define getpagesize() \
533 (GL_LINK_WARNING ("getpagesize is unportable - " \
534 "use gnulib module getpagesize for portability"), \
539 #if @GNULIB_GETUSERSHELL@
540 # if !@HAVE_GETUSERSHELL@
541 /* Return the next valid login shell on the system, or NULL when the end of
542 the list has been reached. */
543 extern char *getusershell (void);
544 /* Rewind to pointer that is advanced at each getusershell() call. */
545 extern void setusershell (void);
546 /* Free the pointer that is advanced at each getusershell() call and
547 associated resources. */
548 extern void endusershell (void);
550 #elif defined GNULIB_POSIXCHECK
552 # define getusershell() \
553 (GL_LINK_WARNING ("getusershell is unportable - " \
554 "use gnulib module getusershell for portability"), \
557 # define setusershell() \
558 (GL_LINK_WARNING ("setusershell is unportable - " \
559 "use gnulib module getusershell for portability"), \
562 # define endusershell() \
563 (GL_LINK_WARNING ("endusershell is unportable - " \
564 "use gnulib module getusershell for portability"), \
570 # if @REPLACE_LCHOWN@
572 # define lchown rpl_lchown
574 # if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
575 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
576 to GID (if GID is not -1). Do not follow symbolic links.
577 Return 0 if successful, otherwise -1 and errno set.
578 See the POSIX:2001 specification
579 <http://www.opengroup.org/susv3xsh/lchown.html>. */
580 extern int lchown (char const *file, uid_t owner, gid_t group)
581 _GL_ARG_NONNULL ((1));
583 #elif defined GNULIB_POSIXCHECK
585 # define lchown(f,u,g) \
586 (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
587 "systems - use gnulib module lchown for portability"), \
594 # define link rpl_link
596 /* Create a new hard link for an existing file.
597 Return 0 if successful, otherwise -1 and errno set.
598 See POSIX:2001 specification
599 <http://www.opengroup.org/susv3xsh/link.html>. */
600 # if !@HAVE_LINK@ || @REPLACE_LINK@
601 extern int link (const char *path1, const char *path2)
602 _GL_ARG_NONNULL ((1, 2));
604 #elif defined GNULIB_POSIXCHECK
606 # define link(path1,path2) \
607 (GL_LINK_WARNING ("link is unportable - " \
608 "use gnulib module link for portability"), \
613 # if @REPLACE_LINKAT@
615 # define linkat rpl_linkat
617 /* Create a new hard link for an existing file, relative to two
618 directories. FLAG controls whether symlinks are followed.
619 Return 0 if successful, otherwise -1 and errno set. */
620 # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
621 extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
623 _GL_ARG_NONNULL ((2, 4));
625 #elif defined GNULIB_POSIXCHECK
627 # define link(f1,path1,f2,path2,f) \
628 (GL_LINK_WARNING ("linkat is unportable - " \
629 "use gnulib module linkat for portability"), \
630 linkat (f1, path1, f2, path2,f))
635 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
636 Return the new offset if successful, otherwise -1 and errno set.
637 See the POSIX:2001 specification
638 <http://www.opengroup.org/susv3xsh/lseek.html>. */
639 # define lseek rpl_lseek
640 extern off_t lseek (int fd, off_t offset, int whence);
642 #elif defined GNULIB_POSIXCHECK
644 # define lseek(f,o,w) \
645 (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
646 "systems - use gnulib module lseek for portability"), \
652 /* Create a pipe, applying the given flags when opening the read-end of the
653 pipe and the write-end of the pipe.
654 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
655 and O_TEXT, O_BINARY (defined in "binary-io.h").
656 Store the read-end as fd[0] and the write-end as fd[1].
657 Return 0 upon success, or -1 with errno set upon failure.
658 See also the Linux man page at
659 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
661 # define pipe2 rpl_pipe2
663 extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
664 #elif defined GNULIB_POSIXCHECK
666 # define pipe2(f,o) \
667 (GL_LINK_WARNING ("pipe2 is unportable - " \
668 "use gnulib module pipe2 for portability"), \
675 # define pread rpl_pread
677 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
678 Return the number of bytes placed into BUF if successful, otherwise
679 set errno and return -1. 0 indicates EOF. See the POSIX:2001
680 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
681 # if !@HAVE_PREAD@ || @REPLACE_PREAD@
682 extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
683 _GL_ARG_NONNULL ((2));
685 #elif defined GNULIB_POSIXCHECK
687 # define pread(f,b,s,o) \
688 (GL_LINK_WARNING ("pread is unportable - " \
689 "use gnulib module pread for portability"), \
694 #if @GNULIB_READLINK@
695 # if @REPLACE_READLINK@
696 # define readlink rpl_readlink
698 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
699 bytes of it into BUF. Return the number of bytes placed into BUF if
700 successful, otherwise -1 and errno set.
701 See the POSIX:2001 specification
702 <http://www.opengroup.org/susv3xsh/readlink.html>. */
703 # if !@HAVE_READLINK@ || @REPLACE_READLINK@
704 extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
705 _GL_ARG_NONNULL ((1, 2));
707 #elif defined GNULIB_POSIXCHECK
709 # define readlink(f,b,s) \
710 (GL_LINK_WARNING ("readlink is unportable - " \
711 "use gnulib module readlink for portability"), \
716 #if @GNULIB_READLINKAT@
717 # if !@HAVE_READLINKAT@
718 extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
719 _GL_ARG_NONNULL ((2, 3));
721 #elif defined GNULIB_POSIXCHECK
723 # define readlinkat(d,n,b,l) \
724 (GL_LINK_WARNING ("readlinkat is not portable - " \
725 "use gnulib module symlinkat for portability"), \
726 readlinkat (d, n, b, l))
732 # define rmdir rpl_rmdir
733 /* Remove the directory DIR. */
734 extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
736 #elif defined GNULIB_POSIXCHECK
739 (GL_LINK_WARNING ("rmdir is unportable - " \
740 "use gnulib module rmdir for portability"), \
748 # define sleep rpl_sleep
750 /* Pause the execution of the current thread for N seconds.
751 Returns the number of seconds left to sleep.
752 See the POSIX:2001 specification
753 <http://www.opengroup.org/susv3xsh/sleep.html>. */
754 # if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
755 extern unsigned int sleep (unsigned int n);
757 #elif defined GNULIB_POSIXCHECK
760 (GL_LINK_WARNING ("sleep is unportable - " \
761 "use gnulib module sleep for portability"), \
767 # if @REPLACE_SYMLINK@
769 # define symlink rpl_symlink
771 # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
772 extern int symlink (char const *contents, char const *file)
773 _GL_ARG_NONNULL ((1, 2));
775 #elif defined GNULIB_POSIXCHECK
777 # define symlink(c,n) \
778 (GL_LINK_WARNING ("symlink is not portable - " \
779 "use gnulib module symlink for portability"), \
784 #if @GNULIB_SYMLINKAT@
785 # if !@HAVE_SYMLINKAT@
786 extern int symlinkat (char const *contents, int fd, char const *file)
787 _GL_ARG_NONNULL ((1, 3));
789 #elif defined GNULIB_POSIXCHECK
791 # define symlinkat(c,d,n) \
792 (GL_LINK_WARNING ("symlinkat is not portable - " \
793 "use gnulib module symlinkat for portability"), \
799 # if @REPLACE_UNLINK@
801 # define unlink rpl_unlink
802 extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
804 #elif defined GNULIB_POSIXCHECK
807 (GL_LINK_WARNING ("unlink is not portable - " \
808 "use gnulib module unlink for portability"), \
813 #if @GNULIB_UNLINKAT@
814 # if @REPLACE_UNLINKAT@
816 # define unlinkat rpl_unlinkat
818 # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
819 extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
821 #elif defined GNULIB_POSIXCHECK
823 # define unlinkat(d,n,f) \
824 (GL_LINK_WARNING ("unlinkat is not portable - " \
825 "use gnulib module openat for portability"), \
831 # if @REPLACE_USLEEP@
833 # define usleep rpl_usleep
835 # if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
836 /* Pause the execution of the current thread for N microseconds.
837 Returns 0 on completion, or -1 on range error.
838 See the POSIX:2001 specification
839 <http://www.opengroup.org/susv3xsh/sleep.html>. */
840 extern int usleep (useconds_t n);
842 #elif defined GNULIB_POSIXCHECK
845 (GL_LINK_WARNING ("usleep is unportable - " \
846 "use gnulib module usleep for portability"), \
851 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
852 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
853 See the POSIX:2001 specification
854 <http://www.opengroup.org/susv3xsh/write.html>. */
856 # define write rpl_write
857 extern ssize_t write (int fd, const void *buf, size_t count)
858 _GL_ARG_NONNULL ((2));
867 #endif /* _GL_UNISTD_H */
868 #endif /* _GL_UNISTD_H */