1/* Substitute for and wrapper around <unistd.h>.
2   Copyright (C) 2003-2014 Free Software Foundation, Inc.
3
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 3, or (at your option)
7   any later version.
8
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.
13
14   You should have received a copy of the GNU General Public License
15   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
16
17#ifndef _@GUARD_PREFIX@_UNISTD_H
18
19#if __GNUC__ >= 3
20@PRAGMA_SYSTEM_HEADER@
21#endif
22@PRAGMA_COLUMNS@
23
24#ifdef _GL_INCLUDING_UNISTD_H
25/* Special invocation convention:
26   - On Mac OS X 10.3.9 we have a sequence of nested includes
27     <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>
28     In this situation, the functions are not yet declared, therefore we cannot
29     provide the C++ aliases.  */
30
31#@INCLUDE_NEXT@ @NEXT_UNISTD_H@
32
33#else
34/* Normal invocation convention.  */
35
36/* The include_next requires a split double-inclusion guard.  */
37#if @HAVE_UNISTD_H@
38# define _GL_INCLUDING_UNISTD_H
39# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
40# undef _GL_INCLUDING_UNISTD_H
41#endif
42
43/* Get all possible declarations of gethostname().  */
44#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
45  && !defined _GL_INCLUDING_WINSOCK2_H
46# define _GL_INCLUDING_WINSOCK2_H
47# include <winsock2.h>
48# undef _GL_INCLUDING_WINSOCK2_H
49#endif
50
51#if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
52#define _@GUARD_PREFIX@_UNISTD_H
53
54/* NetBSD 5.0 mis-defines NULL.  Also get size_t.  */
55#include <stddef.h>
56
57/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>.  */
58/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>.  */
59/* But avoid namespace pollution on glibc systems.  */
60#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
61     || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
62         && defined __CYGWIN__)) \
63    && ! defined __GLIBC__
64# include <stdio.h>
65#endif
66
67/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>.  */
68/* But avoid namespace pollution on glibc systems.  */
69#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
70    && ! defined __GLIBC__
71# include <fcntl.h>
72#endif
73
74/* mingw fails to declare _exit in <unistd.h>.  */
75/* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
76   <unistd.h>.  */
77/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>.  */
78/* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
79   included here.  */
80/* But avoid namespace pollution on glibc systems.  */
81#if !defined __GLIBC__ && !defined __osf__
82# define __need_system_stdlib_h
83# include <stdlib.h>
84# undef __need_system_stdlib_h
85#endif
86
87/* Native Windows platforms declare chdir, getcwd, rmdir in
88   <io.h> and/or <direct.h>, not in <unistd.h>.
89   They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
90   lseek(), read(), unlink(), write() in <io.h>.  */
91#if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
92      || defined GNULIB_POSIXCHECK) \
93     && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
94# include <io.h>     /* mingw32, mingw64 */
95# include <direct.h> /* mingw64, MSVC 9 */
96#elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
97       || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
98       || defined GNULIB_POSIXCHECK) \
99      && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
100# include <io.h>
101#endif
102
103/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
104   NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>.  */
105/* But avoid namespace pollution on glibc systems.  */
106#if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
107     || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
108    && !defined __GLIBC__
109# include <netdb.h>
110#endif
111
112/* MSVC defines off_t in <sys/types.h>.
113   May also define off_t to a 64-bit type on native Windows.  */
114#if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
115/* Get off_t.  */
116# include <sys/types.h>
117#endif
118
119#if (@GNULIB_READ@ || @GNULIB_WRITE@ \
120     || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
121     || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
122/* Get ssize_t.  */
123# include <sys/types.h>
124#endif
125
126/* Get getopt(), optarg, optind, opterr, optopt.
127   But avoid namespace pollution on glibc systems.  */
128#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
129# define __need_getopt
130# include <getopt.h>
131#endif
132
133#ifndef _GL_INLINE_HEADER_BEGIN
134 #error "Please include config.h first."
135#endif
136_GL_INLINE_HEADER_BEGIN
137#ifndef _GL_UNISTD_INLINE
138# define _GL_UNISTD_INLINE _GL_INLINE
139#endif
140
141/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
142
143/* The definition of _GL_ARG_NONNULL is copied here.  */
144
145/* The definition of _GL_WARN_ON_USE is copied here.  */
146
147
148/* Hide some function declarations from <winsock2.h>.  */
149
150#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
151# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
152#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
153#   undef socket
154#   define socket              socket_used_without_including_sys_socket_h
155#   undef connect
156#   define connect             connect_used_without_including_sys_socket_h
157#   undef accept
158#   define accept              accept_used_without_including_sys_socket_h
159#   undef bind
160#   define bind                bind_used_without_including_sys_socket_h
161#   undef getpeername
162#   define getpeername         getpeername_used_without_including_sys_socket_h
163#   undef getsockname
164#   define getsockname         getsockname_used_without_including_sys_socket_h
165#   undef getsockopt
166#   define getsockopt          getsockopt_used_without_including_sys_socket_h
167#   undef listen
168#   define listen              listen_used_without_including_sys_socket_h
169#   undef recv
170#   define recv                recv_used_without_including_sys_socket_h
171#   undef send
172#   define send                send_used_without_including_sys_socket_h
173#   undef recvfrom
174#   define recvfrom            recvfrom_used_without_including_sys_socket_h
175#   undef sendto
176#   define sendto              sendto_used_without_including_sys_socket_h
177#   undef setsockopt
178#   define setsockopt          setsockopt_used_without_including_sys_socket_h
179#   undef shutdown
180#   define shutdown            shutdown_used_without_including_sys_socket_h
181#  else
182    _GL_WARN_ON_USE (socket,
183                     "socket() used without including <sys/socket.h>");
184    _GL_WARN_ON_USE (connect,
185                     "connect() used without including <sys/socket.h>");
186    _GL_WARN_ON_USE (accept,
187                     "accept() used without including <sys/socket.h>");
188    _GL_WARN_ON_USE (bind,
189                     "bind() used without including <sys/socket.h>");
190    _GL_WARN_ON_USE (getpeername,
191                     "getpeername() used without including <sys/socket.h>");
192    _GL_WARN_ON_USE (getsockname,
193                     "getsockname() used without including <sys/socket.h>");
194    _GL_WARN_ON_USE (getsockopt,
195                     "getsockopt() used without including <sys/socket.h>");
196    _GL_WARN_ON_USE (listen,
197                     "listen() used without including <sys/socket.h>");
198    _GL_WARN_ON_USE (recv,
199                     "recv() used without including <sys/socket.h>");
200    _GL_WARN_ON_USE (send,
201                     "send() used without including <sys/socket.h>");
202    _GL_WARN_ON_USE (recvfrom,
203                     "recvfrom() used without including <sys/socket.h>");
204    _GL_WARN_ON_USE (sendto,
205                     "sendto() used without including <sys/socket.h>");
206    _GL_WARN_ON_USE (setsockopt,
207                     "setsockopt() used without including <sys/socket.h>");
208    _GL_WARN_ON_USE (shutdown,
209                     "shutdown() used without including <sys/socket.h>");
210#  endif
211# endif
212# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
213#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
214#   undef select
215#   define select              select_used_without_including_sys_select_h
216#  else
217    _GL_WARN_ON_USE (select,
218                     "select() used without including <sys/select.h>");
219#  endif
220# endif
221#endif
222
223
224/* OS/2 EMX lacks these macros.  */
225#ifndef STDIN_FILENO
226# define STDIN_FILENO 0
227#endif
228#ifndef STDOUT_FILENO
229# define STDOUT_FILENO 1
230#endif
231#ifndef STDERR_FILENO
232# define STDERR_FILENO 2
233#endif
234
235/* Ensure *_OK macros exist.  */
236#ifndef F_OK
237# define F_OK 0
238# define X_OK 1
239# define W_OK 2
240# define R_OK 4
241#endif
242
243
244/* Declare overridden functions.  */
245
246
247#if defined GNULIB_POSIXCHECK
248/* The access() function is a security risk.  */
249_GL_WARN_ON_USE (access, "the access function is a security risk - "
250                 "use the gnulib module faccessat instead");
251#endif
252
253
254#if @GNULIB_CHDIR@
255_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
256_GL_CXXALIASWARN (chdir);
257#elif defined GNULIB_POSIXCHECK
258# undef chdir
259# if HAVE_RAW_DECL_CHDIR
260_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
261                 "use gnulib module chdir for portability");
262# endif
263#endif
264
265
266#if @GNULIB_CHOWN@
267/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
268   to GID (if GID is not -1).  Follow symbolic links.
269   Return 0 if successful, otherwise -1 and errno set.
270   See the POSIX:2008 specification
271   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html.  */
272# if @REPLACE_CHOWN@
273#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
274#   undef chown
275#   define chown rpl_chown
276#  endif
277_GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
278                              _GL_ARG_NONNULL ((1)));
279_GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
280# else
281#  if !@HAVE_CHOWN@
282_GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
283                              _GL_ARG_NONNULL ((1)));
284#  endif
285_GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
286# endif
287_GL_CXXALIASWARN (chown);
288#elif defined GNULIB_POSIXCHECK
289# undef chown
290# if HAVE_RAW_DECL_CHOWN
291_GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
292                 "doesn't treat a uid or gid of -1 on some systems - "
293                 "use gnulib module chown for portability");
294# endif
295#endif
296
297
298#if @GNULIB_CLOSE@
299# if @REPLACE_CLOSE@
300/* Automatically included by modules that need a replacement for close.  */
301#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
302#   undef close
303#   define close rpl_close
304#  endif
305_GL_FUNCDECL_RPL (close, int, (int fd));
306_GL_CXXALIAS_RPL (close, int, (int fd));
307# else
308_GL_CXXALIAS_SYS (close, int, (int fd));
309# endif
310_GL_CXXALIASWARN (close);
311#elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
312# undef close
313# define close close_used_without_requesting_gnulib_module_close
314#elif defined GNULIB_POSIXCHECK
315# undef close
316/* Assume close is always declared.  */
317_GL_WARN_ON_USE (close, "close does not portably work on sockets - "
318                 "use gnulib module close for portability");
319#endif
320
321
322#if @GNULIB_DUP@
323# if @REPLACE_DUP@
324#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
325#   define dup rpl_dup
326#  endif
327_GL_FUNCDECL_RPL (dup, int, (int oldfd));
328_GL_CXXALIAS_RPL (dup, int, (int oldfd));
329# else
330_GL_CXXALIAS_SYS (dup, int, (int oldfd));
331# endif
332_GL_CXXALIASWARN (dup);
333#elif defined GNULIB_POSIXCHECK
334# undef dup
335# if HAVE_RAW_DECL_DUP
336_GL_WARN_ON_USE (dup, "dup is unportable - "
337                 "use gnulib module dup for portability");
338# endif
339#endif
340
341
342#if @GNULIB_DUP2@
343/* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
344   NEWFD = OLDFD, otherwise close NEWFD first if it is open.
345   Return newfd if successful, otherwise -1 and errno set.
346   See the POSIX:2008 specification
347   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>.  */
348# if @REPLACE_DUP2@
349#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
350#   define dup2 rpl_dup2
351#  endif
352_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
353_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
354# else
355#  if !@HAVE_DUP2@
356_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
357#  endif
358_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
359# endif
360_GL_CXXALIASWARN (dup2);
361#elif defined GNULIB_POSIXCHECK
362# undef dup2
363# if HAVE_RAW_DECL_DUP2
364_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
365                 "use gnulib module dup2 for portability");
366# endif
367#endif
368
369
370#if @GNULIB_DUP3@
371/* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
372   specified flags.
373   The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
374   and O_TEXT, O_BINARY (defined in "binary-io.h").
375   Close NEWFD first if it is open.
376   Return newfd if successful, otherwise -1 and errno set.
377   See the Linux man page at
378   <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */
379# if @HAVE_DUP3@
380#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
381#   define dup3 rpl_dup3
382#  endif
383_GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
384_GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
385# else
386_GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
387_GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
388# endif
389_GL_CXXALIASWARN (dup3);
390#elif defined GNULIB_POSIXCHECK
391# undef dup3
392# if HAVE_RAW_DECL_DUP3
393_GL_WARN_ON_USE (dup3, "dup3 is unportable - "
394                 "use gnulib module dup3 for portability");
395# endif
396#endif
397
398
399#if @GNULIB_ENVIRON@
400# if !@HAVE_DECL_ENVIRON@
401/* Set of environment variables and values.  An array of strings of the form
402   "VARIABLE=VALUE", terminated with a NULL.  */
403#  if defined __APPLE__ && defined __MACH__
404#   include <crt_externs.h>
405#   define environ (*_NSGetEnviron ())
406#  else
407#   ifdef __cplusplus
408extern "C" {
409#   endif
410extern char **environ;
411#   ifdef __cplusplus
412}
413#   endif
414#  endif
415# endif
416#elif defined GNULIB_POSIXCHECK
417# if HAVE_RAW_DECL_ENVIRON
418_GL_UNISTD_INLINE char ***
419rpl_environ (void)
420{
421  return &environ;
422}
423_GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
424                 "use gnulib module environ for portability");
425#  undef environ
426#  define environ (*rpl_environ ())
427# endif
428#endif
429
430
431#if @GNULIB_EUIDACCESS@
432/* Like access(), except that it uses the effective user id and group id of
433   the current process.  */
434# if !@HAVE_EUIDACCESS@
435_GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
436                                   _GL_ARG_NONNULL ((1)));
437# endif
438_GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
439_GL_CXXALIASWARN (euidaccess);
440# if defined GNULIB_POSIXCHECK
441/* Like access(), this function is a security risk.  */
442_GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
443                 "use the gnulib module faccessat instead");
444# endif
445#elif defined GNULIB_POSIXCHECK
446# undef euidaccess
447# if HAVE_RAW_DECL_EUIDACCESS
448_GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
449                 "use gnulib module euidaccess for portability");
450# endif
451#endif
452
453
454#if @GNULIB_FACCESSAT@
455# if !@HAVE_FACCESSAT@
456_GL_FUNCDECL_SYS (faccessat, int,
457                  (int fd, char const *file, int mode, int flag)
458                  _GL_ARG_NONNULL ((2)));
459# endif
460_GL_CXXALIAS_SYS (faccessat, int,
461                  (int fd, char const *file, int mode, int flag));
462_GL_CXXALIASWARN (faccessat);
463#elif defined GNULIB_POSIXCHECK
464# undef faccessat
465# if HAVE_RAW_DECL_FACCESSAT
466_GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
467                 "use gnulib module faccessat for portability");
468# endif
469#endif
470
471
472#if @GNULIB_FCHDIR@
473/* Change the process' current working directory to the directory on which
474   the given file descriptor is open.
475   Return 0 if successful, otherwise -1 and errno set.
476   See the POSIX:2008 specification
477   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>.  */
478# if ! @HAVE_FCHDIR@
479_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
480
481/* Gnulib internal hooks needed to maintain the fchdir metadata.  */
482_GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
483     _GL_ARG_NONNULL ((2));
484_GL_EXTERN_C void _gl_unregister_fd (int fd);
485_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
486_GL_EXTERN_C const char *_gl_directory_name (int fd);
487
488# else
489#  if !@HAVE_DECL_FCHDIR@
490_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
491#  endif
492# endif
493_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
494_GL_CXXALIASWARN (fchdir);
495#elif defined GNULIB_POSIXCHECK
496# undef fchdir
497# if HAVE_RAW_DECL_FCHDIR
498_GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
499                 "use gnulib module fchdir for portability");
500# endif
501#endif
502
503
504#if @GNULIB_FCHOWNAT@
505# if @REPLACE_FCHOWNAT@
506#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
507#   undef fchownat
508#   define fchownat rpl_fchownat
509#  endif
510_GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
511                                  uid_t owner, gid_t group, int flag)
512                                 _GL_ARG_NONNULL ((2)));
513_GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
514                                  uid_t owner, gid_t group, int flag));
515# else
516#  if !@HAVE_FCHOWNAT@
517_GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
518                                  uid_t owner, gid_t group, int flag)
519                                 _GL_ARG_NONNULL ((2)));
520#  endif
521_GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
522                                  uid_t owner, gid_t group, int flag));
523# endif
524_GL_CXXALIASWARN (fchownat);
525#elif defined GNULIB_POSIXCHECK
526# undef fchownat
527# if HAVE_RAW_DECL_FCHOWNAT
528_GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
529                 "use gnulib module openat for portability");
530# endif
531#endif
532
533
534#if @GNULIB_FDATASYNC@
535/* Synchronize changes to a file.
536   Return 0 if successful, otherwise -1 and errno set.
537   See POSIX:2008 specification
538   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>.  */
539# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
540_GL_FUNCDECL_SYS (fdatasync, int, (int fd));
541# endif
542_GL_CXXALIAS_SYS (fdatasync, int, (int fd));
543_GL_CXXALIASWARN (fdatasync);
544#elif defined GNULIB_POSIXCHECK
545# undef fdatasync
546# if HAVE_RAW_DECL_FDATASYNC
547_GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
548                 "use gnulib module fdatasync for portability");
549# endif
550#endif
551
552
553#if @GNULIB_FSYNC@
554/* Synchronize changes, including metadata, to a file.
555   Return 0 if successful, otherwise -1 and errno set.
556   See POSIX:2008 specification
557   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>.  */
558# if !@HAVE_FSYNC@
559_GL_FUNCDECL_SYS (fsync, int, (int fd));
560# endif
561_GL_CXXALIAS_SYS (fsync, int, (int fd));
562_GL_CXXALIASWARN (fsync);
563#elif defined GNULIB_POSIXCHECK
564# undef fsync
565# if HAVE_RAW_DECL_FSYNC
566_GL_WARN_ON_USE (fsync, "fsync is unportable - "
567                 "use gnulib module fsync for portability");
568# endif
569#endif
570
571
572#if @GNULIB_FTRUNCATE@
573/* Change the size of the file to which FD is opened to become equal to LENGTH.
574   Return 0 if successful, otherwise -1 and errno set.
575   See the POSIX:2008 specification
576   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>.  */
577# if @REPLACE_FTRUNCATE@
578#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
579#   undef ftruncate
580#   define ftruncate rpl_ftruncate
581#  endif
582_GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
583_GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
584# else
585#  if !@HAVE_FTRUNCATE@
586_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
587#  endif
588_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
589# endif
590_GL_CXXALIASWARN (ftruncate);
591#elif defined GNULIB_POSIXCHECK
592# undef ftruncate
593# if HAVE_RAW_DECL_FTRUNCATE
594_GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
595                 "use gnulib module ftruncate for portability");
596# endif
597#endif
598
599
600#if @GNULIB_GETCWD@
601/* Get the name of the current working directory, and put it in SIZE bytes
602   of BUF.
603   Return BUF if successful, or NULL if the directory couldn't be determined
604   or SIZE was too small.
605   See the POSIX:2008 specification
606   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
607   Additionally, the gnulib module 'getcwd' guarantees the following GNU
608   extension: If BUF is NULL, an array is allocated with 'malloc'; the array
609   is SIZE bytes long, unless SIZE == 0, in which case it is as big as
610   necessary.  */
611# if @REPLACE_GETCWD@
612#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
613#   define getcwd rpl_getcwd
614#  endif
615_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
616_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
617# else
618/* Need to cast, because on mingw, the second parameter is
619                                                   int size.  */
620_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
621# endif
622_GL_CXXALIASWARN (getcwd);
623#elif defined GNULIB_POSIXCHECK
624# undef getcwd
625# if HAVE_RAW_DECL_GETCWD
626_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
627                 "use gnulib module getcwd for portability");
628# endif
629#endif
630
631
632#if @GNULIB_GETDOMAINNAME@
633/* Return the NIS domain name of the machine.
634   WARNING! The NIS domain name is unrelated to the fully qualified host name
635            of the machine.  It is also unrelated to email addresses.
636   WARNING! The NIS domain name is usually the empty string or "(none)" when
637            not using NIS.
638
639   Put up to LEN bytes of the NIS domain name into NAME.
640   Null terminate it if the name is shorter than LEN.
641   If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
642   Return 0 if successful, otherwise set errno and return -1.  */
643# if @REPLACE_GETDOMAINNAME@
644#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
645#   undef getdomainname
646#   define getdomainname rpl_getdomainname
647#  endif
648_GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
649                                      _GL_ARG_NONNULL ((1)));
650_GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
651# else
652#  if !@HAVE_DECL_GETDOMAINNAME@
653_GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
654                                      _GL_ARG_NONNULL ((1)));
655#  endif
656_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
657# endif
658_GL_CXXALIASWARN (getdomainname);
659#elif defined GNULIB_POSIXCHECK
660# undef getdomainname
661# if HAVE_RAW_DECL_GETDOMAINNAME
662_GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
663                 "use gnulib module getdomainname for portability");
664# endif
665#endif
666
667
668#if @GNULIB_GETDTABLESIZE@
669/* Return the maximum number of file descriptors in the current process.
670   In POSIX, this is same as sysconf (_SC_OPEN_MAX).  */
671# if @REPLACE_GETDTABLESIZE@
672#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
673#   undef getdtablesize
674#   define getdtablesize rpl_getdtablesize
675#  endif
676_GL_FUNCDECL_RPL (getdtablesize, int, (void));
677_GL_CXXALIAS_RPL (getdtablesize, int, (void));
678# else
679#  if !@HAVE_GETDTABLESIZE@
680_GL_FUNCDECL_SYS (getdtablesize, int, (void));
681#  endif
682_GL_CXXALIAS_SYS (getdtablesize, int, (void));
683# endif
684_GL_CXXALIASWARN (getdtablesize);
685#elif defined GNULIB_POSIXCHECK
686# undef getdtablesize
687# if HAVE_RAW_DECL_GETDTABLESIZE
688_GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
689                 "use gnulib module getdtablesize for portability");
690# endif
691#endif
692
693
694#if @GNULIB_GETGROUPS@
695/* Return the supplemental groups that the current process belongs to.
696   It is unspecified whether the effective group id is in the list.
697   If N is 0, return the group count; otherwise, N describes how many
698   entries are available in GROUPS.  Return -1 and set errno if N is
699   not 0 and not large enough.  Fails with ENOSYS on some systems.  */
700# if @REPLACE_GETGROUPS@
701#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
702#   undef getgroups
703#   define getgroups rpl_getgroups
704#  endif
705_GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
706_GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
707# else
708#  if !@HAVE_GETGROUPS@
709_GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
710#  endif
711_GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
712# endif
713_GL_CXXALIASWARN (getgroups);
714#elif defined GNULIB_POSIXCHECK
715# undef getgroups
716# if HAVE_RAW_DECL_GETGROUPS
717_GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
718                 "use gnulib module getgroups for portability");
719# endif
720#endif
721
722
723#if @GNULIB_GETHOSTNAME@
724/* Return the standard host name of the machine.
725   WARNING! The host name may or may not be fully qualified.
726
727   Put up to LEN bytes of the host name into NAME.
728   Null terminate it if the name is shorter than LEN.
729   If the host name is longer than LEN, set errno = EINVAL and return -1.
730   Return 0 if successful, otherwise set errno and return -1.  */
731# if @UNISTD_H_HAVE_WINSOCK2_H@
732#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
733#   undef gethostname
734#   define gethostname rpl_gethostname
735#  endif
736_GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
737                                    _GL_ARG_NONNULL ((1)));
738_GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
739# else
740#  if !@HAVE_GETHOSTNAME@
741_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
742                                    _GL_ARG_NONNULL ((1)));
743#  endif
744/* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
745   parameter is
746                                                      int len.  */
747_GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
748# endif
749_GL_CXXALIASWARN (gethostname);
750#elif @UNISTD_H_HAVE_WINSOCK2_H@
751# undef gethostname
752# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
753#elif defined GNULIB_POSIXCHECK
754# undef gethostname
755# if HAVE_RAW_DECL_GETHOSTNAME
756_GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
757                 "use gnulib module gethostname for portability");
758# endif
759#endif
760
761
762#if @GNULIB_GETLOGIN@
763/* Returns the user's login name, or NULL if it cannot be found.  Upon error,
764   returns NULL with errno set.
765
766   See <http://www.opengroup.org/susv3xsh/getlogin.html>.
767
768   Most programs don't need to use this function, because the information is
769   available through environment variables:
770     ${LOGNAME-$USER}        on Unix platforms,
771     $USERNAME               on native Windows platforms.
772 */
773# if !@HAVE_GETLOGIN@
774_GL_FUNCDECL_SYS (getlogin, char *, (void));
775# endif
776_GL_CXXALIAS_SYS (getlogin, char *, (void));
777_GL_CXXALIASWARN (getlogin);
778#elif defined GNULIB_POSIXCHECK
779# undef getlogin
780# if HAVE_RAW_DECL_GETLOGIN
781_GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
782                 "use gnulib module getlogin for portability");
783# endif
784#endif
785
786
787#if @GNULIB_GETLOGIN_R@
788/* Copies the user's login name to NAME.
789   The array pointed to by NAME has room for SIZE bytes.
790
791   Returns 0 if successful.  Upon error, an error number is returned, or -1 in
792   the case that the login name cannot be found but no specific error is
793   provided (this case is hopefully rare but is left open by the POSIX spec).
794
795   See <http://www.opengroup.org/susv3xsh/getlogin.html>.
796
797   Most programs don't need to use this function, because the information is
798   available through environment variables:
799     ${LOGNAME-$USER}        on Unix platforms,
800     $USERNAME               on native Windows platforms.
801 */
802# if @REPLACE_GETLOGIN_R@
803#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
804#   define getlogin_r rpl_getlogin_r
805#  endif
806_GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
807                                   _GL_ARG_NONNULL ((1)));
808_GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
809# else
810#  if !@HAVE_DECL_GETLOGIN_R@
811_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
812                                   _GL_ARG_NONNULL ((1)));
813#  endif
814/* Need to cast, because on Solaris 10 systems, the second argument is
815                                                     int size.  */
816_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
817# endif
818_GL_CXXALIASWARN (getlogin_r);
819#elif defined GNULIB_POSIXCHECK
820# undef getlogin_r
821# if HAVE_RAW_DECL_GETLOGIN_R
822_GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
823                 "use gnulib module getlogin_r for portability");
824# endif
825#endif
826
827
828#if @GNULIB_GETPAGESIZE@
829# if @REPLACE_GETPAGESIZE@
830#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
831#   define getpagesize rpl_getpagesize
832#  endif
833_GL_FUNCDECL_RPL (getpagesize, int, (void));
834_GL_CXXALIAS_RPL (getpagesize, int, (void));
835# else
836#  if !@HAVE_GETPAGESIZE@
837#   if !defined getpagesize
838/* This is for POSIX systems.  */
839#    if !defined _gl_getpagesize && defined _SC_PAGESIZE
840#     if ! (defined __VMS && __VMS_VER < 70000000)
841#      define _gl_getpagesize() sysconf (_SC_PAGESIZE)
842#     endif
843#    endif
844/* This is for older VMS.  */
845#    if !defined _gl_getpagesize && defined __VMS
846#     ifdef __ALPHA
847#      define _gl_getpagesize() 8192
848#     else
849#      define _gl_getpagesize() 512
850#     endif
851#    endif
852/* This is for BeOS.  */
853#    if !defined _gl_getpagesize && @HAVE_OS_H@
854#     include <OS.h>
855#     if defined B_PAGE_SIZE
856#      define _gl_getpagesize() B_PAGE_SIZE
857#     endif
858#    endif
859/* This is for AmigaOS4.0.  */
860#    if !defined _gl_getpagesize && defined __amigaos4__
861#     define _gl_getpagesize() 2048
862#    endif
863/* This is for older Unix systems.  */
864#    if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
865#     include <sys/param.h>
866#     ifdef EXEC_PAGESIZE
867#      define _gl_getpagesize() EXEC_PAGESIZE
868#     else
869#      ifdef NBPG
870#       ifndef CLSIZE
871#        define CLSIZE 1
872#       endif
873#       define _gl_getpagesize() (NBPG * CLSIZE)
874#      else
875#       ifdef NBPC
876#        define _gl_getpagesize() NBPC
877#       endif
878#      endif
879#     endif
880#    endif
881#    if !(defined __cplusplus && defined GNULIB_NAMESPACE)
882#     define getpagesize() _gl_getpagesize ()
883#    else
884#     if !GNULIB_defined_getpagesize_function
885_GL_UNISTD_INLINE int
886getpagesize ()
887{
888  return _gl_getpagesize ();
889}
890#      define GNULIB_defined_getpagesize_function 1
891#     endif
892#    endif
893#   endif
894#  endif
895/* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t.  */
896_GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
897# endif
898# if @HAVE_DECL_GETPAGESIZE@
899_GL_CXXALIASWARN (getpagesize);
900# endif
901#elif defined GNULIB_POSIXCHECK
902# undef getpagesize
903# if HAVE_RAW_DECL_GETPAGESIZE
904_GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
905                 "use gnulib module getpagesize for portability");
906# endif
907#endif
908
909
910#if @GNULIB_GETUSERSHELL@
911/* Return the next valid login shell on the system, or NULL when the end of
912   the list has been reached.  */
913# if !@HAVE_DECL_GETUSERSHELL@
914_GL_FUNCDECL_SYS (getusershell, char *, (void));
915# endif
916_GL_CXXALIAS_SYS (getusershell, char *, (void));
917_GL_CXXALIASWARN (getusershell);
918#elif defined GNULIB_POSIXCHECK
919# undef getusershell
920# if HAVE_RAW_DECL_GETUSERSHELL
921_GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
922                 "use gnulib module getusershell for portability");
923# endif
924#endif
925
926#if @GNULIB_GETUSERSHELL@
927/* Rewind to pointer that is advanced at each getusershell() call.  */
928# if !@HAVE_DECL_GETUSERSHELL@
929_GL_FUNCDECL_SYS (setusershell, void, (void));
930# endif
931_GL_CXXALIAS_SYS (setusershell, void, (void));
932_GL_CXXALIASWARN (setusershell);
933#elif defined GNULIB_POSIXCHECK
934# undef setusershell
935# if HAVE_RAW_DECL_SETUSERSHELL
936_GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
937                 "use gnulib module getusershell for portability");
938# endif
939#endif
940
941#if @GNULIB_GETUSERSHELL@
942/* Free the pointer that is advanced at each getusershell() call and
943   associated resources.  */
944# if !@HAVE_DECL_GETUSERSHELL@
945_GL_FUNCDECL_SYS (endusershell, void, (void));
946# endif
947_GL_CXXALIAS_SYS (endusershell, void, (void));
948_GL_CXXALIASWARN (endusershell);
949#elif defined GNULIB_POSIXCHECK
950# undef endusershell
951# if HAVE_RAW_DECL_ENDUSERSHELL
952_GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
953                 "use gnulib module getusershell for portability");
954# endif
955#endif
956
957
958#if @GNULIB_GROUP_MEMBER@
959/* Determine whether group id is in calling user's group list.  */
960# if !@HAVE_GROUP_MEMBER@
961_GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
962# endif
963_GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
964_GL_CXXALIASWARN (group_member);
965#elif defined GNULIB_POSIXCHECK
966# undef group_member
967# if HAVE_RAW_DECL_GROUP_MEMBER
968_GL_WARN_ON_USE (group_member, "group_member is unportable - "
969                 "use gnulib module group-member for portability");
970# endif
971#endif
972
973
974#if @GNULIB_ISATTY@
975# if @REPLACE_ISATTY@
976#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
977#   undef isatty
978#   define isatty rpl_isatty
979#  endif
980_GL_FUNCDECL_RPL (isatty, int, (int fd));
981_GL_CXXALIAS_RPL (isatty, int, (int fd));
982# else
983_GL_CXXALIAS_SYS (isatty, int, (int fd));
984# endif
985_GL_CXXALIASWARN (isatty);
986#elif defined GNULIB_POSIXCHECK
987# undef isatty
988# if HAVE_RAW_DECL_ISATTY
989_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
990                 "use gnulib module isatty for portability");
991# endif
992#endif
993
994
995#if @GNULIB_LCHOWN@
996/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
997   to GID (if GID is not -1).  Do not follow symbolic links.
998   Return 0 if successful, otherwise -1 and errno set.
999   See the POSIX:2008 specification
1000   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>.  */
1001# if @REPLACE_LCHOWN@
1002#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1003#   undef lchown
1004#   define lchown rpl_lchown
1005#  endif
1006_GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
1007                               _GL_ARG_NONNULL ((1)));
1008_GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
1009# else
1010#  if !@HAVE_LCHOWN@
1011_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
1012                               _GL_ARG_NONNULL ((1)));
1013#  endif
1014_GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
1015# endif
1016_GL_CXXALIASWARN (lchown);
1017#elif defined GNULIB_POSIXCHECK
1018# undef lchown
1019# if HAVE_RAW_DECL_LCHOWN
1020_GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1021                 "use gnulib module lchown for portability");
1022# endif
1023#endif
1024
1025
1026#if @GNULIB_LINK@
1027/* Create a new hard link for an existing file.
1028   Return 0 if successful, otherwise -1 and errno set.
1029   See POSIX:2008 specification
1030   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>.  */
1031# if @REPLACE_LINK@
1032#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1033#   define link rpl_link
1034#  endif
1035_GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
1036                             _GL_ARG_NONNULL ((1, 2)));
1037_GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
1038# else
1039#  if !@HAVE_LINK@
1040_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
1041                             _GL_ARG_NONNULL ((1, 2)));
1042#  endif
1043_GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
1044# endif
1045_GL_CXXALIASWARN (link);
1046#elif defined GNULIB_POSIXCHECK
1047# undef link
1048# if HAVE_RAW_DECL_LINK
1049_GL_WARN_ON_USE (link, "link is unportable - "
1050                 "use gnulib module link for portability");
1051# endif
1052#endif
1053
1054
1055#if @GNULIB_LINKAT@
1056/* Create a new hard link for an existing file, relative to two
1057   directories.  FLAG controls whether symlinks are followed.
1058   Return 0 if successful, otherwise -1 and errno set.  */
1059# if @REPLACE_LINKAT@
1060#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1061#   undef linkat
1062#   define linkat rpl_linkat
1063#  endif
1064_GL_FUNCDECL_RPL (linkat, int,
1065                  (int fd1, const char *path1, int fd2, const char *path2,
1066                   int flag)
1067                  _GL_ARG_NONNULL ((2, 4)));
1068_GL_CXXALIAS_RPL (linkat, int,
1069                  (int fd1, const char *path1, int fd2, const char *path2,
1070                   int flag));
1071# else
1072#  if !@HAVE_LINKAT@
1073_GL_FUNCDECL_SYS (linkat, int,
1074                  (int fd1, const char *path1, int fd2, const char *path2,
1075                   int flag)
1076                  _GL_ARG_NONNULL ((2, 4)));
1077#  endif
1078_GL_CXXALIAS_SYS (linkat, int,
1079                  (int fd1, const char *path1, int fd2, const char *path2,
1080                   int flag));
1081# endif
1082_GL_CXXALIASWARN (linkat);
1083#elif defined GNULIB_POSIXCHECK
1084# undef linkat
1085# if HAVE_RAW_DECL_LINKAT
1086_GL_WARN_ON_USE (linkat, "linkat is unportable - "
1087                 "use gnulib module linkat for portability");
1088# endif
1089#endif
1090
1091
1092#if @GNULIB_LSEEK@
1093/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1094   Return the new offset if successful, otherwise -1 and errno set.
1095   See the POSIX:2008 specification
1096   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>.  */
1097# if @REPLACE_LSEEK@
1098#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1099#   define lseek rpl_lseek
1100#  endif
1101_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1102_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1103# else
1104_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1105# endif
1106_GL_CXXALIASWARN (lseek);
1107#elif defined GNULIB_POSIXCHECK
1108# undef lseek
1109# if HAVE_RAW_DECL_LSEEK
1110_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1111                 "systems - use gnulib module lseek for portability");
1112# endif
1113#endif
1114
1115
1116#if @GNULIB_PIPE@
1117/* Create a pipe, defaulting to O_BINARY mode.
1118   Store the read-end as fd[0] and the write-end as fd[1].
1119   Return 0 upon success, or -1 with errno set upon failure.  */
1120# if !@HAVE_PIPE@
1121_GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1122# endif
1123_GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1124_GL_CXXALIASWARN (pipe);
1125#elif defined GNULIB_POSIXCHECK
1126# undef pipe
1127# if HAVE_RAW_DECL_PIPE
1128_GL_WARN_ON_USE (pipe, "pipe is unportable - "
1129                 "use gnulib module pipe-posix for portability");
1130# endif
1131#endif
1132
1133
1134#if @GNULIB_PIPE2@
1135/* Create a pipe, applying the given flags when opening the read-end of the
1136   pipe and the write-end of the pipe.
1137   The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1138   and O_TEXT, O_BINARY (defined in "binary-io.h").
1139   Store the read-end as fd[0] and the write-end as fd[1].
1140   Return 0 upon success, or -1 with errno set upon failure.
1141   See also the Linux man page at
1142   <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
1143# if @HAVE_PIPE2@
1144#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1145#   define pipe2 rpl_pipe2
1146#  endif
1147_GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1148_GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1149# else
1150_GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1151_GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1152# endif
1153_GL_CXXALIASWARN (pipe2);
1154#elif defined GNULIB_POSIXCHECK
1155# undef pipe2
1156# if HAVE_RAW_DECL_PIPE2
1157_GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1158                 "use gnulib module pipe2 for portability");
1159# endif
1160#endif
1161
1162
1163#if @GNULIB_PREAD@
1164/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1165   Return the number of bytes placed into BUF if successful, otherwise
1166   set errno and return -1.  0 indicates EOF.
1167   See the POSIX:2008 specification
1168   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>.  */
1169# if @REPLACE_PREAD@
1170#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1171#   undef pread
1172#   define pread rpl_pread
1173#  endif
1174_GL_FUNCDECL_RPL (pread, ssize_t,
1175                  (int fd, void *buf, size_t bufsize, off_t offset)
1176                  _GL_ARG_NONNULL ((2)));
1177_GL_CXXALIAS_RPL (pread, ssize_t,
1178                  (int fd, void *buf, size_t bufsize, off_t offset));
1179# else
1180#  if !@HAVE_PREAD@
1181_GL_FUNCDECL_SYS (pread, ssize_t,
1182                  (int fd, void *buf, size_t bufsize, off_t offset)
1183                  _GL_ARG_NONNULL ((2)));
1184#  endif
1185_GL_CXXALIAS_SYS (pread, ssize_t,
1186                  (int fd, void *buf, size_t bufsize, off_t offset));
1187# endif
1188_GL_CXXALIASWARN (pread);
1189#elif defined GNULIB_POSIXCHECK
1190# undef pread
1191# if HAVE_RAW_DECL_PREAD
1192_GL_WARN_ON_USE (pread, "pread is unportable - "
1193                 "use gnulib module pread for portability");
1194# endif
1195#endif
1196
1197
1198#if @GNULIB_PWRITE@
1199/* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1200   Return the number of bytes written if successful, otherwise
1201   set errno and return -1.  0 indicates nothing written.  See the
1202   POSIX:2008 specification
1203   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>.  */
1204# if @REPLACE_PWRITE@
1205#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1206#   undef pwrite
1207#   define pwrite rpl_pwrite
1208#  endif
1209_GL_FUNCDECL_RPL (pwrite, ssize_t,
1210                  (int fd, const void *buf, size_t bufsize, off_t offset)
1211                  _GL_ARG_NONNULL ((2)));
1212_GL_CXXALIAS_RPL (pwrite, ssize_t,
1213                  (int fd, const void *buf, size_t bufsize, off_t offset));
1214# else
1215#  if !@HAVE_PWRITE@
1216_GL_FUNCDECL_SYS (pwrite, ssize_t,
1217                  (int fd, const void *buf, size_t bufsize, off_t offset)
1218                  _GL_ARG_NONNULL ((2)));
1219#  endif
1220_GL_CXXALIAS_SYS (pwrite, ssize_t,
1221                  (int fd, const void *buf, size_t bufsize, off_t offset));
1222# endif
1223_GL_CXXALIASWARN (pwrite);
1224#elif defined GNULIB_POSIXCHECK
1225# undef pwrite
1226# if HAVE_RAW_DECL_PWRITE
1227_GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1228                 "use gnulib module pwrite for portability");
1229# endif
1230#endif
1231
1232
1233#if @GNULIB_READ@
1234/* Read up to COUNT bytes from file descriptor FD into the buffer starting
1235   at BUF.  See the POSIX:2008 specification
1236   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>.  */
1237# if @REPLACE_READ@
1238#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1239#   undef read
1240#   define read rpl_read
1241#  endif
1242_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1243                                 _GL_ARG_NONNULL ((2)));
1244_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1245# else
1246/* Need to cast, because on mingw, the third parameter is
1247                                                          unsigned int count
1248   and the return type is 'int'.  */
1249_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1250# endif
1251_GL_CXXALIASWARN (read);
1252#endif
1253
1254
1255#if @GNULIB_READLINK@
1256/* Read the contents of the symbolic link FILE and place the first BUFSIZE
1257   bytes of it into BUF.  Return the number of bytes placed into BUF if
1258   successful, otherwise -1 and errno set.
1259   See the POSIX:2008 specification
1260   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>.  */
1261# if @REPLACE_READLINK@
1262#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1263#   define readlink rpl_readlink
1264#  endif
1265_GL_FUNCDECL_RPL (readlink, ssize_t,
1266                  (const char *file, char *buf, size_t bufsize)
1267                  _GL_ARG_NONNULL ((1, 2)));
1268_GL_CXXALIAS_RPL (readlink, ssize_t,
1269                  (const char *file, char *buf, size_t bufsize));
1270# else
1271#  if !@HAVE_READLINK@
1272_GL_FUNCDECL_SYS (readlink, ssize_t,
1273                  (const char *file, char *buf, size_t bufsize)
1274                  _GL_ARG_NONNULL ((1, 2)));
1275#  endif
1276_GL_CXXALIAS_SYS (readlink, ssize_t,
1277                  (const char *file, char *buf, size_t bufsize));
1278# endif
1279_GL_CXXALIASWARN (readlink);
1280#elif defined GNULIB_POSIXCHECK
1281# undef readlink
1282# if HAVE_RAW_DECL_READLINK
1283_GL_WARN_ON_USE (readlink, "readlink is unportable - "
1284                 "use gnulib module readlink for portability");
1285# endif
1286#endif
1287
1288
1289#if @GNULIB_READLINKAT@
1290# if !@HAVE_READLINKAT@
1291_GL_FUNCDECL_SYS (readlinkat, ssize_t,
1292                  (int fd, char const *file, char *buf, size_t len)
1293                  _GL_ARG_NONNULL ((2, 3)));
1294# endif
1295_GL_CXXALIAS_SYS (readlinkat, ssize_t,
1296                  (int fd, char const *file, char *buf, size_t len));
1297_GL_CXXALIASWARN (readlinkat);
1298#elif defined GNULIB_POSIXCHECK
1299# undef readlinkat
1300# if HAVE_RAW_DECL_READLINKAT
1301_GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1302                 "use gnulib module readlinkat for portability");
1303# endif
1304#endif
1305
1306
1307#if @GNULIB_RMDIR@
1308/* Remove the directory DIR.  */
1309# if @REPLACE_RMDIR@
1310#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1311#   define rmdir rpl_rmdir
1312#  endif
1313_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1314_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1315# else
1316_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1317# endif
1318_GL_CXXALIASWARN (rmdir);
1319#elif defined GNULIB_POSIXCHECK
1320# undef rmdir
1321# if HAVE_RAW_DECL_RMDIR
1322_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1323                 "use gnulib module rmdir for portability");
1324# endif
1325#endif
1326
1327
1328#if @GNULIB_SETHOSTNAME@
1329/* Set the host name of the machine.
1330   The host name may or may not be fully qualified.
1331
1332   Put LEN bytes of NAME into the host name.
1333   Return 0 if successful, otherwise, set errno and return -1.
1334
1335   Platforms with no ability to set the hostname return -1 and set
1336   errno = ENOSYS.  */
1337# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1338_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
1339                                    _GL_ARG_NONNULL ((1)));
1340# endif
1341/* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1342   and FreeBSD 6.4 the second parameter is int.  On Solaris 11
1343   2011-10, the first parameter is not const.  */
1344_GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
1345_GL_CXXALIASWARN (sethostname);
1346#elif defined GNULIB_POSIXCHECK
1347# undef sethostname
1348# if HAVE_RAW_DECL_SETHOSTNAME
1349_GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1350                 "use gnulib module sethostname for portability");
1351# endif
1352#endif
1353
1354
1355#if @GNULIB_SLEEP@
1356/* Pause the execution of the current thread for N seconds.
1357   Returns the number of seconds left to sleep.
1358   See the POSIX:2008 specification
1359   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>.  */
1360# if @REPLACE_SLEEP@
1361#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1362#   undef sleep
1363#   define sleep rpl_sleep
1364#  endif
1365_GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1366_GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1367# else
1368#  if !@HAVE_SLEEP@
1369_GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1370#  endif
1371_GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1372# endif
1373_GL_CXXALIASWARN (sleep);
1374#elif defined GNULIB_POSIXCHECK
1375# undef sleep
1376# if HAVE_RAW_DECL_SLEEP
1377_GL_WARN_ON_USE (sleep, "sleep is unportable - "
1378                 "use gnulib module sleep for portability");
1379# endif
1380#endif
1381
1382
1383#if @GNULIB_SYMLINK@
1384# if @REPLACE_SYMLINK@
1385#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1386#   undef symlink
1387#   define symlink rpl_symlink
1388#  endif
1389_GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1390                                _GL_ARG_NONNULL ((1, 2)));
1391_GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1392# else
1393#  if !@HAVE_SYMLINK@
1394_GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1395                                _GL_ARG_NONNULL ((1, 2)));
1396#  endif
1397_GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1398# endif
1399_GL_CXXALIASWARN (symlink);
1400#elif defined GNULIB_POSIXCHECK
1401# undef symlink
1402# if HAVE_RAW_DECL_SYMLINK
1403_GL_WARN_ON_USE (symlink, "symlink is not portable - "
1404                 "use gnulib module symlink for portability");
1405# endif
1406#endif
1407
1408
1409#if @GNULIB_SYMLINKAT@
1410# if !@HAVE_SYMLINKAT@
1411_GL_FUNCDECL_SYS (symlinkat, int,
1412                  (char const *contents, int fd, char const *file)
1413                  _GL_ARG_NONNULL ((1, 3)));
1414# endif
1415_GL_CXXALIAS_SYS (symlinkat, int,
1416                  (char const *contents, int fd, char const *file));
1417_GL_CXXALIASWARN (symlinkat);
1418#elif defined GNULIB_POSIXCHECK
1419# undef symlinkat
1420# if HAVE_RAW_DECL_SYMLINKAT
1421_GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1422                 "use gnulib module symlinkat for portability");
1423# endif
1424#endif
1425
1426
1427#if @GNULIB_TTYNAME_R@
1428/* Store at most BUFLEN characters of the pathname of the terminal FD is
1429   open on in BUF.  Return 0 on success, otherwise an error number.  */
1430# if @REPLACE_TTYNAME_R@
1431#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1432#   undef ttyname_r
1433#   define ttyname_r rpl_ttyname_r
1434#  endif
1435_GL_FUNCDECL_RPL (ttyname_r, int,
1436                  (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1437_GL_CXXALIAS_RPL (ttyname_r, int,
1438                  (int fd, char *buf, size_t buflen));
1439# else
1440#  if !@HAVE_DECL_TTYNAME_R@
1441_GL_FUNCDECL_SYS (ttyname_r, int,
1442                  (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1443#  endif
1444_GL_CXXALIAS_SYS (ttyname_r, int,
1445                  (int fd, char *buf, size_t buflen));
1446# endif
1447_GL_CXXALIASWARN (ttyname_r);
1448#elif defined GNULIB_POSIXCHECK
1449# undef ttyname_r
1450# if HAVE_RAW_DECL_TTYNAME_R
1451_GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1452                 "use gnulib module ttyname_r for portability");
1453# endif
1454#endif
1455
1456
1457#if @GNULIB_UNLINK@
1458# if @REPLACE_UNLINK@
1459#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1460#   undef unlink
1461#   define unlink rpl_unlink
1462#  endif
1463_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1464_GL_CXXALIAS_RPL (unlink, int, (char const *file));
1465# else
1466_GL_CXXALIAS_SYS (unlink, int, (char const *file));
1467# endif
1468_GL_CXXALIASWARN (unlink);
1469#elif defined GNULIB_POSIXCHECK
1470# undef unlink
1471# if HAVE_RAW_DECL_UNLINK
1472_GL_WARN_ON_USE (unlink, "unlink is not portable - "
1473                 "use gnulib module unlink for portability");
1474# endif
1475#endif
1476
1477
1478#if @GNULIB_UNLINKAT@
1479# if @REPLACE_UNLINKAT@
1480#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1481#   undef unlinkat
1482#   define unlinkat rpl_unlinkat
1483#  endif
1484_GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1485                                 _GL_ARG_NONNULL ((2)));
1486_GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1487# else
1488#  if !@HAVE_UNLINKAT@
1489_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1490                                 _GL_ARG_NONNULL ((2)));
1491#  endif
1492_GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1493# endif
1494_GL_CXXALIASWARN (unlinkat);
1495#elif defined GNULIB_POSIXCHECK
1496# undef unlinkat
1497# if HAVE_RAW_DECL_UNLINKAT
1498_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1499                 "use gnulib module openat for portability");
1500# endif
1501#endif
1502
1503
1504#if @GNULIB_USLEEP@
1505/* Pause the execution of the current thread for N microseconds.
1506   Returns 0 on completion, or -1 on range error.
1507   See the POSIX:2001 specification
1508   <http://www.opengroup.org/susv3xsh/usleep.html>.  */
1509# if @REPLACE_USLEEP@
1510#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1511#   undef usleep
1512#   define usleep rpl_usleep
1513#  endif
1514_GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1515_GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1516# else
1517#  if !@HAVE_USLEEP@
1518_GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1519#  endif
1520_GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1521# endif
1522_GL_CXXALIASWARN (usleep);
1523#elif defined GNULIB_POSIXCHECK
1524# undef usleep
1525# if HAVE_RAW_DECL_USLEEP
1526_GL_WARN_ON_USE (usleep, "usleep is unportable - "
1527                 "use gnulib module usleep for portability");
1528# endif
1529#endif
1530
1531
1532#if @GNULIB_WRITE@
1533/* Write up to COUNT bytes starting at BUF to file descriptor FD.
1534   See the POSIX:2008 specification
1535   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>.  */
1536# if @REPLACE_WRITE@
1537#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1538#   undef write
1539#   define write rpl_write
1540#  endif
1541_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1542                                  _GL_ARG_NONNULL ((2)));
1543_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1544# else
1545/* Need to cast, because on mingw, the third parameter is
1546                                                             unsigned int count
1547   and the return type is 'int'.  */
1548_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1549# endif
1550_GL_CXXALIASWARN (write);
1551#endif
1552
1553_GL_INLINE_HEADER_END
1554
1555#endif /* _@GUARD_PREFIX@_UNISTD_H */
1556#endif /* _GL_INCLUDING_UNISTD_H */
1557#endif /* _@GUARD_PREFIX@_UNISTD_H */
1558