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