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