getlogin_r: Work around portability problem on OSF/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 # else
439 #  if !@HAVE_DECL_FCHDIR@
440 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
441 #  endif
442 # endif
443 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
444 _GL_CXXALIASWARN (fchdir);
445 #elif defined GNULIB_POSIXCHECK
446 # undef fchdir
447 # if HAVE_RAW_DECL_FCHDIR
448 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
449                  "use gnulib module fchdir for portability");
450 # endif
451 #endif
452
453
454 #if @GNULIB_FCHOWNAT@
455 # if @REPLACE_FCHOWNAT@
456 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
457 #   undef fchownat
458 #   define fchownat rpl_fchownat
459 #  endif
460 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
461                                   uid_t owner, gid_t group, int flag)
462                                  _GL_ARG_NONNULL ((2)));
463 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
464                                   uid_t owner, gid_t group, int flag));
465 # else
466 #  if !@HAVE_FCHOWNAT@
467 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
468                                   uid_t owner, gid_t group, int flag)
469                                  _GL_ARG_NONNULL ((2)));
470 #  endif
471 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
472                                   uid_t owner, gid_t group, int flag));
473 # endif
474 _GL_CXXALIASWARN (fchownat);
475 #elif defined GNULIB_POSIXCHECK
476 # undef fchownat
477 # if HAVE_RAW_DECL_FCHOWNAT
478 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
479                  "use gnulib module openat for portability");
480 # endif
481 #endif
482
483
484 #if @GNULIB_FSYNC@
485 /* Synchronize changes to a file.
486    Return 0 if successful, otherwise -1 and errno set.
487    See POSIX:2001 specification
488    <http://www.opengroup.org/susv3xsh/fsync.html>.  */
489 # if !@HAVE_FSYNC@
490 _GL_FUNCDECL_SYS (fsync, int, (int fd));
491 # endif
492 _GL_CXXALIAS_SYS (fsync, int, (int fd));
493 _GL_CXXALIASWARN (fsync);
494 #elif defined GNULIB_POSIXCHECK
495 # undef fsync
496 # if HAVE_RAW_DECL_FSYNC
497 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
498                  "use gnulib module fsync for portability");
499 # endif
500 #endif
501
502
503 #if @GNULIB_FTRUNCATE@
504 /* Change the size of the file to which FD is opened to become equal to LENGTH.
505    Return 0 if successful, otherwise -1 and errno set.
506    See the POSIX:2001 specification
507    <http://www.opengroup.org/susv3xsh/ftruncate.html>.  */
508 # if !@HAVE_FTRUNCATE@
509 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
510 # endif
511 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
512 _GL_CXXALIASWARN (ftruncate);
513 #elif defined GNULIB_POSIXCHECK
514 # undef ftruncate
515 # if HAVE_RAW_DECL_FTRUNCATE
516 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
517                  "use gnulib module ftruncate for portability");
518 # endif
519 #endif
520
521
522 #if @GNULIB_GETCWD@
523 /* Get the name of the current working directory, and put it in SIZE bytes
524    of BUF.
525    Return BUF if successful, or NULL if the directory couldn't be determined
526    or SIZE was too small.
527    See the POSIX:2001 specification
528    <http://www.opengroup.org/susv3xsh/getcwd.html>.
529    Additionally, the gnulib module 'getcwd' guarantees the following GNU
530    extension: If BUF is NULL, an array is allocated with 'malloc'; the array
531    is SIZE bytes long, unless SIZE == 0, in which case it is as big as
532    necessary.  */
533 # if @REPLACE_GETCWD@
534 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
535 #   define getcwd rpl_getcwd
536 #  endif
537 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
538 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
539 # else
540 /* Need to cast, because on mingw, the second parameter is
541                                                    int size.  */
542 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
543 # endif
544 _GL_CXXALIASWARN (getcwd);
545 #elif defined GNULIB_POSIXCHECK
546 # undef getcwd
547 # if HAVE_RAW_DECL_GETCWD
548 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
549                  "use gnulib module getcwd for portability");
550 # endif
551 #endif
552
553
554 #if @GNULIB_GETDOMAINNAME@
555 /* Return the NIS domain name of the machine.
556    WARNING! The NIS domain name is unrelated to the fully qualified host name
557             of the machine.  It is also unrelated to email addresses.
558    WARNING! The NIS domain name is usually the empty string or "(none)" when
559             not using NIS.
560
561    Put up to LEN bytes of the NIS domain name into NAME.
562    Null terminate it if the name is shorter than LEN.
563    If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
564    Return 0 if successful, otherwise set errno and return -1.  */
565 # if @REPLACE_GETDOMAINNAME@
566 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
567 #   undef getdomainname
568 #   define getdomainname rpl_getdomainname
569 #  endif
570 _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
571                                       _GL_ARG_NONNULL ((1)));
572 _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
573 # else
574 #  if !@HAVE_DECL_GETDOMAINNAME@
575 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
576                                       _GL_ARG_NONNULL ((1)));
577 #  endif
578 _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
579 # endif
580 _GL_CXXALIASWARN (getdomainname);
581 #elif defined GNULIB_POSIXCHECK
582 # undef getdomainname
583 # if HAVE_RAW_DECL_GETDOMAINNAME
584 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
585                  "use gnulib module getdomainname for portability");
586 # endif
587 #endif
588
589
590 #if @GNULIB_GETDTABLESIZE@
591 /* Return the maximum number of file descriptors in the current process.
592    In POSIX, this is same as sysconf (_SC_OPEN_MAX).  */
593 # if !@HAVE_GETDTABLESIZE@
594 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
595 # endif
596 _GL_CXXALIAS_SYS (getdtablesize, int, (void));
597 _GL_CXXALIASWARN (getdtablesize);
598 #elif defined GNULIB_POSIXCHECK
599 # undef getdtablesize
600 # if HAVE_RAW_DECL_GETDTABLESIZE
601 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
602                  "use gnulib module getdtablesize for portability");
603 # endif
604 #endif
605
606
607 #if @GNULIB_GETGROUPS@
608 /* Return the supplemental groups that the current process belongs to.
609    It is unspecified whether the effective group id is in the list.
610    If N is 0, return the group count; otherwise, N describes how many
611    entries are available in GROUPS.  Return -1 and set errno if N is
612    not 0 and not large enough.  Fails with ENOSYS on some systems.  */
613 # if @REPLACE_GETGROUPS@
614 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
615 #   undef getgroups
616 #   define getgroups rpl_getgroups
617 #  endif
618 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
619 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
620 # else
621 #  if !@HAVE_GETGROUPS@
622 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
623 #  endif
624 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
625 # endif
626 _GL_CXXALIASWARN (getgroups);
627 #elif defined GNULIB_POSIXCHECK
628 # undef getgroups
629 # if HAVE_RAW_DECL_GETGROUPS
630 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
631                  "use gnulib module getgroups for portability");
632 # endif
633 #endif
634
635
636 #if @GNULIB_GETHOSTNAME@
637 /* Return the standard host name of the machine.
638    WARNING! The host name may or may not be fully qualified.
639
640    Put up to LEN bytes of the host name into NAME.
641    Null terminate it if the name is shorter than LEN.
642    If the host name is longer than LEN, set errno = EINVAL and return -1.
643    Return 0 if successful, otherwise set errno and return -1.  */
644 # if @UNISTD_H_HAVE_WINSOCK2_H@
645 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
646 #   undef gethostname
647 #   define gethostname rpl_gethostname
648 #  endif
649 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
650                                     _GL_ARG_NONNULL ((1)));
651 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
652 # else
653 #  if !@HAVE_GETHOSTNAME@
654 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
655                                     _GL_ARG_NONNULL ((1)));
656 #  endif
657 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
658    parameter is
659                                                       int len.  */
660 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
661 # endif
662 _GL_CXXALIASWARN (gethostname);
663 #elif @UNISTD_H_HAVE_WINSOCK2_H@
664 # undef gethostname
665 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
666 #elif defined GNULIB_POSIXCHECK
667 # undef gethostname
668 # if HAVE_RAW_DECL_GETHOSTNAME
669 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
670                  "use gnulib module gethostname for portability");
671 # endif
672 #endif
673
674
675 #if @GNULIB_GETLOGIN@
676 /* Returns the user's login name, or NULL if it cannot be found.  Upon error,
677    returns NULL with errno set.
678
679    See <http://www.opengroup.org/susv3xsh/getlogin.html>.
680
681    Most programs don't need to use this function, because the information is
682    available through environment variables:
683      ${LOGNAME-$USER}        on Unix platforms,
684      $USERNAME               on native Windows platforms.
685  */
686 # if !@HAVE_GETLOGIN@
687 _GL_FUNCDECL_SYS (getlogin, char *, (void));
688 # endif
689 _GL_CXXALIAS_SYS (getlogin, char *, (void));
690 _GL_CXXALIASWARN (getlogin);
691 #elif defined GNULIB_POSIXCHECK
692 # undef getlogin
693 # if HAVE_RAW_DECL_GETLOGIN
694 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
695                  "use gnulib module getlogin for portability");
696 # endif
697 #endif
698
699
700 #if @GNULIB_GETLOGIN_R@
701 /* Copies the user's login name to NAME.
702    The array pointed to by NAME has room for SIZE bytes.
703
704    Returns 0 if successful.  Upon error, an error number is returned, or -1 in
705    the case that the login name cannot be found but no specific error is
706    provided (this case is hopefully rare but is left open by the POSIX spec).
707
708    See <http://www.opengroup.org/susv3xsh/getlogin.html>.
709
710    Most programs don't need to use this function, because the information is
711    available through environment variables:
712      ${LOGNAME-$USER}        on Unix platforms,
713      $USERNAME               on native Windows platforms.
714  */
715 # if @REPLACE_GETLOGIN_R@
716 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
717 #   define getlogin_r rpl_getlogin_r
718 #  endif
719 _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
720                                    _GL_ARG_NONNULL ((1)));
721 _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
722 # else
723 #  if !@HAVE_DECL_GETLOGIN_R@
724 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
725                                    _GL_ARG_NONNULL ((1)));
726 #  endif
727 /* Need to cast, because on Solaris 10 systems, the second argument is
728                                                      int size.  */
729 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
730 # endif
731 _GL_CXXALIASWARN (getlogin_r);
732 #elif defined GNULIB_POSIXCHECK
733 # undef getlogin_r
734 # if HAVE_RAW_DECL_GETLOGIN_R
735 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
736                  "use gnulib module getlogin_r for portability");
737 # endif
738 #endif
739
740
741 #if @GNULIB_GETPAGESIZE@
742 # if @REPLACE_GETPAGESIZE@
743 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
744 #   define getpagesize rpl_getpagesize
745 #  endif
746 _GL_FUNCDECL_RPL (getpagesize, int, (void));
747 _GL_CXXALIAS_RPL (getpagesize, int, (void));
748 # else
749 #  if !@HAVE_GETPAGESIZE@
750 #   if !defined getpagesize
751 /* This is for POSIX systems.  */
752 #    if !defined _gl_getpagesize && defined _SC_PAGESIZE
753 #     if ! (defined __VMS && __VMS_VER < 70000000)
754 #      define _gl_getpagesize() sysconf (_SC_PAGESIZE)
755 #     endif
756 #    endif
757 /* This is for older VMS.  */
758 #    if !defined _gl_getpagesize && defined __VMS
759 #     ifdef __ALPHA
760 #      define _gl_getpagesize() 8192
761 #     else
762 #      define _gl_getpagesize() 512
763 #     endif
764 #    endif
765 /* This is for BeOS.  */
766 #    if !defined _gl_getpagesize && @HAVE_OS_H@
767 #     include <OS.h>
768 #     if defined B_PAGE_SIZE
769 #      define _gl_getpagesize() B_PAGE_SIZE
770 #     endif
771 #    endif
772 /* This is for AmigaOS4.0.  */
773 #    if !defined _gl_getpagesize && defined __amigaos4__
774 #     define _gl_getpagesize() 2048
775 #    endif
776 /* This is for older Unix systems.  */
777 #    if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
778 #     include <sys/param.h>
779 #     ifdef EXEC_PAGESIZE
780 #      define _gl_getpagesize() EXEC_PAGESIZE
781 #     else
782 #      ifdef NBPG
783 #       ifndef CLSIZE
784 #        define CLSIZE 1
785 #       endif
786 #       define _gl_getpagesize() (NBPG * CLSIZE)
787 #      else
788 #       ifdef NBPC
789 #        define _gl_getpagesize() NBPC
790 #       endif
791 #      endif
792 #     endif
793 #    endif
794 #    if !(defined __cplusplus && defined GNULIB_NAMESPACE)
795 #     define getpagesize() _gl_getpagesize ()
796 #    else
797 static inline int
798 getpagesize ()
799 {
800   return _gl_getpagesize ();
801 }
802 #    endif
803 #   endif
804 #  endif
805 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t.  */
806 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
807 # endif
808 # if @HAVE_DECL_GETPAGESIZE@
809 _GL_CXXALIASWARN (getpagesize);
810 # endif
811 #elif defined GNULIB_POSIXCHECK
812 # undef getpagesize
813 # if HAVE_RAW_DECL_GETPAGESIZE
814 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
815                  "use gnulib module getpagesize for portability");
816 # endif
817 #endif
818
819
820 #if @GNULIB_GETUSERSHELL@
821 /* Return the next valid login shell on the system, or NULL when the end of
822    the list has been reached.  */
823 # if !@HAVE_DECL_GETUSERSHELL@
824 _GL_FUNCDECL_SYS (getusershell, char *, (void));
825 # endif
826 _GL_CXXALIAS_SYS (getusershell, char *, (void));
827 _GL_CXXALIASWARN (getusershell);
828 #elif defined GNULIB_POSIXCHECK
829 # undef getusershell
830 # if HAVE_RAW_DECL_GETUSERSHELL
831 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
832                  "use gnulib module getusershell for portability");
833 # endif
834 #endif
835
836 #if @GNULIB_GETUSERSHELL@
837 /* Rewind to pointer that is advanced at each getusershell() call.  */
838 # if !@HAVE_DECL_GETUSERSHELL@
839 _GL_FUNCDECL_SYS (setusershell, void, (void));
840 # endif
841 _GL_CXXALIAS_SYS (setusershell, void, (void));
842 _GL_CXXALIASWARN (setusershell);
843 #elif defined GNULIB_POSIXCHECK
844 # undef setusershell
845 # if HAVE_RAW_DECL_SETUSERSHELL
846 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
847                  "use gnulib module getusershell for portability");
848 # endif
849 #endif
850
851 #if @GNULIB_GETUSERSHELL@
852 /* Free the pointer that is advanced at each getusershell() call and
853    associated resources.  */
854 # if !@HAVE_DECL_GETUSERSHELL@
855 _GL_FUNCDECL_SYS (endusershell, void, (void));
856 # endif
857 _GL_CXXALIAS_SYS (endusershell, void, (void));
858 _GL_CXXALIASWARN (endusershell);
859 #elif defined GNULIB_POSIXCHECK
860 # undef endusershell
861 # if HAVE_RAW_DECL_ENDUSERSHELL
862 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
863                  "use gnulib module getusershell for portability");
864 # endif
865 #endif
866
867
868 #if @GNULIB_LCHOWN@
869 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
870    to GID (if GID is not -1).  Do not follow symbolic links.
871    Return 0 if successful, otherwise -1 and errno set.
872    See the POSIX:2001 specification
873    <http://www.opengroup.org/susv3xsh/lchown.html>.  */
874 # if @REPLACE_LCHOWN@
875 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
876 #   undef lchown
877 #   define lchown rpl_lchown
878 #  endif
879 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
880                                _GL_ARG_NONNULL ((1)));
881 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
882 # else
883 #  if !@HAVE_LCHOWN@
884 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
885                                _GL_ARG_NONNULL ((1)));
886 #  endif
887 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
888 # endif
889 _GL_CXXALIASWARN (lchown);
890 #elif defined GNULIB_POSIXCHECK
891 # undef lchown
892 # if HAVE_RAW_DECL_LCHOWN
893 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
894                  "use gnulib module lchown for portability");
895 # endif
896 #endif
897
898
899 #if @GNULIB_LINK@
900 /* Create a new hard link for an existing file.
901    Return 0 if successful, otherwise -1 and errno set.
902    See POSIX:2001 specification
903    <http://www.opengroup.org/susv3xsh/link.html>.  */
904 # if @REPLACE_LINK@
905 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
906 #   define link rpl_link
907 #  endif
908 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
909                              _GL_ARG_NONNULL ((1, 2)));
910 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
911 # else
912 #  if !@HAVE_LINK@
913 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
914                              _GL_ARG_NONNULL ((1, 2)));
915 #  endif
916 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
917 # endif
918 _GL_CXXALIASWARN (link);
919 #elif defined GNULIB_POSIXCHECK
920 # undef link
921 # if HAVE_RAW_DECL_LINK
922 _GL_WARN_ON_USE (link, "link is unportable - "
923                  "use gnulib module link for portability");
924 # endif
925 #endif
926
927
928 #if @GNULIB_LINKAT@
929 /* Create a new hard link for an existing file, relative to two
930    directories.  FLAG controls whether symlinks are followed.
931    Return 0 if successful, otherwise -1 and errno set.  */
932 # if @REPLACE_LINKAT@
933 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
934 #   undef linkat
935 #   define linkat rpl_linkat
936 #  endif
937 _GL_FUNCDECL_RPL (linkat, int,
938                   (int fd1, const char *path1, int fd2, const char *path2,
939                    int flag)
940                   _GL_ARG_NONNULL ((2, 4)));
941 _GL_CXXALIAS_RPL (linkat, int,
942                   (int fd1, const char *path1, int fd2, const char *path2,
943                    int flag));
944 # else
945 #  if !@HAVE_LINKAT@
946 _GL_FUNCDECL_SYS (linkat, int,
947                   (int fd1, const char *path1, int fd2, const char *path2,
948                    int flag)
949                   _GL_ARG_NONNULL ((2, 4)));
950 #  endif
951 _GL_CXXALIAS_SYS (linkat, int,
952                   (int fd1, const char *path1, int fd2, const char *path2,
953                    int flag));
954 # endif
955 _GL_CXXALIASWARN (linkat);
956 #elif defined GNULIB_POSIXCHECK
957 # undef linkat
958 # if HAVE_RAW_DECL_LINKAT
959 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
960                  "use gnulib module linkat for portability");
961 # endif
962 #endif
963
964
965 #if @GNULIB_LSEEK@
966 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
967    Return the new offset if successful, otherwise -1 and errno set.
968    See the POSIX:2001 specification
969    <http://www.opengroup.org/susv3xsh/lseek.html>.  */
970 # if @REPLACE_LSEEK@
971 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
972 #   define lseek rpl_lseek
973 #  endif
974 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
975 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
976 # else
977 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
978 # endif
979 _GL_CXXALIASWARN (lseek);
980 #elif defined GNULIB_POSIXCHECK
981 # undef lseek
982 # if HAVE_RAW_DECL_LSEEK
983 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
984                  "systems - use gnulib module lseek for portability");
985 # endif
986 #endif
987
988
989 #if @GNULIB_PIPE@
990 /* Create a pipe, defaulting to O_BINARY mode.
991    Store the read-end as fd[0] and the write-end as fd[1].
992    Return 0 upon success, or -1 with errno set upon failure.  */
993 # if !@HAVE_PIPE@
994 _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
995 # endif
996 _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
997 _GL_CXXALIASWARN (pipe);
998 #elif defined GNULIB_POSIXCHECK
999 # undef pipe
1000 # if HAVE_RAW_DECL_PIPE
1001 _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1002                  "use gnulib module pipe-posix for portability");
1003 # endif
1004 #endif
1005
1006
1007 #if @GNULIB_PIPE2@
1008 /* Create a pipe, applying the given flags when opening the read-end of the
1009    pipe and the write-end of the pipe.
1010    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1011    and O_TEXT, O_BINARY (defined in "binary-io.h").
1012    Store the read-end as fd[0] and the write-end as fd[1].
1013    Return 0 upon success, or -1 with errno set upon failure.
1014    See also the Linux man page at
1015    <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
1016 # if @HAVE_PIPE2@
1017 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1018 #   define pipe2 rpl_pipe2
1019 #  endif
1020 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1021 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1022 # else
1023 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1024 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1025 # endif
1026 _GL_CXXALIASWARN (pipe2);
1027 #elif defined GNULIB_POSIXCHECK
1028 # undef pipe2
1029 # if HAVE_RAW_DECL_PIPE2
1030 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1031                  "use gnulib module pipe2 for portability");
1032 # endif
1033 #endif
1034
1035
1036 #if @GNULIB_PREAD@
1037 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1038    Return the number of bytes placed into BUF if successful, otherwise
1039    set errno and return -1.  0 indicates EOF.  See the POSIX:2001
1040    specification <http://www.opengroup.org/susv3xsh/pread.html>.  */
1041 # if @REPLACE_PREAD@
1042 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1043 #   define pread rpl_pread
1044 #  endif
1045 _GL_FUNCDECL_RPL (pread, ssize_t,
1046                   (int fd, void *buf, size_t bufsize, off_t offset)
1047                   _GL_ARG_NONNULL ((2)));
1048 _GL_CXXALIAS_RPL (pread, ssize_t,
1049                   (int fd, void *buf, size_t bufsize, off_t offset));
1050 # else
1051 #  if !@HAVE_PREAD@
1052 _GL_FUNCDECL_SYS (pread, ssize_t,
1053                   (int fd, void *buf, size_t bufsize, off_t offset)
1054                   _GL_ARG_NONNULL ((2)));
1055 #  endif
1056 _GL_CXXALIAS_SYS (pread, ssize_t,
1057                   (int fd, void *buf, size_t bufsize, off_t offset));
1058 # endif
1059 _GL_CXXALIASWARN (pread);
1060 #elif defined GNULIB_POSIXCHECK
1061 # undef pread
1062 # if HAVE_RAW_DECL_PREAD
1063 _GL_WARN_ON_USE (pread, "pread is unportable - "
1064                  "use gnulib module pread for portability");
1065 # endif
1066 #endif
1067
1068
1069 #if @GNULIB_PWRITE@
1070 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1071    Return the number of bytes written if successful, otherwise
1072    set errno and return -1.  0 indicates nothing written.  See the
1073    POSIX:2001 specification
1074    <http://www.opengroup.org/susv3xsh/pwrite.html>.  */
1075 # if @REPLACE_PWRITE@
1076 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1077 #   define pwrite rpl_pwrite
1078 #  endif
1079 _GL_FUNCDECL_RPL (pwrite, ssize_t,
1080                   (int fd, const void *buf, size_t bufsize, off_t offset)
1081                   _GL_ARG_NONNULL ((2)));
1082 _GL_CXXALIAS_RPL (pwrite, ssize_t,
1083                   (int fd, const void *buf, size_t bufsize, off_t offset));
1084 # else
1085 #  if !@HAVE_PWRITE@
1086 _GL_FUNCDECL_SYS (pwrite, ssize_t,
1087                   (int fd, const void *buf, size_t bufsize, off_t offset)
1088                   _GL_ARG_NONNULL ((2)));
1089 #  endif
1090 _GL_CXXALIAS_SYS (pwrite, ssize_t,
1091                   (int fd, const void *buf, size_t bufsize, off_t offset));
1092 # endif
1093 _GL_CXXALIASWARN (pwrite);
1094 #elif defined GNULIB_POSIXCHECK
1095 # undef pwrite
1096 # if HAVE_RAW_DECL_PWRITE
1097 _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1098                  "use gnulib module pwrite for portability");
1099 # endif
1100 #endif
1101
1102
1103 #if @GNULIB_READLINK@
1104 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1105    bytes of it into BUF.  Return the number of bytes placed into BUF if
1106    successful, otherwise -1 and errno set.
1107    See the POSIX:2001 specification
1108    <http://www.opengroup.org/susv3xsh/readlink.html>.  */
1109 # if @REPLACE_READLINK@
1110 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1111 #   define readlink rpl_readlink
1112 #  endif
1113 _GL_FUNCDECL_RPL (readlink, ssize_t,
1114                   (const char *file, char *buf, size_t bufsize)
1115                   _GL_ARG_NONNULL ((1, 2)));
1116 _GL_CXXALIAS_RPL (readlink, ssize_t,
1117                   (const char *file, char *buf, size_t bufsize));
1118 # else
1119 #  if !@HAVE_READLINK@
1120 _GL_FUNCDECL_SYS (readlink, ssize_t,
1121                   (const char *file, char *buf, size_t bufsize)
1122                   _GL_ARG_NONNULL ((1, 2)));
1123 #  endif
1124 _GL_CXXALIAS_SYS (readlink, ssize_t,
1125                   (const char *file, char *buf, size_t bufsize));
1126 # endif
1127 _GL_CXXALIASWARN (readlink);
1128 #elif defined GNULIB_POSIXCHECK
1129 # undef readlink
1130 # if HAVE_RAW_DECL_READLINK
1131 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1132                  "use gnulib module readlink for portability");
1133 # endif
1134 #endif
1135
1136
1137 #if @GNULIB_READLINKAT@
1138 # if !@HAVE_READLINKAT@
1139 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
1140                   (int fd, char const *file, char *buf, size_t len)
1141                   _GL_ARG_NONNULL ((2, 3)));
1142 # endif
1143 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1144                   (int fd, char const *file, char *buf, size_t len));
1145 _GL_CXXALIASWARN (readlinkat);
1146 #elif defined GNULIB_POSIXCHECK
1147 # undef readlinkat
1148 # if HAVE_RAW_DECL_READLINKAT
1149 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1150                  "use gnulib module readlinkat for portability");
1151 # endif
1152 #endif
1153
1154
1155 #if @GNULIB_RMDIR@
1156 /* Remove the directory DIR.  */
1157 # if @REPLACE_RMDIR@
1158 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1159 #   define rmdir rpl_rmdir
1160 #  endif
1161 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1162 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1163 # else
1164 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1165 # endif
1166 _GL_CXXALIASWARN (rmdir);
1167 #elif defined GNULIB_POSIXCHECK
1168 # undef rmdir
1169 # if HAVE_RAW_DECL_RMDIR
1170 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1171                  "use gnulib module rmdir for portability");
1172 # endif
1173 #endif
1174
1175
1176 #if @GNULIB_SLEEP@
1177 /* Pause the execution of the current thread for N seconds.
1178    Returns the number of seconds left to sleep.
1179    See the POSIX:2001 specification
1180    <http://www.opengroup.org/susv3xsh/sleep.html>.  */
1181 # if @REPLACE_SLEEP@
1182 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1183 #   undef sleep
1184 #   define sleep rpl_sleep
1185 #  endif
1186 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1187 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1188 # else
1189 #  if !@HAVE_SLEEP@
1190 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1191 #  endif
1192 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1193 # endif
1194 _GL_CXXALIASWARN (sleep);
1195 #elif defined GNULIB_POSIXCHECK
1196 # undef sleep
1197 # if HAVE_RAW_DECL_SLEEP
1198 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1199                  "use gnulib module sleep for portability");
1200 # endif
1201 #endif
1202
1203
1204 #if @GNULIB_SYMLINK@
1205 # if @REPLACE_SYMLINK@
1206 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1207 #   undef symlink
1208 #   define symlink rpl_symlink
1209 #  endif
1210 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1211                                 _GL_ARG_NONNULL ((1, 2)));
1212 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1213 # else
1214 #  if !@HAVE_SYMLINK@
1215 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1216                                 _GL_ARG_NONNULL ((1, 2)));
1217 #  endif
1218 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1219 # endif
1220 _GL_CXXALIASWARN (symlink);
1221 #elif defined GNULIB_POSIXCHECK
1222 # undef symlink
1223 # if HAVE_RAW_DECL_SYMLINK
1224 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1225                  "use gnulib module symlink for portability");
1226 # endif
1227 #endif
1228
1229
1230 #if @GNULIB_SYMLINKAT@
1231 # if !@HAVE_SYMLINKAT@
1232 _GL_FUNCDECL_SYS (symlinkat, int,
1233                   (char const *contents, int fd, char const *file)
1234                   _GL_ARG_NONNULL ((1, 3)));
1235 # endif
1236 _GL_CXXALIAS_SYS (symlinkat, int,
1237                   (char const *contents, int fd, char const *file));
1238 _GL_CXXALIASWARN (symlinkat);
1239 #elif defined GNULIB_POSIXCHECK
1240 # undef symlinkat
1241 # if HAVE_RAW_DECL_SYMLINKAT
1242 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1243                  "use gnulib module symlinkat for portability");
1244 # endif
1245 #endif
1246
1247
1248 #if @GNULIB_TTYNAME_R@
1249 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1250    open on in BUF.  Return 0 on success, otherwise an error number.  */
1251 # if @REPLACE_TTYNAME_R@
1252 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1253 #   undef ttyname_r
1254 #   define ttyname_r rpl_ttyname_r
1255 #  endif
1256 _GL_FUNCDECL_RPL (ttyname_r, int,
1257                   (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1258 _GL_CXXALIAS_RPL (ttyname_r, int,
1259                   (int fd, char *buf, size_t buflen));
1260 # else
1261 #  if !@HAVE_DECL_TTYNAME_R@
1262 _GL_FUNCDECL_SYS (ttyname_r, int,
1263                   (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1264 #  endif
1265 _GL_CXXALIAS_SYS (ttyname_r, int,
1266                   (int fd, char *buf, size_t buflen));
1267 # endif
1268 _GL_CXXALIASWARN (ttyname_r);
1269 #elif defined GNULIB_POSIXCHECK
1270 # undef ttyname_r
1271 # if HAVE_RAW_DECL_TTYNAME_R
1272 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1273                  "use gnulib module ttyname_r for portability");
1274 # endif
1275 #endif
1276
1277
1278 #if @GNULIB_UNLINK@
1279 # if @REPLACE_UNLINK@
1280 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1281 #   undef unlink
1282 #   define unlink rpl_unlink
1283 #  endif
1284 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1285 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
1286 # else
1287 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
1288 # endif
1289 _GL_CXXALIASWARN (unlink);
1290 #elif defined GNULIB_POSIXCHECK
1291 # undef unlink
1292 # if HAVE_RAW_DECL_UNLINK
1293 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
1294                  "use gnulib module unlink for portability");
1295 # endif
1296 #endif
1297
1298
1299 #if @GNULIB_UNLINKAT@
1300 # if @REPLACE_UNLINKAT@
1301 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1302 #   undef unlinkat
1303 #   define unlinkat rpl_unlinkat
1304 #  endif
1305 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1306                                  _GL_ARG_NONNULL ((2)));
1307 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1308 # else
1309 #  if !@HAVE_UNLINKAT@
1310 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1311                                  _GL_ARG_NONNULL ((2)));
1312 #  endif
1313 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1314 # endif
1315 _GL_CXXALIASWARN (unlinkat);
1316 #elif defined GNULIB_POSIXCHECK
1317 # undef unlinkat
1318 # if HAVE_RAW_DECL_UNLINKAT
1319 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1320                  "use gnulib module openat for portability");
1321 # endif
1322 #endif
1323
1324
1325 #if @GNULIB_USLEEP@
1326 /* Pause the execution of the current thread for N microseconds.
1327    Returns 0 on completion, or -1 on range error.
1328    See the POSIX:2001 specification
1329    <http://www.opengroup.org/susv3xsh/sleep.html>.  */
1330 # if @REPLACE_USLEEP@
1331 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1332 #   undef usleep
1333 #   define usleep rpl_usleep
1334 #  endif
1335 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1336 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1337 # else
1338 #  if !@HAVE_USLEEP@
1339 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1340 #  endif
1341 _GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1342 # endif
1343 _GL_CXXALIASWARN (usleep);
1344 #elif defined GNULIB_POSIXCHECK
1345 # undef usleep
1346 # if HAVE_RAW_DECL_USLEEP
1347 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1348                  "use gnulib module usleep for portability");
1349 # endif
1350 #endif
1351
1352
1353 #if @GNULIB_WRITE@
1354 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1355    See the POSIX:2001 specification
1356    <http://www.opengroup.org/susv3xsh/write.html>.  */
1357 # if @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
1358 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1359 #   undef write
1360 #   define write rpl_write
1361 #  endif
1362 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1363                                   _GL_ARG_NONNULL ((2)));
1364 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1365 # else
1366 /* Need to cast, because on mingw, the third parameter is
1367                                                              unsigned int count
1368    and the return type is 'int'.  */
1369 _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1370 # endif
1371 _GL_CXXALIASWARN (write);
1372 #endif
1373
1374
1375 #endif /* _GL_UNISTD_H */
1376 #endif /* _GL_UNISTD_H */