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