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. */
19 @PRAGMA_SYSTEM_HEADER@
23 /* Special invocation convention:
24 - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
25 but we need to ensure that both the system <unistd.h> and <winsock2.h>
26 are completely included before we replace gethostname. */
27 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
28 && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
29 /* <unistd.h> is being indirectly included for the first time from
30 <winsock2.h>; avoid declaring any overrides. */
32 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
34 # error unexpected; report this to bug-gnulib@gnu.org
36 # define _GL_WINSOCK2_H_WITNESS
38 /* Normal invocation. */
39 #elif !defined _GL_UNISTD_H
41 /* The include_next requires a split double-inclusion guard. */
43 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
46 /* Get all possible declarations of gethostname(). */
47 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
48 && !defined _GL_INCLUDING_WINSOCK2_H
49 # define _GL_INCLUDING_WINSOCK2_H
50 # include <winsock2.h>
51 # undef _GL_INCLUDING_WINSOCK2_H
54 #if !defined _GL_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
57 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
60 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
61 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
62 /* But avoid namespace pollution on glibc systems. */
63 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
64 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
65 && defined __CYGWIN__)) \
66 && ! defined __GLIBC__
70 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
71 /* But avoid namespace pollution on glibc systems. */
72 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
73 && ! defined __GLIBC__
77 /* mingw fails to declare _exit in <unistd.h>. */
78 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
79 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
80 /* But avoid namespace pollution on glibc systems. */
85 /* mingw declares getcwd in <io.h>, not in <unistd.h>. */
86 #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
87 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
91 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>. */
92 /* But avoid namespace pollution on glibc systems. */
93 #if @GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__) \
98 #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
99 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
101 # include <sys/types.h>
104 /* Get getopt(), optarg, optind, opterr, optopt.
105 But avoid namespace pollution on glibc systems. */
106 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
110 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
112 /* The definition of _GL_ARG_NONNULL is copied here. */
114 /* The definition of _GL_WARN_ON_USE is copied here. */
117 #if @GNULIB_GETHOSTNAME@
118 /* Get all possible declarations of gethostname(). */
119 # if @UNISTD_H_HAVE_WINSOCK2_H@
120 # if !defined _GL_SYS_SOCKET_H
121 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
123 # define socket socket_used_without_including_sys_socket_h
125 # define connect connect_used_without_including_sys_socket_h
127 # define accept accept_used_without_including_sys_socket_h
129 # define bind bind_used_without_including_sys_socket_h
131 # define getpeername getpeername_used_without_including_sys_socket_h
133 # define getsockname getsockname_used_without_including_sys_socket_h
135 # define getsockopt getsockopt_used_without_including_sys_socket_h
137 # define listen listen_used_without_including_sys_socket_h
139 # define recv recv_used_without_including_sys_socket_h
141 # define send send_used_without_including_sys_socket_h
143 # define recvfrom recvfrom_used_without_including_sys_socket_h
145 # define sendto sendto_used_without_including_sys_socket_h
147 # define setsockopt setsockopt_used_without_including_sys_socket_h
149 # define shutdown shutdown_used_without_including_sys_socket_h
151 _GL_WARN_ON_USE (socket,
152 "socket() used without including <sys/socket.h>");
153 _GL_WARN_ON_USE (connect,
154 "connect() used without including <sys/socket.h>");
155 _GL_WARN_ON_USE (accept,
156 "accept() used without including <sys/socket.h>");
157 _GL_WARN_ON_USE (bind,
158 "bind() used without including <sys/socket.h>");
159 _GL_WARN_ON_USE (getpeername,
160 "getpeername() used without including <sys/socket.h>");
161 _GL_WARN_ON_USE (getsockname,
162 "getsockname() used without including <sys/socket.h>");
163 _GL_WARN_ON_USE (getsockopt,
164 "getsockopt() used without including <sys/socket.h>");
165 _GL_WARN_ON_USE (listen,
166 "listen() used without including <sys/socket.h>");
167 _GL_WARN_ON_USE (recv,
168 "recv() used without including <sys/socket.h>");
169 _GL_WARN_ON_USE (send,
170 "send() used without including <sys/socket.h>");
171 _GL_WARN_ON_USE (recvfrom,
172 "recvfrom() used without including <sys/socket.h>");
173 _GL_WARN_ON_USE (sendto,
174 "sendto() used without including <sys/socket.h>");
175 _GL_WARN_ON_USE (setsockopt,
176 "setsockopt() used without including <sys/socket.h>");
177 _GL_WARN_ON_USE (shutdown,
178 "shutdown() used without including <sys/socket.h>");
181 # if !defined _GL_SYS_SELECT_H
182 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
184 # define select select_used_without_including_sys_select_h
186 _GL_WARN_ON_USE (select,
187 "select() used without including <sys/select.h>");
194 /* OS/2 EMX lacks these macros. */
196 # define STDIN_FILENO 0
198 #ifndef STDOUT_FILENO
199 # define STDOUT_FILENO 1
201 #ifndef STDERR_FILENO
202 # define STDERR_FILENO 2
205 /* Ensure *_OK macros exist. */
214 /* Declare overridden functions. */
217 #if defined GNULIB_POSIXCHECK
218 /* The access() function is a security risk. */
219 _GL_WARN_ON_USE (access, "the access function is a security risk - "
220 "use the gnulib module faccessat instead");
225 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
226 to GID (if GID is not -1). Follow symbolic links.
227 Return 0 if successful, otherwise -1 and errno set.
228 See the POSIX:2001 specification
229 <http://www.opengroup.org/susv3xsh/chown.html>. */
231 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
233 # define chown rpl_chown
235 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
236 _GL_ARG_NONNULL ((1)));
237 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
240 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
241 _GL_ARG_NONNULL ((1)));
243 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
245 _GL_CXXALIASWARN (chown);
246 #elif defined GNULIB_POSIXCHECK
248 # if HAVE_RAW_DECL_CHOWN
249 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
250 "doesn't treat a uid or gid of -1 on some systems - "
251 "use gnulib module chown for portability");
258 /* Automatically included by modules that need a replacement for close. */
259 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
261 # define close rpl_close
263 _GL_FUNCDECL_RPL (close, int, (int fd));
264 _GL_CXXALIAS_RPL (close, int, (int fd));
266 _GL_CXXALIAS_SYS (close, int, (int fd));
268 _GL_CXXALIASWARN (close);
269 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
271 # define close close_used_without_requesting_gnulib_module_close
272 #elif defined GNULIB_POSIXCHECK
274 /* Assume close is always declared. */
275 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
276 "use gnulib module close for portability");
281 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
284 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
285 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
287 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
289 _GL_CXXALIASWARN (dup);
293 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
294 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
295 Return newfd if successful, otherwise -1 and errno set.
296 See the POSIX:2001 specification
297 <http://www.opengroup.org/susv3xsh/dup2.html>. */
299 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
300 # define dup2 rpl_dup2
302 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
303 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
306 _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
308 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
310 _GL_CXXALIASWARN (dup2);
311 #elif defined GNULIB_POSIXCHECK
313 # if HAVE_RAW_DECL_DUP2
314 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
315 "use gnulib module dup2 for portability");
321 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
323 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
324 and O_TEXT, O_BINARY (defined in "binary-io.h").
325 Close NEWFD first if it is open.
326 Return newfd if successful, otherwise -1 and errno set.
327 See the Linux man page at
328 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
330 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
331 # define dup3 rpl_dup3
333 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
334 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
336 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
337 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
339 _GL_CXXALIASWARN (dup3);
340 #elif defined GNULIB_POSIXCHECK
342 # if HAVE_RAW_DECL_DUP3
343 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
344 "use gnulib module dup3 for portability");
350 # if !@HAVE_DECL_ENVIRON@
351 /* Set of environment variables and values. An array of strings of the form
352 "VARIABLE=VALUE", terminated with a NULL. */
353 # if defined __APPLE__ && defined __MACH__
354 # include <crt_externs.h>
355 # define environ (*_NSGetEnviron ())
360 extern char **environ;
366 #elif defined GNULIB_POSIXCHECK
367 # if HAVE_RAW_DECL_ENVIRON
368 static inline char ***
373 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
374 "use gnulib module environ for portability");
376 # define environ (*rpl_environ ())
381 #if @GNULIB_EUIDACCESS@
382 /* Like access(), except that it uses the effective user id and group id of
383 the current process. */
384 # if !@HAVE_EUIDACCESS@
385 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
386 _GL_ARG_NONNULL ((1)));
388 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
389 _GL_CXXALIASWARN (euidaccess);
390 # if defined GNULIB_POSIXCHECK
391 /* Like access(), this function is a security risk. */
392 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
393 "use the gnulib module faccessat instead");
395 #elif defined GNULIB_POSIXCHECK
397 # if HAVE_RAW_DECL_EUIDACCESS
398 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
399 "use gnulib module euidaccess for portability");
404 #if @GNULIB_FACCESSAT@
405 # if !@HAVE_FACCESSAT@
406 _GL_FUNCDECL_SYS (faccessat, int,
407 (int fd, char const *file, int mode, int flag)
408 _GL_ARG_NONNULL ((2)));
410 _GL_CXXALIAS_SYS (faccessat, int,
411 (int fd, char const *file, int mode, int flag));
412 _GL_CXXALIASWARN (faccessat);
413 #elif defined GNULIB_POSIXCHECK
415 # if HAVE_RAW_DECL_FACCESSAT
416 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
417 "use gnulib module faccessat for portability");
423 /* Change the process' current working directory to the directory on which
424 the given file descriptor is open.
425 Return 0 if successful, otherwise -1 and errno set.
426 See the POSIX:2001 specification
427 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
429 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
431 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
432 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
433 _GL_ARG_NONNULL ((2));
434 _GL_EXTERN_C void _gl_unregister_fd (int fd);
435 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
436 _GL_EXTERN_C const char *_gl_directory_name (int fd);
439 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
440 _GL_CXXALIASWARN (fchdir);
441 #elif defined GNULIB_POSIXCHECK
443 # if HAVE_RAW_DECL_FCHDIR
444 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
445 "use gnulib module fchdir for portability");
450 #if @GNULIB_FCHOWNAT@
451 # if @REPLACE_FCHOWNAT@
452 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
454 # define fchownat rpl_fchownat
456 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
457 uid_t owner, gid_t group, int flag)
458 _GL_ARG_NONNULL ((2)));
459 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
460 uid_t owner, gid_t group, int flag));
462 # if !@HAVE_FCHOWNAT@
463 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
464 uid_t owner, gid_t group, int flag)
465 _GL_ARG_NONNULL ((2)));
467 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
468 uid_t owner, gid_t group, int flag));
470 _GL_CXXALIASWARN (fchownat);
471 #elif defined GNULIB_POSIXCHECK
473 # if HAVE_RAW_DECL_FCHOWNAT
474 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
475 "use gnulib module openat for portability");
481 /* Synchronize changes to a file.
482 Return 0 if successful, otherwise -1 and errno set.
483 See POSIX:2001 specification
484 <http://www.opengroup.org/susv3xsh/fsync.html>. */
486 _GL_FUNCDECL_SYS (fsync, int, (int fd));
488 _GL_CXXALIAS_SYS (fsync, int, (int fd));
489 _GL_CXXALIASWARN (fsync);
490 #elif defined GNULIB_POSIXCHECK
492 # if HAVE_RAW_DECL_FSYNC
493 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
494 "use gnulib module fsync for portability");
499 #if @GNULIB_FTRUNCATE@
500 /* Change the size of the file to which FD is opened to become equal to LENGTH.
501 Return 0 if successful, otherwise -1 and errno set.
502 See the POSIX:2001 specification
503 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
504 # if !@HAVE_FTRUNCATE@
505 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
507 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
508 _GL_CXXALIASWARN (ftruncate);
509 #elif defined GNULIB_POSIXCHECK
511 # if HAVE_RAW_DECL_FTRUNCATE
512 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
513 "use gnulib module ftruncate for portability");
519 /* Get the name of the current working directory, and put it in SIZE bytes
521 Return BUF if successful, or NULL if the directory couldn't be determined
522 or SIZE was too small.
523 See the POSIX:2001 specification
524 <http://www.opengroup.org/susv3xsh/getcwd.html>.
525 Additionally, the gnulib module 'getcwd' guarantees the following GNU
526 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
527 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
529 # if @REPLACE_GETCWD@
530 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
531 # define getcwd rpl_getcwd
533 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
534 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
536 /* Need to cast, because on mingw, the second parameter is
538 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
540 _GL_CXXALIASWARN (getcwd);
541 #elif defined GNULIB_POSIXCHECK
543 # if HAVE_RAW_DECL_GETCWD
544 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
545 "use gnulib module getcwd for portability");
550 #if @GNULIB_GETDOMAINNAME@
551 /* Return the NIS domain name of the machine.
552 WARNING! The NIS domain name is unrelated to the fully qualified host name
553 of the machine. It is also unrelated to email addresses.
554 WARNING! The NIS domain name is usually the empty string or "(none)" when
557 Put up to LEN bytes of the NIS domain name into NAME.
558 Null terminate it if the name is shorter than LEN.
559 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
560 Return 0 if successful, otherwise set errno and return -1. */
561 # if @REPLACE_GETDOMAINNAME@
562 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
563 # undef getdomainname
564 # define getdomainname rpl_getdomainname
566 _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
567 _GL_ARG_NONNULL ((1)));
568 _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
570 # if !@HAVE_DECL_GETDOMAINNAME@
571 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
572 _GL_ARG_NONNULL ((1)));
574 _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
576 _GL_CXXALIASWARN (getdomainname);
577 #elif defined GNULIB_POSIXCHECK
578 # undef getdomainname
579 # if HAVE_RAW_DECL_GETDOMAINNAME
580 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
581 "use gnulib module getdomainname for portability");
586 #if @GNULIB_GETDTABLESIZE@
587 /* Return the maximum number of file descriptors in the current process.
588 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
589 # if !@HAVE_GETDTABLESIZE@
590 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
592 _GL_CXXALIAS_SYS (getdtablesize, int, (void));
593 _GL_CXXALIASWARN (getdtablesize);
594 #elif defined GNULIB_POSIXCHECK
595 # undef getdtablesize
596 # if HAVE_RAW_DECL_GETDTABLESIZE
597 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
598 "use gnulib module getdtablesize for portability");
603 #if @GNULIB_GETGROUPS@
604 /* Return the supplemental groups that the current process belongs to.
605 It is unspecified whether the effective group id is in the list.
606 If N is 0, return the group count; otherwise, N describes how many
607 entries are available in GROUPS. Return -1 and set errno if N is
608 not 0 and not large enough. Fails with ENOSYS on some systems. */
609 # if @REPLACE_GETGROUPS@
610 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
612 # define getgroups rpl_getgroups
614 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
615 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
617 # if !@HAVE_GETGROUPS@
618 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
620 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
622 _GL_CXXALIASWARN (getgroups);
623 #elif defined GNULIB_POSIXCHECK
625 # if HAVE_RAW_DECL_GETGROUPS
626 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
627 "use gnulib module getgroups for portability");
632 #if @GNULIB_GETHOSTNAME@
633 /* Return the standard host name of the machine.
634 WARNING! The host name may or may not be fully qualified.
636 Put up to LEN bytes of the host name into NAME.
637 Null terminate it if the name is shorter than LEN.
638 If the host name is longer than LEN, set errno = EINVAL and return -1.
639 Return 0 if successful, otherwise set errno and return -1. */
640 # if @UNISTD_H_HAVE_WINSOCK2_H@
641 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
643 # define gethostname rpl_gethostname
645 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
646 _GL_ARG_NONNULL ((1)));
647 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
649 # if !@HAVE_GETHOSTNAME@
650 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
651 _GL_ARG_NONNULL ((1)));
653 /* Need to cast, because on Solaris 10 systems, the second parameter is
655 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
657 _GL_CXXALIASWARN (gethostname);
658 #elif @UNISTD_H_HAVE_WINSOCK2_H@
660 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
661 #elif defined GNULIB_POSIXCHECK
663 # if HAVE_RAW_DECL_GETHOSTNAME
664 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
665 "use gnulib module gethostname for portability");
670 #if @GNULIB_GETLOGIN@
671 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
672 returns NULL with errno set.
674 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
676 Most programs don't need to use this function, because the information is
677 available through environment variables:
678 ${LOGNAME-$USER} on Unix platforms,
679 $USERNAME on native Windows platforms.
681 # if !@HAVE_GETLOGIN@
682 _GL_FUNCDECL_SYS (getlogin, char *, (void));
684 _GL_CXXALIAS_SYS (getlogin, char *, (void));
685 _GL_CXXALIASWARN (getlogin);
686 #elif defined GNULIB_POSIXCHECK
688 # if HAVE_RAW_DECL_GETLOGIN
689 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
690 "use gnulib module getlogin for portability");
695 #if @GNULIB_GETLOGIN_R@
696 /* Copies the user's login name to NAME.
697 The array pointed to by NAME has room for SIZE bytes.
699 Returns 0 if successful. Upon error, an error number is returned, or -1 in
700 the case that the login name cannot be found but no specific error is
701 provided (this case is hopefully rare but is left open by the POSIX spec).
703 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
705 Most programs don't need to use this function, because the information is
706 available through environment variables:
707 ${LOGNAME-$USER} on Unix platforms,
708 $USERNAME on native Windows platforms.
710 # if !@HAVE_DECL_GETLOGIN_R@
711 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
712 _GL_ARG_NONNULL ((1)));
714 /* Need to cast, because on Solaris 10 systems, the second argument is
716 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
717 _GL_CXXALIASWARN (getlogin_r);
718 #elif defined GNULIB_POSIXCHECK
720 # if HAVE_RAW_DECL_GETLOGIN_R
721 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
722 "use gnulib module getlogin_r for portability");
727 #if @GNULIB_GETPAGESIZE@
728 # if @REPLACE_GETPAGESIZE@
729 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
730 # define getpagesize rpl_getpagesize
732 _GL_FUNCDECL_RPL (getpagesize, int, (void));
733 _GL_CXXALIAS_RPL (getpagesize, int, (void));
735 # if !@HAVE_GETPAGESIZE@
736 # if !defined getpagesize
737 /* This is for POSIX systems. */
738 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
739 # if ! (defined __VMS && __VMS_VER < 70000000)
740 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
743 /* This is for older VMS. */
744 # if !defined _gl_getpagesize && defined __VMS
746 # define _gl_getpagesize() 8192
748 # define _gl_getpagesize() 512
751 /* This is for BeOS. */
752 # if !defined _gl_getpagesize && @HAVE_OS_H@
754 # if defined B_PAGE_SIZE
755 # define _gl_getpagesize() B_PAGE_SIZE
758 /* This is for AmigaOS4.0. */
759 # if !defined _gl_getpagesize && defined __amigaos4__
760 # define _gl_getpagesize() 2048
762 /* This is for older Unix systems. */
763 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
764 # include <sys/param.h>
765 # ifdef EXEC_PAGESIZE
766 # define _gl_getpagesize() EXEC_PAGESIZE
772 # define _gl_getpagesize() (NBPG * CLSIZE)
775 # define _gl_getpagesize() NBPC
780 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
781 # define getpagesize() _gl_getpagesize ()
786 return _gl_getpagesize ();
791 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
792 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
794 # if @HAVE_DECL_GETPAGESIZE@
795 _GL_CXXALIASWARN (getpagesize);
797 #elif defined GNULIB_POSIXCHECK
799 # if HAVE_RAW_DECL_GETPAGESIZE
800 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
801 "use gnulib module getpagesize for portability");
806 #if @GNULIB_GETUSERSHELL@
807 /* Return the next valid login shell on the system, or NULL when the end of
808 the list has been reached. */
809 # if !@HAVE_DECL_GETUSERSHELL@
810 _GL_FUNCDECL_SYS (getusershell, char *, (void));
812 _GL_CXXALIAS_SYS (getusershell, char *, (void));
813 _GL_CXXALIASWARN (getusershell);
814 #elif defined GNULIB_POSIXCHECK
816 # if HAVE_RAW_DECL_GETUSERSHELL
817 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
818 "use gnulib module getusershell for portability");
822 #if @GNULIB_GETUSERSHELL@
823 /* Rewind to pointer that is advanced at each getusershell() call. */
824 # if !@HAVE_DECL_GETUSERSHELL@
825 _GL_FUNCDECL_SYS (setusershell, void, (void));
827 _GL_CXXALIAS_SYS (setusershell, void, (void));
828 _GL_CXXALIASWARN (setusershell);
829 #elif defined GNULIB_POSIXCHECK
831 # if HAVE_RAW_DECL_SETUSERSHELL
832 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
833 "use gnulib module getusershell for portability");
837 #if @GNULIB_GETUSERSHELL@
838 /* Free the pointer that is advanced at each getusershell() call and
839 associated resources. */
840 # if !@HAVE_DECL_GETUSERSHELL@
841 _GL_FUNCDECL_SYS (endusershell, void, (void));
843 _GL_CXXALIAS_SYS (endusershell, void, (void));
844 _GL_CXXALIASWARN (endusershell);
845 #elif defined GNULIB_POSIXCHECK
847 # if HAVE_RAW_DECL_ENDUSERSHELL
848 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
849 "use gnulib module getusershell for portability");
855 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
856 to GID (if GID is not -1). Do not follow symbolic links.
857 Return 0 if successful, otherwise -1 and errno set.
858 See the POSIX:2001 specification
859 <http://www.opengroup.org/susv3xsh/lchown.html>. */
860 # if @REPLACE_LCHOWN@
861 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
863 # define lchown rpl_lchown
865 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
866 _GL_ARG_NONNULL ((1)));
867 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
870 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
871 _GL_ARG_NONNULL ((1)));
873 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
875 _GL_CXXALIASWARN (lchown);
876 #elif defined GNULIB_POSIXCHECK
878 # if HAVE_RAW_DECL_LCHOWN
879 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
880 "use gnulib module lchown for portability");
886 /* Create a new hard link for an existing file.
887 Return 0 if successful, otherwise -1 and errno set.
888 See POSIX:2001 specification
889 <http://www.opengroup.org/susv3xsh/link.html>. */
891 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
892 # define link rpl_link
894 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
895 _GL_ARG_NONNULL ((1, 2)));
896 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
899 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
900 _GL_ARG_NONNULL ((1, 2)));
902 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
904 _GL_CXXALIASWARN (link);
905 #elif defined GNULIB_POSIXCHECK
907 # if HAVE_RAW_DECL_LINK
908 _GL_WARN_ON_USE (link, "link is unportable - "
909 "use gnulib module link for portability");
915 /* Create a new hard link for an existing file, relative to two
916 directories. FLAG controls whether symlinks are followed.
917 Return 0 if successful, otherwise -1 and errno set. */
918 # if @REPLACE_LINKAT@
919 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
921 # define linkat rpl_linkat
923 _GL_FUNCDECL_RPL (linkat, int,
924 (int fd1, const char *path1, int fd2, const char *path2,
926 _GL_ARG_NONNULL ((2, 4)));
927 _GL_CXXALIAS_RPL (linkat, int,
928 (int fd1, const char *path1, int fd2, const char *path2,
932 _GL_FUNCDECL_SYS (linkat, int,
933 (int fd1, const char *path1, int fd2, const char *path2,
935 _GL_ARG_NONNULL ((2, 4)));
937 _GL_CXXALIAS_SYS (linkat, int,
938 (int fd1, const char *path1, int fd2, const char *path2,
941 _GL_CXXALIASWARN (linkat);
942 #elif defined GNULIB_POSIXCHECK
944 # if HAVE_RAW_DECL_LINKAT
945 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
946 "use gnulib module linkat for portability");
952 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
953 Return the new offset if successful, otherwise -1 and errno set.
954 See the POSIX:2001 specification
955 <http://www.opengroup.org/susv3xsh/lseek.html>. */
957 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
958 # define lseek rpl_lseek
960 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
961 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
963 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
965 _GL_CXXALIASWARN (lseek);
966 #elif defined GNULIB_POSIXCHECK
968 # if HAVE_RAW_DECL_LSEEK
969 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
970 "systems - use gnulib module lseek for portability");
976 /* Create a pipe, defaulting to O_BINARY mode.
977 Store the read-end as fd[0] and the write-end as fd[1].
978 Return 0 upon success, or -1 with errno set upon failure. */
980 _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
982 _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
983 _GL_CXXALIASWARN (pipe);
984 #elif defined GNULIB_POSIXCHECK
986 # if HAVE_RAW_DECL_PIPE
987 _GL_WARN_ON_USE (pipe, "pipe is unportable - "
988 "use gnulib module pipe-posix for portability");
994 /* Create a pipe, applying the given flags when opening the read-end of the
995 pipe and the write-end of the pipe.
996 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
997 and O_TEXT, O_BINARY (defined in "binary-io.h").
998 Store the read-end as fd[0] and the write-end as fd[1].
999 Return 0 upon success, or -1 with errno set upon failure.
1000 See also the Linux man page at
1001 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1003 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1004 # define pipe2 rpl_pipe2
1006 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1007 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1009 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1010 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1012 _GL_CXXALIASWARN (pipe2);
1013 #elif defined GNULIB_POSIXCHECK
1015 # if HAVE_RAW_DECL_PIPE2
1016 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1017 "use gnulib module pipe2 for portability");
1023 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1024 Return the number of bytes placed into BUF if successful, otherwise
1025 set errno and return -1. 0 indicates EOF. See the POSIX:2001
1026 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
1027 # if @REPLACE_PREAD@
1028 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1029 # define pread rpl_pread
1031 _GL_FUNCDECL_RPL (pread, ssize_t,
1032 (int fd, void *buf, size_t bufsize, off_t offset)
1033 _GL_ARG_NONNULL ((2)));
1034 _GL_CXXALIAS_RPL (pread, ssize_t,
1035 (int fd, void *buf, size_t bufsize, off_t offset));
1038 _GL_FUNCDECL_SYS (pread, ssize_t,
1039 (int fd, void *buf, size_t bufsize, off_t offset)
1040 _GL_ARG_NONNULL ((2)));
1042 _GL_CXXALIAS_SYS (pread, ssize_t,
1043 (int fd, void *buf, size_t bufsize, off_t offset));
1045 _GL_CXXALIASWARN (pread);
1046 #elif defined GNULIB_POSIXCHECK
1048 # if HAVE_RAW_DECL_PREAD
1049 _GL_WARN_ON_USE (pread, "pread is unportable - "
1050 "use gnulib module pread for portability");
1056 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1057 Return the number of bytes written if successful, otherwise
1058 set errno and return -1. 0 indicates nothing written. See the
1059 POSIX:2001 specification
1060 <http://www.opengroup.org/susv3xsh/pwrite.html>. */
1061 # if @REPLACE_PWRITE@
1062 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1063 # define pwrite rpl_pwrite
1065 _GL_FUNCDECL_RPL (pwrite, ssize_t,
1066 (int fd, const void *buf, size_t bufsize, off_t offset)
1067 _GL_ARG_NONNULL ((2)));
1068 _GL_CXXALIAS_RPL (pwrite, ssize_t,
1069 (int fd, const void *buf, size_t bufsize, off_t offset));
1072 _GL_FUNCDECL_SYS (pwrite, ssize_t,
1073 (int fd, const void *buf, size_t bufsize, off_t offset)
1074 _GL_ARG_NONNULL ((2)));
1076 _GL_CXXALIAS_SYS (pwrite, ssize_t,
1077 (int fd, const void *buf, size_t bufsize, off_t offset));
1079 _GL_CXXALIASWARN (pwrite);
1080 #elif defined GNULIB_POSIXCHECK
1082 # if HAVE_RAW_DECL_PWRITE
1083 _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1084 "use gnulib module pwrite for portability");
1089 #if @GNULIB_READLINK@
1090 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1091 bytes of it into BUF. Return the number of bytes placed into BUF if
1092 successful, otherwise -1 and errno set.
1093 See the POSIX:2001 specification
1094 <http://www.opengroup.org/susv3xsh/readlink.html>. */
1095 # if @REPLACE_READLINK@
1096 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1097 # define readlink rpl_readlink
1099 _GL_FUNCDECL_RPL (readlink, ssize_t,
1100 (const char *file, char *buf, size_t bufsize)
1101 _GL_ARG_NONNULL ((1, 2)));
1102 _GL_CXXALIAS_RPL (readlink, ssize_t,
1103 (const char *file, char *buf, size_t bufsize));
1105 # if !@HAVE_READLINK@
1106 _GL_FUNCDECL_SYS (readlink, ssize_t,
1107 (const char *file, char *buf, size_t bufsize)
1108 _GL_ARG_NONNULL ((1, 2)));
1110 _GL_CXXALIAS_SYS (readlink, ssize_t,
1111 (const char *file, char *buf, size_t bufsize));
1113 _GL_CXXALIASWARN (readlink);
1114 #elif defined GNULIB_POSIXCHECK
1116 # if HAVE_RAW_DECL_READLINK
1117 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1118 "use gnulib module readlink for portability");
1123 #if @GNULIB_READLINKAT@
1124 # if !@HAVE_READLINKAT@
1125 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
1126 (int fd, char const *file, char *buf, size_t len)
1127 _GL_ARG_NONNULL ((2, 3)));
1129 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1130 (int fd, char const *file, char *buf, size_t len));
1131 _GL_CXXALIASWARN (readlinkat);
1132 #elif defined GNULIB_POSIXCHECK
1134 # if HAVE_RAW_DECL_READLINKAT
1135 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1136 "use gnulib module readlinkat for portability");
1142 /* Remove the directory DIR. */
1143 # if @REPLACE_RMDIR@
1144 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1145 # define rmdir rpl_rmdir
1147 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1148 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1150 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1152 _GL_CXXALIASWARN (rmdir);
1153 #elif defined GNULIB_POSIXCHECK
1155 # if HAVE_RAW_DECL_RMDIR
1156 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1157 "use gnulib module rmdir for portability");
1163 /* Pause the execution of the current thread for N seconds.
1164 Returns the number of seconds left to sleep.
1165 See the POSIX:2001 specification
1166 <http://www.opengroup.org/susv3xsh/sleep.html>. */
1167 # if @REPLACE_SLEEP@
1168 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1170 # define sleep rpl_sleep
1172 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1173 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1176 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1178 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1180 _GL_CXXALIASWARN (sleep);
1181 #elif defined GNULIB_POSIXCHECK
1183 # if HAVE_RAW_DECL_SLEEP
1184 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1185 "use gnulib module sleep for portability");
1190 #if @GNULIB_SYMLINK@
1191 # if @REPLACE_SYMLINK@
1192 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1194 # define symlink rpl_symlink
1196 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1197 _GL_ARG_NONNULL ((1, 2)));
1198 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1200 # if !@HAVE_SYMLINK@
1201 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1202 _GL_ARG_NONNULL ((1, 2)));
1204 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1206 _GL_CXXALIASWARN (symlink);
1207 #elif defined GNULIB_POSIXCHECK
1209 # if HAVE_RAW_DECL_SYMLINK
1210 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1211 "use gnulib module symlink for portability");
1216 #if @GNULIB_SYMLINKAT@
1217 # if !@HAVE_SYMLINKAT@
1218 _GL_FUNCDECL_SYS (symlinkat, int,
1219 (char const *contents, int fd, char const *file)
1220 _GL_ARG_NONNULL ((1, 3)));
1222 _GL_CXXALIAS_SYS (symlinkat, int,
1223 (char const *contents, int fd, char const *file));
1224 _GL_CXXALIASWARN (symlinkat);
1225 #elif defined GNULIB_POSIXCHECK
1227 # if HAVE_RAW_DECL_SYMLINKAT
1228 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1229 "use gnulib module symlinkat for portability");
1234 #if @GNULIB_TTYNAME_R@
1235 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1236 open on in BUF. Return 0 on success, otherwise an error number. */
1237 # if @REPLACE_TTYNAME_R@
1238 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1240 # define ttyname_r rpl_ttyname_r
1242 _GL_FUNCDECL_RPL (ttyname_r, int,
1243 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1244 _GL_CXXALIAS_RPL (ttyname_r, int,
1245 (int fd, char *buf, size_t buflen));
1247 # if !@HAVE_TTYNAME_R@
1248 _GL_FUNCDECL_SYS (ttyname_r, int,
1249 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1251 _GL_CXXALIAS_SYS (ttyname_r, int,
1252 (int fd, char *buf, size_t buflen));
1254 _GL_CXXALIASWARN (ttyname_r);
1255 #elif defined GNULIB_POSIXCHECK
1257 # if HAVE_RAW_DECL_TTYNAME_R
1258 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1259 "use gnulib module ttyname_r for portability");
1265 # if @REPLACE_UNLINK@
1266 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1268 # define unlink rpl_unlink
1270 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1271 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
1273 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
1275 _GL_CXXALIASWARN (unlink);
1276 #elif defined GNULIB_POSIXCHECK
1278 # if HAVE_RAW_DECL_UNLINK
1279 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
1280 "use gnulib module unlink for portability");
1285 #if @GNULIB_UNLINKAT@
1286 # if @REPLACE_UNLINKAT@
1287 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1289 # define unlinkat rpl_unlinkat
1291 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1292 _GL_ARG_NONNULL ((2)));
1293 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1295 # if !@HAVE_UNLINKAT@
1296 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1297 _GL_ARG_NONNULL ((2)));
1299 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1301 _GL_CXXALIASWARN (unlinkat);
1302 #elif defined GNULIB_POSIXCHECK
1304 # if HAVE_RAW_DECL_UNLINKAT
1305 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1306 "use gnulib module openat for portability");
1312 /* Pause the execution of the current thread for N microseconds.
1313 Returns 0 on completion, or -1 on range error.
1314 See the POSIX:2001 specification
1315 <http://www.opengroup.org/susv3xsh/sleep.html>. */
1316 # if @REPLACE_USLEEP@
1317 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1319 # define usleep rpl_usleep
1321 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1322 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1325 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1327 _GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1329 _GL_CXXALIASWARN (usleep);
1330 #elif defined GNULIB_POSIXCHECK
1332 # if HAVE_RAW_DECL_USLEEP
1333 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1334 "use gnulib module usleep for portability");
1340 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1341 See the POSIX:2001 specification
1342 <http://www.opengroup.org/susv3xsh/write.html>. */
1343 # if @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
1344 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1346 # define write rpl_write
1348 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1349 _GL_ARG_NONNULL ((2)));
1350 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1352 /* Need to cast, because on mingw, the third parameter is
1354 and the return type is 'int'. */
1355 _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1357 _GL_CXXALIASWARN (write);
1361 #endif /* _GL_UNISTD_H */
1362 #endif /* _GL_UNISTD_H */