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