1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2010 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
21 @PRAGMA_SYSTEM_HEADER@
24 /* The include_next requires a split double-inclusion guard. */
26 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
32 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
35 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
36 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
37 /* But avoid namespace pollution on glibc systems. */
38 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
39 || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \
40 && ! defined __GLIBC__
44 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
45 /* But avoid namespace pollution on glibc systems. */
46 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
50 /* mingw fails to declare _exit in <unistd.h>. */
51 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
52 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
53 /* But avoid namespace pollution on glibc systems. */
58 /* mingw declares getcwd in <io.h>, not in <unistd.h>. */
59 #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
60 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
64 #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
65 || @GNULIB_PREAD@ || defined GNULIB_POSIXCHECK)
67 # include <sys/types.h>
70 /* Get getopt(), optarg, optind, opterr, optopt.
71 But avoid namespace pollution on glibc systems. */
72 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
76 #if @GNULIB_GETHOSTNAME@
77 /* Get all possible declarations of gethostname(). */
78 # if @UNISTD_H_HAVE_WINSOCK2_H@
79 # include <winsock2.h>
80 # if !defined _GL_SYS_SOCKET_H
82 # define socket socket_used_without_including_sys_socket_h
84 # define connect connect_used_without_including_sys_socket_h
86 # define accept accept_used_without_including_sys_socket_h
88 # define bind bind_used_without_including_sys_socket_h
90 # define getpeername getpeername_used_without_including_sys_socket_h
92 # define getsockname getsockname_used_without_including_sys_socket_h
94 # define getsockopt getsockopt_used_without_including_sys_socket_h
96 # define listen listen_used_without_including_sys_socket_h
98 # define recv recv_used_without_including_sys_socket_h
100 # define send send_used_without_including_sys_socket_h
102 # define recvfrom recvfrom_used_without_including_sys_socket_h
104 # define sendto sendto_used_without_including_sys_socket_h
106 # define setsockopt setsockopt_used_without_including_sys_socket_h
108 # define shutdown shutdown_used_without_including_sys_socket_h
110 # if !defined _GL_SYS_SELECT_H
112 # define select select_used_without_including_sys_select_h
117 /* The definition of _GL_ARG_NONNULL is copied here. */
119 /* The definition of _GL_WARN_ON_USE is copied here. */
122 /* OS/2 EMX lacks these macros. */
124 # define STDIN_FILENO 0
126 #ifndef STDOUT_FILENO
127 # define STDOUT_FILENO 1
129 #ifndef STDERR_FILENO
130 # define STDERR_FILENO 2
133 /* Ensure *_OK macros exist. */
142 /* Declare overridden functions. */
152 # define chown rpl_chown
154 # if !@HAVE_CHOWN@ || @REPLACE_CHOWN@
155 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
156 to GID (if GID is not -1). Follow symbolic links.
157 Return 0 if successful, otherwise -1 and errno set.
158 See the POSIX:2001 specification
159 <http://www.opengroup.org/susv3xsh/chown.html>. */
160 extern int chown (const char *file, uid_t uid, gid_t gid)
161 _GL_ARG_NONNULL ((1));
163 #elif defined GNULIB_POSIXCHECK
165 # if HAVE_RAW_DECL_CHOWN
166 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
167 "doesn't treat a uid or gid of -1 on some systems - "
168 "use gnulib module chown for portability");
175 /* Automatically included by modules that need a replacement for close. */
177 # define close rpl_close
178 extern int close (int);
180 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
182 # define close close_used_without_requesting_gnulib_module_close
183 #elif defined GNULIB_POSIXCHECK
185 /* Assume close is always declared. */
186 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
187 "use gnulib module close for portability");
193 extern int dup (int);
199 # define dup2 rpl_dup2
201 # if !@HAVE_DUP2@ || @REPLACE_DUP2@
202 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
203 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
204 Return newfd if successful, otherwise -1 and errno set.
205 See the POSIX:2001 specification
206 <http://www.opengroup.org/susv3xsh/dup2.html>. */
207 extern int dup2 (int oldfd, int newfd);
209 #elif defined GNULIB_POSIXCHECK
211 # if HAVE_RAW_DECL_DUP2
212 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
213 "use gnulib module dup2 for portability");
219 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
221 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
222 and O_TEXT, O_BINARY (defined in "binary-io.h").
223 Close NEWFD first if it is open.
224 Return newfd if successful, otherwise -1 and errno set.
225 See the Linux man page at
226 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
228 # define dup3 rpl_dup3
230 extern int dup3 (int oldfd, int newfd, int flags);
231 #elif defined GNULIB_POSIXCHECK
233 # if HAVE_RAW_DECL_DUP3
234 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
235 "use gnulib module dup3 for portability");
241 # if !@HAVE_DECL_ENVIRON@
242 /* Set of environment variables and values. An array of strings of the form
243 "VARIABLE=VALUE", terminated with a NULL. */
244 # if defined __APPLE__ && defined __MACH__
245 # include <crt_externs.h>
246 # define environ (*_NSGetEnviron ())
248 extern char **environ;
251 #elif defined GNULIB_POSIXCHECK
252 # if HAVE_RAW_DECL_ENVIRON
253 static inline char ***
258 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
259 "use gnulib module environ for portability");
261 # define environ (*rpl_environ ())
266 #if @GNULIB_EUIDACCESS@
267 # if !@HAVE_EUIDACCESS@
268 /* Like access(), except that it uses the effective user id and group id of
269 the current process. */
270 extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
272 #elif defined GNULIB_POSIXCHECK
274 # if HAVE_RAW_DECL_EUIDACCESS
275 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
276 "use gnulib module euidaccess for portability");
281 #if @GNULIB_FACCESSAT@
282 # if !@HAVE_FACCESSAT@
283 extern int faccessat (int fd, char const *file, int mode, int flag)
284 _GL_ARG_NONNULL ((2));
286 #elif defined GNULIB_POSIXCHECK
288 # if HAVE_RAW_DECL_FACCESSAT
289 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
290 "use gnulib module faccessat for portability");
296 # if @REPLACE_FCHDIR@
297 /* Change the process' current working directory to the directory on which
298 the given file descriptor is open.
299 Return 0 if successful, otherwise -1 and errno set.
300 See the POSIX:2001 specification
301 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
302 extern int fchdir (int /*fd*/);
304 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
305 extern int _gl_register_fd (int fd, const char *filename)
306 _GL_ARG_NONNULL ((2));
307 extern void _gl_unregister_fd (int fd);
308 extern int _gl_register_dup (int oldfd, int newfd);
309 extern const char *_gl_directory_name (int fd);
312 #elif defined GNULIB_POSIXCHECK
314 # if HAVE_RAW_DECL_FCHDIR
315 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
316 "use gnulib module fchdir for portability");
321 #if @GNULIB_FCHOWNAT@
322 # if @REPLACE_FCHOWNAT@
324 # define fchownat rpl_fchownat
326 # if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
327 extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
328 _GL_ARG_NONNULL ((2));
330 #elif defined GNULIB_POSIXCHECK
332 # if HAVE_RAW_DECL_FCHOWNAT
333 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
334 "use gnulib module openat for portability");
340 /* Synchronize changes to a file.
341 Return 0 if successful, otherwise -1 and errno set.
342 See POSIX:2001 specification
343 <http://www.opengroup.org/susv3xsh/fsync.html>. */
345 extern int fsync (int fd);
347 #elif defined GNULIB_POSIXCHECK
349 # if HAVE_RAW_DECL_FSYNC
350 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
351 "use gnulib module fsync for portability");
356 #if @GNULIB_FTRUNCATE@
357 # if !@HAVE_FTRUNCATE@
358 /* Change the size of the file to which FD is opened to become equal to LENGTH.
359 Return 0 if successful, otherwise -1 and errno set.
360 See the POSIX:2001 specification
361 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
362 extern int ftruncate (int fd, off_t length);
364 #elif defined GNULIB_POSIXCHECK
366 # if HAVE_RAW_DECL_FTRUNCATE
367 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
368 "use gnulib module ftruncate for portability");
374 # if @REPLACE_GETCWD@
375 /* Get the name of the current working directory, and put it in SIZE bytes
377 Return BUF if successful, or NULL if the directory couldn't be determined
378 or SIZE was too small.
379 See the POSIX:2001 specification
380 <http://www.opengroup.org/susv3xsh/getcwd.html>.
381 Additionally, the gnulib module 'getcwd' guarantees the following GNU
382 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
383 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
385 # define getcwd rpl_getcwd
386 extern char * getcwd (char *buf, size_t size);
388 #elif defined GNULIB_POSIXCHECK
390 # if HAVE_RAW_DECL_GETCWD
391 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
392 "use gnulib module getcwd for portability");
397 #if @GNULIB_GETDOMAINNAME@
398 /* Return the NIS domain name of the machine.
399 WARNING! The NIS domain name is unrelated to the fully qualified host name
400 of the machine. It is also unrelated to email addresses.
401 WARNING! The NIS domain name is usually the empty string or "(none)" when
404 Put up to LEN bytes of the NIS domain name into NAME.
405 Null terminate it if the name is shorter than LEN.
406 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
407 Return 0 if successful, otherwise set errno and return -1. */
408 # if !@HAVE_GETDOMAINNAME@
409 extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
411 #elif defined GNULIB_POSIXCHECK
412 # undef getdomainname
413 # if HAVE_RAW_DECL_GETDOMAINNAME
414 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
415 "use gnulib module getdomainname for portability");
420 #if @GNULIB_GETDTABLESIZE@
421 # if !@HAVE_GETDTABLESIZE@
422 /* Return the maximum number of file descriptors in the current process.
423 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
424 extern int getdtablesize (void);
426 #elif defined GNULIB_POSIXCHECK
427 # undef getdtablesize
428 # if HAVE_RAW_DECL_GETDTABLESIZE
429 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
430 "use gnulib module getdtablesize for portability");
435 #if @GNULIB_GETGROUPS@
436 # if @REPLACE_GETGROUPS@
438 # define getgroups rpl_getgroups
440 # if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@
441 /* Return the supplemental groups that the current process belongs to.
442 It is unspecified whether the effective group id is in the list.
443 If N is 0, return the group count; otherwise, N describes how many
444 entries are available in GROUPS. Return -1 and set errno if N is
445 not 0 and not large enough. Fails with ENOSYS on some systems. */
446 int getgroups (int n, gid_t *groups);
448 #elif defined GNULIB_POSIXCHECK
450 # if HAVE_RAW_DECL_GETGROUPS
451 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
452 "use gnulib module getgroups for portability");
457 #if @GNULIB_GETHOSTNAME@
458 /* Return the standard host name of the machine.
459 WARNING! The host name may or may not be fully qualified.
461 Put up to LEN bytes of the host name into NAME.
462 Null terminate it if the name is shorter than LEN.
463 If the host name is longer than LEN, set errno = EINVAL and return -1.
464 Return 0 if successful, otherwise set errno and return -1. */
465 # if @UNISTD_H_HAVE_WINSOCK2_H@
467 # define gethostname rpl_gethostname
469 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
470 extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
472 #elif @UNISTD_H_HAVE_WINSOCK2_H@
474 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
475 #elif defined GNULIB_POSIXCHECK
477 # if HAVE_RAW_DECL_GETHOSTNAME
478 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
479 "use gnulib module gethostname for portability");
484 #if @GNULIB_GETLOGIN@
485 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
486 returns NULL with errno set.
488 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
490 Most programs don't need to use this function, because the information is
491 available through environment variables:
492 ${LOGNAME-$USER} on Unix platforms,
493 $USERNAME on native Windows platforms.
495 # if !@HAVE_GETLOGIN@
496 extern char *getlogin (void);
498 #elif defined GNULIB_POSIXCHECK
500 # if HAVE_RAW_DECL_GETLOGIN
501 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
502 "use gnulib module getlogin for portability");
507 #if @GNULIB_GETLOGIN_R@
508 /* Copies the user's login name to NAME.
509 The array pointed to by NAME has room for SIZE bytes.
511 Returns 0 if successful. Upon error, an error number is returned, or -1 in
512 the case that the login name cannot be found but no specific error is
513 provided (this case is hopefully rare but is left open by the POSIX spec).
515 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
517 Most programs don't need to use this function, because the information is
518 available through environment variables:
519 ${LOGNAME-$USER} on Unix platforms,
520 $USERNAME on native Windows platforms.
522 # if !@HAVE_DECL_GETLOGIN_R@
523 extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
525 #elif defined GNULIB_POSIXCHECK
527 # if HAVE_RAW_DECL_GETLOGIN_R
528 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
529 "use gnulib module getlogin_r for portability");
534 #if @GNULIB_GETPAGESIZE@
535 # if @REPLACE_GETPAGESIZE@
536 # define getpagesize rpl_getpagesize
537 extern int getpagesize (void);
538 # elif !@HAVE_GETPAGESIZE@
539 /* This is for POSIX systems. */
540 # if !defined getpagesize && defined _SC_PAGESIZE
541 # if ! (defined __VMS && __VMS_VER < 70000000)
542 # define getpagesize() sysconf (_SC_PAGESIZE)
545 /* This is for older VMS. */
546 # if !defined getpagesize && defined __VMS
548 # define getpagesize() 8192
550 # define getpagesize() 512
553 /* This is for BeOS. */
554 # if !defined getpagesize && @HAVE_OS_H@
556 # if defined B_PAGE_SIZE
557 # define getpagesize() B_PAGE_SIZE
560 /* This is for AmigaOS4.0. */
561 # if !defined getpagesize && defined __amigaos4__
562 # define getpagesize() 2048
564 /* This is for older Unix systems. */
565 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
566 # include <sys/param.h>
567 # ifdef EXEC_PAGESIZE
568 # define getpagesize() EXEC_PAGESIZE
574 # define getpagesize() (NBPG * CLSIZE)
577 # define getpagesize() NBPC
583 #elif defined GNULIB_POSIXCHECK
585 # if HAVE_RAW_DECL_GETPAGESIZE
586 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
587 "use gnulib module getpagesize for portability");
592 #if @GNULIB_GETUSERSHELL@
593 # if !@HAVE_GETUSERSHELL@
594 /* Return the next valid login shell on the system, or NULL when the end of
595 the list has been reached. */
596 extern char *getusershell (void);
597 /* Rewind to pointer that is advanced at each getusershell() call. */
598 extern void setusershell (void);
599 /* Free the pointer that is advanced at each getusershell() call and
600 associated resources. */
601 extern void endusershell (void);
603 #elif defined GNULIB_POSIXCHECK
605 # if HAVE_RAW_DECL_GETUSERSHELL
606 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
607 "use gnulib module getusershell for portability");
610 # if HAVE_RAW_DECL_SETUSERSHELL
611 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
612 "use gnulib module getusershell for portability");
615 # if HAVE_RAW_DECL_ENDUSERSHELL
616 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
617 "use gnulib module getusershell for portability");
623 # if @REPLACE_LCHOWN@
625 # define lchown rpl_lchown
627 # if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
628 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
629 to GID (if GID is not -1). Do not follow symbolic links.
630 Return 0 if successful, otherwise -1 and errno set.
631 See the POSIX:2001 specification
632 <http://www.opengroup.org/susv3xsh/lchown.html>. */
633 extern int lchown (char const *file, uid_t owner, gid_t group)
634 _GL_ARG_NONNULL ((1));
636 #elif defined GNULIB_POSIXCHECK
638 # if HAVE_RAW_DECL_LCHOWN
639 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
640 "use gnulib module lchown for portability");
647 # define link rpl_link
649 /* Create a new hard link for an existing file.
650 Return 0 if successful, otherwise -1 and errno set.
651 See POSIX:2001 specification
652 <http://www.opengroup.org/susv3xsh/link.html>. */
653 # if !@HAVE_LINK@ || @REPLACE_LINK@
654 extern int link (const char *path1, const char *path2)
655 _GL_ARG_NONNULL ((1, 2));
657 #elif defined GNULIB_POSIXCHECK
659 # if HAVE_RAW_DECL_LINK
660 _GL_WARN_ON_USE (link, "link is unportable - "
661 "use gnulib module link for portability");
666 # if @REPLACE_LINKAT@
668 # define linkat rpl_linkat
670 /* Create a new hard link for an existing file, relative to two
671 directories. FLAG controls whether symlinks are followed.
672 Return 0 if successful, otherwise -1 and errno set. */
673 # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
674 extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
676 _GL_ARG_NONNULL ((2, 4));
678 #elif defined GNULIB_POSIXCHECK
680 # if HAVE_RAW_DECL_LINKAT
681 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
682 "use gnulib module linkat for portability");
688 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
689 Return the new offset if successful, otherwise -1 and errno set.
690 See the POSIX:2001 specification
691 <http://www.opengroup.org/susv3xsh/lseek.html>. */
692 # define lseek rpl_lseek
693 extern off_t lseek (int fd, off_t offset, int whence);
695 #elif defined GNULIB_POSIXCHECK
697 # if HAVE_RAW_DECL_LSEEK
698 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
699 "systems - use gnulib module lseek for portability");
705 /* Create a pipe, applying the given flags when opening the read-end of the
706 pipe and the write-end of the pipe.
707 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
708 and O_TEXT, O_BINARY (defined in "binary-io.h").
709 Store the read-end as fd[0] and the write-end as fd[1].
710 Return 0 upon success, or -1 with errno set upon failure.
711 See also the Linux man page at
712 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
714 # define pipe2 rpl_pipe2
716 extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
717 #elif defined GNULIB_POSIXCHECK
719 # if HAVE_RAW_DECL_PIPE2
720 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
721 "use gnulib module pipe2 for portability");
728 # define pread rpl_pread
730 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
731 Return the number of bytes placed into BUF if successful, otherwise
732 set errno and return -1. 0 indicates EOF. See the POSIX:2001
733 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
734 # if !@HAVE_PREAD@ || @REPLACE_PREAD@
735 extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
736 _GL_ARG_NONNULL ((2));
738 #elif defined GNULIB_POSIXCHECK
740 # if HAVE_RAW_DECL_PREAD
741 _GL_WARN_ON_USE (pread, "pread is unportable - "
742 "use gnulib module pread for portability");
747 #if @GNULIB_READLINK@
748 # if @REPLACE_READLINK@
749 # define readlink rpl_readlink
751 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
752 bytes of it into BUF. Return the number of bytes placed into BUF if
753 successful, otherwise -1 and errno set.
754 See the POSIX:2001 specification
755 <http://www.opengroup.org/susv3xsh/readlink.html>. */
756 # if !@HAVE_READLINK@ || @REPLACE_READLINK@
757 extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
758 _GL_ARG_NONNULL ((1, 2));
760 #elif defined GNULIB_POSIXCHECK
762 # if HAVE_RAW_DECL_READLINK
763 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
764 "use gnulib module readlink for portability");
769 #if @GNULIB_READLINKAT@
770 # if !@HAVE_READLINKAT@
771 extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
772 _GL_ARG_NONNULL ((2, 3));
774 #elif defined GNULIB_POSIXCHECK
776 # if HAVE_RAW_DECL_READLINKAT
777 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
778 "use gnulib module symlinkat for portability");
785 # define rmdir rpl_rmdir
786 /* Remove the directory DIR. */
787 extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
789 #elif defined GNULIB_POSIXCHECK
791 # if HAVE_RAW_DECL_RMDIR
792 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
793 "use gnulib module rmdir for portability");
801 # define sleep rpl_sleep
803 /* Pause the execution of the current thread for N seconds.
804 Returns the number of seconds left to sleep.
805 See the POSIX:2001 specification
806 <http://www.opengroup.org/susv3xsh/sleep.html>. */
807 # if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
808 extern unsigned int sleep (unsigned int n);
810 #elif defined GNULIB_POSIXCHECK
812 # if HAVE_RAW_DECL_SLEEP
813 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
814 "use gnulib module sleep for portability");
820 # if @REPLACE_SYMLINK@
822 # define symlink rpl_symlink
824 # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
825 extern int symlink (char const *contents, char const *file)
826 _GL_ARG_NONNULL ((1, 2));
828 #elif defined GNULIB_POSIXCHECK
830 # if HAVE_RAW_DECL_SYMLINK
831 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
832 "use gnulib module symlink for portability");
837 #if @GNULIB_SYMLINKAT@
838 # if !@HAVE_SYMLINKAT@
839 extern int symlinkat (char const *contents, int fd, char const *file)
840 _GL_ARG_NONNULL ((1, 3));
842 #elif defined GNULIB_POSIXCHECK
844 # if HAVE_RAW_DECL_SYMLINKAT
845 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
846 "use gnulib module symlinkat for portability");
852 # if @REPLACE_UNLINK@
854 # define unlink rpl_unlink
855 extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
857 #elif defined GNULIB_POSIXCHECK
859 # if HAVE_RAW_DECL_UNLINK
860 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
861 "use gnulib module unlink for portability");
866 #if @GNULIB_UNLINKAT@
867 # if @REPLACE_UNLINKAT@
869 # define unlinkat rpl_unlinkat
871 # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
872 extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
874 #elif defined GNULIB_POSIXCHECK
876 # if HAVE_RAW_DECL_UNLINKAT
877 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
878 "use gnulib module openat for portability");
884 # if @REPLACE_USLEEP@
886 # define usleep rpl_usleep
888 # if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
889 /* Pause the execution of the current thread for N microseconds.
890 Returns 0 on completion, or -1 on range error.
891 See the POSIX:2001 specification
892 <http://www.opengroup.org/susv3xsh/sleep.html>. */
893 extern int usleep (useconds_t n);
895 #elif defined GNULIB_POSIXCHECK
897 # if HAVE_RAW_DECL_USLEEP
898 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
899 "use gnulib module usleep for portability");
904 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
905 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
906 See the POSIX:2001 specification
907 <http://www.opengroup.org/susv3xsh/write.html>. */
909 # define write rpl_write
910 extern ssize_t write (int fd, const void *buf, size_t count)
911 _GL_ARG_NONNULL ((2));
920 #endif /* _GL_UNISTD_H */
921 #endif /* _GL_UNISTD_H */