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