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