Debian Codegraph @

lib/unistd.in.h

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