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 Lesser 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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser 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 /* Include the headers that might declare getcwd so that they will not
350 cause confusion if included after this file. */
352 # if @REPLACE_GETCWD@
353 /* Get the name of the current working directory, and put it in SIZE bytes
355 Return BUF if successful, or NULL if the directory couldn't be determined
356 or SIZE was too small.
357 See the POSIX:2001 specification
358 <http://www.opengroup.org/susv3xsh/getcwd.html>.
359 Additionally, the gnulib module 'getcwd' guarantees the following GNU
360 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
361 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
363 # define getcwd rpl_getcwd
364 extern char * getcwd (char *buf
, size_t size
);
366 #elif defined GNULIB_POSIXCHECK
368 # define getcwd(b,s) \
369 (GL_LINK_WARNING ("getcwd is unportable - " \
370 "use gnulib module getcwd for portability"), \
375 #if @GNULIB_GETDOMAINNAME@
376 /* Return the NIS domain name of the machine.
377 WARNING! The NIS domain name is unrelated to the fully qualified host name
378 of the machine. It is also unrelated to email addresses.
379 WARNING! The NIS domain name is usually the empty string or "(none)" when
382 Put up to LEN bytes of the NIS domain name into NAME.
383 Null terminate it if the name is shorter than LEN.
384 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
385 Return 0 if successful, otherwise set errno and return -1. */
386 # if !@HAVE_GETDOMAINNAME@
387 extern int getdomainname(char *name
, size_t len
) _GL_ARG_NONNULL ((1));
389 #elif defined GNULIB_POSIXCHECK
390 # undef getdomainname
391 # define getdomainname(n,l) \
392 (GL_LINK_WARNING ("getdomainname is unportable - " \
393 "use gnulib module getdomainname for portability"), \
394 getdomainname (n, l))
398 #if @GNULIB_GETDTABLESIZE@
399 # if !@HAVE_GETDTABLESIZE@
400 /* Return the maximum number of file descriptors in the current process.
401 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
402 extern int getdtablesize (void);
404 #elif defined GNULIB_POSIXCHECK
405 # undef getdtablesize
406 # define getdtablesize() \
407 (GL_LINK_WARNING ("getdtablesize is unportable - " \
408 "use gnulib module getdtablesize for portability"), \
413 #if @GNULIB_GETGROUPS@
414 # if @REPLACE_GETGROUPS@
416 # define getgroups rpl_getgroups
418 # if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@
419 /* Return the supplemental groups that the current process belongs to.
420 It is unspecified whether the effective group id is in the list.
421 If N is 0, return the group count; otherwise, N describes how many
422 entries are available in GROUPS. Return -1 and set errno if N is
423 not 0 and not large enough. Fails with ENOSYS on some systems. */
424 int getgroups (int n
, gid_t
*groups
);
426 #elif defined GNULIB_POSIXCHECK
428 # define getgroups(n,g) \
429 (GL_LINK_WARNING ("getgroups is unportable - " \
430 "use gnulib module getgroups for portability"), \
435 #if @GNULIB_GETHOSTNAME@
436 /* Return the standard host name of the machine.
437 WARNING! The host name may or may not be fully qualified.
439 Put up to LEN bytes of the host name into NAME.
440 Null terminate it if the name is shorter than LEN.
441 If the host name is longer than LEN, set errno = EINVAL and return -1.
442 Return 0 if successful, otherwise set errno and return -1. */
443 # if @UNISTD_H_HAVE_WINSOCK2_H@
445 # define gethostname rpl_gethostname
447 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
448 extern int gethostname(char *name
, size_t len
) _GL_ARG_NONNULL ((1));
450 #elif @UNISTD_H_HAVE_WINSOCK2_H@
452 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
453 #elif defined GNULIB_POSIXCHECK
455 # define gethostname(n,l) \
456 (GL_LINK_WARNING ("gethostname is unportable - " \
457 "use gnulib module gethostname for portability"), \
462 #if @GNULIB_GETLOGIN_R@
463 /* Copies the user's login name to NAME.
464 The array pointed to by NAME has room for SIZE bytes.
466 Returns 0 if successful. Upon error, an error number is returned, or -1 in
467 the case that the login name cannot be found but no specific error is
468 provided (this case is hopefully rare but is left open by the POSIX spec).
470 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
472 # if !@HAVE_DECL_GETLOGIN_R@
473 extern int getlogin_r (char *name
, size_t size
) _GL_ARG_NONNULL ((1));
475 #elif defined GNULIB_POSIXCHECK
477 # define getlogin_r(n,s) \
478 (GL_LINK_WARNING ("getlogin_r is unportable - " \
479 "use gnulib module getlogin_r for portability"), \
484 #if @GNULIB_GETPAGESIZE@
485 # if @REPLACE_GETPAGESIZE@
486 # define getpagesize rpl_getpagesize
487 extern int getpagesize (void);
488 # elif !@HAVE_GETPAGESIZE@
489 /* This is for POSIX systems. */
490 # if !defined getpagesize && defined _SC_PAGESIZE
491 # if ! (defined __VMS && __VMS_VER < 70000000)
492 # define getpagesize() sysconf (_SC_PAGESIZE)
495 /* This is for older VMS. */
496 # if !defined getpagesize && defined __VMS
498 # define getpagesize() 8192
500 # define getpagesize() 512
503 /* This is for BeOS. */
504 # if !defined getpagesize && @HAVE_OS_H@
506 # if defined B_PAGE_SIZE
507 # define getpagesize() B_PAGE_SIZE
510 /* This is for AmigaOS4.0. */
511 # if !defined getpagesize && defined __amigaos4__
512 # define getpagesize() 2048
514 /* This is for older Unix systems. */
515 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
516 # include <sys/param.h>
517 # ifdef EXEC_PAGESIZE
518 # define getpagesize() EXEC_PAGESIZE
524 # define getpagesize() (NBPG * CLSIZE)
527 # define getpagesize() NBPC
533 #elif defined GNULIB_POSIXCHECK
535 # define getpagesize() \
536 (GL_LINK_WARNING ("getpagesize is unportable - " \
537 "use gnulib module getpagesize for portability"), \
542 #if @GNULIB_GETUSERSHELL@
543 # if !@HAVE_GETUSERSHELL@
544 /* Return the next valid login shell on the system, or NULL when the end of
545 the list has been reached. */
546 extern char *getusershell (void);
547 /* Rewind to pointer that is advanced at each getusershell() call. */
548 extern void setusershell (void);
549 /* Free the pointer that is advanced at each getusershell() call and
550 associated resources. */
551 extern void endusershell (void);
553 #elif defined GNULIB_POSIXCHECK
555 # define getusershell() \
556 (GL_LINK_WARNING ("getusershell is unportable - " \
557 "use gnulib module getusershell for portability"), \
560 # define setusershell() \
561 (GL_LINK_WARNING ("setusershell is unportable - " \
562 "use gnulib module getusershell for portability"), \
565 # define endusershell() \
566 (GL_LINK_WARNING ("endusershell is unportable - " \
567 "use gnulib module getusershell for portability"), \
573 # if @REPLACE_LCHOWN@
575 # define lchown rpl_lchown
577 # if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
578 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
579 to GID (if GID is not -1). Do not follow symbolic links.
580 Return 0 if successful, otherwise -1 and errno set.
581 See the POSIX:2001 specification
582 <http://www.opengroup.org/susv3xsh/lchown.html>. */
583 extern int lchown (char const *file
, uid_t owner
, gid_t group
)
584 _GL_ARG_NONNULL ((1));
586 #elif defined GNULIB_POSIXCHECK
588 # define lchown(f,u,g) \
589 (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
590 "systems - use gnulib module lchown for portability"), \
597 # define link rpl_link
599 /* Create a new hard link for an existing file.
600 Return 0 if successful, otherwise -1 and errno set.
601 See POSIX:2001 specification
602 <http://www.opengroup.org/susv3xsh/link.html>. */
603 # if !@HAVE_LINK@ || @REPLACE_LINK@
604 extern int link (const char *path1
, const char *path2
)
605 _GL_ARG_NONNULL ((1, 2));
607 #elif defined GNULIB_POSIXCHECK
609 # define link(path1,path2) \
610 (GL_LINK_WARNING ("link is unportable - " \
611 "use gnulib module link for portability"), \
616 # if @REPLACE_LINKAT@
618 # define linkat rpl_linkat
620 /* Create a new hard link for an existing file, relative to two
621 directories. FLAG controls whether symlinks are followed.
622 Return 0 if successful, otherwise -1 and errno set. */
623 # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
624 extern int linkat (int fd1
, const char *path1
, int fd2
, const char *path2
,
626 _GL_ARG_NONNULL ((2, 4));
628 #elif defined GNULIB_POSIXCHECK
630 # define link(f1,path1,f2,path2,f) \
631 (GL_LINK_WARNING ("linkat is unportable - " \
632 "use gnulib module linkat for portability"), \
633 linkat (f1, path1, f2, path2,f))
638 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
639 Return the new offset if successful, otherwise -1 and errno set.
640 See the POSIX:2001 specification
641 <http://www.opengroup.org/susv3xsh/lseek.html>. */
642 # define lseek rpl_lseek
643 extern off_t
lseek (int fd
, off_t offset
, int whence
);
645 #elif defined GNULIB_POSIXCHECK
647 # define lseek(f,o,w) \
648 (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
649 "systems - use gnulib module lseek for portability"), \
655 /* Create a pipe, applying the given flags when opening the read-end of the
656 pipe and the write-end of the pipe.
657 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
658 and O_TEXT, O_BINARY (defined in "binary-io.h").
659 Store the read-end as fd[0] and the write-end as fd[1].
660 Return 0 upon success, or -1 with errno set upon failure.
661 See also the Linux man page at
662 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
664 # define pipe2 rpl_pipe2
666 extern int pipe2 (int fd
[2], int flags
) _GL_ARG_NONNULL ((1));
667 #elif defined GNULIB_POSIXCHECK
669 # define pipe2(f,o) \
670 (GL_LINK_WARNING ("pipe2 is unportable - " \
671 "use gnulib module pipe2 for portability"), \
678 # define pread rpl_pread
680 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
681 Return the number of bytes placed into BUF if successful, otherwise
682 set errno and return -1. 0 indicates EOF. See the POSIX:2001
683 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
684 # if !@HAVE_PREAD@ || @REPLACE_PREAD@
685 extern ssize_t
pread (int fd
, void *buf
, size_t bufsize
, off_t offset
)
686 _GL_ARG_NONNULL ((2));
688 #elif defined GNULIB_POSIXCHECK
690 # define pread(f,b,s,o) \
691 (GL_LINK_WARNING ("pread is unportable - " \
692 "use gnulib module pread for portability"), \
697 #if @GNULIB_READLINK@
698 # if @REPLACE_READLINK@
699 # define readlink rpl_readlink
701 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
702 bytes of it into BUF. Return the number of bytes placed into BUF if
703 successful, otherwise -1 and errno set.
704 See the POSIX:2001 specification
705 <http://www.opengroup.org/susv3xsh/readlink.html>. */
706 # if !@HAVE_READLINK@ || @REPLACE_READLINK@
707 extern ssize_t
readlink (const char *file
, char *buf
, size_t bufsize
)
708 _GL_ARG_NONNULL ((1, 2));
710 #elif defined GNULIB_POSIXCHECK
712 # define readlink(f,b,s) \
713 (GL_LINK_WARNING ("readlink is unportable - " \
714 "use gnulib module readlink for portability"), \
719 #if @GNULIB_READLINKAT@
720 # if !@HAVE_READLINKAT@
721 extern ssize_t
readlinkat (int fd
, char const *file
, char *buf
, size_t len
)
722 _GL_ARG_NONNULL ((2, 3));
724 #elif defined GNULIB_POSIXCHECK
726 # define readlinkat(d,n,b,l) \
727 (GL_LINK_WARNING ("readlinkat is not portable - " \
728 "use gnulib module symlinkat for portability"), \
729 readlinkat (d, n, b, l))
735 # define rmdir rpl_rmdir
736 /* Remove the directory DIR. */
737 extern int rmdir (char const *name
) _GL_ARG_NONNULL ((1));
739 #elif defined GNULIB_POSIXCHECK
742 (GL_LINK_WARNING ("rmdir is unportable - " \
743 "use gnulib module rmdir for portability"), \
751 # define sleep rpl_sleep
753 /* Pause the execution of the current thread for N seconds.
754 Returns the number of seconds left to sleep.
755 See the POSIX:2001 specification
756 <http://www.opengroup.org/susv3xsh/sleep.html>. */
757 # if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
758 extern unsigned int sleep (unsigned int n
);
760 #elif defined GNULIB_POSIXCHECK
763 (GL_LINK_WARNING ("sleep is unportable - " \
764 "use gnulib module sleep for portability"), \
770 # if @REPLACE_SYMLINK@
772 # define symlink rpl_symlink
774 # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
775 extern int symlink (char const *contents
, char const *file
)
776 _GL_ARG_NONNULL ((1, 2));
778 #elif defined GNULIB_POSIXCHECK
780 # define symlink(c,n) \
781 (GL_LINK_WARNING ("symlink is not portable - " \
782 "use gnulib module symlink for portability"), \
787 #if @GNULIB_SYMLINKAT@
788 # if !@HAVE_SYMLINKAT@
789 extern int symlinkat (char const *contents
, int fd
, char const *file
)
790 _GL_ARG_NONNULL ((1, 3));
792 #elif defined GNULIB_POSIXCHECK
794 # define symlinkat(c,d,n) \
795 (GL_LINK_WARNING ("symlinkat is not portable - " \
796 "use gnulib module symlinkat for portability"), \
802 # if @REPLACE_UNLINK@
804 # define unlink rpl_unlink
805 extern int unlink (char const *file
) _GL_ARG_NONNULL ((1));
807 #elif defined GNULIB_POSIXCHECK
810 (GL_LINK_WARNING ("unlink is not portable - " \
811 "use gnulib module unlink for portability"), \
816 #if @GNULIB_UNLINKAT@
817 # if @REPLACE_UNLINKAT@
819 # define unlinkat rpl_unlinkat
821 # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
822 extern int unlinkat (int fd
, char const *file
, int flag
) _GL_ARG_NONNULL ((2));
824 #elif defined GNULIB_POSIXCHECK
826 # define unlinkat(d,n,f) \
827 (GL_LINK_WARNING ("unlinkat is not portable - " \
828 "use gnulib module openat for portability"), \
834 # if @REPLACE_USLEEP@
836 # define usleep rpl_usleep
838 # if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
839 /* Pause the execution of the current thread for N microseconds.
840 Returns 0 on completion, or -1 on range error.
841 See the POSIX:2001 specification
842 <http://www.opengroup.org/susv3xsh/sleep.html>. */
843 extern int usleep (useconds_t n
);
845 #elif defined GNULIB_POSIXCHECK
848 (GL_LINK_WARNING ("usleep is unportable - " \
849 "use gnulib module usleep for portability"), \
854 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
855 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
856 See the POSIX:2001 specification
857 <http://www.opengroup.org/susv3xsh/write.html>. */
859 # define write rpl_write
860 extern ssize_t
write (int fd
, const void *buf
, size_t count
)
861 _GL_ARG_NONNULL ((2));
870 #endif /* _GL_UNISTD_H */
871 #endif /* _GL_UNISTD_H */