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