1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file 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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser 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 /* Avoid lseek bugs in FreeBSD, macOS <https://bugs.gnu.org/61386>.
44 This bug is fixed after FreeBSD 13; see <https://bugs.freebsd.org/256205>.
45 Use macOS "9999" to stand for a future fixed macOS version. */
46 #if defined __FreeBSD__ && __FreeBSD__ < 14
47 # undef SEEK_DATA
48 # undef SEEK_HOLE
49 #elif defined __APPLE__ && defined __MACH__ && defined SEEK_DATA
50 # ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
51 # include <AvailabilityMacros.h>
52 # endif
53 # if (!defined MAC_OS_X_VERSION_MIN_REQUIRED \
54 || MAC_OS_X_VERSION_MIN_REQUIRED < 99990000)
55 # include <sys/fcntl.h> /* It also defines the two macros. */
56 # undef SEEK_DATA
57 # undef SEEK_HOLE
58 # endif
59 #endif
60
61 /* Get all possible declarations of gethostname(). */
62 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
63 && !defined _GL_INCLUDING_WINSOCK2_H
64 # define _GL_INCLUDING_WINSOCK2_H
65 # include <winsock2.h>
66 # undef _GL_INCLUDING_WINSOCK2_H
67 #endif
68
69 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
70 #define _@GUARD_PREFIX@_UNISTD_H
71
72 /* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK,
73 HAVE_RAW_DECL_*. */
74 #if !_GL_CONFIG_H_INCLUDED
75 #error "Please include config.h first."
76 #endif
77
78 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
79 /* But avoid namespace pollution on glibc systems. */
80 #ifndef __GLIBC__
81 # include <stddef.h>
82 #endif
83
84 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
85 /* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>. We must include
86 it before we #define unlink rpl_unlink. */
87 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
88 /* But avoid namespace pollution on glibc systems. */
89 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
90 || ((@GNULIB_UNLINK@ || defined GNULIB_POSIXCHECK) \
91 && (defined _WIN32 && ! defined __CYGWIN__)) \
92 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
93 && defined __CYGWIN__)) \
94 && ! defined __GLIBC__
95 # include <stdio.h>
96 #endif
97
98 /* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
99 <unistd.h>. */
100 /* But avoid namespace pollution on glibc systems. */
101 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
102 && (defined __CYGWIN__ || defined __ANDROID__) \
103 && ! defined __GLIBC__
104 # include <fcntl.h>
105 #endif
106
107 /* mingw fails to declare _exit in <unistd.h>. */
108 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
109 <unistd.h>. */
110 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
111 /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
112 included here. */
113 /* But avoid namespace pollution on glibc systems. */
114 #if !defined __GLIBC__ && !defined __osf__
115 # define __need_system_stdlib_h
116 # include <stdlib.h>
117 # undef __need_system_stdlib_h
118 #endif
119
120 /* Native Windows platforms declare _chdir, _getcwd, _rmdir in
121 <io.h> and/or <direct.h>, not in <unistd.h>.
122 They also declare _access(), _chmod(), _close(), _dup(), _dup2(), _isatty(),
123 _lseek(), _read(), _unlink(), _write() in <io.h>. */
124 #if defined _WIN32 && !defined __CYGWIN__
125 # include <io.h>
126 # include <direct.h>
127 #endif
128
129 /* Native Windows platforms declare _execl*, _execv* in <process.h>. */
130 #if defined _WIN32 && !defined __CYGWIN__
131 # include <process.h>
132 #endif
133
134 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
135 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
136 /* But avoid namespace pollution on glibc systems. */
137 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
138 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
139 && !defined __GLIBC__
140 # include <netdb.h>
141 #endif
142
143 /* Mac OS X 10.13, Solaris 11.4, and Android 9.0 declare getentropy in
144 <sys/random.h>, not in <unistd.h>. */
145 /* But avoid namespace pollution on glibc systems. */
146 #if (@GNULIB_GETENTROPY@ || defined GNULIB_POSIXCHECK) \
147 && ((defined __APPLE__ && defined __MACH__) || defined __sun \
148 || defined __ANDROID__) \
149 && @UNISTD_H_HAVE_SYS_RANDOM_H@ \
150 && !defined __GLIBC__
151 # include <sys/random.h>
152 #endif
153
154 /* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>. */
155 /* But avoid namespace pollution on glibc systems. */
156 #if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
157 && !defined __GLIBC__
158 # include <sys/stat.h>
159 #endif
160
161 /* MSVC defines off_t in <sys/types.h>.
162 May also define off_t to a 64-bit type on native Windows. */
163 /* Get off_t, ssize_t, mode_t. */
164 #include <sys/types.h>
165
166 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
167
168 /* The definition of _GL_ARG_NONNULL is copied here. */
169
170 /* The definition of _GL_WARN_ON_USE is copied here. */
171
172
173 /* Get getopt(), optarg, optind, opterr, optopt. */
174 /* Also, don't include <getopt.h> inside libgettextpo, because we use
175 the getopt module only in gettext-tools/gnulib-lib/, not in
176 gettext-tools/libgettextpo/, but there is only a single
177 GNULIB_UNISTD_H_GETOPT variable for both. */
178 #if @GNULIB_GETOPT_POSIX@ && @GNULIB_UNISTD_H_GETOPT@ && !defined GTPO_CONFIG_H && !defined _GL_SYSTEM_GETOPT
179 # include <getopt-cdefs.h>
180 # include <getopt-pfx-core.h>
181 #endif
182
183 _GL_INLINE_HEADER_BEGIN
184 #ifndef _GL_UNISTD_INLINE
185 # define _GL_UNISTD_INLINE _GL_INLINE
186 #endif
187
188 /* Hide some function declarations from <winsock2.h>. */
189
190 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
191 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
192 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
193 # undef socket
194 # define socket socket_used_without_including_sys_socket_h
195 # undef connect
196 # define connect connect_used_without_including_sys_socket_h
197 # undef accept
198 # define accept accept_used_without_including_sys_socket_h
199 # undef bind
200 # define bind bind_used_without_including_sys_socket_h
201 # undef getpeername
202 # define getpeername getpeername_used_without_including_sys_socket_h
203 # undef getsockname
204 # define getsockname getsockname_used_without_including_sys_socket_h
205 # undef getsockopt
206 # define getsockopt getsockopt_used_without_including_sys_socket_h
207 # undef listen
208 # define listen listen_used_without_including_sys_socket_h
209 # undef recv
210 # define recv recv_used_without_including_sys_socket_h
211 # undef send
212 # define send send_used_without_including_sys_socket_h
213 # undef recvfrom
214 # define recvfrom recvfrom_used_without_including_sys_socket_h
215 # undef sendto
216 # define sendto sendto_used_without_including_sys_socket_h
217 # undef setsockopt
218 # define setsockopt setsockopt_used_without_including_sys_socket_h
219 # undef shutdown
220 # define shutdown shutdown_used_without_including_sys_socket_h
221 # else
222 _GL_WARN_ON_USE (socket,
223 "socket() used without including <sys/socket.h>");
224 _GL_WARN_ON_USE (connect,
225 "connect() used without including <sys/socket.h>");
226 _GL_WARN_ON_USE (accept,
227 "accept() used without including <sys/socket.h>");
228 _GL_WARN_ON_USE (bind,
229 "bind() used without including <sys/socket.h>");
230 _GL_WARN_ON_USE (getpeername,
231 "getpeername() used without including <sys/socket.h>");
232 _GL_WARN_ON_USE (getsockname,
233 "getsockname() used without including <sys/socket.h>");
234 _GL_WARN_ON_USE (getsockopt,
235 "getsockopt() used without including <sys/socket.h>");
236 _GL_WARN_ON_USE (listen,
237 "listen() used without including <sys/socket.h>");
238 _GL_WARN_ON_USE (recv,
239 "recv() used without including <sys/socket.h>");
240 _GL_WARN_ON_USE (send,
241 "send() used without including <sys/socket.h>");
242 _GL_WARN_ON_USE (recvfrom,
243 "recvfrom() used without including <sys/socket.h>");
244 _GL_WARN_ON_USE (sendto,
245 "sendto() used without including <sys/socket.h>");
246 _GL_WARN_ON_USE (setsockopt,
247 "setsockopt() used without including <sys/socket.h>");
248 _GL_WARN_ON_USE (shutdown,
249 "shutdown() used without including <sys/socket.h>");
250 # endif
251 # endif
252 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
253 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
254 # undef select
255 # define select select_used_without_including_sys_select_h
256 # else
257 _GL_WARN_ON_USE (select,
258 "select() used without including <sys/select.h>");
259 # endif
260 # endif
261 #endif
262
263
264 /* OS/2 EMX lacks these macros. */
265 #ifndef STDIN_FILENO
266 # define STDIN_FILENO 0
267 #endif
268 #ifndef STDOUT_FILENO
269 # define STDOUT_FILENO 1
270 #endif
271 #ifndef STDERR_FILENO
272 # define STDERR_FILENO 2
273 #endif
274
275 /* Ensure *_OK macros exist. */
276 #ifndef F_OK
277 # define F_OK 0
278 # define X_OK 1
279 # define W_OK 2
280 # define R_OK 4
281 #endif
282
283
284 /* Declare overridden functions. */
285
286
287 #if @GNULIB_ACCESS@
288 # if @REPLACE_ACCESS@
289 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
290 # undef access
291 # define access rpl_access
292 # endif
293 _GL_FUNCDECL_RPL (access, int, (const char *file, int mode)
294 _GL_ARG_NONNULL ((1)));
295 _GL_CXXALIAS_RPL (access, int, (const char *file, int mode));
296 # elif defined _WIN32 && !defined __CYGWIN__
297 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
298 # undef access
299 # define access _access
300 # endif
301 _GL_CXXALIAS_MDA (access, int, (const char *file, int mode));
302 # else
303 _GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
304 # endif
305 _GL_CXXALIASWARN (access);
306 #elif defined GNULIB_POSIXCHECK
307 # undef access
308 # if HAVE_RAW_DECL_ACCESS
309 /* The access() function is a security risk. */
310 _GL_WARN_ON_USE (access, "access does not always support X_OK - "
311 "use gnulib module access for portability; "
312 "also, this function is a security risk - "
313 "use the gnulib module faccessat instead");
314 # endif
315 #elif @GNULIB_MDA_ACCESS@
316 /* On native Windows, map 'access' to '_access', so that -loldnames is not
317 required. In C++ with GNULIB_NAMESPACE, avoid differences between
318 platforms by defining GNULIB_NAMESPACE::access always. */
319 # if defined _WIN32 && !defined __CYGWIN__
320 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
321 # undef access
322 # define access _access
323 # endif
324 _GL_CXXALIAS_MDA (access, int, (const char *file, int mode));
325 # else
326 _GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
327 # endif
328 _GL_CXXALIASWARN (access);
329 #endif
330
331
332 #if @GNULIB_CHDIR@
333 # if defined _WIN32 && !defined __CYGWIN__
334 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
335 # undef chdir
336 # define chdir _chdir
337 # endif
338 _GL_CXXALIAS_MDA (chdir, int, (const char *file));
339 # else
340 _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
341 # endif
342 _GL_CXXALIASWARN (chdir);
343 #elif defined GNULIB_POSIXCHECK
344 # undef chdir
345 # if HAVE_RAW_DECL_CHDIR
346 _GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
347 "use gnulib module chdir for portability");
348 # endif
349 #elif @GNULIB_MDA_CHDIR@
350 /* On native Windows, map 'chdir' to '_chdir', so that -loldnames is not
351 required. In C++ with GNULIB_NAMESPACE, avoid differences between
352 platforms by defining GNULIB_NAMESPACE::chdir always. */
353 # if defined _WIN32 && !defined __CYGWIN__
354 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
355 # undef chdir
356 # define chdir _chdir
357 # endif
358 _GL_CXXALIAS_MDA (chdir, int, (const char *file));
359 # else
360 _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
361 # endif
362 _GL_CXXALIASWARN (chdir);
363 #endif
364
365
366 #if @GNULIB_CHOWN@
367 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
368 to GID (if GID is not -1). Follow symbolic links.
369 Return 0 if successful, otherwise -1 and errno set.
370 See the POSIX:2008 specification
371 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
372 # if @REPLACE_CHOWN@
373 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
374 # undef chown
375 # define chown rpl_chown
376 # endif
377 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
378 _GL_ARG_NONNULL ((1)));
379 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
380 # else
381 # if !@HAVE_CHOWN@
382 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
383 _GL_ARG_NONNULL ((1)));
384 # endif
385 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
386 # endif
387 _GL_CXXALIASWARN (chown);
388 #elif defined GNULIB_POSIXCHECK
389 # undef chown
390 # if HAVE_RAW_DECL_CHOWN
391 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
392 "doesn't treat a uid or gid of -1 on some systems - "
393 "use gnulib module chown for portability");
394 # endif
395 #endif
396
397
398 #if @GNULIB_CLOSE@
399 # if @REPLACE_CLOSE@
400 /* Automatically included by modules that need a replacement for close. */
401 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
402 # undef close
403 # define close rpl_close
404 # endif
405 _GL_FUNCDECL_RPL (close, int, (int fd));
406 _GL_CXXALIAS_RPL (close, int, (int fd));
407 # elif defined _WIN32 && !defined __CYGWIN__
408 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
409 # undef close
410 # define close _close
411 # endif
412 _GL_CXXALIAS_MDA (close, int, (int fd));
413 # else
414 _GL_CXXALIAS_SYS (close, int, (int fd));
415 # endif
416 _GL_CXXALIASWARN (close);
417 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
418 # undef close
419 # define close close_used_without_requesting_gnulib_module_close
420 #elif defined GNULIB_POSIXCHECK
421 # undef close
422 /* Assume close is always declared. */
423 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
424 "use gnulib module close for portability");
425 #elif @GNULIB_MDA_CLOSE@
426 /* On native Windows, map 'close' to '_close', so that -loldnames is not
427 required. In C++ with GNULIB_NAMESPACE, avoid differences between
428 platforms by defining GNULIB_NAMESPACE::close always. */
429 # if defined _WIN32 && !defined __CYGWIN__
430 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
431 # undef close
432 # define close _close
433 # endif
434 _GL_CXXALIAS_MDA (close, int, (int fd));
435 # else
436 _GL_CXXALIAS_SYS (close, int, (int fd));
437 # endif
438 _GL_CXXALIASWARN (close);
439 #endif
440
441
442 #if @GNULIB_COPY_FILE_RANGE@
443 # if @REPLACE_COPY_FILE_RANGE@
444 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
445 # undef copy_file_range
446 # define copy_file_range rpl_copy_file_range
447 # endif
448 _GL_FUNCDECL_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
449 int ofd, off_t *opos,
450 size_t len, unsigned flags));
451 _GL_CXXALIAS_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
452 int ofd, off_t *opos,
453 size_t len, unsigned flags));
454 # else
455 # if !@HAVE_COPY_FILE_RANGE@
456 _GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
457 int ofd, off_t *opos,
458 size_t len, unsigned flags));
459 # endif
460 _GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
461 int ofd, off_t *opos,
462 size_t len, unsigned flags));
463 # endif
464 _GL_CXXALIASWARN (copy_file_range);
465 #elif defined GNULIB_POSIXCHECK
466 # undef copy_file_range
467 # if HAVE_RAW_DECL_COPY_FILE_RANGE
468 _GL_WARN_ON_USE (copy_file_range,
469 "copy_file_range is unportable - "
470 "use gnulib module copy_file_range for portability");
471 # endif
472 #endif
473
474
475 #if @GNULIB_DUP@
476 # if @REPLACE_DUP@
477 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
478 # define dup rpl_dup
479 # endif
480 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
481 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
482 # elif defined _WIN32 && !defined __CYGWIN__
483 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
484 # undef dup
485 # define dup _dup
486 # endif
487 _GL_CXXALIAS_MDA (dup, int, (int oldfd));
488 # else
489 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
490 # endif
491 _GL_CXXALIASWARN (dup);
492 #elif defined GNULIB_POSIXCHECK
493 # undef dup
494 # if HAVE_RAW_DECL_DUP
495 _GL_WARN_ON_USE (dup, "dup is unportable - "
496 "use gnulib module dup for portability");
497 # endif
498 #elif @GNULIB_MDA_DUP@
499 /* On native Windows, map 'dup' to '_dup', so that -loldnames is not
500 required. In C++ with GNULIB_NAMESPACE, avoid differences between
501 platforms by defining GNULIB_NAMESPACE::dup always. */
502 # if defined _WIN32 && !defined __CYGWIN__
503 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
504 # undef dup
505 # define dup _dup
506 # endif
507 _GL_CXXALIAS_MDA (dup, int, (int oldfd));
508 # else
509 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
510 # endif
511 _GL_CXXALIASWARN (dup);
512 #endif
513
514
515 #if @GNULIB_DUP2@
516 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
517 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
518 Return newfd if successful, otherwise -1 and errno set.
519 See the POSIX:2008 specification
520 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
521 # if @REPLACE_DUP2@
522 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
523 # define dup2 rpl_dup2
524 # endif
525 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
526 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
527 # elif defined _WIN32 && !defined __CYGWIN__
528 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
529 # undef dup2
530 # define dup2 _dup2
531 # endif
532 _GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
533 # else
534 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
535 # endif
536 _GL_CXXALIASWARN (dup2);
537 #elif defined GNULIB_POSIXCHECK
538 # undef dup2
539 # if HAVE_RAW_DECL_DUP2
540 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
541 "use gnulib module dup2 for portability");
542 # endif
543 #elif @GNULIB_MDA_DUP2@
544 /* On native Windows, map 'dup2' to '_dup2', so that -loldnames is not
545 required. In C++ with GNULIB_NAMESPACE, avoid differences between
546 platforms by defining GNULIB_NAMESPACE::dup2 always. */
547 # if defined _WIN32 && !defined __CYGWIN__
548 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
549 # undef dup2
550 # define dup2 _dup2
551 # endif
552 _GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
553 # else
554 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
555 # endif
556 _GL_CXXALIASWARN (dup2);
557 #endif
558
559
560 #if @GNULIB_DUP3@
561 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
562 specified flags.
563 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
564 and O_TEXT, O_BINARY (defined in "binary-io.h").
565 Close NEWFD first if it is open.
566 Return newfd if successful, otherwise -1 and errno set.
567 See the Linux man page at
568 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
569 # if @REPLACE_DUP3@
570 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
571 # undef dup3
572 # define dup3 rpl_dup3
573 # endif
574 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
575 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
576 # else
577 # if !@HAVE_DUP3@
578 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
579 # endif
580 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
581 # endif
582 # if __GLIBC__ >= 2
583 _GL_CXXALIASWARN (dup3);
584 # endif
585 #elif defined GNULIB_POSIXCHECK
586 # undef dup3
587 # if HAVE_RAW_DECL_DUP3
588 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
589 "use gnulib module dup3 for portability");
590 # endif
591 #endif
592
593
594 #if @GNULIB_ENVIRON@
595 # if defined __CYGWIN__ && !defined __i386__
596 /* The 'environ' variable is defined in a DLL. Therefore its declaration needs
597 the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
598 This leads to a link error on 64-bit Cygwin when the option
599 -Wl,--disable-auto-import is in use. */
600 _GL_EXTERN_C __declspec(dllimport) char **environ;
601 # endif
602 # if !@HAVE_DECL_ENVIRON@
603 /* Set of environment variables and values. An array of strings of the form
604 "VARIABLE=VALUE", terminated with a NULL. */
605 # if defined __APPLE__ && defined __MACH__
606 # include <TargetConditionals.h>
607 # if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
608 # define _GL_USE_CRT_EXTERNS
609 # endif
610 # endif
611 # ifdef _GL_USE_CRT_EXTERNS
612 # include <crt_externs.h>
613 # define environ (*_NSGetEnviron ())
614 # else
615 # ifdef __cplusplus
616 extern "C" {
617 # endif
618 extern char **environ;
619 # ifdef __cplusplus
620 }
621 # endif
622 # endif
623 # endif
624 #elif defined GNULIB_POSIXCHECK
625 # if HAVE_RAW_DECL_ENVIRON
626 _GL_UNISTD_INLINE char ***
627 _GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
628 "use gnulib module environ for portability")
629 rpl_environ (void)
630 {
631 return &environ;
632 }
633 # undef environ
634 # define environ (*rpl_environ ())
635 # endif
636 #endif
637
638
639 #if @GNULIB_EUIDACCESS@
640 /* Like access(), except that it uses the effective user id and group id of
641 the current process. */
642 # if !@HAVE_EUIDACCESS@
643 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
644 _GL_ARG_NONNULL ((1)));
645 # endif
646 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
647 _GL_CXXALIASWARN (euidaccess);
648 # if defined GNULIB_POSIXCHECK
649 /* Like access(), this function is a security risk. */
650 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
651 "use the gnulib module faccessat instead");
652 # endif
653 #elif defined GNULIB_POSIXCHECK
654 # undef euidaccess
655 # if HAVE_RAW_DECL_EUIDACCESS
656 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
657 "use gnulib module euidaccess for portability");
658 # endif
659 #endif
660
661
662 #if @GNULIB_EXECL@
663 # if @REPLACE_EXECL@
664 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
665 # undef execl
666 # define execl rpl_execl
667 # endif
668 _GL_FUNCDECL_RPL (execl, int, (const char *program, const char *arg, ...)
669 _GL_ARG_NONNULL ((1)));
670 _GL_CXXALIAS_RPL (execl, int, (const char *program, const char *arg, ...));
671 # else
672 _GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
673 # endif
674 _GL_CXXALIASWARN (execl);
675 #elif defined GNULIB_POSIXCHECK
676 # undef execl
677 # if HAVE_RAW_DECL_EXECL
678 _GL_WARN_ON_USE (execl, "execl behaves very differently on mingw - "
679 "use gnulib module execl for portability");
680 # endif
681 #elif @GNULIB_MDA_EXECL@
682 /* On native Windows, map 'execl' to '_execl', so that -loldnames is not
683 required. In C++ with GNULIB_NAMESPACE, avoid differences between
684 platforms by defining GNULIB_NAMESPACE::execl always. */
685 # if defined _WIN32 && !defined __CYGWIN__
686 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
687 # undef execl
688 # define execl _execl
689 # endif
690 _GL_CXXALIAS_MDA (execl, intptr_t, (const char *program, const char *arg, ...));
691 # else
692 _GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
693 # endif
694 _GL_CXXALIASWARN (execl);
695 #endif
696
697 #if @GNULIB_EXECLE@
698 # if @REPLACE_EXECLE@
699 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
700 # undef execle
701 # define execle rpl_execle
702 # endif
703 _GL_FUNCDECL_RPL (execle, int, (const char *program, const char *arg, ...)
704 _GL_ARG_NONNULL ((1)));
705 _GL_CXXALIAS_RPL (execle, int, (const char *program, const char *arg, ...));
706 # else
707 _GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
708 # endif
709 _GL_CXXALIASWARN (execle);
710 #elif defined GNULIB_POSIXCHECK
711 # undef execle
712 # if HAVE_RAW_DECL_EXECLE
713 _GL_WARN_ON_USE (execle, "execle behaves very differently on mingw - "
714 "use gnulib module execle for portability");
715 # endif
716 #elif @GNULIB_MDA_EXECLE@
717 /* On native Windows, map 'execle' to '_execle', so that -loldnames is not
718 required. In C++ with GNULIB_NAMESPACE, avoid differences between
719 platforms by defining GNULIB_NAMESPACE::execle always. */
720 # if defined _WIN32 && !defined __CYGWIN__
721 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
722 # undef execle
723 # define execle _execle
724 # endif
725 _GL_CXXALIAS_MDA (execle, intptr_t,
726 (const char *program, const char *arg, ...));
727 # else
728 _GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
729 # endif
730 _GL_CXXALIASWARN (execle);
731 #endif
732
733 #if @GNULIB_EXECLP@
734 # if @REPLACE_EXECLP@
735 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
736 # undef execlp
737 # define execlp rpl_execlp
738 # endif
739 _GL_FUNCDECL_RPL (execlp, int, (const char *program, const char *arg, ...)
740 _GL_ARG_NONNULL ((1)));
741 _GL_CXXALIAS_RPL (execlp, int, (const char *program, const char *arg, ...));
742 # else
743 _GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
744 # endif
745 _GL_CXXALIASWARN (execlp);
746 #elif defined GNULIB_POSIXCHECK
747 # undef execlp
748 # if HAVE_RAW_DECL_EXECLP
749 _GL_WARN_ON_USE (execlp, "execlp behaves very differently on mingw - "
750 "use gnulib module execlp for portability");
751 # endif
752 #elif @GNULIB_MDA_EXECLP@
753 /* On native Windows, map 'execlp' to '_execlp', so that -loldnames is not
754 required. In C++ with GNULIB_NAMESPACE, avoid differences between
755 platforms by defining GNULIB_NAMESPACE::execlp always. */
756 # if defined _WIN32 && !defined __CYGWIN__
757 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
758 # undef execlp
759 # define execlp _execlp
760 # endif
761 _GL_CXXALIAS_MDA (execlp, intptr_t,
762 (const char *program, const char *arg, ...));
763 # else
764 _GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
765 # endif
766 _GL_CXXALIASWARN (execlp);
767 #endif
768
769
770 #if @GNULIB_EXECV@
771 # if @REPLACE_EXECV@
772 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
773 # undef execv
774 # define execv rpl_execv
775 # endif
776 _GL_FUNCDECL_RPL (execv, int, (const char *program, char * const *argv)
777 _GL_ARG_NONNULL ((1, 2)));
778 _GL_CXXALIAS_RPL (execv, int, (const char *program, char * const *argv));
779 # else
780 _GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
781 # endif
782 _GL_CXXALIASWARN (execv);
783 #elif defined GNULIB_POSIXCHECK
784 # undef execv
785 # if HAVE_RAW_DECL_EXECV
786 _GL_WARN_ON_USE (execv, "execv behaves very differently on mingw - "
787 "use gnulib module execv for portability");
788 # endif
789 #elif @GNULIB_MDA_EXECV@
790 /* On native Windows, map 'execv' to '_execv', so that -loldnames is not
791 required. In C++ with GNULIB_NAMESPACE, avoid differences between
792 platforms by defining GNULIB_NAMESPACE::execv always. */
793 # if defined _WIN32 && !defined __CYGWIN__
794 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
795 # undef execv
796 # define execv _execv
797 # endif
798 _GL_CXXALIAS_MDA_CAST (execv, intptr_t,
799 (const char *program, char * const *argv));
800 # else
801 _GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
802 # endif
803 _GL_CXXALIASWARN (execv);
804 #endif
805
806 #if @GNULIB_EXECVE@
807 # if @REPLACE_EXECVE@
808 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
809 # undef execve
810 # define execve rpl_execve
811 # endif
812 _GL_FUNCDECL_RPL (execve, int,
813 (const char *program, char * const *argv, char * const *env)
814 _GL_ARG_NONNULL ((1, 2)));
815 _GL_CXXALIAS_RPL (execve, int,
816 (const char *program, char * const *argv, char * const *env));
817 # else
818 _GL_CXXALIAS_SYS (execve, int,
819 (const char *program, char * const *argv, char * const *env));
820 # endif
821 _GL_CXXALIASWARN (execve);
822 #elif defined GNULIB_POSIXCHECK
823 # undef execve
824 # if HAVE_RAW_DECL_EXECVE
825 _GL_WARN_ON_USE (execve, "execve behaves very differently on mingw - "
826 "use gnulib module execve for portability");
827 # endif
828 #elif @GNULIB_MDA_EXECVE@
829 /* On native Windows, map 'execve' to '_execve', so that -loldnames is not
830 required. In C++ with GNULIB_NAMESPACE, avoid differences between
831 platforms by defining GNULIB_NAMESPACE::execve always. */
832 # if defined _WIN32 && !defined __CYGWIN__
833 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
834 # undef execve
835 # define execve _execve
836 # endif
837 _GL_CXXALIAS_MDA_CAST (execve, intptr_t,
838 (const char *program, char * const *argv,
839 char * const *env));
840 # else
841 _GL_CXXALIAS_SYS (execve, int,
842 (const char *program, char * const *argv, char * const *env));
843 # endif
844 _GL_CXXALIASWARN (execve);
845 #endif
846
847 #if @GNULIB_EXECVP@
848 # if @REPLACE_EXECVP@
849 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
850 # undef execvp
851 # define execvp rpl_execvp
852 # endif
853 _GL_FUNCDECL_RPL (execvp, int, (const char *program, char * const *argv)
854 _GL_ARG_NONNULL ((1, 2)));
855 _GL_CXXALIAS_RPL (execvp, int, (const char *program, char * const *argv));
856 # else
857 _GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
858 # endif
859 _GL_CXXALIASWARN (execvp);
860 #elif defined GNULIB_POSIXCHECK
861 # undef execvp
862 # if HAVE_RAW_DECL_EXECVP
863 _GL_WARN_ON_USE (execvp, "execvp behaves very differently on mingw - "
864 "use gnulib module execvp for portability");
865 # endif
866 #elif @GNULIB_MDA_EXECVP@
867 /* On native Windows, map 'execvp' to '_execvp', so that -loldnames is not
868 required. In C++ with GNULIB_NAMESPACE, avoid differences between
869 platforms by defining GNULIB_NAMESPACE::execvp always. */
870 # if defined _WIN32 && !defined __CYGWIN__
871 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
872 # undef execvp
873 # define execvp _execvp
874 # endif
875 _GL_CXXALIAS_MDA_CAST (execvp, intptr_t,
876 (const char *program, char * const *argv));
877 # else
878 _GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
879 # endif
880 _GL_CXXALIASWARN (execvp);
881 #endif
882
883 #if @GNULIB_EXECVPE@
884 # if @REPLACE_EXECVPE@
885 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
886 # undef execvpe
887 # define execvpe rpl_execvpe
888 # endif
889 _GL_FUNCDECL_RPL (execvpe, int,
890 (const char *program, char * const *argv, char * const *env)
891 _GL_ARG_NONNULL ((1, 2)));
892 _GL_CXXALIAS_RPL (execvpe, int,
893 (const char *program, char * const *argv, char * const *env));
894 # else
895 # if !@HAVE_DECL_EXECVPE@
896 _GL_FUNCDECL_SYS (execvpe, int,
897 (const char *program, char * const *argv, char * const *env)
898 _GL_ARG_NONNULL ((1, 2)));
899 # endif
900 _GL_CXXALIAS_SYS (execvpe, int,
901 (const char *program, char * const *argv, char * const *env));
902 # endif
903 # if __GLIBC__ >= 2
904 _GL_CXXALIASWARN (execvpe);
905 # endif
906 #elif defined GNULIB_POSIXCHECK
907 # undef execvpe
908 # if HAVE_RAW_DECL_EXECVPE
909 _GL_WARN_ON_USE (execvpe, "execvpe behaves very differently on mingw - "
910 "use gnulib module execvpe for portability");
911 # endif
912 #elif @GNULIB_MDA_EXECVPE@
913 /* On native Windows, map 'execvpe' to '_execvpe', so that -loldnames is not
914 required. In C++ with GNULIB_NAMESPACE, avoid differences between
915 platforms by defining GNULIB_NAMESPACE::execvpe on all platforms that have
916 it. */
917 # if defined _WIN32 && !defined __CYGWIN__
918 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
919 # undef execvpe
920 # define execvpe _execvpe
921 # endif
922 _GL_CXXALIAS_MDA_CAST (execvpe, intptr_t,
923 (const char *program, char * const *argv,
924 char * const *env));
925 # elif @HAVE_EXECVPE@
926 # if !@HAVE_DECL_EXECVPE@
927 _GL_FUNCDECL_SYS (execvpe, int,
928 (const char *program, char * const *argv, char * const *env)
929 _GL_ARG_NONNULL ((1, 2)));
930 # endif
931 _GL_CXXALIAS_SYS (execvpe, int,
932 (const char *program, char * const *argv, char * const *env));
933 # endif
934 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_EXECVPE@
935 _GL_CXXALIASWARN (execvpe);
936 # endif
937 #endif
938
939
940 #if @GNULIB_FACCESSAT@
941 # if @REPLACE_FACCESSAT@
942 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
943 # undef faccessat
944 # define faccessat rpl_faccessat
945 # endif
946 _GL_FUNCDECL_RPL (faccessat, int,
947 (int fd, char const *name, int mode, int flag)
948 _GL_ARG_NONNULL ((2)));
949 _GL_CXXALIAS_RPL (faccessat, int,
950 (int fd, char const *name, int mode, int flag));
951 # else
952 # if !@HAVE_FACCESSAT@
953 _GL_FUNCDECL_SYS (faccessat, int,
954 (int fd, char const *file, int mode, int flag)
955 _GL_ARG_NONNULL ((2)));
956 # endif
957 _GL_CXXALIAS_SYS (faccessat, int,
958 (int fd, char const *file, int mode, int flag));
959 # endif
960 # if __GLIBC__ >= 2
961 _GL_CXXALIASWARN (faccessat);
962 # endif
963 #elif defined GNULIB_POSIXCHECK
964 # undef faccessat
965 # if HAVE_RAW_DECL_FACCESSAT
966 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
967 "use gnulib module faccessat for portability");
968 # endif
969 #endif
970
971
972 #if @GNULIB_FCHDIR@
973 /* Change the process' current working directory to the directory on which
974 the given file descriptor is open.
975 Return 0 if successful, otherwise -1 and errno set.
976 See the POSIX:2008 specification
977 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
978 # if @REPLACE_FCHDIR@
979 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
980 # undef fchdir
981 # define fchdir rpl_fchdir
982 # endif
983 _GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/));
984 _GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/));
985 # else
986 # if !@HAVE_FCHDIR@ || !@HAVE_DECL_FCHDIR@
987 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
988 # endif
989 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
990 # endif
991 _GL_CXXALIASWARN (fchdir);
992 # if @REPLACE_FCHDIR@ || !@HAVE_FCHDIR@
993 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
994 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
995 _GL_ARG_NONNULL ((2));
996 _GL_EXTERN_C void _gl_unregister_fd (int fd);
997 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
998 _GL_EXTERN_C const char *_gl_directory_name (int fd);
999 # endif
1000 #elif defined GNULIB_POSIXCHECK
1001 # undef fchdir
1002 # if HAVE_RAW_DECL_FCHDIR
1003 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
1004 "use gnulib module fchdir for portability");
1005 # endif
1006 #endif
1007
1008
1009 #if @GNULIB_FCHOWNAT@
1010 # if @REPLACE_FCHOWNAT@
1011 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1012 # undef fchownat
1013 # define fchownat rpl_fchownat
1014 # endif
1015 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
1016 uid_t owner, gid_t group, int flag)
1017 _GL_ARG_NONNULL ((2)));
1018 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
1019 uid_t owner, gid_t group, int flag));
1020 # else
1021 # if !@HAVE_FCHOWNAT@
1022 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
1023 uid_t owner, gid_t group, int flag)
1024 _GL_ARG_NONNULL ((2)));
1025 # endif
1026 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
1027 uid_t owner, gid_t group, int flag));
1028 # endif
1029 _GL_CXXALIASWARN (fchownat);
1030 #elif defined GNULIB_POSIXCHECK
1031 # undef fchownat
1032 # if HAVE_RAW_DECL_FCHOWNAT
1033 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
1034 "use gnulib module fchownat for portability");
1035 # endif
1036 #endif
1037
1038
1039 #if @GNULIB_FDATASYNC@
1040 /* Synchronize changes to a file.
1041 Return 0 if successful, otherwise -1 and errno set.
1042 See POSIX:2008 specification
1043 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
1044 # if @REPLACE_FDATASYNC@
1045 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1046 # undef fdatasync
1047 # define fdatasync rpl_fdatasync
1048 # endif
1049 _GL_FUNCDECL_RPL (fdatasync, int, (int fd));
1050 _GL_CXXALIAS_RPL (fdatasync, int, (int fd));
1051 # else
1052 # if !@HAVE_FDATASYNC@|| !@HAVE_DECL_FDATASYNC@
1053 _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
1054 # endif
1055 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
1056 # endif
1057 # if __GLIBC__ >= 2
1058 _GL_CXXALIASWARN (fdatasync);
1059 # endif
1060 #elif defined GNULIB_POSIXCHECK
1061 # undef fdatasync
1062 # if HAVE_RAW_DECL_FDATASYNC
1063 _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
1064 "use gnulib module fdatasync for portability");
1065 # endif
1066 #endif
1067
1068
1069 #if @GNULIB_FSYNC@
1070 /* Synchronize changes, including metadata, to a file.
1071 Return 0 if successful, otherwise -1 and errno set.
1072 See POSIX:2008 specification
1073 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
1074 # if !@HAVE_FSYNC@
1075 _GL_FUNCDECL_SYS (fsync, int, (int fd));
1076 # endif
1077 _GL_CXXALIAS_SYS (fsync, int, (int fd));
1078 _GL_CXXALIASWARN (fsync);
1079 #elif defined GNULIB_POSIXCHECK
1080 # undef fsync
1081 # if HAVE_RAW_DECL_FSYNC
1082 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
1083 "use gnulib module fsync for portability");
1084 # endif
1085 #endif
1086
1087
1088 #if @GNULIB_FTRUNCATE@
1089 /* Change the size of the file to which FD is opened to become equal to LENGTH.
1090 Return 0 if successful, otherwise -1 and errno set.
1091 See the POSIX:2008 specification
1092 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
1093 # if @REPLACE_FTRUNCATE@
1094 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1095 # undef ftruncate
1096 # define ftruncate rpl_ftruncate
1097 # endif
1098 _GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
1099 _GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
1100 # else
1101 # if !@HAVE_FTRUNCATE@
1102 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
1103 # endif
1104 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
1105 # endif
1106 # if __GLIBC__ >= 2
1107 _GL_CXXALIASWARN (ftruncate);
1108 # endif
1109 #elif defined GNULIB_POSIXCHECK
1110 # undef ftruncate
1111 # if HAVE_RAW_DECL_FTRUNCATE
1112 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
1113 "use gnulib module ftruncate for portability");
1114 # endif
1115 #endif
1116
1117
1118 #if @GNULIB_GETCWD@
1119 /* Get the name of the current working directory, and put it in SIZE bytes
1120 of BUF.
1121 Return BUF if successful, or NULL if the directory couldn't be determined
1122 or SIZE was too small.
1123 See the POSIX:2008 specification
1124 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
1125 Additionally, the gnulib module 'getcwd' or 'getcwd-lgpl' guarantees the
1126 following GNU extension: If BUF is NULL, an array is allocated with
1127 'malloc'; the array is SIZE bytes long, unless SIZE == 0, in which case
1128 it is as big as necessary. */
1129 # if @REPLACE_GETCWD@
1130 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1131 # define getcwd rpl_getcwd
1132 # endif
1133 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
1134 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
1135 # elif defined _WIN32 && !defined __CYGWIN__
1136 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1137 # undef getcwd
1138 # define getcwd _getcwd
1139 # endif
1140 _GL_CXXALIAS_MDA (getcwd, char *, (char *buf, size_t size));
1141 # else
1142 /* Need to cast, because on mingw, the second parameter is
1143 int size. */
1144 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
1145 # endif
1146 _GL_CXXALIASWARN (getcwd);
1147 #elif defined GNULIB_POSIXCHECK
1148 # undef getcwd
1149 # if HAVE_RAW_DECL_GETCWD
1150 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
1151 "use gnulib module getcwd for portability");
1152 # endif
1153 #elif @GNULIB_MDA_GETCWD@
1154 /* On native Windows, map 'getcwd' to '_getcwd', so that -loldnames is not
1155 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1156 platforms by defining GNULIB_NAMESPACE::getcwd always. */
1157 # if defined _WIN32 && !defined __CYGWIN__
1158 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1159 # undef getcwd
1160 # define getcwd _getcwd
1161 # endif
1162 /* Need to cast, because on mingw, the second parameter is either
1163 'int size' or 'size_t size'. */
1164 _GL_CXXALIAS_MDA_CAST (getcwd, char *, (char *buf, size_t size));
1165 # else
1166 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
1167 # endif
1168 _GL_CXXALIASWARN (getcwd);
1169 #endif
1170
1171
1172 #if @GNULIB_GETDOMAINNAME@
1173 /* Return the NIS domain name of the machine.
1174 WARNING! The NIS domain name is unrelated to the fully qualified host name
1175 of the machine. It is also unrelated to email addresses.
1176 WARNING! The NIS domain name is usually the empty string or "(none)" when
1177 not using NIS.
1178
1179 Put up to LEN bytes of the NIS domain name into NAME.
1180 Null terminate it if the name is shorter than LEN.
1181 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
1182 Return 0 if successful, otherwise set errno and return -1. */
1183 # if @REPLACE_GETDOMAINNAME@
1184 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1185 # undef getdomainname
1186 # define getdomainname rpl_getdomainname
1187 # endif
1188 _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
1189 _GL_ARG_NONNULL ((1)));
1190 _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
1191 # else
1192 # if !@HAVE_DECL_GETDOMAINNAME@
1193 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
1194 _GL_ARG_NONNULL ((1)));
1195 # endif
1196 _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
1197 # endif
1198 # if __GLIBC__ >= 2
1199 _GL_CXXALIASWARN (getdomainname);
1200 # endif
1201 #elif defined GNULIB_POSIXCHECK
1202 # undef getdomainname
1203 # if HAVE_RAW_DECL_GETDOMAINNAME
1204 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
1205 "use gnulib module getdomainname for portability");
1206 # endif
1207 #endif
1208
1209
1210 #if @GNULIB_GETDTABLESIZE@
1211 /* Return the maximum number of file descriptors in the current process.
1212 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
1213 # if @REPLACE_GETDTABLESIZE@
1214 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1215 # undef getdtablesize
1216 # define getdtablesize rpl_getdtablesize
1217 # endif
1218 _GL_FUNCDECL_RPL (getdtablesize, int, (void));
1219 _GL_CXXALIAS_RPL (getdtablesize, int, (void));
1220 # else
1221 # if !@HAVE_GETDTABLESIZE@
1222 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
1223 # endif
1224 /* Need to cast, because on AIX, the parameter list is
1225 (...). */
1226 _GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void));
1227 # endif
1228 _GL_CXXALIASWARN (getdtablesize);
1229 #elif defined GNULIB_POSIXCHECK
1230 # undef getdtablesize
1231 # if HAVE_RAW_DECL_GETDTABLESIZE
1232 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
1233 "use gnulib module getdtablesize for portability");
1234 # endif
1235 #endif
1236
1237
1238 #if @GNULIB_GETENTROPY@
1239 /* Fill a buffer with random bytes. */
1240 # if @REPLACE_GETENTROPY@
1241 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1242 # undef getentropy
1243 # define getentropy rpl_getentropy
1244 # endif
1245 _GL_FUNCDECL_RPL (getentropy, int, (void *buffer, size_t length));
1246 _GL_CXXALIAS_RPL (getentropy, int, (void *buffer, size_t length));
1247 # else
1248 # if !@HAVE_GETENTROPY@
1249 _GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length));
1250 # endif
1251 _GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length));
1252 # endif
1253 # if __GLIBC__ >= 2
1254 _GL_CXXALIASWARN (getentropy);
1255 # endif
1256 #elif defined GNULIB_POSIXCHECK
1257 # undef getentropy
1258 # if HAVE_RAW_DECL_GETENTROPY
1259 _GL_WARN_ON_USE (getentropy, "getentropy is unportable - "
1260 "use gnulib module getentropy for portability");
1261 # endif
1262 #endif
1263
1264
1265 #if @GNULIB_GETGROUPS@
1266 /* Return the supplemental groups that the current process belongs to.
1267 It is unspecified whether the effective group id is in the list.
1268 If N is 0, return the group count; otherwise, N describes how many
1269 entries are available in GROUPS. Return -1 and set errno if N is
1270 not 0 and not large enough. Fails with ENOSYS on some systems. */
1271 # if @REPLACE_GETGROUPS@
1272 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1273 # undef getgroups
1274 # define getgroups rpl_getgroups
1275 # endif
1276 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
1277 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
1278 # else
1279 # if !@HAVE_GETGROUPS@
1280 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
1281 # endif
1282 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
1283 # endif
1284 _GL_CXXALIASWARN (getgroups);
1285 #elif defined GNULIB_POSIXCHECK
1286 # undef getgroups
1287 # if HAVE_RAW_DECL_GETGROUPS
1288 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
1289 "use gnulib module getgroups for portability");
1290 # endif
1291 #endif
1292
1293
1294 #if @GNULIB_GETHOSTNAME@
1295 /* Return the standard host name of the machine.
1296 WARNING! The host name may or may not be fully qualified.
1297
1298 Put up to LEN bytes of the host name into NAME.
1299 Null terminate it if the name is shorter than LEN.
1300 If the host name is longer than LEN, set errno = EINVAL and return -1.
1301 Return 0 if successful, otherwise set errno and return -1. */
1302 # if @UNISTD_H_HAVE_WINSOCK2_H@
1303 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1304 # undef gethostname
1305 # define gethostname rpl_gethostname
1306 # endif
1307 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
1308 _GL_ARG_NONNULL ((1)));
1309 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
1310 # else
1311 # if !@HAVE_GETHOSTNAME@
1312 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
1313 _GL_ARG_NONNULL ((1)));
1314 # endif
1315 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
1316 parameter is
1317 int len. */
1318 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
1319 # endif
1320 _GL_CXXALIASWARN (gethostname);
1321 #elif @UNISTD_H_HAVE_WINSOCK2_H@
1322 # undef gethostname
1323 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
1324 #elif defined GNULIB_POSIXCHECK
1325 # undef gethostname
1326 # if HAVE_RAW_DECL_GETHOSTNAME
1327 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
1328 "use gnulib module gethostname for portability");
1329 # endif
1330 #endif
1331
1332
1333 #if @GNULIB_GETLOGIN@
1334 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
1335 returns NULL with errno set.
1336
1337 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1338
1339 Most programs don't need to use this function, because the information is
1340 available through environment variables:
1341 ${LOGNAME-$USER} on Unix platforms,
1342 $USERNAME on native Windows platforms.
1343 */
1344 # if !@HAVE_DECL_GETLOGIN@
1345 _GL_FUNCDECL_SYS (getlogin, char *, (void));
1346 # endif
1347 _GL_CXXALIAS_SYS (getlogin, char *, (void));
1348 _GL_CXXALIASWARN (getlogin);
1349 #elif defined GNULIB_POSIXCHECK
1350 # undef getlogin
1351 # if HAVE_RAW_DECL_GETLOGIN
1352 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
1353 "use gnulib module getlogin for portability");
1354 # endif
1355 #endif
1356
1357
1358 #if @GNULIB_GETLOGIN_R@
1359 /* Copies the user's login name to NAME.
1360 The array pointed to by NAME has room for SIZE bytes.
1361
1362 Returns 0 if successful. Upon error, an error number is returned, or -1 in
1363 the case that the login name cannot be found but no specific error is
1364 provided (this case is hopefully rare but is left open by the POSIX spec).
1365
1366 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
1367
1368 Most programs don't need to use this function, because the information is
1369 available through environment variables:
1370 ${LOGNAME-$USER} on Unix platforms,
1371 $USERNAME on native Windows platforms.
1372 */
1373 # if @REPLACE_GETLOGIN_R@
1374 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1375 # define getlogin_r rpl_getlogin_r
1376 # endif
1377 _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
1378 _GL_ARG_NONNULL ((1)));
1379 _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
1380 # else
1381 # if !@HAVE_DECL_GETLOGIN_R@
1382 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
1383 _GL_ARG_NONNULL ((1)));
1384 # endif
1385 /* Need to cast, because on Solaris 10 systems, the second argument is
1386 int size. */
1387 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
1388 # endif
1389 # if __GLIBC__ >= 2
1390 _GL_CXXALIASWARN (getlogin_r);
1391 # endif
1392 #elif defined GNULIB_POSIXCHECK
1393 # undef getlogin_r
1394 # if HAVE_RAW_DECL_GETLOGIN_R
1395 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
1396 "use gnulib module getlogin_r for portability");
1397 # endif
1398 #endif
1399
1400
1401 #if @GNULIB_GETPAGESIZE@
1402 # if @REPLACE_GETPAGESIZE@
1403 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1404 # define getpagesize rpl_getpagesize
1405 # endif
1406 _GL_FUNCDECL_RPL (getpagesize, int, (void));
1407 _GL_CXXALIAS_RPL (getpagesize, int, (void));
1408 # else
1409 /* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
1410 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */
1411 # if defined __hpux
1412 _GL_FUNCDECL_SYS (getpagesize, int, (void));
1413 # endif
1414 # if !@HAVE_GETPAGESIZE@
1415 # if !defined getpagesize
1416 /* This is for POSIX systems. */
1417 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
1418 # if ! (defined __VMS && __VMS_VER < 70000000)
1419 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
1420 # endif
1421 # endif
1422 /* This is for older VMS. */
1423 # if !defined _gl_getpagesize && defined __VMS
1424 # ifdef __ALPHA
1425 # define _gl_getpagesize() 8192
1426 # else
1427 # define _gl_getpagesize() 512
1428 # endif
1429 # endif
1430 /* This is for BeOS. */
1431 # if !defined _gl_getpagesize && @HAVE_OS_H@
1432 # include <OS.h>
1433 # if defined B_PAGE_SIZE
1434 # define _gl_getpagesize() B_PAGE_SIZE
1435 # endif
1436 # endif
1437 /* This is for AmigaOS4.0. */
1438 # if !defined _gl_getpagesize && defined __amigaos4__
1439 # define _gl_getpagesize() 2048
1440 # endif
1441 /* This is for older Unix systems. */
1442 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
1443 # include <sys/param.h>
1444 # ifdef EXEC_PAGESIZE
1445 # define _gl_getpagesize() EXEC_PAGESIZE
1446 # else
1447 # ifdef NBPG
1448 # ifndef CLSIZE
1449 # define CLSIZE 1
1450 # endif
1451 # define _gl_getpagesize() (NBPG * CLSIZE)
1452 # else
1453 # ifdef NBPC
1454 # define _gl_getpagesize() NBPC
1455 # endif
1456 # endif
1457 # endif
1458 # endif
1459 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1460 # define getpagesize() _gl_getpagesize ()
1461 # else
1462 # if !GNULIB_defined_getpagesize_function
1463 _GL_UNISTD_INLINE int
1464 getpagesize ()
1465 {
1466 return _gl_getpagesize ();
1467 }
1468 # define GNULIB_defined_getpagesize_function 1
1469 # endif
1470 # endif
1471 # endif
1472 # endif
1473 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
1474 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
1475 # endif
1476 # if @HAVE_DECL_GETPAGESIZE@
1477 _GL_CXXALIASWARN (getpagesize);
1478 # endif
1479 #elif defined GNULIB_POSIXCHECK
1480 # undef getpagesize
1481 # if HAVE_RAW_DECL_GETPAGESIZE
1482 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
1483 "use gnulib module getpagesize for portability");
1484 # endif
1485 #endif
1486
1487
1488 #if @GNULIB_GETPASS@
1489 /* Function getpass() from module 'getpass':
1490 Read a password from /dev/tty or stdin.
1491 Function getpass() from module 'getpass-gnu':
1492 Read a password of arbitrary length from /dev/tty or stdin. */
1493 # if (@GNULIB_GETPASS@ && @REPLACE_GETPASS@) \
1494 || (@GNULIB_GETPASS_GNU@ && @REPLACE_GETPASS_FOR_GETPASS_GNU@)
1495 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1496 # undef getpass
1497 # define getpass rpl_getpass
1498 # endif
1499 _GL_FUNCDECL_RPL (getpass, char *, (const char *prompt)
1500 _GL_ARG_NONNULL ((1)));
1501 _GL_CXXALIAS_RPL (getpass, char *, (const char *prompt));
1502 # else
1503 # if !@HAVE_GETPASS@
1504 _GL_FUNCDECL_SYS (getpass, char *, (const char *prompt)
1505 _GL_ARG_NONNULL ((1)));
1506 # endif
1507 _GL_CXXALIAS_SYS (getpass, char *, (const char *prompt));
1508 # endif
1509 _GL_CXXALIASWARN (getpass);
1510 #elif defined GNULIB_POSIXCHECK
1511 # undef getpass
1512 # if HAVE_RAW_DECL_GETPASS
1513 _GL_WARN_ON_USE (getpass, "getpass is unportable - "
1514 "use gnulib module getpass or getpass-gnu for portability");
1515 # endif
1516 #endif
1517
1518
1519 #if @GNULIB_MDA_GETPID@
1520 /* On native Windows, map 'getpid' to '_getpid', so that -loldnames is not
1521 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1522 platforms by defining GNULIB_NAMESPACE::getpid always. */
1523 # if defined _WIN32 && !defined __CYGWIN__
1524 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1525 # undef getpid
1526 # define getpid _getpid
1527 # endif
1528 _GL_CXXALIAS_MDA (getpid, int, (void));
1529 # else
1530 _GL_CXXALIAS_SYS (getpid, pid_t, (void));
1531 # endif
1532 _GL_CXXALIASWARN (getpid);
1533 #endif
1534
1535
1536 #if @GNULIB_GETUSERSHELL@
1537 /* Return the next valid login shell on the system, or NULL when the end of
1538 the list has been reached. */
1539 # if !@HAVE_DECL_GETUSERSHELL@
1540 _GL_FUNCDECL_SYS (getusershell, char *, (void));
1541 # endif
1542 _GL_CXXALIAS_SYS (getusershell, char *, (void));
1543 _GL_CXXALIASWARN (getusershell);
1544 #elif defined GNULIB_POSIXCHECK
1545 # undef getusershell
1546 # if HAVE_RAW_DECL_GETUSERSHELL
1547 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
1548 "use gnulib module getusershell for portability");
1549 # endif
1550 #endif
1551
1552 #if @GNULIB_GETUSERSHELL@
1553 /* Rewind to pointer that is advanced at each getusershell() call. */
1554 # if !@HAVE_DECL_GETUSERSHELL@
1555 _GL_FUNCDECL_SYS (setusershell, void, (void));
1556 # endif
1557 _GL_CXXALIAS_SYS (setusershell, void, (void));
1558 _GL_CXXALIASWARN (setusershell);
1559 #elif defined GNULIB_POSIXCHECK
1560 # undef setusershell
1561 # if HAVE_RAW_DECL_SETUSERSHELL
1562 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
1563 "use gnulib module getusershell for portability");
1564 # endif
1565 #endif
1566
1567 #if @GNULIB_GETUSERSHELL@
1568 /* Free the pointer that is advanced at each getusershell() call and
1569 associated resources. */
1570 # if !@HAVE_DECL_GETUSERSHELL@
1571 _GL_FUNCDECL_SYS (endusershell, void, (void));
1572 # endif
1573 _GL_CXXALIAS_SYS (endusershell, void, (void));
1574 _GL_CXXALIASWARN (endusershell);
1575 #elif defined GNULIB_POSIXCHECK
1576 # undef endusershell
1577 # if HAVE_RAW_DECL_ENDUSERSHELL
1578 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
1579 "use gnulib module getusershell for portability");
1580 # endif
1581 #endif
1582
1583
1584 #if @GNULIB_GROUP_MEMBER@
1585 /* Determine whether group id is in calling user's group list. */
1586 # if !@HAVE_GROUP_MEMBER@
1587 _GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
1588 # endif
1589 _GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
1590 _GL_CXXALIASWARN (group_member);
1591 #elif defined GNULIB_POSIXCHECK
1592 # undef group_member
1593 # if HAVE_RAW_DECL_GROUP_MEMBER
1594 _GL_WARN_ON_USE (group_member, "group_member is unportable - "
1595 "use gnulib module group-member for portability");
1596 # endif
1597 #endif
1598
1599
1600 #if @GNULIB_ISATTY@
1601 # if @REPLACE_ISATTY@
1602 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1603 # undef isatty
1604 # define isatty rpl_isatty
1605 # endif
1606 # define GNULIB_defined_isatty 1
1607 _GL_FUNCDECL_RPL (isatty, int, (int fd));
1608 _GL_CXXALIAS_RPL (isatty, int, (int fd));
1609 # elif defined _WIN32 && !defined __CYGWIN__
1610 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1611 # undef isatty
1612 # define isatty _isatty
1613 # endif
1614 _GL_CXXALIAS_MDA (isatty, int, (int fd));
1615 # else
1616 _GL_CXXALIAS_SYS (isatty, int, (int fd));
1617 # endif
1618 _GL_CXXALIASWARN (isatty);
1619 #elif defined GNULIB_POSIXCHECK
1620 # undef isatty
1621 # if HAVE_RAW_DECL_ISATTY
1622 _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
1623 "use gnulib module isatty for portability");
1624 # endif
1625 #elif @GNULIB_MDA_ISATTY@
1626 /* On native Windows, map 'isatty' to '_isatty', so that -loldnames is not
1627 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1628 platforms by defining GNULIB_NAMESPACE::isatty always. */
1629 # if defined _WIN32 && !defined __CYGWIN__
1630 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1631 # undef isatty
1632 # define isatty _isatty
1633 # endif
1634 _GL_CXXALIAS_MDA (isatty, int, (int fd));
1635 # else
1636 _GL_CXXALIAS_SYS (isatty, int, (int fd));
1637 # endif
1638 _GL_CXXALIASWARN (isatty);
1639 #endif
1640
1641
1642 #if @GNULIB_LCHOWN@
1643 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1644 to GID (if GID is not -1). Do not follow symbolic links.
1645 Return 0 if successful, otherwise -1 and errno set.
1646 See the POSIX:2008 specification
1647 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1648 # if @REPLACE_LCHOWN@
1649 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1650 # undef lchown
1651 # define lchown rpl_lchown
1652 # endif
1653 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
1654 _GL_ARG_NONNULL ((1)));
1655 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
1656 # else
1657 # if !@HAVE_LCHOWN@
1658 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
1659 _GL_ARG_NONNULL ((1)));
1660 # endif
1661 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
1662 # endif
1663 _GL_CXXALIASWARN (lchown);
1664 #elif defined GNULIB_POSIXCHECK
1665 # undef lchown
1666 # if HAVE_RAW_DECL_LCHOWN
1667 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1668 "use gnulib module lchown for portability");
1669 # endif
1670 #endif
1671
1672
1673 #if @GNULIB_LINK@
1674 /* Create a new hard link for an existing file.
1675 Return 0 if successful, otherwise -1 and errno set.
1676 See POSIX:2008 specification
1677 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1678 # if @REPLACE_LINK@
1679 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1680 # define link rpl_link
1681 # endif
1682 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
1683 _GL_ARG_NONNULL ((1, 2)));
1684 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
1685 # else
1686 # if !@HAVE_LINK@
1687 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
1688 _GL_ARG_NONNULL ((1, 2)));
1689 # endif
1690 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
1691 # endif
1692 _GL_CXXALIASWARN (link);
1693 #elif defined GNULIB_POSIXCHECK
1694 # undef link
1695 # if HAVE_RAW_DECL_LINK
1696 _GL_WARN_ON_USE (link, "link is unportable - "
1697 "use gnulib module link for portability");
1698 # endif
1699 #endif
1700
1701
1702 #if @GNULIB_LINKAT@
1703 /* Create a new hard link for an existing file, relative to two
1704 directories. FLAG controls whether symlinks are followed.
1705 Return 0 if successful, otherwise -1 and errno set. */
1706 # if @REPLACE_LINKAT@
1707 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1708 # undef linkat
1709 # define linkat rpl_linkat
1710 # endif
1711 _GL_FUNCDECL_RPL (linkat, int,
1712 (int fd1, const char *path1, int fd2, const char *path2,
1713 int flag)
1714 _GL_ARG_NONNULL ((2, 4)));
1715 _GL_CXXALIAS_RPL (linkat, int,
1716 (int fd1, const char *path1, int fd2, const char *path2,
1717 int flag));
1718 # else
1719 # if !@HAVE_LINKAT@
1720 _GL_FUNCDECL_SYS (linkat, int,
1721 (int fd1, const char *path1, int fd2, const char *path2,
1722 int flag)
1723 _GL_ARG_NONNULL ((2, 4)));
1724 # endif
1725 _GL_CXXALIAS_SYS (linkat, int,
1726 (int fd1, const char *path1, int fd2, const char *path2,
1727 int flag));
1728 # endif
1729 # if __GLIBC__ >= 2
1730 _GL_CXXALIASWARN (linkat);
1731 # endif
1732 #elif defined GNULIB_POSIXCHECK
1733 # undef linkat
1734 # if HAVE_RAW_DECL_LINKAT
1735 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1736 "use gnulib module linkat for portability");
1737 # endif
1738 #endif
1739
1740
1741 #if @GNULIB_LSEEK@
1742 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1743 Return the new offset if successful, otherwise -1 and errno set.
1744 See the POSIX:2008 specification
1745 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1746 # if @REPLACE_LSEEK@
1747 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1748 # define lseek rpl_lseek
1749 # endif
1750 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1751 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1752 # elif defined _WIN32 && !defined __CYGWIN__
1753 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1754 # undef lseek
1755 # define lseek _lseek
1756 # endif
1757 _GL_CXXALIAS_MDA (lseek, off_t, (int fd, off_t offset, int whence));
1758 # else
1759 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1760 # endif
1761 _GL_CXXALIASWARN (lseek);
1762 #elif defined GNULIB_POSIXCHECK
1763 # undef lseek
1764 # if HAVE_RAW_DECL_LSEEK
1765 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1766 "systems - use gnulib module lseek for portability");
1767 # endif
1768 #elif @GNULIB_MDA_LSEEK@
1769 /* On native Windows, map 'lseek' to '_lseek', so that -loldnames is not
1770 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1771 platforms by defining GNULIB_NAMESPACE::lseek always. */
1772 # if defined _WIN32 && !defined __CYGWIN__
1773 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1774 # undef lseek
1775 # define lseek _lseek
1776 # endif
1777 _GL_CXXALIAS_MDA (lseek, long, (int fd, long offset, int whence));
1778 # else
1779 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1780 # endif
1781 _GL_CXXALIASWARN (lseek);
1782 #endif
1783
1784
1785 #if @GNULIB_PIPE@
1786 /* Create a pipe, defaulting to O_BINARY mode.
1787 Store the read-end as fd[0] and the write-end as fd[1].
1788 Return 0 upon success, or -1 with errno set upon failure. */
1789 # if !@HAVE_PIPE@
1790 _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1791 # endif
1792 _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1793 _GL_CXXALIASWARN (pipe);
1794 #elif defined GNULIB_POSIXCHECK
1795 # undef pipe
1796 # if HAVE_RAW_DECL_PIPE
1797 _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1798 "use gnulib module pipe-posix for portability");
1799 # endif
1800 #endif
1801
1802
1803 #if @GNULIB_PIPE2@
1804 /* Create a pipe, applying the given flags when opening the read-end of the
1805 pipe and the write-end of the pipe.
1806 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1807 and O_TEXT, O_BINARY (defined in "binary-io.h").
1808 Store the read-end as fd[0] and the write-end as fd[1].
1809 Return 0 upon success, or -1 with errno set upon failure.
1810 See also the Linux man page at
1811 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1812 # if @REPLACE_PIPE2@
1813 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1814 # undef pipe2
1815 # define pipe2 rpl_pipe2
1816 # endif
1817 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1818 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1819 # else
1820 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1821 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1822 # endif
1823 # if __GLIBC__ >= 2
1824 _GL_CXXALIASWARN (pipe2);
1825 # endif
1826 #elif defined GNULIB_POSIXCHECK
1827 # undef pipe2
1828 # if HAVE_RAW_DECL_PIPE2
1829 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1830 "use gnulib module pipe2 for portability");
1831 # endif
1832 #endif
1833
1834
1835 #if @GNULIB_PREAD@
1836 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1837 Return the number of bytes placed into BUF if successful, otherwise
1838 set errno and return -1. 0 indicates EOF.
1839 See the POSIX:2008 specification
1840 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1841 # if @REPLACE_PREAD@
1842 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1843 # undef pread
1844 # define pread rpl_pread
1845 # endif
1846 _GL_FUNCDECL_RPL (pread, ssize_t,
1847 (int fd, void *buf, size_t bufsize, off_t offset)
1848 _GL_ARG_NONNULL ((2)));
1849 _GL_CXXALIAS_RPL (pread, ssize_t,
1850 (int fd, void *buf, size_t bufsize, off_t offset));
1851 # else
1852 # if !@HAVE_PREAD@
1853 _GL_FUNCDECL_SYS (pread, ssize_t,
1854 (int fd, void *buf, size_t bufsize, off_t offset)
1855 _GL_ARG_NONNULL ((2)));
1856 # endif
1857 _GL_CXXALIAS_SYS (pread, ssize_t,
1858 (int fd, void *buf, size_t bufsize, off_t offset));
1859 # endif
1860 # if __GLIBC__ >= 2
1861 _GL_CXXALIASWARN (pread);
1862 # endif
1863 #elif defined GNULIB_POSIXCHECK
1864 # undef pread
1865 # if HAVE_RAW_DECL_PREAD
1866 _GL_WARN_ON_USE (pread, "pread is unportable - "
1867 "use gnulib module pread for portability");
1868 # endif
1869 #endif
1870
1871
1872 #if @GNULIB_PWRITE@
1873 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1874 Return the number of bytes written if successful, otherwise
1875 set errno and return -1. 0 indicates nothing written. See the
1876 POSIX:2008 specification
1877 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1878 # if @REPLACE_PWRITE@
1879 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1880 # undef pwrite
1881 # define pwrite rpl_pwrite
1882 # endif
1883 _GL_FUNCDECL_RPL (pwrite, ssize_t,
1884 (int fd, const void *buf, size_t bufsize, off_t offset)
1885 _GL_ARG_NONNULL ((2)));
1886 _GL_CXXALIAS_RPL (pwrite, ssize_t,
1887 (int fd, const void *buf, size_t bufsize, off_t offset));
1888 # else
1889 # if !@HAVE_PWRITE@
1890 _GL_FUNCDECL_SYS (pwrite, ssize_t,
1891 (int fd, const void *buf, size_t bufsize, off_t offset)
1892 _GL_ARG_NONNULL ((2)));
1893 # endif
1894 _GL_CXXALIAS_SYS (pwrite, ssize_t,
1895 (int fd, const void *buf, size_t bufsize, off_t offset));
1896 # endif
1897 # if __GLIBC__ >= 2
1898 _GL_CXXALIASWARN (pwrite);
1899 # endif
1900 #elif defined GNULIB_POSIXCHECK
1901 # undef pwrite
1902 # if HAVE_RAW_DECL_PWRITE
1903 _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1904 "use gnulib module pwrite for portability");
1905 # endif
1906 #endif
1907
1908
1909 #if @GNULIB_READ@
1910 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1911 at BUF. See the POSIX:2008 specification
1912 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1913 # if @REPLACE_READ@
1914 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1915 # undef read
1916 # define read rpl_read
1917 # endif
1918 _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1919 _GL_ARG_NONNULL ((2)));
1920 _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1921 # elif defined _WIN32 && !defined __CYGWIN__
1922 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1923 # undef read
1924 # define read _read
1925 # endif
1926 _GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, size_t count));
1927 # else
1928 _GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1929 # endif
1930 _GL_CXXALIASWARN (read);
1931 #elif @GNULIB_MDA_READ@
1932 /* On native Windows, map 'read' to '_read', so that -loldnames is not
1933 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1934 platforms by defining GNULIB_NAMESPACE::read always. */
1935 # if defined _WIN32 && !defined __CYGWIN__
1936 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1937 # undef read
1938 # define read _read
1939 # endif
1940 # ifdef __MINGW32__
1941 _GL_CXXALIAS_MDA (read, int, (int fd, void *buf, unsigned int count));
1942 # else
1943 _GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, unsigned int count));
1944 # endif
1945 # else
1946 _GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1947 # endif
1948 _GL_CXXALIASWARN (read);
1949 #endif
1950
1951
1952 #if @GNULIB_READLINK@
1953 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1954 bytes of it into BUF. Return the number of bytes placed into BUF if
1955 successful, otherwise -1 and errno set.
1956 See the POSIX:2008 specification
1957 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1958 # if @REPLACE_READLINK@
1959 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1960 # define readlink rpl_readlink
1961 # endif
1962 _GL_FUNCDECL_RPL (readlink, ssize_t,
1963 (const char *restrict file,
1964 char *restrict buf, size_t bufsize)
1965 _GL_ARG_NONNULL ((1, 2)));
1966 _GL_CXXALIAS_RPL (readlink, ssize_t,
1967 (const char *restrict file,
1968 char *restrict buf, size_t bufsize));
1969 # else
1970 # if !@HAVE_READLINK@
1971 _GL_FUNCDECL_SYS (readlink, ssize_t,
1972 (const char *restrict file,
1973 char *restrict buf, size_t bufsize)
1974 _GL_ARG_NONNULL ((1, 2)));
1975 # endif
1976 _GL_CXXALIAS_SYS (readlink, ssize_t,
1977 (const char *restrict file,
1978 char *restrict buf, size_t bufsize));
1979 # endif
1980 _GL_CXXALIASWARN (readlink);
1981 #elif defined GNULIB_POSIXCHECK
1982 # undef readlink
1983 # if HAVE_RAW_DECL_READLINK
1984 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1985 "use gnulib module readlink for portability");
1986 # endif
1987 #endif
1988
1989
1990 #if @GNULIB_READLINKAT@
1991 # if @REPLACE_READLINKAT@
1992 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1993 # define readlinkat rpl_readlinkat
1994 # endif
1995 _GL_FUNCDECL_RPL (readlinkat, ssize_t,
1996 (int fd, char const *restrict file,
1997 char *restrict buf, size_t len)
1998 _GL_ARG_NONNULL ((2, 3)));
1999 _GL_CXXALIAS_RPL (readlinkat, ssize_t,
2000 (int fd, char const *restrict file,
2001 char *restrict buf, size_t len));
2002 # else
2003 # if !@HAVE_READLINKAT@
2004 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
2005 (int fd, char const *restrict file,
2006 char *restrict buf, size_t len)
2007 _GL_ARG_NONNULL ((2, 3)));
2008 # endif
2009 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
2010 (int fd, char const *restrict file,
2011 char *restrict buf, size_t len));
2012 # endif
2013 # if __GLIBC__ >= 2
2014 _GL_CXXALIASWARN (readlinkat);
2015 # endif
2016 #elif defined GNULIB_POSIXCHECK
2017 # undef readlinkat
2018 # if HAVE_RAW_DECL_READLINKAT
2019 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
2020 "use gnulib module readlinkat for portability");
2021 # endif
2022 #endif
2023
2024
2025 #if @GNULIB_RMDIR@
2026 /* Remove the directory DIR. */
2027 # if @REPLACE_RMDIR@
2028 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2029 # define rmdir rpl_rmdir
2030 # endif
2031 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
2032 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
2033 # elif defined _WIN32 && !defined __CYGWIN__
2034 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2035 # undef rmdir
2036 # define rmdir _rmdir
2037 # endif
2038 _GL_CXXALIAS_MDA (rmdir, int, (char const *name));
2039 # else
2040 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
2041 # endif
2042 _GL_CXXALIASWARN (rmdir);
2043 #elif defined GNULIB_POSIXCHECK
2044 # undef rmdir
2045 # if HAVE_RAW_DECL_RMDIR
2046 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
2047 "use gnulib module rmdir for portability");
2048 # endif
2049 #elif @GNULIB_MDA_RMDIR@
2050 /* On native Windows, map 'rmdir' to '_rmdir', so that -loldnames is not
2051 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2052 platforms by defining GNULIB_NAMESPACE::rmdir always. */
2053 # if defined _WIN32 && !defined __CYGWIN__
2054 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2055 # undef rmdir
2056 # define rmdir _rmdir
2057 # endif
2058 _GL_CXXALIAS_MDA (rmdir, int, (char const *name));
2059 # else
2060 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
2061 # endif
2062 _GL_CXXALIASWARN (rmdir);
2063 #endif
2064
2065
2066 #if @GNULIB_SETHOSTNAME@
2067 /* Set the host name of the machine.
2068 The host name may or may not be fully qualified.
2069
2070 Put LEN bytes of NAME into the host name.
2071 Return 0 if successful, otherwise, set errno and return -1.
2072
2073 Platforms with no ability to set the hostname return -1 and set
2074 errno = ENOSYS. */
2075 # if @REPLACE_SETHOSTNAME@
2076 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2077 # undef sethostname
2078 # define sethostname rpl_sethostname
2079 # endif
2080 _GL_FUNCDECL_RPL (sethostname, int, (const char *name, size_t len)
2081 _GL_ARG_NONNULL ((1)));
2082 _GL_CXXALIAS_RPL (sethostname, int, (const char *name, size_t len));
2083 # else
2084 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
2085 _GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
2086 _GL_ARG_NONNULL ((1)));
2087 # endif
2088 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
2089 and FreeBSD 6.4 the second parameter is int. On Solaris 11
2090 2011-10, the first parameter is not const. */
2091 _GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
2092 # endif
2093 # if __GLIBC__ >= 2
2094 _GL_CXXALIASWARN (sethostname);
2095 # endif
2096 #elif defined GNULIB_POSIXCHECK
2097 # undef sethostname
2098 # if HAVE_RAW_DECL_SETHOSTNAME
2099 _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
2100 "use gnulib module sethostname for portability");
2101 # endif
2102 #endif
2103
2104
2105 #if @GNULIB_SLEEP@
2106 /* Pause the execution of the current thread for N seconds.
2107 Returns the number of seconds left to sleep.
2108 See the POSIX:2008 specification
2109 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
2110 # if @REPLACE_SLEEP@
2111 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2112 # undef sleep
2113 # define sleep rpl_sleep
2114 # endif
2115 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
2116 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
2117 # else
2118 # if !@HAVE_SLEEP@
2119 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
2120 # endif
2121 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
2122 # endif
2123 _GL_CXXALIASWARN (sleep);
2124 #elif defined GNULIB_POSIXCHECK
2125 # undef sleep
2126 # if HAVE_RAW_DECL_SLEEP
2127 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
2128 "use gnulib module sleep for portability");
2129 # endif
2130 #endif
2131
2132
2133 #if @GNULIB_MDA_SWAB@
2134 /* On native Windows, map 'swab' to '_swab', so that -loldnames is not
2135 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2136 platforms by defining GNULIB_NAMESPACE::swab always. */
2137 # if defined _WIN32 && !defined __CYGWIN__
2138 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2139 # undef swab
2140 # define swab _swab
2141 # endif
2142 /* Need to cast, because in old mingw the arguments are
2143 (const char *from, char *to, size_t n). */
2144 _GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n));
2145 # else
2146 # if defined __hpux /* HP-UX */
2147 _GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
2148 # elif defined __sun && (defined __SunOS_5_10 || defined __XOPEN_OR_POSIX) && !defined _XPG4 /* Solaris */
2149 _GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
2150 # else
2151 _GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));
2152 # endif
2153 # endif
2154 _GL_CXXALIASWARN (swab);
2155 #endif
2156
2157
2158 #if @GNULIB_SYMLINK@
2159 # if @REPLACE_SYMLINK@
2160 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2161 # undef symlink
2162 # define symlink rpl_symlink
2163 # endif
2164 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
2165 _GL_ARG_NONNULL ((1, 2)));
2166 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
2167 # else
2168 # if !@HAVE_SYMLINK@
2169 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
2170 _GL_ARG_NONNULL ((1, 2)));
2171 # endif
2172 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
2173 # endif
2174 _GL_CXXALIASWARN (symlink);
2175 #elif defined GNULIB_POSIXCHECK
2176 # undef symlink
2177 # if HAVE_RAW_DECL_SYMLINK
2178 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
2179 "use gnulib module symlink for portability");
2180 # endif
2181 #endif
2182
2183
2184 #if @GNULIB_SYMLINKAT@
2185 # if @REPLACE_SYMLINKAT@
2186 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2187 # undef symlinkat
2188 # define symlinkat rpl_symlinkat
2189 # endif
2190 _GL_FUNCDECL_RPL (symlinkat, int,
2191 (char const *contents, int fd, char const *file)
2192 _GL_ARG_NONNULL ((1, 3)));
2193 _GL_CXXALIAS_RPL (symlinkat, int,
2194 (char const *contents, int fd, char const *file));
2195 # else
2196 # if !@HAVE_SYMLINKAT@
2197 _GL_FUNCDECL_SYS (symlinkat, int,
2198 (char const *contents, int fd, char const *file)
2199 _GL_ARG_NONNULL ((1, 3)));
2200 # endif
2201 _GL_CXXALIAS_SYS (symlinkat, int,
2202 (char const *contents, int fd, char const *file));
2203 # endif
2204 # if __GLIBC__ >= 2
2205 _GL_CXXALIASWARN (symlinkat);
2206 # endif
2207 #elif defined GNULIB_POSIXCHECK
2208 # undef symlinkat
2209 # if HAVE_RAW_DECL_SYMLINKAT
2210 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
2211 "use gnulib module symlinkat for portability");
2212 # endif
2213 #endif
2214
2215
2216 #if @GNULIB_TRUNCATE@
2217 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
2218 Return 0 if successful, otherwise -1 and errno set.
2219 See the POSIX:2008 specification
2220 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
2221 # if @REPLACE_TRUNCATE@
2222 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2223 # undef truncate
2224 # define truncate rpl_truncate
2225 # endif
2226 _GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
2227 _GL_ARG_NONNULL ((1)));
2228 _GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
2229 # else
2230 # if !@HAVE_DECL_TRUNCATE@
2231 _GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
2232 _GL_ARG_NONNULL ((1)));
2233 # endif
2234 _GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
2235 # endif
2236 # if __GLIBC__ >= 2
2237 _GL_CXXALIASWARN (truncate);
2238 # endif
2239 #elif defined GNULIB_POSIXCHECK
2240 # undef truncate
2241 # if HAVE_RAW_DECL_TRUNCATE
2242 _GL_WARN_ON_USE (truncate, "truncate is unportable - "
2243 "use gnulib module truncate for portability");
2244 # endif
2245 #endif
2246
2247
2248 #if @GNULIB_TTYNAME_R@
2249 /* Store at most BUFLEN characters of the pathname of the terminal FD is
2250 open on in BUF. Return 0 on success, otherwise an error number. */
2251 # if @REPLACE_TTYNAME_R@
2252 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2253 # undef ttyname_r
2254 # define ttyname_r rpl_ttyname_r
2255 # endif
2256 _GL_FUNCDECL_RPL (ttyname_r, int,
2257 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
2258 _GL_CXXALIAS_RPL (ttyname_r, int,
2259 (int fd, char *buf, size_t buflen));
2260 # else
2261 # if !@HAVE_DECL_TTYNAME_R@
2262 _GL_FUNCDECL_SYS (ttyname_r, int,
2263 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
2264 # endif
2265 _GL_CXXALIAS_SYS (ttyname_r, int,
2266 (int fd, char *buf, size_t buflen));
2267 # endif
2268 # if __GLIBC__ >= 2
2269 _GL_CXXALIASWARN (ttyname_r);
2270 # endif
2271 #elif defined GNULIB_POSIXCHECK
2272 # undef ttyname_r
2273 # if HAVE_RAW_DECL_TTYNAME_R
2274 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
2275 "use gnulib module ttyname_r for portability");
2276 # endif
2277 #endif
2278
2279
2280 #if @GNULIB_UNLINK@
2281 # if @REPLACE_UNLINK@
2282 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2283 # undef unlink
2284 # define unlink rpl_unlink
2285 # endif
2286 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
2287 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
2288 # elif defined _WIN32 && !defined __CYGWIN__
2289 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2290 # undef unlink
2291 # define unlink _unlink
2292 # endif
2293 _GL_CXXALIAS_MDA (unlink, int, (char const *file));
2294 # else
2295 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
2296 # endif
2297 _GL_CXXALIASWARN (unlink);
2298 #elif defined GNULIB_POSIXCHECK
2299 # undef unlink
2300 # if HAVE_RAW_DECL_UNLINK
2301 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
2302 "use gnulib module unlink for portability");
2303 # endif
2304 #elif @GNULIB_MDA_UNLINK@
2305 /* On native Windows, map 'unlink' to '_unlink', so that -loldnames is not
2306 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2307 platforms by defining GNULIB_NAMESPACE::unlink always. */
2308 # if defined _WIN32 && !defined __CYGWIN__
2309 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2310 # undef unlink
2311 # define unlink _unlink
2312 # endif
2313 _GL_CXXALIAS_MDA (unlink, int, (char const *file));
2314 # else
2315 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
2316 # endif
2317 _GL_CXXALIASWARN (unlink);
2318 #endif
2319
2320
2321 #if @GNULIB_UNLINKAT@
2322 # if @REPLACE_UNLINKAT@
2323 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2324 # undef unlinkat
2325 # define unlinkat rpl_unlinkat
2326 # endif
2327 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
2328 _GL_ARG_NONNULL ((2)));
2329 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
2330 # else
2331 # if !@HAVE_UNLINKAT@
2332 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
2333 _GL_ARG_NONNULL ((2)));
2334 # endif
2335 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
2336 # endif
2337 _GL_CXXALIASWARN (unlinkat);
2338 #elif defined GNULIB_POSIXCHECK
2339 # undef unlinkat
2340 # if HAVE_RAW_DECL_UNLINKAT
2341 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
2342 "use gnulib module unlinkat for portability");
2343 # endif
2344 #endif
2345
2346
2347 #if @GNULIB_USLEEP@
2348 /* Pause the execution of the current thread for N microseconds.
2349 Returns 0 on completion, or -1 on range error.
2350 See the POSIX:2001 specification
2351 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
2352 # if @REPLACE_USLEEP@
2353 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2354 # undef usleep
2355 # define usleep rpl_usleep
2356 # endif
2357 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
2358 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
2359 # else
2360 # if !@HAVE_USLEEP@
2361 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
2362 # endif
2363 /* Need to cast, because on Haiku, the first parameter is
2364 unsigned int n. */
2365 _GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n));
2366 # endif
2367 _GL_CXXALIASWARN (usleep);
2368 #elif defined GNULIB_POSIXCHECK
2369 # undef usleep
2370 # if HAVE_RAW_DECL_USLEEP
2371 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
2372 "use gnulib module usleep for portability");
2373 # endif
2374 #endif
2375
2376
2377 #if @GNULIB_WRITE@
2378 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
2379 See the POSIX:2008 specification
2380 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
2381 # if @REPLACE_WRITE@
2382 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2383 # undef write
2384 # define write rpl_write
2385 # endif
2386 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
2387 _GL_ARG_NONNULL ((2)));
2388 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
2389 # elif defined _WIN32 && !defined __CYGWIN__
2390 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2391 # undef write
2392 # define write _write
2393 # endif
2394 _GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, size_t count));
2395 # else
2396 _GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
2397 # endif
2398 _GL_CXXALIASWARN (write);
2399 #elif @GNULIB_MDA_WRITE@
2400 /* On native Windows, map 'write' to '_write', so that -loldnames is not
2401 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2402 platforms by defining GNULIB_NAMESPACE::write always. */
2403 # if defined _WIN32 && !defined __CYGWIN__
2404 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2405 # undef write
2406 # define write _write
2407 # endif
2408 # ifdef __MINGW32__
2409 _GL_CXXALIAS_MDA (write, int, (int fd, const void *buf, unsigned int count));
2410 # else
2411 _GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, unsigned int count));
2412 # endif
2413 # else
2414 _GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
2415 # endif
2416 _GL_CXXALIASWARN (write);
2417 #endif
2418
2419 _GL_INLINE_HEADER_END
2420
2421 #endif /* _@GUARD_PREFIX@_UNISTD_H */
2422 #endif /* _GL_INCLUDING_UNISTD_H */
2423 #endif /* _@GUARD_PREFIX@_UNISTD_H */