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. */
149 #if defined GNULIB_POSIXCHECK
150 /* The access() function is a security risk. */
151 _GL_WARN_ON_USE (access, "the access function is a security risk - "
152 "use the gnulib module faccessat instead");
159 # define chown rpl_chown
161 # if !@HAVE_CHOWN@ || @REPLACE_CHOWN@
162 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
163 to GID (if GID is not -1). Follow symbolic links.
164 Return 0 if successful, otherwise -1 and errno set.
165 See the POSIX:2001 specification
166 <http://www.opengroup.org/susv3xsh/chown.html>. */
167 extern int chown (const char *file, uid_t uid, gid_t gid)
168 _GL_ARG_NONNULL ((1));
170 #elif defined GNULIB_POSIXCHECK
172 # if HAVE_RAW_DECL_CHOWN
173 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
174 "doesn't treat a uid or gid of -1 on some systems - "
175 "use gnulib module chown for portability");
182 /* Automatically included by modules that need a replacement for close. */
184 # define close rpl_close
185 extern int close (int);
187 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
189 # define close close_used_without_requesting_gnulib_module_close
190 #elif defined GNULIB_POSIXCHECK
192 /* Assume close is always declared. */
193 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
194 "use gnulib module close for portability");
200 extern int dup (int);
206 # define dup2 rpl_dup2
208 # if !@HAVE_DUP2@ || @REPLACE_DUP2@
209 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
210 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
211 Return newfd if successful, otherwise -1 and errno set.
212 See the POSIX:2001 specification
213 <http://www.opengroup.org/susv3xsh/dup2.html>. */
214 extern int dup2 (int oldfd, int newfd);
216 #elif defined GNULIB_POSIXCHECK
218 # if HAVE_RAW_DECL_DUP2
219 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
220 "use gnulib module dup2 for portability");
226 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
228 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
229 and O_TEXT, O_BINARY (defined in "binary-io.h").
230 Close NEWFD first if it is open.
231 Return newfd if successful, otherwise -1 and errno set.
232 See the Linux man page at
233 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
235 # define dup3 rpl_dup3
237 extern int dup3 (int oldfd, int newfd, int flags);
238 #elif defined GNULIB_POSIXCHECK
240 # if HAVE_RAW_DECL_DUP3
241 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
242 "use gnulib module dup3 for portability");
248 # if !@HAVE_DECL_ENVIRON@
249 /* Set of environment variables and values. An array of strings of the form
250 "VARIABLE=VALUE", terminated with a NULL. */
251 # if defined __APPLE__ && defined __MACH__
252 # include <crt_externs.h>
253 # define environ (*_NSGetEnviron ())
255 extern char **environ;
258 #elif defined GNULIB_POSIXCHECK
259 # if HAVE_RAW_DECL_ENVIRON
260 static inline char ***
265 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
266 "use gnulib module environ for portability");
268 # define environ (*rpl_environ ())
273 #if @GNULIB_EUIDACCESS@
274 # if !@HAVE_EUIDACCESS@
275 /* Like access(), except that it uses the effective user id and group id of
276 the current process. */
277 extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
279 # if defined GNULIB_POSIXCHECK
280 /* Like access(), this function is a security risk. */
281 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
282 "use the gnulib module faccessat instead");
284 #elif defined GNULIB_POSIXCHECK
286 # if HAVE_RAW_DECL_EUIDACCESS
287 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
288 "use gnulib module euidaccess for portability");
293 #if @GNULIB_FACCESSAT@
294 # if !@HAVE_FACCESSAT@
295 extern int faccessat (int fd, char const *file, int mode, int flag)
296 _GL_ARG_NONNULL ((2));
298 #elif defined GNULIB_POSIXCHECK
300 # if HAVE_RAW_DECL_FACCESSAT
301 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
302 "use gnulib module faccessat for portability");
308 # if @REPLACE_FCHDIR@
309 /* Change the process' current working directory to the directory on which
310 the given file descriptor is open.
311 Return 0 if successful, otherwise -1 and errno set.
312 See the POSIX:2001 specification
313 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
314 extern int fchdir (int /*fd*/);
316 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
317 extern int _gl_register_fd (int fd, const char *filename)
318 _GL_ARG_NONNULL ((2));
319 extern void _gl_unregister_fd (int fd);
320 extern int _gl_register_dup (int oldfd, int newfd);
321 extern const char *_gl_directory_name (int fd);
324 #elif defined GNULIB_POSIXCHECK
326 # if HAVE_RAW_DECL_FCHDIR
327 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
328 "use gnulib module fchdir for portability");
333 #if @GNULIB_FCHOWNAT@
334 # if @REPLACE_FCHOWNAT@
336 # define fchownat rpl_fchownat
338 # if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
339 extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
340 _GL_ARG_NONNULL ((2));
342 #elif defined GNULIB_POSIXCHECK
344 # if HAVE_RAW_DECL_FCHOWNAT
345 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
346 "use gnulib module openat for portability");
352 /* Synchronize changes to a file.
353 Return 0 if successful, otherwise -1 and errno set.
354 See POSIX:2001 specification
355 <http://www.opengroup.org/susv3xsh/fsync.html>. */
357 extern int fsync (int fd);
359 #elif defined GNULIB_POSIXCHECK
361 # if HAVE_RAW_DECL_FSYNC
362 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
363 "use gnulib module fsync for portability");
368 #if @GNULIB_FTRUNCATE@
369 # if !@HAVE_FTRUNCATE@
370 /* Change the size of the file to which FD is opened to become equal to LENGTH.
371 Return 0 if successful, otherwise -1 and errno set.
372 See the POSIX:2001 specification
373 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
374 extern int ftruncate (int fd, off_t length);
376 #elif defined GNULIB_POSIXCHECK
378 # if HAVE_RAW_DECL_FTRUNCATE
379 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
380 "use gnulib module ftruncate for portability");
386 # if @REPLACE_GETCWD@
387 /* Get the name of the current working directory, and put it in SIZE bytes
389 Return BUF if successful, or NULL if the directory couldn't be determined
390 or SIZE was too small.
391 See the POSIX:2001 specification
392 <http://www.opengroup.org/susv3xsh/getcwd.html>.
393 Additionally, the gnulib module 'getcwd' guarantees the following GNU
394 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
395 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
397 # define getcwd rpl_getcwd
398 extern char * getcwd (char *buf, size_t size);
400 #elif defined GNULIB_POSIXCHECK
402 # if HAVE_RAW_DECL_GETCWD
403 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
404 "use gnulib module getcwd for portability");
409 #if @GNULIB_GETDOMAINNAME@
410 /* Return the NIS domain name of the machine.
411 WARNING! The NIS domain name is unrelated to the fully qualified host name
412 of the machine. It is also unrelated to email addresses.
413 WARNING! The NIS domain name is usually the empty string or "(none)" when
416 Put up to LEN bytes of the NIS domain name into NAME.
417 Null terminate it if the name is shorter than LEN.
418 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
419 Return 0 if successful, otherwise set errno and return -1. */
420 # if !@HAVE_GETDOMAINNAME@
421 extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
423 #elif defined GNULIB_POSIXCHECK
424 # undef getdomainname
425 # if HAVE_RAW_DECL_GETDOMAINNAME
426 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
427 "use gnulib module getdomainname for portability");
432 #if @GNULIB_GETDTABLESIZE@
433 # if !@HAVE_GETDTABLESIZE@
434 /* Return the maximum number of file descriptors in the current process.
435 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
436 extern int getdtablesize (void);
438 #elif defined GNULIB_POSIXCHECK
439 # undef getdtablesize
440 # if HAVE_RAW_DECL_GETDTABLESIZE
441 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
442 "use gnulib module getdtablesize for portability");
447 #if @GNULIB_GETGROUPS@
448 # if @REPLACE_GETGROUPS@
450 # define getgroups rpl_getgroups
452 # if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@
453 /* Return the supplemental groups that the current process belongs to.
454 It is unspecified whether the effective group id is in the list.
455 If N is 0, return the group count; otherwise, N describes how many
456 entries are available in GROUPS. Return -1 and set errno if N is
457 not 0 and not large enough. Fails with ENOSYS on some systems. */
458 int getgroups (int n, gid_t *groups);
460 #elif defined GNULIB_POSIXCHECK
462 # if HAVE_RAW_DECL_GETGROUPS
463 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
464 "use gnulib module getgroups for portability");
469 #if @GNULIB_GETHOSTNAME@
470 /* Return the standard host name of the machine.
471 WARNING! The host name may or may not be fully qualified.
473 Put up to LEN bytes of the host name into NAME.
474 Null terminate it if the name is shorter than LEN.
475 If the host name is longer than LEN, set errno = EINVAL and return -1.
476 Return 0 if successful, otherwise set errno and return -1. */
477 # if @UNISTD_H_HAVE_WINSOCK2_H@
479 # define gethostname rpl_gethostname
481 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
482 extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
484 #elif @UNISTD_H_HAVE_WINSOCK2_H@
486 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
487 #elif defined GNULIB_POSIXCHECK
489 # if HAVE_RAW_DECL_GETHOSTNAME
490 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
491 "use gnulib module gethostname for portability");
496 #if @GNULIB_GETLOGIN@
497 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
498 returns NULL with errno set.
500 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
502 Most programs don't need to use this function, because the information is
503 available through environment variables:
504 ${LOGNAME-$USER} on Unix platforms,
505 $USERNAME on native Windows platforms.
507 # if !@HAVE_GETLOGIN@
508 extern char *getlogin (void);
510 #elif defined GNULIB_POSIXCHECK
512 # if HAVE_RAW_DECL_GETLOGIN
513 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
514 "use gnulib module getlogin for portability");
519 #if @GNULIB_GETLOGIN_R@
520 /* Copies the user's login name to NAME.
521 The array pointed to by NAME has room for SIZE bytes.
523 Returns 0 if successful. Upon error, an error number is returned, or -1 in
524 the case that the login name cannot be found but no specific error is
525 provided (this case is hopefully rare but is left open by the POSIX spec).
527 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
529 Most programs don't need to use this function, because the information is
530 available through environment variables:
531 ${LOGNAME-$USER} on Unix platforms,
532 $USERNAME on native Windows platforms.
534 # if !@HAVE_DECL_GETLOGIN_R@
535 extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
537 #elif defined GNULIB_POSIXCHECK
539 # if HAVE_RAW_DECL_GETLOGIN_R
540 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
541 "use gnulib module getlogin_r for portability");
546 #if @GNULIB_GETPAGESIZE@
547 # if @REPLACE_GETPAGESIZE@
548 # define getpagesize rpl_getpagesize
549 extern int getpagesize (void);
550 # elif !@HAVE_GETPAGESIZE@
551 /* This is for POSIX systems. */
552 # if !defined getpagesize && defined _SC_PAGESIZE
553 # if ! (defined __VMS && __VMS_VER < 70000000)
554 # define getpagesize() sysconf (_SC_PAGESIZE)
557 /* This is for older VMS. */
558 # if !defined getpagesize && defined __VMS
560 # define getpagesize() 8192
562 # define getpagesize() 512
565 /* This is for BeOS. */
566 # if !defined getpagesize && @HAVE_OS_H@
568 # if defined B_PAGE_SIZE
569 # define getpagesize() B_PAGE_SIZE
572 /* This is for AmigaOS4.0. */
573 # if !defined getpagesize && defined __amigaos4__
574 # define getpagesize() 2048
576 /* This is for older Unix systems. */
577 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
578 # include <sys/param.h>
579 # ifdef EXEC_PAGESIZE
580 # define getpagesize() EXEC_PAGESIZE
586 # define getpagesize() (NBPG * CLSIZE)
589 # define getpagesize() NBPC
595 #elif defined GNULIB_POSIXCHECK
597 # if HAVE_RAW_DECL_GETPAGESIZE
598 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
599 "use gnulib module getpagesize for portability");
604 #if @GNULIB_GETUSERSHELL@
605 # if !@HAVE_GETUSERSHELL@
606 /* Return the next valid login shell on the system, or NULL when the end of
607 the list has been reached. */
608 extern char *getusershell (void);
609 /* Rewind to pointer that is advanced at each getusershell() call. */
610 extern void setusershell (void);
611 /* Free the pointer that is advanced at each getusershell() call and
612 associated resources. */
613 extern void endusershell (void);
615 #elif defined GNULIB_POSIXCHECK
617 # if HAVE_RAW_DECL_GETUSERSHELL
618 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
619 "use gnulib module getusershell for portability");
622 # if HAVE_RAW_DECL_SETUSERSHELL
623 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
624 "use gnulib module getusershell for portability");
627 # if HAVE_RAW_DECL_ENDUSERSHELL
628 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
629 "use gnulib module getusershell for portability");
635 # if @REPLACE_LCHOWN@
637 # define lchown rpl_lchown
639 # if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
640 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
641 to GID (if GID is not -1). Do not follow symbolic links.
642 Return 0 if successful, otherwise -1 and errno set.
643 See the POSIX:2001 specification
644 <http://www.opengroup.org/susv3xsh/lchown.html>. */
645 extern int lchown (char const *file, uid_t owner, gid_t group)
646 _GL_ARG_NONNULL ((1));
648 #elif defined GNULIB_POSIXCHECK
650 # if HAVE_RAW_DECL_LCHOWN
651 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
652 "use gnulib module lchown for portability");
659 # define link rpl_link
661 /* Create a new hard link for an existing file.
662 Return 0 if successful, otherwise -1 and errno set.
663 See POSIX:2001 specification
664 <http://www.opengroup.org/susv3xsh/link.html>. */
665 # if !@HAVE_LINK@ || @REPLACE_LINK@
666 extern int link (const char *path1, const char *path2)
667 _GL_ARG_NONNULL ((1, 2));
669 #elif defined GNULIB_POSIXCHECK
671 # if HAVE_RAW_DECL_LINK
672 _GL_WARN_ON_USE (link, "link is unportable - "
673 "use gnulib module link for portability");
678 # if @REPLACE_LINKAT@
680 # define linkat rpl_linkat
682 /* Create a new hard link for an existing file, relative to two
683 directories. FLAG controls whether symlinks are followed.
684 Return 0 if successful, otherwise -1 and errno set. */
685 # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
686 extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
688 _GL_ARG_NONNULL ((2, 4));
690 #elif defined GNULIB_POSIXCHECK
692 # if HAVE_RAW_DECL_LINKAT
693 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
694 "use gnulib module linkat for portability");
700 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
701 Return the new offset if successful, otherwise -1 and errno set.
702 See the POSIX:2001 specification
703 <http://www.opengroup.org/susv3xsh/lseek.html>. */
704 # define lseek rpl_lseek
705 extern off_t lseek (int fd, off_t offset, int whence);
707 #elif defined GNULIB_POSIXCHECK
709 # if HAVE_RAW_DECL_LSEEK
710 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
711 "systems - use gnulib module lseek for portability");
717 /* Create a pipe, applying the given flags when opening the read-end of the
718 pipe and the write-end of the pipe.
719 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
720 and O_TEXT, O_BINARY (defined in "binary-io.h").
721 Store the read-end as fd[0] and the write-end as fd[1].
722 Return 0 upon success, or -1 with errno set upon failure.
723 See also the Linux man page at
724 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
726 # define pipe2 rpl_pipe2
728 extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
729 #elif defined GNULIB_POSIXCHECK
731 # if HAVE_RAW_DECL_PIPE2
732 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
733 "use gnulib module pipe2 for portability");
740 # define pread rpl_pread
742 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
743 Return the number of bytes placed into BUF if successful, otherwise
744 set errno and return -1. 0 indicates EOF. See the POSIX:2001
745 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
746 # if !@HAVE_PREAD@ || @REPLACE_PREAD@
747 extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
748 _GL_ARG_NONNULL ((2));
750 #elif defined GNULIB_POSIXCHECK
752 # if HAVE_RAW_DECL_PREAD
753 _GL_WARN_ON_USE (pread, "pread is unportable - "
754 "use gnulib module pread for portability");
759 #if @GNULIB_READLINK@
760 # if @REPLACE_READLINK@
761 # define readlink rpl_readlink
763 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
764 bytes of it into BUF. Return the number of bytes placed into BUF if
765 successful, otherwise -1 and errno set.
766 See the POSIX:2001 specification
767 <http://www.opengroup.org/susv3xsh/readlink.html>. */
768 # if !@HAVE_READLINK@ || @REPLACE_READLINK@
769 extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
770 _GL_ARG_NONNULL ((1, 2));
772 #elif defined GNULIB_POSIXCHECK
774 # if HAVE_RAW_DECL_READLINK
775 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
776 "use gnulib module readlink for portability");
781 #if @GNULIB_READLINKAT@
782 # if !@HAVE_READLINKAT@
783 extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
784 _GL_ARG_NONNULL ((2, 3));
786 #elif defined GNULIB_POSIXCHECK
788 # if HAVE_RAW_DECL_READLINKAT
789 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
790 "use gnulib module symlinkat for portability");
797 # define rmdir rpl_rmdir
798 /* Remove the directory DIR. */
799 extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
801 #elif defined GNULIB_POSIXCHECK
803 # if HAVE_RAW_DECL_RMDIR
804 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
805 "use gnulib module rmdir for portability");
813 # define sleep rpl_sleep
815 /* Pause the execution of the current thread for N seconds.
816 Returns the number of seconds left to sleep.
817 See the POSIX:2001 specification
818 <http://www.opengroup.org/susv3xsh/sleep.html>. */
819 # if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
820 extern unsigned int sleep (unsigned int n);
822 #elif defined GNULIB_POSIXCHECK
824 # if HAVE_RAW_DECL_SLEEP
825 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
826 "use gnulib module sleep for portability");
832 # if @REPLACE_SYMLINK@
834 # define symlink rpl_symlink
836 # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
837 extern int symlink (char const *contents, char const *file)
838 _GL_ARG_NONNULL ((1, 2));
840 #elif defined GNULIB_POSIXCHECK
842 # if HAVE_RAW_DECL_SYMLINK
843 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
844 "use gnulib module symlink for portability");
849 #if @GNULIB_SYMLINKAT@
850 # if !@HAVE_SYMLINKAT@
851 extern int symlinkat (char const *contents, int fd, char const *file)
852 _GL_ARG_NONNULL ((1, 3));
854 #elif defined GNULIB_POSIXCHECK
856 # if HAVE_RAW_DECL_SYMLINKAT
857 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
858 "use gnulib module symlinkat for portability");
864 # if @REPLACE_UNLINK@
866 # define unlink rpl_unlink
867 extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
869 #elif defined GNULIB_POSIXCHECK
871 # if HAVE_RAW_DECL_UNLINK
872 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
873 "use gnulib module unlink for portability");
878 #if @GNULIB_UNLINKAT@
879 # if @REPLACE_UNLINKAT@
881 # define unlinkat rpl_unlinkat
883 # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
884 extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
886 #elif defined GNULIB_POSIXCHECK
888 # if HAVE_RAW_DECL_UNLINKAT
889 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
890 "use gnulib module openat for portability");
896 # if @REPLACE_USLEEP@
898 # define usleep rpl_usleep
900 # if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
901 /* Pause the execution of the current thread for N microseconds.
902 Returns 0 on completion, or -1 on range error.
903 See the POSIX:2001 specification
904 <http://www.opengroup.org/susv3xsh/sleep.html>. */
905 extern int usleep (useconds_t n);
907 #elif defined GNULIB_POSIXCHECK
909 # if HAVE_RAW_DECL_USLEEP
910 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
911 "use gnulib module usleep for portability");
916 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
917 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
918 See the POSIX:2001 specification
919 <http://www.opengroup.org/susv3xsh/write.html>. */
921 # define write rpl_write
922 extern ssize_t write (int fd, const void *buf, size_t count)
923 _GL_ARG_NONNULL ((2));
932 #endif /* _GL_UNISTD_H */
933 #endif /* _GL_UNISTD_H */