Imported Upstream version 4.3
[platform/upstream/make.git] / lib / unistd.in.h
1 /* Substitute for and wrapper around <unistd.h>.
2    Copyright (C) 2003-2020 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 3, 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, see <https://www.gnu.org/licenses/>.  */
16
17 #ifndef _@GUARD_PREFIX@_UNISTD_H
18
19 #if __GNUC__ >= 3
20 @PRAGMA_SYSTEM_HEADER@
21 #endif
22 @PRAGMA_COLUMNS@
23
24 #if @HAVE_UNISTD_H@ && defined _GL_INCLUDING_UNISTD_H
25 /* Special invocation convention:
26    - On Mac OS X 10.3.9 we have a sequence of nested includes
27      <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>
28      In this situation, the functions are not yet declared, therefore we cannot
29      provide the C++ aliases.  */
30
31 #@INCLUDE_NEXT@ @NEXT_UNISTD_H@
32
33 #else
34 /* Normal invocation convention.  */
35
36 /* The include_next requires a split double-inclusion guard.  */
37 #if @HAVE_UNISTD_H@
38 # define _GL_INCLUDING_UNISTD_H
39 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
40 # undef _GL_INCLUDING_UNISTD_H
41 #endif
42
43 /* Get all possible declarations of gethostname().  */
44 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
45   && !defined _GL_INCLUDING_WINSOCK2_H
46 # define _GL_INCLUDING_WINSOCK2_H
47 # include <winsock2.h>
48 # undef _GL_INCLUDING_WINSOCK2_H
49 #endif
50
51 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
52 #define _@GUARD_PREFIX@_UNISTD_H
53
54 /* NetBSD 5.0 mis-defines NULL.  Also get size_t.  */
55 /* But avoid namespace pollution on glibc systems.  */
56 #ifndef __GLIBC__
57 # include <stddef.h>
58 #endif
59
60 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>.  */
61 /* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>.  We must include
62    it before we  #define unlink rpl_unlink.  */
63 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>.  */
64 /* But avoid namespace pollution on glibc systems.  */
65 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
66      || ((@GNULIB_UNLINK@ || defined GNULIB_POSIXCHECK) \
67          && (defined _WIN32 && ! defined __CYGWIN__)) \
68      || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
69          && defined __CYGWIN__)) \
70     && ! defined __GLIBC__
71 # include <stdio.h>
72 #endif
73
74 /* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
75    <unistd.h>.  */
76 /* But avoid namespace pollution on glibc systems.  */
77 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
78     && (defined __CYGWIN__ || defined __ANDROID__) \
79     && ! defined __GLIBC__
80 # include <fcntl.h>
81 #endif
82
83 /* mingw fails to declare _exit in <unistd.h>.  */
84 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
85    <unistd.h>.  */
86 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>.  */
87 /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
88    included here.  */
89 /* But avoid namespace pollution on glibc systems.  */
90 #if !defined __GLIBC__ && !defined __osf__
91 # define __need_system_stdlib_h
92 # include <stdlib.h>
93 # undef __need_system_stdlib_h
94 #endif
95
96 /* Native Windows platforms declare chdir, getcwd, rmdir in
97    <io.h> and/or <direct.h>, not in <unistd.h>.
98    They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
99    lseek(), read(), unlink(), write() in <io.h>.  */
100 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
101       || defined GNULIB_POSIXCHECK) \
102      && (defined _WIN32 && ! defined __CYGWIN__))
103 # include <io.h>     /* mingw32, mingw64 */
104 # include <direct.h> /* mingw64, MSVC 9 */
105 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
106        || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
107        || defined GNULIB_POSIXCHECK) \
108       && (defined _WIN32 && ! defined __CYGWIN__)
109 # include <io.h>
110 #endif
111
112 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
113    NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>.  */
114 /* But avoid namespace pollution on glibc systems.  */
115 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
116      || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
117     && !defined __GLIBC__
118 # include <netdb.h>
119 #endif
120
121 /* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>.  */
122 /* But avoid namespace pollution on glibc systems.  */
123 #if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
124     && !defined __GLIBC__
125 # include <sys/stat.h>
126 #endif
127
128 /* MSVC defines off_t in <sys/types.h>.
129    May also define off_t to a 64-bit type on native Windows.  */
130 /* But avoid namespace pollution on glibc systems.  */
131 #ifndef __GLIBC__
132 /* Get off_t, ssize_t.  */
133 # include <sys/types.h>
134 #endif
135
136 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
137
138 /* The definition of _GL_ARG_NONNULL is copied here.  */
139
140 /* The definition of _GL_WARN_ON_USE is copied here.  */
141
142
143 /* Get getopt(), optarg, optind, opterr, optopt.  */
144 #if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
145 # include <getopt-cdefs.h>
146 # include <getopt-pfx-core.h>
147 #endif
148
149 #ifndef _GL_INLINE_HEADER_BEGIN
150  #error "Please include config.h first."
151 #endif
152 _GL_INLINE_HEADER_BEGIN
153 #ifndef _GL_UNISTD_INLINE
154 # define _GL_UNISTD_INLINE _GL_INLINE
155 #endif
156
157 /* Hide some function declarations from <winsock2.h>.  */
158
159 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
160 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
161 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
162 #   undef socket
163 #   define socket              socket_used_without_including_sys_socket_h
164 #   undef connect
165 #   define connect             connect_used_without_including_sys_socket_h
166 #   undef accept
167 #   define accept              accept_used_without_including_sys_socket_h
168 #   undef bind
169 #   define bind                bind_used_without_including_sys_socket_h
170 #   undef getpeername
171 #   define getpeername         getpeername_used_without_including_sys_socket_h
172 #   undef getsockname
173 #   define getsockname         getsockname_used_without_including_sys_socket_h
174 #   undef getsockopt
175 #   define getsockopt          getsockopt_used_without_including_sys_socket_h
176 #   undef listen
177 #   define listen              listen_used_without_including_sys_socket_h
178 #   undef recv
179 #   define recv                recv_used_without_including_sys_socket_h
180 #   undef send
181 #   define send                send_used_without_including_sys_socket_h
182 #   undef recvfrom
183 #   define recvfrom            recvfrom_used_without_including_sys_socket_h
184 #   undef sendto
185 #   define sendto              sendto_used_without_including_sys_socket_h
186 #   undef setsockopt
187 #   define setsockopt          setsockopt_used_without_including_sys_socket_h
188 #   undef shutdown
189 #   define shutdown            shutdown_used_without_including_sys_socket_h
190 #  else
191     _GL_WARN_ON_USE (socket,
192                      "socket() used without including <sys/socket.h>");
193     _GL_WARN_ON_USE (connect,
194                      "connect() used without including <sys/socket.h>");
195     _GL_WARN_ON_USE (accept,
196                      "accept() used without including <sys/socket.h>");
197     _GL_WARN_ON_USE (bind,
198                      "bind() used without including <sys/socket.h>");
199     _GL_WARN_ON_USE (getpeername,
200                      "getpeername() used without including <sys/socket.h>");
201     _GL_WARN_ON_USE (getsockname,
202                      "getsockname() used without including <sys/socket.h>");
203     _GL_WARN_ON_USE (getsockopt,
204                      "getsockopt() used without including <sys/socket.h>");
205     _GL_WARN_ON_USE (listen,
206                      "listen() used without including <sys/socket.h>");
207     _GL_WARN_ON_USE (recv,
208                      "recv() used without including <sys/socket.h>");
209     _GL_WARN_ON_USE (send,
210                      "send() used without including <sys/socket.h>");
211     _GL_WARN_ON_USE (recvfrom,
212                      "recvfrom() used without including <sys/socket.h>");
213     _GL_WARN_ON_USE (sendto,
214                      "sendto() used without including <sys/socket.h>");
215     _GL_WARN_ON_USE (setsockopt,
216                      "setsockopt() used without including <sys/socket.h>");
217     _GL_WARN_ON_USE (shutdown,
218                      "shutdown() used without including <sys/socket.h>");
219 #  endif
220 # endif
221 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
222 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
223 #   undef select
224 #   define select              select_used_without_including_sys_select_h
225 #  else
226     _GL_WARN_ON_USE (select,
227                      "select() used without including <sys/select.h>");
228 #  endif
229 # endif
230 #endif
231
232
233 /* OS/2 EMX lacks these macros.  */
234 #ifndef STDIN_FILENO
235 # define STDIN_FILENO 0
236 #endif
237 #ifndef STDOUT_FILENO
238 # define STDOUT_FILENO 1
239 #endif
240 #ifndef STDERR_FILENO
241 # define STDERR_FILENO 2
242 #endif
243
244 /* Ensure *_OK macros exist.  */
245 #ifndef F_OK
246 # define F_OK 0
247 # define X_OK 1
248 # define W_OK 2
249 # define R_OK 4
250 #endif
251
252
253 /* Declare overridden functions.  */
254
255
256 #if @GNULIB_ACCESS@
257 # if @REPLACE_ACCESS@
258 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
259 #   undef access
260 #   define access rpl_access
261 #  endif
262 _GL_FUNCDECL_RPL (access, int, (const char *file, int mode)
263                                _GL_ARG_NONNULL ((1)));
264 _GL_CXXALIAS_RPL (access, int, (const char *file, int mode));
265 # else
266 _GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
267 # endif
268 _GL_CXXALIASWARN (access);
269 #elif defined GNULIB_POSIXCHECK
270 # undef access
271 # if HAVE_RAW_DECL_ACCESS
272 /* The access() function is a security risk.  */
273 _GL_WARN_ON_USE (access, "access does not always support X_OK - "
274                  "use gnulib module access for portability; "
275                  "also, this function is a security risk - "
276                  "use the gnulib module faccessat instead");
277 # endif
278 #endif
279
280
281 #if @GNULIB_CHDIR@
282 _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
283 _GL_CXXALIASWARN (chdir);
284 #elif defined GNULIB_POSIXCHECK
285 # undef chdir
286 # if HAVE_RAW_DECL_CHDIR
287 _GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
288                  "use gnulib module chdir for portability");
289 # endif
290 #endif
291
292
293 #if @GNULIB_CHOWN@
294 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
295    to GID (if GID is not -1).  Follow symbolic links.
296    Return 0 if successful, otherwise -1 and errno set.
297    See the POSIX:2008 specification
298    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html.  */
299 # if @REPLACE_CHOWN@
300 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
301 #   undef chown
302 #   define chown rpl_chown
303 #  endif
304 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
305                               _GL_ARG_NONNULL ((1)));
306 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
307 # else
308 #  if !@HAVE_CHOWN@
309 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
310                               _GL_ARG_NONNULL ((1)));
311 #  endif
312 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
313 # endif
314 _GL_CXXALIASWARN (chown);
315 #elif defined GNULIB_POSIXCHECK
316 # undef chown
317 # if HAVE_RAW_DECL_CHOWN
318 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
319                  "doesn't treat a uid or gid of -1 on some systems - "
320                  "use gnulib module chown for portability");
321 # endif
322 #endif
323
324
325 #if @GNULIB_CLOSE@
326 # if @REPLACE_CLOSE@
327 /* Automatically included by modules that need a replacement for close.  */
328 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
329 #   undef close
330 #   define close rpl_close
331 #  endif
332 _GL_FUNCDECL_RPL (close, int, (int fd));
333 _GL_CXXALIAS_RPL (close, int, (int fd));
334 # else
335 _GL_CXXALIAS_SYS (close, int, (int fd));
336 # endif
337 _GL_CXXALIASWARN (close);
338 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
339 # undef close
340 # define close close_used_without_requesting_gnulib_module_close
341 #elif defined GNULIB_POSIXCHECK
342 # undef close
343 /* Assume close is always declared.  */
344 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
345                  "use gnulib module close for portability");
346 #endif
347
348
349 #if @GNULIB_COPY_FILE_RANGE@
350 # if !@HAVE_COPY_FILE_RANGE@
351 _GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
352                                              int ofd, off_t *opos,
353                                              size_t len, unsigned flags));
354 _GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
355                                              int ofd, off_t *opos,
356                                              size_t len, unsigned flags));
357 # endif
358 _GL_CXXALIASWARN (copy_file_range);
359 #elif defined GNULIB_POSIXCHECK
360 /* Assume copy_file_range is always declared.  */
361 _GL_WARN_ON_USE (copy_file_range,
362                  "copy_file_range is unportable - "
363                  "use gnulib module copy_file_range for portability");
364 #endif
365
366
367 #if @GNULIB_DUP@
368 # if @REPLACE_DUP@
369 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
370 #   define dup rpl_dup
371 #  endif
372 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
373 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
374 # else
375 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
376 # endif
377 _GL_CXXALIASWARN (dup);
378 #elif defined GNULIB_POSIXCHECK
379 # undef dup
380 # if HAVE_RAW_DECL_DUP
381 _GL_WARN_ON_USE (dup, "dup is unportable - "
382                  "use gnulib module dup for portability");
383 # endif
384 #endif
385
386
387 #if @GNULIB_DUP2@
388 /* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
389    NEWFD = OLDFD, otherwise close NEWFD first if it is open.
390    Return newfd if successful, otherwise -1 and errno set.
391    See the POSIX:2008 specification
392    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>.  */
393 # if @REPLACE_DUP2@
394 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
395 #   define dup2 rpl_dup2
396 #  endif
397 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
398 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
399 # else
400 #  if !@HAVE_DUP2@
401 _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
402 #  endif
403 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
404 # endif
405 _GL_CXXALIASWARN (dup2);
406 #elif defined GNULIB_POSIXCHECK
407 # undef dup2
408 # if HAVE_RAW_DECL_DUP2
409 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
410                  "use gnulib module dup2 for portability");
411 # endif
412 #endif
413
414
415 #if @GNULIB_DUP3@
416 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
417    specified flags.
418    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
419    and O_TEXT, O_BINARY (defined in "binary-io.h").
420    Close NEWFD first if it is open.
421    Return newfd if successful, otherwise -1 and errno set.
422    See the Linux man page at
423    <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */
424 # if @HAVE_DUP3@
425 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
426 #   define dup3 rpl_dup3
427 #  endif
428 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
429 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
430 # else
431 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
432 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
433 # endif
434 _GL_CXXALIASWARN (dup3);
435 #elif defined GNULIB_POSIXCHECK
436 # undef dup3
437 # if HAVE_RAW_DECL_DUP3
438 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
439                  "use gnulib module dup3 for portability");
440 # endif
441 #endif
442
443
444 #if @GNULIB_ENVIRON@
445 # if defined __CYGWIN__ && !defined __i386__
446 /* The 'environ' variable is defined in a DLL. Therefore its declaration needs
447    the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
448    This leads to a link error on 64-bit Cygwin when the option
449    -Wl,--disable-auto-import is in use.  */
450 _GL_EXTERN_C __declspec(dllimport) char **environ;
451 # endif
452 # if !@HAVE_DECL_ENVIRON@
453 /* Set of environment variables and values.  An array of strings of the form
454    "VARIABLE=VALUE", terminated with a NULL.  */
455 #  if defined __APPLE__ && defined __MACH__
456 #   include <TargetConditionals.h>
457 #   if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
458 #    define _GL_USE_CRT_EXTERNS
459 #   endif
460 #  endif
461 #  ifdef _GL_USE_CRT_EXTERNS
462 #   include <crt_externs.h>
463 #   define environ (*_NSGetEnviron ())
464 #  else
465 #   ifdef __cplusplus
466 extern "C" {
467 #   endif
468 extern char **environ;
469 #   ifdef __cplusplus
470 }
471 #   endif
472 #  endif
473 # endif
474 #elif defined GNULIB_POSIXCHECK
475 # if HAVE_RAW_DECL_ENVIRON
476 _GL_UNISTD_INLINE char ***
477 _GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
478                            "use gnulib module environ for portability")
479 rpl_environ (void)
480 {
481   return &environ;
482 }
483 #  undef environ
484 #  define environ (*rpl_environ ())
485 # endif
486 #endif
487
488
489 #if @GNULIB_EUIDACCESS@
490 /* Like access(), except that it uses the effective user id and group id of
491    the current process.  */
492 # if !@HAVE_EUIDACCESS@
493 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
494                                    _GL_ARG_NONNULL ((1)));
495 # endif
496 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
497 _GL_CXXALIASWARN (euidaccess);
498 # if defined GNULIB_POSIXCHECK
499 /* Like access(), this function is a security risk.  */
500 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
501                  "use the gnulib module faccessat instead");
502 # endif
503 #elif defined GNULIB_POSIXCHECK
504 # undef euidaccess
505 # if HAVE_RAW_DECL_EUIDACCESS
506 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
507                  "use gnulib module euidaccess for portability");
508 # endif
509 #endif
510
511
512 #if @GNULIB_FACCESSAT@
513 # if @REPLACE_FACCESSAT@
514 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
515 #   undef faccessat
516 #   define faccessat rpl_faccessat
517 #  endif
518 _GL_FUNCDECL_RPL (faccessat, int,
519                   (int fd, char const *name, int mode, int flag)
520                   _GL_ARG_NONNULL ((2)));
521 _GL_CXXALIAS_RPL (faccessat, int,
522                   (int fd, char const *name, int mode, int flag));
523 # else
524 #  if !@HAVE_FACCESSAT@
525 _GL_FUNCDECL_SYS (faccessat, int,
526                   (int fd, char const *file, int mode, int flag)
527                   _GL_ARG_NONNULL ((2)));
528 #  endif
529 _GL_CXXALIAS_SYS (faccessat, int,
530                   (int fd, char const *file, int mode, int flag));
531 # endif
532 _GL_CXXALIASWARN (faccessat);
533 #elif defined GNULIB_POSIXCHECK
534 # undef faccessat
535 # if HAVE_RAW_DECL_FACCESSAT
536 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
537                  "use gnulib module faccessat for portability");
538 # endif
539 #endif
540
541
542 #if @GNULIB_FCHDIR@
543 /* Change the process' current working directory to the directory on which
544    the given file descriptor is open.
545    Return 0 if successful, otherwise -1 and errno set.
546    See the POSIX:2008 specification
547    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>.  */
548 # if ! @HAVE_FCHDIR@
549 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
550
551 /* Gnulib internal hooks needed to maintain the fchdir metadata.  */
552 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
553      _GL_ARG_NONNULL ((2));
554 _GL_EXTERN_C void _gl_unregister_fd (int fd);
555 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
556 _GL_EXTERN_C const char *_gl_directory_name (int fd);
557
558 # else
559 #  if !@HAVE_DECL_FCHDIR@
560 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
561 #  endif
562 # endif
563 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
564 _GL_CXXALIASWARN (fchdir);
565 #elif defined GNULIB_POSIXCHECK
566 # undef fchdir
567 # if HAVE_RAW_DECL_FCHDIR
568 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
569                  "use gnulib module fchdir for portability");
570 # endif
571 #endif
572
573
574 #if @GNULIB_FCHOWNAT@
575 # if @REPLACE_FCHOWNAT@
576 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
577 #   undef fchownat
578 #   define fchownat rpl_fchownat
579 #  endif
580 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
581                                   uid_t owner, gid_t group, int flag)
582                                  _GL_ARG_NONNULL ((2)));
583 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
584                                   uid_t owner, gid_t group, int flag));
585 # else
586 #  if !@HAVE_FCHOWNAT@
587 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
588                                   uid_t owner, gid_t group, int flag)
589                                  _GL_ARG_NONNULL ((2)));
590 #  endif
591 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
592                                   uid_t owner, gid_t group, int flag));
593 # endif
594 _GL_CXXALIASWARN (fchownat);
595 #elif defined GNULIB_POSIXCHECK
596 # undef fchownat
597 # if HAVE_RAW_DECL_FCHOWNAT
598 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
599                  "use gnulib module openat for portability");
600 # endif
601 #endif
602
603
604 #if @GNULIB_FDATASYNC@
605 /* Synchronize changes to a file.
606    Return 0 if successful, otherwise -1 and errno set.
607    See POSIX:2008 specification
608    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>.  */
609 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
610 _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
611 # endif
612 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
613 _GL_CXXALIASWARN (fdatasync);
614 #elif defined GNULIB_POSIXCHECK
615 # undef fdatasync
616 # if HAVE_RAW_DECL_FDATASYNC
617 _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
618                  "use gnulib module fdatasync for portability");
619 # endif
620 #endif
621
622
623 #if @GNULIB_FSYNC@
624 /* Synchronize changes, including metadata, to a file.
625    Return 0 if successful, otherwise -1 and errno set.
626    See POSIX:2008 specification
627    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>.  */
628 # if !@HAVE_FSYNC@
629 _GL_FUNCDECL_SYS (fsync, int, (int fd));
630 # endif
631 _GL_CXXALIAS_SYS (fsync, int, (int fd));
632 _GL_CXXALIASWARN (fsync);
633 #elif defined GNULIB_POSIXCHECK
634 # undef fsync
635 # if HAVE_RAW_DECL_FSYNC
636 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
637                  "use gnulib module fsync for portability");
638 # endif
639 #endif
640
641
642 #if @GNULIB_FTRUNCATE@
643 /* Change the size of the file to which FD is opened to become equal to LENGTH.
644    Return 0 if successful, otherwise -1 and errno set.
645    See the POSIX:2008 specification
646    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>.  */
647 # if @REPLACE_FTRUNCATE@
648 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
649 #   undef ftruncate
650 #   define ftruncate rpl_ftruncate
651 #  endif
652 _GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
653 _GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
654 # else
655 #  if !@HAVE_FTRUNCATE@
656 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
657 #  endif
658 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
659 # endif
660 _GL_CXXALIASWARN (ftruncate);
661 #elif defined GNULIB_POSIXCHECK
662 # undef ftruncate
663 # if HAVE_RAW_DECL_FTRUNCATE
664 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
665                  "use gnulib module ftruncate for portability");
666 # endif
667 #endif
668
669
670 #if @GNULIB_GETCWD@
671 /* Get the name of the current working directory, and put it in SIZE bytes
672    of BUF.
673    Return BUF if successful, or NULL if the directory couldn't be determined
674    or SIZE was too small.
675    See the POSIX:2008 specification
676    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
677    Additionally, the gnulib module 'getcwd' guarantees the following GNU
678    extension: If BUF is NULL, an array is allocated with 'malloc'; the array
679    is SIZE bytes long, unless SIZE == 0, in which case it is as big as
680    necessary.  */
681 # if @REPLACE_GETCWD@
682 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
683 #   define getcwd rpl_getcwd
684 #  endif
685 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
686 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
687 # else
688 /* Need to cast, because on mingw, the second parameter is
689                                                    int size.  */
690 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
691 # endif
692 _GL_CXXALIASWARN (getcwd);
693 #elif defined GNULIB_POSIXCHECK
694 # undef getcwd
695 # if HAVE_RAW_DECL_GETCWD
696 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
697                  "use gnulib module getcwd for portability");
698 # endif
699 #endif
700
701
702 #if @GNULIB_GETDOMAINNAME@
703 /* Return the NIS domain name of the machine.
704    WARNING! The NIS domain name is unrelated to the fully qualified host name
705             of the machine.  It is also unrelated to email addresses.
706    WARNING! The NIS domain name is usually the empty string or "(none)" when
707             not using NIS.
708
709    Put up to LEN bytes of the NIS domain name into NAME.
710    Null terminate it if the name is shorter than LEN.
711    If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
712    Return 0 if successful, otherwise set errno and return -1.  */
713 # if @REPLACE_GETDOMAINNAME@
714 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
715 #   undef getdomainname
716 #   define getdomainname rpl_getdomainname
717 #  endif
718 _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
719                                       _GL_ARG_NONNULL ((1)));
720 _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
721 # else
722 #  if !@HAVE_DECL_GETDOMAINNAME@
723 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
724                                       _GL_ARG_NONNULL ((1)));
725 #  endif
726 _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
727 # endif
728 _GL_CXXALIASWARN (getdomainname);
729 #elif defined GNULIB_POSIXCHECK
730 # undef getdomainname
731 # if HAVE_RAW_DECL_GETDOMAINNAME
732 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
733                  "use gnulib module getdomainname for portability");
734 # endif
735 #endif
736
737
738 #if @GNULIB_GETDTABLESIZE@
739 /* Return the maximum number of file descriptors in the current process.
740    In POSIX, this is same as sysconf (_SC_OPEN_MAX).  */
741 # if @REPLACE_GETDTABLESIZE@
742 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
743 #   undef getdtablesize
744 #   define getdtablesize rpl_getdtablesize
745 #  endif
746 _GL_FUNCDECL_RPL (getdtablesize, int, (void));
747 _GL_CXXALIAS_RPL (getdtablesize, int, (void));
748 # else
749 #  if !@HAVE_GETDTABLESIZE@
750 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
751 #  endif
752 /* Need to cast, because on AIX, the parameter list is
753                                            (...).  */
754 _GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void));
755 # endif
756 _GL_CXXALIASWARN (getdtablesize);
757 #elif defined GNULIB_POSIXCHECK
758 # undef getdtablesize
759 # if HAVE_RAW_DECL_GETDTABLESIZE
760 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
761                  "use gnulib module getdtablesize for portability");
762 # endif
763 #endif
764
765
766 #if @GNULIB_GETGROUPS@
767 /* Return the supplemental groups that the current process belongs to.
768    It is unspecified whether the effective group id is in the list.
769    If N is 0, return the group count; otherwise, N describes how many
770    entries are available in GROUPS.  Return -1 and set errno if N is
771    not 0 and not large enough.  Fails with ENOSYS on some systems.  */
772 # if @REPLACE_GETGROUPS@
773 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
774 #   undef getgroups
775 #   define getgroups rpl_getgroups
776 #  endif
777 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
778 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
779 # else
780 #  if !@HAVE_GETGROUPS@
781 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
782 #  endif
783 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
784 # endif
785 _GL_CXXALIASWARN (getgroups);
786 #elif defined GNULIB_POSIXCHECK
787 # undef getgroups
788 # if HAVE_RAW_DECL_GETGROUPS
789 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
790                  "use gnulib module getgroups for portability");
791 # endif
792 #endif
793
794
795 #if @GNULIB_GETHOSTNAME@
796 /* Return the standard host name of the machine.
797    WARNING! The host name may or may not be fully qualified.
798
799    Put up to LEN bytes of the host name into NAME.
800    Null terminate it if the name is shorter than LEN.
801    If the host name is longer than LEN, set errno = EINVAL and return -1.
802    Return 0 if successful, otherwise set errno and return -1.  */
803 # if @UNISTD_H_HAVE_WINSOCK2_H@
804 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
805 #   undef gethostname
806 #   define gethostname rpl_gethostname
807 #  endif
808 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
809                                     _GL_ARG_NONNULL ((1)));
810 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
811 # else
812 #  if !@HAVE_GETHOSTNAME@
813 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
814                                     _GL_ARG_NONNULL ((1)));
815 #  endif
816 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
817    parameter is
818                                                       int len.  */
819 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
820 # endif
821 _GL_CXXALIASWARN (gethostname);
822 #elif @UNISTD_H_HAVE_WINSOCK2_H@
823 # undef gethostname
824 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
825 #elif defined GNULIB_POSIXCHECK
826 # undef gethostname
827 # if HAVE_RAW_DECL_GETHOSTNAME
828 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
829                  "use gnulib module gethostname for portability");
830 # endif
831 #endif
832
833
834 #if @GNULIB_GETLOGIN@
835 /* Returns the user's login name, or NULL if it cannot be found.  Upon error,
836    returns NULL with errno set.
837
838    See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
839
840    Most programs don't need to use this function, because the information is
841    available through environment variables:
842      ${LOGNAME-$USER}        on Unix platforms,
843      $USERNAME               on native Windows platforms.
844  */
845 # if !@HAVE_DECL_GETLOGIN@
846 _GL_FUNCDECL_SYS (getlogin, char *, (void));
847 # endif
848 _GL_CXXALIAS_SYS (getlogin, char *, (void));
849 _GL_CXXALIASWARN (getlogin);
850 #elif defined GNULIB_POSIXCHECK
851 # undef getlogin
852 # if HAVE_RAW_DECL_GETLOGIN
853 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
854                  "use gnulib module getlogin for portability");
855 # endif
856 #endif
857
858
859 #if @GNULIB_GETLOGIN_R@
860 /* Copies the user's login name to NAME.
861    The array pointed to by NAME has room for SIZE bytes.
862
863    Returns 0 if successful.  Upon error, an error number is returned, or -1 in
864    the case that the login name cannot be found but no specific error is
865    provided (this case is hopefully rare but is left open by the POSIX spec).
866
867    See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
868
869    Most programs don't need to use this function, because the information is
870    available through environment variables:
871      ${LOGNAME-$USER}        on Unix platforms,
872      $USERNAME               on native Windows platforms.
873  */
874 # if @REPLACE_GETLOGIN_R@
875 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
876 #   define getlogin_r rpl_getlogin_r
877 #  endif
878 _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
879                                    _GL_ARG_NONNULL ((1)));
880 _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
881 # else
882 #  if !@HAVE_DECL_GETLOGIN_R@
883 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
884                                    _GL_ARG_NONNULL ((1)));
885 #  endif
886 /* Need to cast, because on Solaris 10 systems, the second argument is
887                                                      int size.  */
888 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
889 # endif
890 _GL_CXXALIASWARN (getlogin_r);
891 #elif defined GNULIB_POSIXCHECK
892 # undef getlogin_r
893 # if HAVE_RAW_DECL_GETLOGIN_R
894 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
895                  "use gnulib module getlogin_r for portability");
896 # endif
897 #endif
898
899
900 #if @GNULIB_GETPAGESIZE@
901 # if @REPLACE_GETPAGESIZE@
902 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
903 #   define getpagesize rpl_getpagesize
904 #  endif
905 _GL_FUNCDECL_RPL (getpagesize, int, (void));
906 _GL_CXXALIAS_RPL (getpagesize, int, (void));
907 # else
908 /* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
909    the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used.  */
910 #  if defined __hpux
911 _GL_FUNCDECL_SYS (getpagesize, int, (void));
912 #  endif
913 #  if !@HAVE_GETPAGESIZE@
914 #   if !defined getpagesize
915 /* This is for POSIX systems.  */
916 #    if !defined _gl_getpagesize && defined _SC_PAGESIZE
917 #     if ! (defined __VMS && __VMS_VER < 70000000)
918 #      define _gl_getpagesize() sysconf (_SC_PAGESIZE)
919 #     endif
920 #    endif
921 /* This is for older VMS.  */
922 #    if !defined _gl_getpagesize && defined __VMS
923 #     ifdef __ALPHA
924 #      define _gl_getpagesize() 8192
925 #     else
926 #      define _gl_getpagesize() 512
927 #     endif
928 #    endif
929 /* This is for BeOS.  */
930 #    if !defined _gl_getpagesize && @HAVE_OS_H@
931 #     include <OS.h>
932 #     if defined B_PAGE_SIZE
933 #      define _gl_getpagesize() B_PAGE_SIZE
934 #     endif
935 #    endif
936 /* This is for AmigaOS4.0.  */
937 #    if !defined _gl_getpagesize && defined __amigaos4__
938 #     define _gl_getpagesize() 2048
939 #    endif
940 /* This is for older Unix systems.  */
941 #    if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
942 #     include <sys/param.h>
943 #     ifdef EXEC_PAGESIZE
944 #      define _gl_getpagesize() EXEC_PAGESIZE
945 #     else
946 #      ifdef NBPG
947 #       ifndef CLSIZE
948 #        define CLSIZE 1
949 #       endif
950 #       define _gl_getpagesize() (NBPG * CLSIZE)
951 #      else
952 #       ifdef NBPC
953 #        define _gl_getpagesize() NBPC
954 #       endif
955 #      endif
956 #     endif
957 #    endif
958 #    if !(defined __cplusplus && defined GNULIB_NAMESPACE)
959 #     define getpagesize() _gl_getpagesize ()
960 #    else
961 #     if !GNULIB_defined_getpagesize_function
962 _GL_UNISTD_INLINE int
963 getpagesize ()
964 {
965   return _gl_getpagesize ();
966 }
967 #      define GNULIB_defined_getpagesize_function 1
968 #     endif
969 #    endif
970 #   endif
971 #  endif
972 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t.  */
973 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
974 # endif
975 # if @HAVE_DECL_GETPAGESIZE@
976 _GL_CXXALIASWARN (getpagesize);
977 # endif
978 #elif defined GNULIB_POSIXCHECK
979 # undef getpagesize
980 # if HAVE_RAW_DECL_GETPAGESIZE
981 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
982                  "use gnulib module getpagesize for portability");
983 # endif
984 #endif
985
986
987 #if @GNULIB_GETPASS@
988 /* Function getpass() from module 'getpass':
989      Read a password from /dev/tty or stdin.
990    Function getpass() from module 'getpass-gnu':
991      Read a password of arbitrary length from /dev/tty or stdin.  */
992 # if @REPLACE_GETPASS@
993 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
994 #   undef getpass
995 #   define getpass rpl_getpass
996 #  endif
997 _GL_FUNCDECL_RPL (getpass, char *, (const char *prompt)
998                                    _GL_ARG_NONNULL ((1)));
999 _GL_CXXALIAS_RPL (getpass, char *, (const char *prompt));
1000 # else
1001 #  if !@HAVE_GETPASS@
1002 _GL_FUNCDECL_SYS (getpass, char *, (const char *prompt)
1003                                    _GL_ARG_NONNULL ((1)));
1004 #  endif
1005 _GL_CXXALIAS_SYS (getpass, char *, (const char *prompt));
1006 # endif
1007 _GL_CXXALIASWARN (getpass);
1008 #elif defined GNULIB_POSIXCHECK
1009 # undef getpass
1010 # if HAVE_RAW_DECL_GETPASS
1011 _GL_WARN_ON_USE (getpass, "getpass is unportable - "
1012                  "use gnulib module getpass or getpass-gnu for portability");
1013 # endif
1014 #endif
1015
1016
1017 #if @GNULIB_GETUSERSHELL@
1018 /* Return the next valid login shell on the system, or NULL when the end of
1019    the list has been reached.  */
1020 # if !@HAVE_DECL_GETUSERSHELL@
1021 _GL_FUNCDECL_SYS (getusershell, char *, (void));
1022 # endif
1023 _GL_CXXALIAS_SYS (getusershell, char *, (void));
1024 _GL_CXXALIASWARN (getusershell);
1025 #elif defined GNULIB_POSIXCHECK
1026 # undef getusershell
1027 # if HAVE_RAW_DECL_GETUSERSHELL
1028 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
1029                  "use gnulib module getusershell for portability");
1030 # endif
1031 #endif
1032
1033 #if @GNULIB_GETUSERSHELL@
1034 /* Rewind to pointer that is advanced at each getusershell() call.  */
1035 # if !@HAVE_DECL_GETUSERSHELL@
1036 _GL_FUNCDECL_SYS (setusershell, void, (void));
1037 # endif
1038 _GL_CXXALIAS_SYS (setusershell, void, (void));
1039 _GL_CXXALIASWARN (setusershell);
1040 #elif defined GNULIB_POSIXCHECK
1041 # undef setusershell
1042 # if HAVE_RAW_DECL_SETUSERSHELL
1043 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
1044                  "use gnulib module getusershell for portability");
1045 # endif
1046 #endif
1047
1048 #if @GNULIB_GETUSERSHELL@
1049 /* Free the pointer that is advanced at each getusershell() call and
1050    associated resources.  */
1051 # if !@HAVE_DECL_GETUSERSHELL@
1052 _GL_FUNCDECL_SYS (endusershell, void, (void));
1053 # endif
1054 _GL_CXXALIAS_SYS (endusershell, void, (void));
1055 _GL_CXXALIASWARN (endusershell);
1056 #elif defined GNULIB_POSIXCHECK
1057 # undef endusershell
1058 # if HAVE_RAW_DECL_ENDUSERSHELL
1059 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
1060                  "use gnulib module getusershell for portability");
1061 # endif
1062 #endif
1063
1064
1065 #if @GNULIB_GROUP_MEMBER@
1066 /* Determine whether group id is in calling user's group list.  */
1067 # if !@HAVE_GROUP_MEMBER@
1068 _GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
1069 # endif
1070 _GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
1071 _GL_CXXALIASWARN (group_member);
1072 #elif defined GNULIB_POSIXCHECK
1073 # undef group_member
1074 # if HAVE_RAW_DECL_GROUP_MEMBER
1075 _GL_WARN_ON_USE (group_member, "group_member is unportable - "
1076                  "use gnulib module group-member for portability");
1077 # endif
1078 #endif
1079
1080
1081 #if @GNULIB_ISATTY@
1082 # if @REPLACE_ISATTY@
1083 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1084 #   undef isatty
1085 #   define isatty rpl_isatty
1086 #  endif
1087 _GL_FUNCDECL_RPL (isatty, int, (int fd));
1088 _GL_CXXALIAS_RPL (isatty, int, (int fd));
1089 # else
1090 _GL_CXXALIAS_SYS (isatty, int, (int fd));
1091 # endif
1092 _GL_CXXALIASWARN (isatty);
1093 #elif defined GNULIB_POSIXCHECK
1094 # undef isatty
1095 # if HAVE_RAW_DECL_ISATTY
1096 _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
1097                  "use gnulib module isatty for portability");
1098 # endif
1099 #endif
1100
1101
1102 #if @GNULIB_LCHOWN@
1103 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1104    to GID (if GID is not -1).  Do not follow symbolic links.
1105    Return 0 if successful, otherwise -1 and errno set.
1106    See the POSIX:2008 specification
1107    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>.  */
1108 # if @REPLACE_LCHOWN@
1109 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1110 #   undef lchown
1111 #   define lchown rpl_lchown
1112 #  endif
1113 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
1114                                _GL_ARG_NONNULL ((1)));
1115 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
1116 # else
1117 #  if !@HAVE_LCHOWN@
1118 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
1119                                _GL_ARG_NONNULL ((1)));
1120 #  endif
1121 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
1122 # endif
1123 _GL_CXXALIASWARN (lchown);
1124 #elif defined GNULIB_POSIXCHECK
1125 # undef lchown
1126 # if HAVE_RAW_DECL_LCHOWN
1127 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1128                  "use gnulib module lchown for portability");
1129 # endif
1130 #endif
1131
1132
1133 #if @GNULIB_LINK@
1134 /* Create a new hard link for an existing file.
1135    Return 0 if successful, otherwise -1 and errno set.
1136    See POSIX:2008 specification
1137    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>.  */
1138 # if @REPLACE_LINK@
1139 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1140 #   define link rpl_link
1141 #  endif
1142 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
1143                              _GL_ARG_NONNULL ((1, 2)));
1144 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
1145 # else
1146 #  if !@HAVE_LINK@
1147 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
1148                              _GL_ARG_NONNULL ((1, 2)));
1149 #  endif
1150 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
1151 # endif
1152 _GL_CXXALIASWARN (link);
1153 #elif defined GNULIB_POSIXCHECK
1154 # undef link
1155 # if HAVE_RAW_DECL_LINK
1156 _GL_WARN_ON_USE (link, "link is unportable - "
1157                  "use gnulib module link for portability");
1158 # endif
1159 #endif
1160
1161
1162 #if @GNULIB_LINKAT@
1163 /* Create a new hard link for an existing file, relative to two
1164    directories.  FLAG controls whether symlinks are followed.
1165    Return 0 if successful, otherwise -1 and errno set.  */
1166 # if @REPLACE_LINKAT@
1167 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1168 #   undef linkat
1169 #   define linkat rpl_linkat
1170 #  endif
1171 _GL_FUNCDECL_RPL (linkat, int,
1172                   (int fd1, const char *path1, int fd2, const char *path2,
1173                    int flag)
1174                   _GL_ARG_NONNULL ((2, 4)));
1175 _GL_CXXALIAS_RPL (linkat, int,
1176                   (int fd1, const char *path1, int fd2, const char *path2,
1177                    int flag));
1178 # else
1179 #  if !@HAVE_LINKAT@
1180 _GL_FUNCDECL_SYS (linkat, int,
1181                   (int fd1, const char *path1, int fd2, const char *path2,
1182                    int flag)
1183                   _GL_ARG_NONNULL ((2, 4)));
1184 #  endif
1185 _GL_CXXALIAS_SYS (linkat, int,
1186                   (int fd1, const char *path1, int fd2, const char *path2,
1187                    int flag));
1188 # endif
1189 _GL_CXXALIASWARN (linkat);
1190 #elif defined GNULIB_POSIXCHECK
1191 # undef linkat
1192 # if HAVE_RAW_DECL_LINKAT
1193 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1194                  "use gnulib module linkat for portability");
1195 # endif
1196 #endif
1197
1198
1199 #if @GNULIB_LSEEK@
1200 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1201    Return the new offset if successful, otherwise -1 and errno set.
1202    See the POSIX:2008 specification
1203    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>.  */
1204 # if @REPLACE_LSEEK@
1205 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1206 #   define lseek rpl_lseek
1207 #  endif
1208 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1209 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1210 # else
1211 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1212 # endif
1213 _GL_CXXALIASWARN (lseek);
1214 #elif defined GNULIB_POSIXCHECK
1215 # undef lseek
1216 # if HAVE_RAW_DECL_LSEEK
1217 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1218                  "systems - use gnulib module lseek for portability");
1219 # endif
1220 #endif
1221
1222
1223 #if @GNULIB_PIPE@
1224 /* Create a pipe, defaulting to O_BINARY mode.
1225    Store the read-end as fd[0] and the write-end as fd[1].
1226    Return 0 upon success, or -1 with errno set upon failure.  */
1227 # if !@HAVE_PIPE@
1228 _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1229 # endif
1230 _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1231 _GL_CXXALIASWARN (pipe);
1232 #elif defined GNULIB_POSIXCHECK
1233 # undef pipe
1234 # if HAVE_RAW_DECL_PIPE
1235 _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1236                  "use gnulib module pipe-posix for portability");
1237 # endif
1238 #endif
1239
1240
1241 #if @GNULIB_PIPE2@
1242 /* Create a pipe, applying the given flags when opening the read-end of the
1243    pipe and the write-end of the pipe.
1244    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1245    and O_TEXT, O_BINARY (defined in "binary-io.h").
1246    Store the read-end as fd[0] and the write-end as fd[1].
1247    Return 0 upon success, or -1 with errno set upon failure.
1248    See also the Linux man page at
1249    <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
1250 # if @HAVE_PIPE2@
1251 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1252 #   define pipe2 rpl_pipe2
1253 #  endif
1254 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1255 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1256 # else
1257 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1258 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1259 # endif
1260 _GL_CXXALIASWARN (pipe2);
1261 #elif defined GNULIB_POSIXCHECK
1262 # undef pipe2
1263 # if HAVE_RAW_DECL_PIPE2
1264 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1265                  "use gnulib module pipe2 for portability");
1266 # endif
1267 #endif
1268
1269
1270 #if @GNULIB_PREAD@
1271 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1272    Return the number of bytes placed into BUF if successful, otherwise
1273    set errno and return -1.  0 indicates EOF.
1274    See the POSIX:2008 specification
1275    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>.  */
1276 # if @REPLACE_PREAD@
1277 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1278 #   undef pread
1279 #   define pread rpl_pread
1280 #  endif
1281 _GL_FUNCDECL_RPL (pread, ssize_t,
1282                   (int fd, void *buf, size_t bufsize, off_t offset)
1283                   _GL_ARG_NONNULL ((2)));
1284 _GL_CXXALIAS_RPL (pread, ssize_t,
1285                   (int fd, void *buf, size_t bufsize, off_t offset));
1286 # else
1287 #  if !@HAVE_PREAD@
1288 _GL_FUNCDECL_SYS (pread, ssize_t,
1289                   (int fd, void *buf, size_t bufsize, off_t offset)
1290                   _GL_ARG_NONNULL ((2)));
1291 #  endif
1292 _GL_CXXALIAS_SYS (pread, ssize_t,
1293                   (int fd, void *buf, size_t bufsize, off_t offset));
1294 # endif
1295 _GL_CXXALIASWARN (pread);
1296 #elif defined GNULIB_POSIXCHECK
1297 # undef pread
1298 # if HAVE_RAW_DECL_PREAD
1299 _GL_WARN_ON_USE (pread, "pread is unportable - "
1300                  "use gnulib module pread for portability");
1301 # endif
1302 #endif
1303
1304
1305 #if @GNULIB_PWRITE@
1306 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1307    Return the number of bytes written if successful, otherwise
1308    set errno and return -1.  0 indicates nothing written.  See the
1309    POSIX:2008 specification
1310    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>.  */
1311 # if @REPLACE_PWRITE@
1312 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1313 #   undef pwrite
1314 #   define pwrite rpl_pwrite
1315 #  endif
1316 _GL_FUNCDECL_RPL (pwrite, ssize_t,
1317                   (int fd, const void *buf, size_t bufsize, off_t offset)
1318                   _GL_ARG_NONNULL ((2)));
1319 _GL_CXXALIAS_RPL (pwrite, ssize_t,
1320                   (int fd, const void *buf, size_t bufsize, off_t offset));
1321 # else
1322 #  if !@HAVE_PWRITE@
1323 _GL_FUNCDECL_SYS (pwrite, ssize_t,
1324                   (int fd, const void *buf, size_t bufsize, off_t offset)
1325                   _GL_ARG_NONNULL ((2)));
1326 #  endif
1327 _GL_CXXALIAS_SYS (pwrite, ssize_t,
1328                   (int fd, const void *buf, size_t bufsize, off_t offset));
1329 # endif
1330 _GL_CXXALIASWARN (pwrite);
1331 #elif defined GNULIB_POSIXCHECK
1332 # undef pwrite
1333 # if HAVE_RAW_DECL_PWRITE
1334 _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1335                  "use gnulib module pwrite for portability");
1336 # endif
1337 #endif
1338
1339
1340 #if @GNULIB_READ@
1341 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1342    at BUF.  See the POSIX:2008 specification
1343    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>.  */
1344 # if @REPLACE_READ@
1345 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1346 #   undef read
1347 #   define read rpl_read
1348 #  endif
1349 _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1350                                  _GL_ARG_NONNULL ((2)));
1351 _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1352 # else
1353 /* Need to cast, because on mingw, the third parameter is
1354                                                           unsigned int count
1355    and the return type is 'int'.  */
1356 _GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1357 # endif
1358 _GL_CXXALIASWARN (read);
1359 #endif
1360
1361
1362 #if @GNULIB_READLINK@
1363 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1364    bytes of it into BUF.  Return the number of bytes placed into BUF if
1365    successful, otherwise -1 and errno set.
1366    See the POSIX:2008 specification
1367    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>.  */
1368 # if @REPLACE_READLINK@
1369 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1370 #   define readlink rpl_readlink
1371 #  endif
1372 _GL_FUNCDECL_RPL (readlink, ssize_t,
1373                   (const char *file, char *buf, size_t bufsize)
1374                   _GL_ARG_NONNULL ((1, 2)));
1375 _GL_CXXALIAS_RPL (readlink, ssize_t,
1376                   (const char *file, char *buf, size_t bufsize));
1377 # else
1378 #  if !@HAVE_READLINK@
1379 _GL_FUNCDECL_SYS (readlink, ssize_t,
1380                   (const char *file, char *buf, size_t bufsize)
1381                   _GL_ARG_NONNULL ((1, 2)));
1382 #  endif
1383 _GL_CXXALIAS_SYS (readlink, ssize_t,
1384                   (const char *file, char *buf, size_t bufsize));
1385 # endif
1386 _GL_CXXALIASWARN (readlink);
1387 #elif defined GNULIB_POSIXCHECK
1388 # undef readlink
1389 # if HAVE_RAW_DECL_READLINK
1390 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1391                  "use gnulib module readlink for portability");
1392 # endif
1393 #endif
1394
1395
1396 #if @GNULIB_READLINKAT@
1397 # if @REPLACE_READLINKAT@
1398 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1399 #   define readlinkat rpl_readlinkat
1400 #  endif
1401 _GL_FUNCDECL_RPL (readlinkat, ssize_t,
1402                   (int fd, char const *file, char *buf, size_t len)
1403                   _GL_ARG_NONNULL ((2, 3)));
1404 _GL_CXXALIAS_RPL (readlinkat, ssize_t,
1405                   (int fd, char const *file, char *buf, size_t len));
1406 # else
1407 #  if !@HAVE_READLINKAT@
1408 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
1409                   (int fd, char const *file, char *buf, size_t len)
1410                   _GL_ARG_NONNULL ((2, 3)));
1411 #  endif
1412 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1413                   (int fd, char const *file, char *buf, size_t len));
1414 # endif
1415 _GL_CXXALIASWARN (readlinkat);
1416 #elif defined GNULIB_POSIXCHECK
1417 # undef readlinkat
1418 # if HAVE_RAW_DECL_READLINKAT
1419 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1420                  "use gnulib module readlinkat for portability");
1421 # endif
1422 #endif
1423
1424
1425 #if @GNULIB_RMDIR@
1426 /* Remove the directory DIR.  */
1427 # if @REPLACE_RMDIR@
1428 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1429 #   define rmdir rpl_rmdir
1430 #  endif
1431 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1432 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1433 # else
1434 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1435 # endif
1436 _GL_CXXALIASWARN (rmdir);
1437 #elif defined GNULIB_POSIXCHECK
1438 # undef rmdir
1439 # if HAVE_RAW_DECL_RMDIR
1440 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1441                  "use gnulib module rmdir for portability");
1442 # endif
1443 #endif
1444
1445
1446 #if @GNULIB_SETHOSTNAME@
1447 /* Set the host name of the machine.
1448    The host name may or may not be fully qualified.
1449
1450    Put LEN bytes of NAME into the host name.
1451    Return 0 if successful, otherwise, set errno and return -1.
1452
1453    Platforms with no ability to set the hostname return -1 and set
1454    errno = ENOSYS.  */
1455 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1456 _GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
1457                                     _GL_ARG_NONNULL ((1)));
1458 # endif
1459 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1460    and FreeBSD 6.4 the second parameter is int.  On Solaris 11
1461    2011-10, the first parameter is not const.  */
1462 _GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
1463 _GL_CXXALIASWARN (sethostname);
1464 #elif defined GNULIB_POSIXCHECK
1465 # undef sethostname
1466 # if HAVE_RAW_DECL_SETHOSTNAME
1467 _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1468                  "use gnulib module sethostname for portability");
1469 # endif
1470 #endif
1471
1472
1473 #if @GNULIB_SLEEP@
1474 /* Pause the execution of the current thread for N seconds.
1475    Returns the number of seconds left to sleep.
1476    See the POSIX:2008 specification
1477    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>.  */
1478 # if @REPLACE_SLEEP@
1479 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1480 #   undef sleep
1481 #   define sleep rpl_sleep
1482 #  endif
1483 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1484 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1485 # else
1486 #  if !@HAVE_SLEEP@
1487 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1488 #  endif
1489 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1490 # endif
1491 _GL_CXXALIASWARN (sleep);
1492 #elif defined GNULIB_POSIXCHECK
1493 # undef sleep
1494 # if HAVE_RAW_DECL_SLEEP
1495 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1496                  "use gnulib module sleep for portability");
1497 # endif
1498 #endif
1499
1500
1501 #if @GNULIB_SYMLINK@
1502 # if @REPLACE_SYMLINK@
1503 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1504 #   undef symlink
1505 #   define symlink rpl_symlink
1506 #  endif
1507 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1508                                 _GL_ARG_NONNULL ((1, 2)));
1509 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1510 # else
1511 #  if !@HAVE_SYMLINK@
1512 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1513                                 _GL_ARG_NONNULL ((1, 2)));
1514 #  endif
1515 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1516 # endif
1517 _GL_CXXALIASWARN (symlink);
1518 #elif defined GNULIB_POSIXCHECK
1519 # undef symlink
1520 # if HAVE_RAW_DECL_SYMLINK
1521 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1522                  "use gnulib module symlink for portability");
1523 # endif
1524 #endif
1525
1526
1527 #if @GNULIB_SYMLINKAT@
1528 # if @REPLACE_SYMLINKAT@
1529 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1530 #   undef symlinkat
1531 #   define symlinkat rpl_symlinkat
1532 #  endif
1533 _GL_FUNCDECL_RPL (symlinkat, int,
1534                   (char const *contents, int fd, char const *file)
1535                   _GL_ARG_NONNULL ((1, 3)));
1536 _GL_CXXALIAS_RPL (symlinkat, int,
1537                   (char const *contents, int fd, char const *file));
1538 # else
1539 #  if !@HAVE_SYMLINKAT@
1540 _GL_FUNCDECL_SYS (symlinkat, int,
1541                   (char const *contents, int fd, char const *file)
1542                   _GL_ARG_NONNULL ((1, 3)));
1543 #  endif
1544 _GL_CXXALIAS_SYS (symlinkat, int,
1545                   (char const *contents, int fd, char const *file));
1546 # endif
1547 _GL_CXXALIASWARN (symlinkat);
1548 #elif defined GNULIB_POSIXCHECK
1549 # undef symlinkat
1550 # if HAVE_RAW_DECL_SYMLINKAT
1551 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1552                  "use gnulib module symlinkat for portability");
1553 # endif
1554 #endif
1555
1556
1557 #if @GNULIB_TRUNCATE@
1558 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
1559    Return 0 if successful, otherwise -1 and errno set.
1560    See the POSIX:2008 specification
1561    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>.  */
1562 # if @REPLACE_TRUNCATE@
1563 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1564 #   undef truncate
1565 #   define truncate rpl_truncate
1566 #  endif
1567 _GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
1568                                  _GL_ARG_NONNULL ((1)));
1569 _GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
1570 # else
1571 #  if !@HAVE_DECL_TRUNCATE@
1572 _GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
1573                                  _GL_ARG_NONNULL ((1)));
1574 #  endif
1575 _GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
1576 # endif
1577 _GL_CXXALIASWARN (truncate);
1578 #elif defined GNULIB_POSIXCHECK
1579 # undef truncate
1580 # if HAVE_RAW_DECL_TRUNCATE
1581 _GL_WARN_ON_USE (truncate, "truncate is unportable - "
1582                  "use gnulib module truncate for portability");
1583 # endif
1584 #endif
1585
1586
1587 #if @GNULIB_TTYNAME_R@
1588 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1589    open on in BUF.  Return 0 on success, otherwise an error number.  */
1590 # if @REPLACE_TTYNAME_R@
1591 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1592 #   undef ttyname_r
1593 #   define ttyname_r rpl_ttyname_r
1594 #  endif
1595 _GL_FUNCDECL_RPL (ttyname_r, int,
1596                   (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1597 _GL_CXXALIAS_RPL (ttyname_r, int,
1598                   (int fd, char *buf, size_t buflen));
1599 # else
1600 #  if !@HAVE_DECL_TTYNAME_R@
1601 _GL_FUNCDECL_SYS (ttyname_r, int,
1602                   (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1603 #  endif
1604 _GL_CXXALIAS_SYS (ttyname_r, int,
1605                   (int fd, char *buf, size_t buflen));
1606 # endif
1607 _GL_CXXALIASWARN (ttyname_r);
1608 #elif defined GNULIB_POSIXCHECK
1609 # undef ttyname_r
1610 # if HAVE_RAW_DECL_TTYNAME_R
1611 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1612                  "use gnulib module ttyname_r for portability");
1613 # endif
1614 #endif
1615
1616
1617 #if @GNULIB_UNLINK@
1618 # if @REPLACE_UNLINK@
1619 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1620 #   undef unlink
1621 #   define unlink rpl_unlink
1622 #  endif
1623 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1624 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
1625 # else
1626 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
1627 # endif
1628 _GL_CXXALIASWARN (unlink);
1629 #elif defined GNULIB_POSIXCHECK
1630 # undef unlink
1631 # if HAVE_RAW_DECL_UNLINK
1632 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
1633                  "use gnulib module unlink for portability");
1634 # endif
1635 #endif
1636
1637
1638 #if @GNULIB_UNLINKAT@
1639 # if @REPLACE_UNLINKAT@
1640 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1641 #   undef unlinkat
1642 #   define unlinkat rpl_unlinkat
1643 #  endif
1644 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1645                                  _GL_ARG_NONNULL ((2)));
1646 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1647 # else
1648 #  if !@HAVE_UNLINKAT@
1649 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1650                                  _GL_ARG_NONNULL ((2)));
1651 #  endif
1652 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1653 # endif
1654 _GL_CXXALIASWARN (unlinkat);
1655 #elif defined GNULIB_POSIXCHECK
1656 # undef unlinkat
1657 # if HAVE_RAW_DECL_UNLINKAT
1658 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1659                  "use gnulib module openat for portability");
1660 # endif
1661 #endif
1662
1663
1664 #if @GNULIB_USLEEP@
1665 /* Pause the execution of the current thread for N microseconds.
1666    Returns 0 on completion, or -1 on range error.
1667    See the POSIX:2001 specification
1668    <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>.  */
1669 # if @REPLACE_USLEEP@
1670 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1671 #   undef usleep
1672 #   define usleep rpl_usleep
1673 #  endif
1674 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1675 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1676 # else
1677 #  if !@HAVE_USLEEP@
1678 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1679 #  endif
1680 /* Need to cast, because on Haiku, the first parameter is
1681                                      unsigned int n.  */
1682 _GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n));
1683 # endif
1684 _GL_CXXALIASWARN (usleep);
1685 #elif defined GNULIB_POSIXCHECK
1686 # undef usleep
1687 # if HAVE_RAW_DECL_USLEEP
1688 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1689                  "use gnulib module usleep for portability");
1690 # endif
1691 #endif
1692
1693
1694 #if @GNULIB_WRITE@
1695 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1696    See the POSIX:2008 specification
1697    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>.  */
1698 # if @REPLACE_WRITE@
1699 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1700 #   undef write
1701 #   define write rpl_write
1702 #  endif
1703 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1704                                   _GL_ARG_NONNULL ((2)));
1705 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1706 # else
1707 /* Need to cast, because on mingw, the third parameter is
1708                                                              unsigned int count
1709    and the return type is 'int'.  */
1710 _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1711 # endif
1712 _GL_CXXALIASWARN (write);
1713 #endif
1714
1715 _GL_INLINE_HEADER_END
1716
1717 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1718 #endif /* _GL_INCLUDING_UNISTD_H */
1719 #endif /* _@GUARD_PREFIX@_UNISTD_H */