summaryrefslogtreecommitdiffstats
path: root/gl/unistd.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/unistd.in.h')
-rw-r--r--gl/unistd.in.h997
1 files changed, 898 insertions, 99 deletions
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index 2ea9af4..4812fdb 100644
--- a/gl/unistd.in.h
+++ b/gl/unistd.in.h
@@ -1,18 +1,18 @@
1/* Substitute for and wrapper around <unistd.h>. 1/* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2013 Free Software Foundation, Inc. 2 Copyright (C) 2003-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#ifndef _@GUARD_PREFIX@_UNISTD_H 17#ifndef _@GUARD_PREFIX@_UNISTD_H
18 18
@@ -21,9 +21,23 @@
21#endif 21#endif
22@PRAGMA_COLUMNS@ 22@PRAGMA_COLUMNS@
23 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
24/* The include_next requires a split double-inclusion guard. */ 36/* The include_next requires a split double-inclusion guard. */
25#if @HAVE_UNISTD_H@ 37#if @HAVE_UNISTD_H@
38# define _GL_INCLUDING_UNISTD_H
26# @INCLUDE_NEXT@ @NEXT_UNISTD_H@ 39# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
40# undef _GL_INCLUDING_UNISTD_H
27#endif 41#endif
28 42
29/* Get all possible declarations of gethostname(). */ 43/* Get all possible declarations of gethostname(). */
@@ -38,21 +52,30 @@
38#define _@GUARD_PREFIX@_UNISTD_H 52#define _@GUARD_PREFIX@_UNISTD_H
39 53
40/* NetBSD 5.0 mis-defines NULL. Also get size_t. */ 54/* NetBSD 5.0 mis-defines NULL. Also get size_t. */
41#include <stddef.h> 55/* But avoid namespace pollution on glibc systems. */
56#ifndef __GLIBC__
57# include <stddef.h>
58#endif
42 59
43/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */ 60/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
61/* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>. We must include
62 it before we #define unlink rpl_unlink. */
44/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */ 63/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
45/* But avoid namespace pollution on glibc systems. */ 64/* But avoid namespace pollution on glibc systems. */
46#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \ 65#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
66 || ((@GNULIB_UNLINK@ || defined GNULIB_POSIXCHECK) \
67 && (defined _WIN32 && ! defined __CYGWIN__)) \
47 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \ 68 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
48 && defined __CYGWIN__)) \ 69 && defined __CYGWIN__)) \
49 && ! defined __GLIBC__ 70 && ! defined __GLIBC__
50# include <stdio.h> 71# include <stdio.h>
51#endif 72#endif
52 73
53/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */ 74/* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
75 <unistd.h>. */
54/* But avoid namespace pollution on glibc systems. */ 76/* But avoid namespace pollution on glibc systems. */
55#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \ 77#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
78 && (defined __CYGWIN__ || defined __ANDROID__) \
56 && ! defined __GLIBC__ 79 && ! defined __GLIBC__
57# include <fcntl.h> 80# include <fcntl.h>
58#endif 81#endif
@@ -70,20 +93,18 @@
70# undef __need_system_stdlib_h 93# undef __need_system_stdlib_h
71#endif 94#endif
72 95
73/* Native Windows platforms declare chdir, getcwd, rmdir in 96/* Native Windows platforms declare _chdir, _getcwd, _rmdir in
74 <io.h> and/or <direct.h>, not in <unistd.h>. 97 <io.h> and/or <direct.h>, not in <unistd.h>.
75 They also declare access(), chmod(), close(), dup(), dup2(), isatty(), 98 They also declare _access(), _chmod(), _close(), _dup(), _dup2(), _isatty(),
76 lseek(), read(), unlink(), write() in <io.h>. */ 99 _lseek(), _read(), _unlink(), _write() in <io.h>. */
77#if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \ 100#if defined _WIN32 && !defined __CYGWIN__
78 || defined GNULIB_POSIXCHECK) \
79 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
80# include <io.h> /* mingw32, mingw64 */
81# include <direct.h> /* mingw64, MSVC 9 */
82#elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
83 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
84 || defined GNULIB_POSIXCHECK) \
85 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
86# include <io.h> 101# include <io.h>
102# include <direct.h>
103#endif
104
105/* Native Windows platforms declare _execl*, _execv* in <process.h>. */
106#if defined _WIN32 && !defined __CYGWIN__
107# include <process.h>
87#endif 108#endif
88 109
89/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>. 110/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
@@ -95,31 +116,28 @@
95# include <netdb.h> 116# include <netdb.h>
96#endif 117#endif
97 118
98/* MSVC defines off_t in <sys/types.h>. 119/* Mac OS X 10.13, Solaris 11.4, and Android 9.0 declare getentropy in
99 May also define off_t to a 64-bit type on native Windows. */ 120 <sys/random.h>, not in <unistd.h>. */
100#if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@ 121/* But avoid namespace pollution on glibc systems. */
101/* Get off_t. */ 122#if (@GNULIB_GETENTROPY@ || defined GNULIB_POSIXCHECK) \
102# include <sys/types.h> 123 && ((defined __APPLE__ && defined __MACH__) || defined __sun \
103#endif 124 || defined __ANDROID__) \
104 125 && @UNISTD_H_HAVE_SYS_RANDOM_H@ \
105#if (@GNULIB_READ@ || @GNULIB_WRITE@ \ 126 && !defined __GLIBC__
106 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ 127# include <sys/random.h>
107 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
108/* Get ssize_t. */
109# include <sys/types.h>
110#endif 128#endif
111 129
112/* Get getopt(), optarg, optind, opterr, optopt. 130/* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>. */
113 But avoid namespace pollution on glibc systems. */ 131/* But avoid namespace pollution on glibc systems. */
114#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT 132#if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
115# define __need_getopt 133 && !defined __GLIBC__
116# include <getopt.h> 134# include <sys/stat.h>
117#endif 135#endif
118 136
119_GL_INLINE_HEADER_BEGIN 137/* MSVC defines off_t in <sys/types.h>.
120#ifndef _GL_UNISTD_INLINE 138 May also define off_t to a 64-bit type on native Windows. */
121# define _GL_UNISTD_INLINE _GL_INLINE 139/* Get off_t, ssize_t, mode_t. */
122#endif 140#include <sys/types.h>
123 141
124/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 142/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
125 143
@@ -128,6 +146,20 @@ _GL_INLINE_HEADER_BEGIN
128/* The definition of _GL_WARN_ON_USE is copied here. */ 146/* The definition of _GL_WARN_ON_USE is copied here. */
129 147
130 148
149/* Get getopt(), optarg, optind, opterr, optopt. */
150#if @GNULIB_GETOPT_POSIX@ && @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
151# include <getopt-cdefs.h>
152# include <getopt-pfx-core.h>
153#endif
154
155#ifndef _GL_INLINE_HEADER_BEGIN
156 #error "Please include config.h first."
157#endif
158_GL_INLINE_HEADER_BEGIN
159#ifndef _GL_UNISTD_INLINE
160# define _GL_UNISTD_INLINE _GL_INLINE
161#endif
162
131/* Hide some function declarations from <winsock2.h>. */ 163/* Hide some function declarations from <winsock2.h>. */
132 164
133#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ 165#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
@@ -227,15 +259,61 @@ _GL_INLINE_HEADER_BEGIN
227/* Declare overridden functions. */ 259/* Declare overridden functions. */
228 260
229 261
230#if defined GNULIB_POSIXCHECK 262#if @GNULIB_ACCESS@
263# if @REPLACE_ACCESS@
264# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
265# undef access
266# define access rpl_access
267# endif
268_GL_FUNCDECL_RPL (access, int, (const char *file, int mode)
269 _GL_ARG_NONNULL ((1)));
270_GL_CXXALIAS_RPL (access, int, (const char *file, int mode));
271# elif defined _WIN32 && !defined __CYGWIN__
272# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
273# undef access
274# define access _access
275# endif
276_GL_CXXALIAS_MDA (access, int, (const char *file, int mode));
277# else
278_GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
279# endif
280_GL_CXXALIASWARN (access);
281#elif defined GNULIB_POSIXCHECK
282# undef access
283# if HAVE_RAW_DECL_ACCESS
231/* The access() function is a security risk. */ 284/* The access() function is a security risk. */
232_GL_WARN_ON_USE (access, "the access function is a security risk - " 285_GL_WARN_ON_USE (access, "access does not always support X_OK - "
286 "use gnulib module access for portability; "
287 "also, this function is a security risk - "
233 "use the gnulib module faccessat instead"); 288 "use the gnulib module faccessat instead");
289# endif
290#elif @GNULIB_MDA_ACCESS@
291/* On native Windows, map 'access' to '_access', so that -loldnames is not
292 required. In C++ with GNULIB_NAMESPACE, avoid differences between
293 platforms by defining GNULIB_NAMESPACE::access always. */
294# if 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);
234#endif 304#endif
235 305
236 306
237#if @GNULIB_CHDIR@ 307#if @GNULIB_CHDIR@
308# if defined _WIN32 && !defined __CYGWIN__
309# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
310# undef chdir
311# define chdir _chdir
312# endif
313_GL_CXXALIAS_MDA (chdir, int, (const char *file));
314# else
238_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1))); 315_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
316# endif
239_GL_CXXALIASWARN (chdir); 317_GL_CXXALIASWARN (chdir);
240#elif defined GNULIB_POSIXCHECK 318#elif defined GNULIB_POSIXCHECK
241# undef chdir 319# undef chdir
@@ -243,6 +321,20 @@ _GL_CXXALIASWARN (chdir);
243_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - " 321_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
244 "use gnulib module chdir for portability"); 322 "use gnulib module chdir for portability");
245# endif 323# endif
324#elif @GNULIB_MDA_CHDIR@
325/* On native Windows, map 'chdir' to '_chdir', so that -loldnames is not
326 required. In C++ with GNULIB_NAMESPACE, avoid differences between
327 platforms by defining GNULIB_NAMESPACE::chdir always. */
328# if defined _WIN32 && !defined __CYGWIN__
329# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
330# undef chdir
331# define chdir _chdir
332# endif
333_GL_CXXALIAS_MDA (chdir, int, (const char *file));
334# else
335_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
336# endif
337_GL_CXXALIASWARN (chdir);
246#endif 338#endif
247 339
248 340
@@ -251,7 +343,7 @@ _GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
251 to GID (if GID is not -1). Follow symbolic links. 343 to GID (if GID is not -1). Follow symbolic links.
252 Return 0 if successful, otherwise -1 and errno set. 344 Return 0 if successful, otherwise -1 and errno set.
253 See the POSIX:2008 specification 345 See the POSIX:2008 specification
254 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */ 346 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
255# if @REPLACE_CHOWN@ 347# if @REPLACE_CHOWN@
256# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 348# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
257# undef chown 349# undef chown
@@ -287,6 +379,12 @@ _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
287# endif 379# endif
288_GL_FUNCDECL_RPL (close, int, (int fd)); 380_GL_FUNCDECL_RPL (close, int, (int fd));
289_GL_CXXALIAS_RPL (close, int, (int fd)); 381_GL_CXXALIAS_RPL (close, int, (int fd));
382# elif defined _WIN32 && !defined __CYGWIN__
383# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
384# undef close
385# define close _close
386# endif
387_GL_CXXALIAS_MDA (close, int, (int fd));
290# else 388# else
291_GL_CXXALIAS_SYS (close, int, (int fd)); 389_GL_CXXALIAS_SYS (close, int, (int fd));
292# endif 390# endif
@@ -299,6 +397,53 @@ _GL_CXXALIASWARN (close);
299/* Assume close is always declared. */ 397/* Assume close is always declared. */
300_GL_WARN_ON_USE (close, "close does not portably work on sockets - " 398_GL_WARN_ON_USE (close, "close does not portably work on sockets - "
301 "use gnulib module close for portability"); 399 "use gnulib module close for portability");
400#elif @GNULIB_MDA_CLOSE@
401/* On native Windows, map 'close' to '_close', so that -loldnames is not
402 required. In C++ with GNULIB_NAMESPACE, avoid differences between
403 platforms by defining GNULIB_NAMESPACE::close always. */
404# if defined _WIN32 && !defined __CYGWIN__
405# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
406# undef close
407# define close _close
408# endif
409_GL_CXXALIAS_MDA (close, int, (int fd));
410# else
411_GL_CXXALIAS_SYS (close, int, (int fd));
412# endif
413_GL_CXXALIASWARN (close);
414#endif
415
416
417#if @GNULIB_COPY_FILE_RANGE@
418# if @REPLACE_COPY_FILE_RANGE@
419# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
420# undef copy_file_range
421# define copy_file_range rpl_copy_file_range
422# endif
423_GL_FUNCDECL_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
424 int ofd, off_t *opos,
425 size_t len, unsigned flags));
426_GL_CXXALIAS_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
427 int ofd, off_t *opos,
428 size_t len, unsigned flags));
429# else
430# if !@HAVE_COPY_FILE_RANGE@
431_GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
432 int ofd, off_t *opos,
433 size_t len, unsigned flags));
434# endif
435_GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
436 int ofd, off_t *opos,
437 size_t len, unsigned flags));
438# endif
439_GL_CXXALIASWARN (copy_file_range);
440#elif defined GNULIB_POSIXCHECK
441# undef copy_file_range
442# if HAVE_RAW_DECL_COPY_FILE_RANGE
443_GL_WARN_ON_USE (copy_file_range,
444 "copy_file_range is unportable - "
445 "use gnulib module copy_file_range for portability");
446# endif
302#endif 447#endif
303 448
304 449
@@ -309,6 +454,12 @@ _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
309# endif 454# endif
310_GL_FUNCDECL_RPL (dup, int, (int oldfd)); 455_GL_FUNCDECL_RPL (dup, int, (int oldfd));
311_GL_CXXALIAS_RPL (dup, int, (int oldfd)); 456_GL_CXXALIAS_RPL (dup, int, (int oldfd));
457# elif defined _WIN32 && !defined __CYGWIN__
458# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
459# undef dup
460# define dup _dup
461# endif
462_GL_CXXALIAS_MDA (dup, int, (int oldfd));
312# else 463# else
313_GL_CXXALIAS_SYS (dup, int, (int oldfd)); 464_GL_CXXALIAS_SYS (dup, int, (int oldfd));
314# endif 465# endif
@@ -319,6 +470,20 @@ _GL_CXXALIASWARN (dup);
319_GL_WARN_ON_USE (dup, "dup is unportable - " 470_GL_WARN_ON_USE (dup, "dup is unportable - "
320 "use gnulib module dup for portability"); 471 "use gnulib module dup for portability");
321# endif 472# endif
473#elif @GNULIB_MDA_DUP@
474/* On native Windows, map 'dup' to '_dup', so that -loldnames is not
475 required. In C++ with GNULIB_NAMESPACE, avoid differences between
476 platforms by defining GNULIB_NAMESPACE::dup always. */
477# if defined _WIN32 && !defined __CYGWIN__
478# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
479# undef dup
480# define dup _dup
481# endif
482_GL_CXXALIAS_MDA (dup, int, (int oldfd));
483# else
484_GL_CXXALIAS_SYS (dup, int, (int oldfd));
485# endif
486_GL_CXXALIASWARN (dup);
322#endif 487#endif
323 488
324 489
@@ -327,17 +492,20 @@ _GL_WARN_ON_USE (dup, "dup is unportable - "
327 NEWFD = OLDFD, otherwise close NEWFD first if it is open. 492 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
328 Return newfd if successful, otherwise -1 and errno set. 493 Return newfd if successful, otherwise -1 and errno set.
329 See the POSIX:2008 specification 494 See the POSIX:2008 specification
330 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */ 495 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
331# if @REPLACE_DUP2@ 496# if @REPLACE_DUP2@
332# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 497# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
333# define dup2 rpl_dup2 498# define dup2 rpl_dup2
334# endif 499# endif
335_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd)); 500_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
336_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd)); 501_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
337# else 502# elif defined _WIN32 && !defined __CYGWIN__
338# if !@HAVE_DUP2@ 503# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
339_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd)); 504# undef dup2
505# define dup2 _dup2
340# endif 506# endif
507_GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
508# else
341_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd)); 509_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
342# endif 510# endif
343_GL_CXXALIASWARN (dup2); 511_GL_CXXALIASWARN (dup2);
@@ -347,6 +515,20 @@ _GL_CXXALIASWARN (dup2);
347_GL_WARN_ON_USE (dup2, "dup2 is unportable - " 515_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
348 "use gnulib module dup2 for portability"); 516 "use gnulib module dup2 for portability");
349# endif 517# endif
518#elif @GNULIB_MDA_DUP2@
519/* On native Windows, map 'dup2' to '_dup2', so that -loldnames is not
520 required. In C++ with GNULIB_NAMESPACE, avoid differences between
521 platforms by defining GNULIB_NAMESPACE::dup2 always. */
522# if defined _WIN32 && !defined __CYGWIN__
523# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
524# undef dup2
525# define dup2 _dup2
526# endif
527_GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
528# else
529_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
530# endif
531_GL_CXXALIASWARN (dup2);
350#endif 532#endif
351 533
352 534
@@ -358,7 +540,7 @@ _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
358 Close NEWFD first if it is open. 540 Close NEWFD first if it is open.
359 Return newfd if successful, otherwise -1 and errno set. 541 Return newfd if successful, otherwise -1 and errno set.
360 See the Linux man page at 542 See the Linux man page at
361 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */ 543 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
362# if @HAVE_DUP3@ 544# if @HAVE_DUP3@
363# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 545# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
364# define dup3 rpl_dup3 546# define dup3 rpl_dup3
@@ -380,10 +562,23 @@ _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
380 562
381 563
382#if @GNULIB_ENVIRON@ 564#if @GNULIB_ENVIRON@
565# if defined __CYGWIN__ && !defined __i386__
566/* The 'environ' variable is defined in a DLL. Therefore its declaration needs
567 the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
568 This leads to a link error on 64-bit Cygwin when the option
569 -Wl,--disable-auto-import is in use. */
570_GL_EXTERN_C __declspec(dllimport) char **environ;
571# endif
383# if !@HAVE_DECL_ENVIRON@ 572# if !@HAVE_DECL_ENVIRON@
384/* Set of environment variables and values. An array of strings of the form 573/* Set of environment variables and values. An array of strings of the form
385 "VARIABLE=VALUE", terminated with a NULL. */ 574 "VARIABLE=VALUE", terminated with a NULL. */
386# if defined __APPLE__ && defined __MACH__ 575# if defined __APPLE__ && defined __MACH__
576# include <TargetConditionals.h>
577# if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
578# define _GL_USE_CRT_EXTERNS
579# endif
580# endif
581# ifdef _GL_USE_CRT_EXTERNS
387# include <crt_externs.h> 582# include <crt_externs.h>
388# define environ (*_NSGetEnviron ()) 583# define environ (*_NSGetEnviron ())
389# else 584# else
@@ -399,12 +594,12 @@ extern char **environ;
399#elif defined GNULIB_POSIXCHECK 594#elif defined GNULIB_POSIXCHECK
400# if HAVE_RAW_DECL_ENVIRON 595# if HAVE_RAW_DECL_ENVIRON
401_GL_UNISTD_INLINE char *** 596_GL_UNISTD_INLINE char ***
597_GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
598 "use gnulib module environ for portability")
402rpl_environ (void) 599rpl_environ (void)
403{ 600{
404 return &environ; 601 return &environ;
405} 602}
406_GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
407 "use gnulib module environ for portability");
408# undef environ 603# undef environ
409# define environ (*rpl_environ ()) 604# define environ (*rpl_environ ())
410# endif 605# endif
@@ -434,14 +629,302 @@ _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
434#endif 629#endif
435 630
436 631
632#if @GNULIB_EXECL@
633# if @REPLACE_EXECL@
634# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
635# undef execl
636# define execl rpl_execl
637# endif
638_GL_FUNCDECL_RPL (execl, int, (const char *program, const char *arg, ...)
639 _GL_ARG_NONNULL ((1)));
640_GL_CXXALIAS_RPL (execl, int, (const char *program, const char *arg, ...));
641# else
642_GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
643# endif
644_GL_CXXALIASWARN (execl);
645#elif defined GNULIB_POSIXCHECK
646# undef execl
647# if HAVE_RAW_DECL_EXECL
648_GL_WARN_ON_USE (execl, "execl behaves very differently on mingw - "
649 "use gnulib module execl for portability");
650# endif
651#elif @GNULIB_MDA_EXECL@
652/* On native Windows, map 'execl' to '_execl', so that -loldnames is not
653 required. In C++ with GNULIB_NAMESPACE, avoid differences between
654 platforms by defining GNULIB_NAMESPACE::execl always. */
655# if defined _WIN32 && !defined __CYGWIN__
656# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
657# undef execl
658# define execl _execl
659# endif
660_GL_CXXALIAS_MDA (execl, intptr_t, (const char *program, const char *arg, ...));
661# else
662_GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
663# endif
664_GL_CXXALIASWARN (execl);
665#endif
666
667#if @GNULIB_EXECLE@
668# if @REPLACE_EXECLE@
669# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
670# undef execle
671# define execle rpl_execle
672# endif
673_GL_FUNCDECL_RPL (execle, int, (const char *program, const char *arg, ...)
674 _GL_ARG_NONNULL ((1)));
675_GL_CXXALIAS_RPL (execle, int, (const char *program, const char *arg, ...));
676# else
677_GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
678# endif
679_GL_CXXALIASWARN (execle);
680#elif defined GNULIB_POSIXCHECK
681# undef execle
682# if HAVE_RAW_DECL_EXECLE
683_GL_WARN_ON_USE (execle, "execle behaves very differently on mingw - "
684 "use gnulib module execle for portability");
685# endif
686#elif @GNULIB_MDA_EXECLE@
687/* On native Windows, map 'execle' to '_execle', so that -loldnames is not
688 required. In C++ with GNULIB_NAMESPACE, avoid differences between
689 platforms by defining GNULIB_NAMESPACE::execle always. */
690# if defined _WIN32 && !defined __CYGWIN__
691# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
692# undef execle
693# define execle _execle
694# endif
695_GL_CXXALIAS_MDA (execle, intptr_t,
696 (const char *program, const char *arg, ...));
697# else
698_GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
699# endif
700_GL_CXXALIASWARN (execle);
701#endif
702
703#if @GNULIB_EXECLP@
704# if @REPLACE_EXECLP@
705# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
706# undef execlp
707# define execlp rpl_execlp
708# endif
709_GL_FUNCDECL_RPL (execlp, int, (const char *program, const char *arg, ...)
710 _GL_ARG_NONNULL ((1)));
711_GL_CXXALIAS_RPL (execlp, int, (const char *program, const char *arg, ...));
712# else
713_GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
714# endif
715_GL_CXXALIASWARN (execlp);
716#elif defined GNULIB_POSIXCHECK
717# undef execlp
718# if HAVE_RAW_DECL_EXECLP
719_GL_WARN_ON_USE (execlp, "execlp behaves very differently on mingw - "
720 "use gnulib module execlp for portability");
721# endif
722#elif @GNULIB_MDA_EXECLP@
723/* On native Windows, map 'execlp' to '_execlp', so that -loldnames is not
724 required. In C++ with GNULIB_NAMESPACE, avoid differences between
725 platforms by defining GNULIB_NAMESPACE::execlp always. */
726# if defined _WIN32 && !defined __CYGWIN__
727# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
728# undef execlp
729# define execlp _execlp
730# endif
731_GL_CXXALIAS_MDA (execlp, intptr_t,
732 (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#endif
738
739
740#if @GNULIB_EXECV@
741# if @REPLACE_EXECV@
742# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
743# undef execv
744# define execv rpl_execv
745# endif
746_GL_FUNCDECL_RPL (execv, int, (const char *program, char * const *argv)
747 _GL_ARG_NONNULL ((1, 2)));
748_GL_CXXALIAS_RPL (execv, int, (const char *program, char * const *argv));
749# else
750_GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
751# endif
752_GL_CXXALIASWARN (execv);
753#elif defined GNULIB_POSIXCHECK
754# undef execv
755# if HAVE_RAW_DECL_EXECV
756_GL_WARN_ON_USE (execv, "execv behaves very differently on mingw - "
757 "use gnulib module execv for portability");
758# endif
759#elif @GNULIB_MDA_EXECV@
760/* On native Windows, map 'execv' to '_execv', so that -loldnames is not
761 required. In C++ with GNULIB_NAMESPACE, avoid differences between
762 platforms by defining GNULIB_NAMESPACE::execv always. */
763# if defined _WIN32 && !defined __CYGWIN__
764# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
765# undef execv
766# define execv _execv
767# endif
768_GL_CXXALIAS_MDA_CAST (execv, intptr_t,
769 (const char *program, char * const *argv));
770# else
771_GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
772# endif
773_GL_CXXALIASWARN (execv);
774#endif
775
776#if @GNULIB_EXECVE@
777# if @REPLACE_EXECVE@
778# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
779# undef execve
780# define execve rpl_execve
781# endif
782_GL_FUNCDECL_RPL (execve, int,
783 (const char *program, char * const *argv, char * const *env)
784 _GL_ARG_NONNULL ((1, 2)));
785_GL_CXXALIAS_RPL (execve, int,
786 (const char *program, char * const *argv, char * const *env));
787# else
788_GL_CXXALIAS_SYS (execve, int,
789 (const char *program, char * const *argv, char * const *env));
790# endif
791_GL_CXXALIASWARN (execve);
792#elif defined GNULIB_POSIXCHECK
793# undef execve
794# if HAVE_RAW_DECL_EXECVE
795_GL_WARN_ON_USE (execve, "execve behaves very differently on mingw - "
796 "use gnulib module execve for portability");
797# endif
798#elif @GNULIB_MDA_EXECVE@
799/* On native Windows, map 'execve' to '_execve', so that -loldnames is not
800 required. In C++ with GNULIB_NAMESPACE, avoid differences between
801 platforms by defining GNULIB_NAMESPACE::execve always. */
802# if defined _WIN32 && !defined __CYGWIN__
803# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
804# undef execve
805# define execve _execve
806# endif
807_GL_CXXALIAS_MDA_CAST (execve, intptr_t,
808 (const char *program, char * const *argv,
809 char * const *env));
810# else
811_GL_CXXALIAS_SYS (execve, int,
812 (const char *program, char * const *argv, char * const *env));
813# endif
814_GL_CXXALIASWARN (execve);
815#endif
816
817#if @GNULIB_EXECVP@
818# if @REPLACE_EXECVP@
819# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
820# undef execvp
821# define execvp rpl_execvp
822# endif
823_GL_FUNCDECL_RPL (execvp, int, (const char *program, char * const *argv)
824 _GL_ARG_NONNULL ((1, 2)));
825_GL_CXXALIAS_RPL (execvp, int, (const char *program, char * const *argv));
826# else
827_GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
828# endif
829_GL_CXXALIASWARN (execvp);
830#elif defined GNULIB_POSIXCHECK
831# undef execvp
832# if HAVE_RAW_DECL_EXECVP
833_GL_WARN_ON_USE (execvp, "execvp behaves very differently on mingw - "
834 "use gnulib module execvp for portability");
835# endif
836#elif @GNULIB_MDA_EXECVP@
837/* On native Windows, map 'execvp' to '_execvp', so that -loldnames is not
838 required. In C++ with GNULIB_NAMESPACE, avoid differences between
839 platforms by defining GNULIB_NAMESPACE::execvp always. */
840# if defined _WIN32 && !defined __CYGWIN__
841# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
842# undef execvp
843# define execvp _execvp
844# endif
845_GL_CXXALIAS_MDA_CAST (execvp, intptr_t,
846 (const char *program, char * const *argv));
847# else
848_GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
849# endif
850_GL_CXXALIASWARN (execvp);
851#endif
852
853#if @GNULIB_EXECVPE@
854# if @REPLACE_EXECVPE@
855# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
856# undef execvpe
857# define execvpe rpl_execvpe
858# endif
859_GL_FUNCDECL_RPL (execvpe, int,
860 (const char *program, char * const *argv, char * const *env)
861 _GL_ARG_NONNULL ((1, 2)));
862_GL_CXXALIAS_RPL (execvpe, int,
863 (const char *program, char * const *argv, char * const *env));
864# else
865# if !@HAVE_DECL_EXECVPE@
866_GL_FUNCDECL_SYS (execvpe, int,
867 (const char *program, char * const *argv, char * const *env)
868 _GL_ARG_NONNULL ((1, 2)));
869# endif
870_GL_CXXALIAS_SYS (execvpe, int,
871 (const char *program, char * const *argv, char * const *env));
872# endif
873_GL_CXXALIASWARN (execvpe);
874#elif defined GNULIB_POSIXCHECK
875# undef execvpe
876# if HAVE_RAW_DECL_EXECVPE
877_GL_WARN_ON_USE (execvpe, "execvpe behaves very differently on mingw - "
878 "use gnulib module execvpe for portability");
879# endif
880#elif @GNULIB_MDA_EXECVPE@
881/* On native Windows, map 'execvpe' to '_execvpe', so that -loldnames is not
882 required. In C++ with GNULIB_NAMESPACE, avoid differences between
883 platforms by defining GNULIB_NAMESPACE::execvpe on all platforms that have
884 it. */
885# if defined _WIN32 && !defined __CYGWIN__
886# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
887# undef execvpe
888# define execvpe _execvpe
889# endif
890_GL_CXXALIAS_MDA_CAST (execvpe, intptr_t,
891 (const char *program, char * const *argv,
892 char * const *env));
893# elif @HAVE_EXECVPE@
894# if !@HAVE_DECL_EXECVPE@
895_GL_FUNCDECL_SYS (execvpe, int,
896 (const char *program, char * const *argv, char * const *env)
897 _GL_ARG_NONNULL ((1, 2)));
898# endif
899_GL_CXXALIAS_SYS (execvpe, int,
900 (const char *program, char * const *argv, char * const *env));
901# endif
902# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_EXECVPE@
903_GL_CXXALIASWARN (execvpe);
904# endif
905#endif
906
907
437#if @GNULIB_FACCESSAT@ 908#if @GNULIB_FACCESSAT@
438# if !@HAVE_FACCESSAT@ 909# if @REPLACE_FACCESSAT@
910# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
911# undef faccessat
912# define faccessat rpl_faccessat
913# endif
914_GL_FUNCDECL_RPL (faccessat, int,
915 (int fd, char const *name, int mode, int flag)
916 _GL_ARG_NONNULL ((2)));
917_GL_CXXALIAS_RPL (faccessat, int,
918 (int fd, char const *name, int mode, int flag));
919# else
920# if !@HAVE_FACCESSAT@
439_GL_FUNCDECL_SYS (faccessat, int, 921_GL_FUNCDECL_SYS (faccessat, int,
440 (int fd, char const *file, int mode, int flag) 922 (int fd, char const *file, int mode, int flag)
441 _GL_ARG_NONNULL ((2))); 923 _GL_ARG_NONNULL ((2)));
442# endif 924# endif
443_GL_CXXALIAS_SYS (faccessat, int, 925_GL_CXXALIAS_SYS (faccessat, int,
444 (int fd, char const *file, int mode, int flag)); 926 (int fd, char const *file, int mode, int flag));
927# endif
445_GL_CXXALIASWARN (faccessat); 928_GL_CXXALIASWARN (faccessat);
446#elif defined GNULIB_POSIXCHECK 929#elif defined GNULIB_POSIXCHECK
447# undef faccessat 930# undef faccessat
@@ -457,7 +940,7 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
457 the given file descriptor is open. 940 the given file descriptor is open.
458 Return 0 if successful, otherwise -1 and errno set. 941 Return 0 if successful, otherwise -1 and errno set.
459 See the POSIX:2008 specification 942 See the POSIX:2008 specification
460 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */ 943 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
461# if ! @HAVE_FCHDIR@ 944# if ! @HAVE_FCHDIR@
462_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); 945_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
463 946
@@ -509,7 +992,7 @@ _GL_CXXALIASWARN (fchownat);
509# undef fchownat 992# undef fchownat
510# if HAVE_RAW_DECL_FCHOWNAT 993# if HAVE_RAW_DECL_FCHOWNAT
511_GL_WARN_ON_USE (fchownat, "fchownat is not portable - " 994_GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
512 "use gnulib module openat for portability"); 995 "use gnulib module fchownat for portability");
513# endif 996# endif
514#endif 997#endif
515 998
@@ -518,7 +1001,7 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
518/* Synchronize changes to a file. 1001/* Synchronize changes to a file.
519 Return 0 if successful, otherwise -1 and errno set. 1002 Return 0 if successful, otherwise -1 and errno set.
520 See POSIX:2008 specification 1003 See POSIX:2008 specification
521 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */ 1004 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
522# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@ 1005# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
523_GL_FUNCDECL_SYS (fdatasync, int, (int fd)); 1006_GL_FUNCDECL_SYS (fdatasync, int, (int fd));
524# endif 1007# endif
@@ -537,7 +1020,7 @@ _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
537/* Synchronize changes, including metadata, to a file. 1020/* Synchronize changes, including metadata, to a file.
538 Return 0 if successful, otherwise -1 and errno set. 1021 Return 0 if successful, otherwise -1 and errno set.
539 See POSIX:2008 specification 1022 See POSIX:2008 specification
540 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */ 1023 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
541# if !@HAVE_FSYNC@ 1024# if !@HAVE_FSYNC@
542_GL_FUNCDECL_SYS (fsync, int, (int fd)); 1025_GL_FUNCDECL_SYS (fsync, int, (int fd));
543# endif 1026# endif
@@ -556,7 +1039,7 @@ _GL_WARN_ON_USE (fsync, "fsync is unportable - "
556/* Change the size of the file to which FD is opened to become equal to LENGTH. 1039/* Change the size of the file to which FD is opened to become equal to LENGTH.
557 Return 0 if successful, otherwise -1 and errno set. 1040 Return 0 if successful, otherwise -1 and errno set.
558 See the POSIX:2008 specification 1041 See the POSIX:2008 specification
559 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */ 1042 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
560# if @REPLACE_FTRUNCATE@ 1043# if @REPLACE_FTRUNCATE@
561# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1044# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
562# undef ftruncate 1045# undef ftruncate
@@ -586,7 +1069,7 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
586 Return BUF if successful, or NULL if the directory couldn't be determined 1069 Return BUF if successful, or NULL if the directory couldn't be determined
587 or SIZE was too small. 1070 or SIZE was too small.
588 See the POSIX:2008 specification 1071 See the POSIX:2008 specification
589 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>. 1072 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
590 Additionally, the gnulib module 'getcwd' guarantees the following GNU 1073 Additionally, the gnulib module 'getcwd' guarantees the following GNU
591 extension: If BUF is NULL, an array is allocated with 'malloc'; the array 1074 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
592 is SIZE bytes long, unless SIZE == 0, in which case it is as big as 1075 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
@@ -597,6 +1080,12 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
597# endif 1080# endif
598_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); 1081_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
599_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); 1082_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
1083# elif defined _WIN32 && !defined __CYGWIN__
1084# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1085# undef getcwd
1086# define getcwd _getcwd
1087# endif
1088_GL_CXXALIAS_MDA (getcwd, char *, (char *buf, size_t size));
600# else 1089# else
601/* Need to cast, because on mingw, the second parameter is 1090/* Need to cast, because on mingw, the second parameter is
602 int size. */ 1091 int size. */
@@ -609,6 +1098,22 @@ _GL_CXXALIASWARN (getcwd);
609_GL_WARN_ON_USE (getcwd, "getcwd is unportable - " 1098_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
610 "use gnulib module getcwd for portability"); 1099 "use gnulib module getcwd for portability");
611# endif 1100# endif
1101#elif @GNULIB_MDA_GETCWD@
1102/* On native Windows, map 'getcwd' to '_getcwd', so that -loldnames is not
1103 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1104 platforms by defining GNULIB_NAMESPACE::getcwd always. */
1105# if defined _WIN32 && !defined __CYGWIN__
1106# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1107# undef getcwd
1108# define getcwd _getcwd
1109# endif
1110/* Need to cast, because on mingw, the second parameter is either
1111 'int size' or 'size_t size'. */
1112_GL_CXXALIAS_MDA_CAST (getcwd, char *, (char *buf, size_t size));
1113# else
1114_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
1115# endif
1116_GL_CXXALIASWARN (getcwd);
612#endif 1117#endif
613 1118
614 1119
@@ -638,7 +1143,9 @@ _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
638# endif 1143# endif
639_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len)); 1144_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
640# endif 1145# endif
1146# if __GLIBC__ >= 2
641_GL_CXXALIASWARN (getdomainname); 1147_GL_CXXALIASWARN (getdomainname);
1148# endif
642#elif defined GNULIB_POSIXCHECK 1149#elif defined GNULIB_POSIXCHECK
643# undef getdomainname 1150# undef getdomainname
644# if HAVE_RAW_DECL_GETDOMAINNAME 1151# if HAVE_RAW_DECL_GETDOMAINNAME
@@ -651,10 +1158,21 @@ _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
651#if @GNULIB_GETDTABLESIZE@ 1158#if @GNULIB_GETDTABLESIZE@
652/* Return the maximum number of file descriptors in the current process. 1159/* Return the maximum number of file descriptors in the current process.
653 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */ 1160 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
654# if !@HAVE_GETDTABLESIZE@ 1161# if @REPLACE_GETDTABLESIZE@
1162# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1163# undef getdtablesize
1164# define getdtablesize rpl_getdtablesize
1165# endif
1166_GL_FUNCDECL_RPL (getdtablesize, int, (void));
1167_GL_CXXALIAS_RPL (getdtablesize, int, (void));
1168# else
1169# if !@HAVE_GETDTABLESIZE@
655_GL_FUNCDECL_SYS (getdtablesize, int, (void)); 1170_GL_FUNCDECL_SYS (getdtablesize, int, (void));
1171# endif
1172/* Need to cast, because on AIX, the parameter list is
1173 (...). */
1174_GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void));
656# endif 1175# endif
657_GL_CXXALIAS_SYS (getdtablesize, int, (void));
658_GL_CXXALIASWARN (getdtablesize); 1176_GL_CXXALIASWARN (getdtablesize);
659#elif defined GNULIB_POSIXCHECK 1177#elif defined GNULIB_POSIXCHECK
660# undef getdtablesize 1178# undef getdtablesize
@@ -665,6 +1183,22 @@ _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
665#endif 1183#endif
666 1184
667 1185
1186#if @GNULIB_GETENTROPY@
1187/* Fill a buffer with random bytes. */
1188# if !@HAVE_GETENTROPY@
1189_GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length));
1190# endif
1191_GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length));
1192_GL_CXXALIASWARN (getentropy);
1193#elif defined GNULIB_POSIXCHECK
1194# undef getentropy
1195# if HAVE_RAW_DECL_GETENTROPY
1196_GL_WARN_ON_USE (getentropy, "getentropy is unportable - "
1197 "use gnulib module getentropy for portability");
1198# endif
1199#endif
1200
1201
668#if @GNULIB_GETGROUPS@ 1202#if @GNULIB_GETGROUPS@
669/* Return the supplemental groups that the current process belongs to. 1203/* Return the supplemental groups that the current process belongs to.
670 It is unspecified whether the effective group id is in the list. 1204 It is unspecified whether the effective group id is in the list.
@@ -737,14 +1271,14 @@ _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
737/* Returns the user's login name, or NULL if it cannot be found. Upon error, 1271/* Returns the user's login name, or NULL if it cannot be found. Upon error,
738 returns NULL with errno set. 1272 returns NULL with errno set.
739 1273
740 See <http://www.opengroup.org/susv3xsh/getlogin.html>. 1274 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
741 1275
742 Most programs don't need to use this function, because the information is 1276 Most programs don't need to use this function, because the information is
743 available through environment variables: 1277 available through environment variables:
744 ${LOGNAME-$USER} on Unix platforms, 1278 ${LOGNAME-$USER} on Unix platforms,
745 $USERNAME on native Windows platforms. 1279 $USERNAME on native Windows platforms.
746 */ 1280 */
747# if !@HAVE_GETLOGIN@ 1281# if !@HAVE_DECL_GETLOGIN@
748_GL_FUNCDECL_SYS (getlogin, char *, (void)); 1282_GL_FUNCDECL_SYS (getlogin, char *, (void));
749# endif 1283# endif
750_GL_CXXALIAS_SYS (getlogin, char *, (void)); 1284_GL_CXXALIAS_SYS (getlogin, char *, (void));
@@ -766,7 +1300,7 @@ _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
766 the case that the login name cannot be found but no specific error is 1300 the case that the login name cannot be found but no specific error is
767 provided (this case is hopefully rare but is left open by the POSIX spec). 1301 provided (this case is hopefully rare but is left open by the POSIX spec).
768 1302
769 See <http://www.opengroup.org/susv3xsh/getlogin.html>. 1303 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
770 1304
771 Most programs don't need to use this function, because the information is 1305 Most programs don't need to use this function, because the information is
772 available through environment variables: 1306 available through environment variables:
@@ -807,6 +1341,11 @@ _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
807_GL_FUNCDECL_RPL (getpagesize, int, (void)); 1341_GL_FUNCDECL_RPL (getpagesize, int, (void));
808_GL_CXXALIAS_RPL (getpagesize, int, (void)); 1342_GL_CXXALIAS_RPL (getpagesize, int, (void));
809# else 1343# else
1344/* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
1345 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */
1346# if defined __hpux
1347_GL_FUNCDECL_SYS (getpagesize, int, (void));
1348# endif
810# if !@HAVE_GETPAGESIZE@ 1349# if !@HAVE_GETPAGESIZE@
811# if !defined getpagesize 1350# if !defined getpagesize
812/* This is for POSIX systems. */ 1351/* This is for POSIX systems. */
@@ -881,6 +1420,54 @@ _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
881#endif 1420#endif
882 1421
883 1422
1423#if @GNULIB_GETPASS@
1424/* Function getpass() from module 'getpass':
1425 Read a password from /dev/tty or stdin.
1426 Function getpass() from module 'getpass-gnu':
1427 Read a password of arbitrary length from /dev/tty or stdin. */
1428# if (@GNULIB_GETPASS@ && @REPLACE_GETPASS@) \
1429 || (@GNULIB_GETPASS_GNU@ && @REPLACE_GETPASS_FOR_GETPASS_GNU@)
1430# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1431# undef getpass
1432# define getpass rpl_getpass
1433# endif
1434_GL_FUNCDECL_RPL (getpass, char *, (const char *prompt)
1435 _GL_ARG_NONNULL ((1)));
1436_GL_CXXALIAS_RPL (getpass, char *, (const char *prompt));
1437# else
1438# if !@HAVE_GETPASS@
1439_GL_FUNCDECL_SYS (getpass, char *, (const char *prompt)
1440 _GL_ARG_NONNULL ((1)));
1441# endif
1442_GL_CXXALIAS_SYS (getpass, char *, (const char *prompt));
1443# endif
1444_GL_CXXALIASWARN (getpass);
1445#elif defined GNULIB_POSIXCHECK
1446# undef getpass
1447# if HAVE_RAW_DECL_GETPASS
1448_GL_WARN_ON_USE (getpass, "getpass is unportable - "
1449 "use gnulib module getpass or getpass-gnu for portability");
1450# endif
1451#endif
1452
1453
1454#if @GNULIB_MDA_GETPID@
1455/* On native Windows, map 'getpid' to '_getpid', so that -loldnames is not
1456 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1457 platforms by defining GNULIB_NAMESPACE::getpid always. */
1458# if defined _WIN32 && !defined __CYGWIN__
1459# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1460# undef getpid
1461# define getpid _getpid
1462# endif
1463_GL_CXXALIAS_MDA (getpid, int, (void));
1464# else
1465_GL_CXXALIAS_SYS (getpid, pid_t, (void));
1466# endif
1467_GL_CXXALIASWARN (getpid);
1468#endif
1469
1470
884#if @GNULIB_GETUSERSHELL@ 1471#if @GNULIB_GETUSERSHELL@
885/* Return the next valid login shell on the system, or NULL when the end of 1472/* Return the next valid login shell on the system, or NULL when the end of
886 the list has been reached. */ 1473 the list has been reached. */
@@ -951,8 +1538,15 @@ _GL_WARN_ON_USE (group_member, "group_member is unportable - "
951# undef isatty 1538# undef isatty
952# define isatty rpl_isatty 1539# define isatty rpl_isatty
953# endif 1540# endif
1541# define GNULIB_defined_isatty 1
954_GL_FUNCDECL_RPL (isatty, int, (int fd)); 1542_GL_FUNCDECL_RPL (isatty, int, (int fd));
955_GL_CXXALIAS_RPL (isatty, int, (int fd)); 1543_GL_CXXALIAS_RPL (isatty, int, (int fd));
1544# elif defined _WIN32 && !defined __CYGWIN__
1545# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1546# undef isatty
1547# define isatty _isatty
1548# endif
1549_GL_CXXALIAS_MDA (isatty, int, (int fd));
956# else 1550# else
957_GL_CXXALIAS_SYS (isatty, int, (int fd)); 1551_GL_CXXALIAS_SYS (isatty, int, (int fd));
958# endif 1552# endif
@@ -963,6 +1557,20 @@ _GL_CXXALIASWARN (isatty);
963_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - " 1557_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
964 "use gnulib module isatty for portability"); 1558 "use gnulib module isatty for portability");
965# endif 1559# endif
1560#elif @GNULIB_MDA_ISATTY@
1561/* On native Windows, map 'isatty' to '_isatty', so that -loldnames is not
1562 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1563 platforms by defining GNULIB_NAMESPACE::isatty always. */
1564# if defined _WIN32 && !defined __CYGWIN__
1565# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1566# undef isatty
1567# define isatty _isatty
1568# endif
1569_GL_CXXALIAS_MDA (isatty, int, (int fd));
1570# else
1571_GL_CXXALIAS_SYS (isatty, int, (int fd));
1572# endif
1573_GL_CXXALIASWARN (isatty);
966#endif 1574#endif
967 1575
968 1576
@@ -971,7 +1579,7 @@ _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
971 to GID (if GID is not -1). Do not follow symbolic links. 1579 to GID (if GID is not -1). Do not follow symbolic links.
972 Return 0 if successful, otherwise -1 and errno set. 1580 Return 0 if successful, otherwise -1 and errno set.
973 See the POSIX:2008 specification 1581 See the POSIX:2008 specification
974 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */ 1582 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
975# if @REPLACE_LCHOWN@ 1583# if @REPLACE_LCHOWN@
976# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1584# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
977# undef lchown 1585# undef lchown
@@ -1001,7 +1609,7 @@ _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1001/* Create a new hard link for an existing file. 1609/* Create a new hard link for an existing file.
1002 Return 0 if successful, otherwise -1 and errno set. 1610 Return 0 if successful, otherwise -1 and errno set.
1003 See POSIX:2008 specification 1611 See POSIX:2008 specification
1004 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */ 1612 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1005# if @REPLACE_LINK@ 1613# if @REPLACE_LINK@
1006# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1614# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1007# define link rpl_link 1615# define link rpl_link
@@ -1067,13 +1675,19 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1067/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. 1675/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1068 Return the new offset if successful, otherwise -1 and errno set. 1676 Return the new offset if successful, otherwise -1 and errno set.
1069 See the POSIX:2008 specification 1677 See the POSIX:2008 specification
1070 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */ 1678 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1071# if @REPLACE_LSEEK@ 1679# if @REPLACE_LSEEK@
1072# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1680# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1073# define lseek rpl_lseek 1681# define lseek rpl_lseek
1074# endif 1682# endif
1075_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence)); 1683_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1076_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence)); 1684_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1685# elif defined _WIN32 && !defined __CYGWIN__
1686# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1687# undef lseek
1688# define lseek _lseek
1689# endif
1690_GL_CXXALIAS_MDA (lseek, off_t, (int fd, off_t offset, int whence));
1077# else 1691# else
1078_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence)); 1692_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1079# endif 1693# endif
@@ -1084,6 +1698,20 @@ _GL_CXXALIASWARN (lseek);
1084_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some " 1698_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1085 "systems - use gnulib module lseek for portability"); 1699 "systems - use gnulib module lseek for portability");
1086# endif 1700# endif
1701#elif @GNULIB_MDA_LSEEK@
1702/* On native Windows, map 'lseek' to '_lseek', so that -loldnames is not
1703 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1704 platforms by defining GNULIB_NAMESPACE::lseek always. */
1705# if defined _WIN32 && !defined __CYGWIN__
1706# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1707# undef lseek
1708# define lseek _lseek
1709# endif
1710_GL_CXXALIAS_MDA (lseek, long, (int fd, long offset, int whence));
1711# else
1712_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1713# endif
1714_GL_CXXALIASWARN (lseek);
1087#endif 1715#endif
1088 1716
1089 1717
@@ -1113,7 +1741,7 @@ _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1113 Store the read-end as fd[0] and the write-end as fd[1]. 1741 Store the read-end as fd[0] and the write-end as fd[1].
1114 Return 0 upon success, or -1 with errno set upon failure. 1742 Return 0 upon success, or -1 with errno set upon failure.
1115 See also the Linux man page at 1743 See also the Linux man page at
1116 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */ 1744 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1117# if @HAVE_PIPE2@ 1745# if @HAVE_PIPE2@
1118# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1746# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1119# define pipe2 rpl_pipe2 1747# define pipe2 rpl_pipe2
@@ -1139,7 +1767,7 @@ _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1139 Return the number of bytes placed into BUF if successful, otherwise 1767 Return the number of bytes placed into BUF if successful, otherwise
1140 set errno and return -1. 0 indicates EOF. 1768 set errno and return -1. 0 indicates EOF.
1141 See the POSIX:2008 specification 1769 See the POSIX:2008 specification
1142 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */ 1770 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1143# if @REPLACE_PREAD@ 1771# if @REPLACE_PREAD@
1144# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1772# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1145# undef pread 1773# undef pread
@@ -1174,7 +1802,7 @@ _GL_WARN_ON_USE (pread, "pread is unportable - "
1174 Return the number of bytes written if successful, otherwise 1802 Return the number of bytes written if successful, otherwise
1175 set errno and return -1. 0 indicates nothing written. See the 1803 set errno and return -1. 0 indicates nothing written. See the
1176 POSIX:2008 specification 1804 POSIX:2008 specification
1177 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */ 1805 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1178# if @REPLACE_PWRITE@ 1806# if @REPLACE_PWRITE@
1179# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1807# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1180# undef pwrite 1808# undef pwrite
@@ -1207,7 +1835,7 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1207#if @GNULIB_READ@ 1835#if @GNULIB_READ@
1208/* Read up to COUNT bytes from file descriptor FD into the buffer starting 1836/* Read up to COUNT bytes from file descriptor FD into the buffer starting
1209 at BUF. See the POSIX:2008 specification 1837 at BUF. See the POSIX:2008 specification
1210 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */ 1838 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1211# if @REPLACE_READ@ 1839# if @REPLACE_READ@
1212# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1840# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1213# undef read 1841# undef read
@@ -1216,11 +1844,32 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1216_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count) 1844_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1217 _GL_ARG_NONNULL ((2))); 1845 _GL_ARG_NONNULL ((2)));
1218_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count)); 1846_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1847# elif defined _WIN32 && !defined __CYGWIN__
1848# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1849# undef read
1850# define read _read
1851# endif
1852_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, size_t count));
1853# else
1854_GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1855# endif
1856_GL_CXXALIASWARN (read);
1857#elif @GNULIB_MDA_READ@
1858/* On native Windows, map 'read' to '_read', so that -loldnames is not
1859 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1860 platforms by defining GNULIB_NAMESPACE::read always. */
1861# if defined _WIN32 && !defined __CYGWIN__
1862# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1863# undef read
1864# define read _read
1865# endif
1866# ifdef __MINGW32__
1867_GL_CXXALIAS_MDA (read, int, (int fd, void *buf, unsigned int count));
1868# else
1869_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, unsigned int count));
1870# endif
1219# else 1871# else
1220/* Need to cast, because on mingw, the third parameter is 1872_GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1221 unsigned int count
1222 and the return type is 'int'. */
1223_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1224# endif 1873# endif
1225_GL_CXXALIASWARN (read); 1874_GL_CXXALIASWARN (read);
1226#endif 1875#endif
@@ -1231,24 +1880,28 @@ _GL_CXXALIASWARN (read);
1231 bytes of it into BUF. Return the number of bytes placed into BUF if 1880 bytes of it into BUF. Return the number of bytes placed into BUF if
1232 successful, otherwise -1 and errno set. 1881 successful, otherwise -1 and errno set.
1233 See the POSIX:2008 specification 1882 See the POSIX:2008 specification
1234 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */ 1883 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1235# if @REPLACE_READLINK@ 1884# if @REPLACE_READLINK@
1236# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1885# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1237# define readlink rpl_readlink 1886# define readlink rpl_readlink
1238# endif 1887# endif
1239_GL_FUNCDECL_RPL (readlink, ssize_t, 1888_GL_FUNCDECL_RPL (readlink, ssize_t,
1240 (const char *file, char *buf, size_t bufsize) 1889 (const char *restrict file,
1890 char *restrict buf, size_t bufsize)
1241 _GL_ARG_NONNULL ((1, 2))); 1891 _GL_ARG_NONNULL ((1, 2)));
1242_GL_CXXALIAS_RPL (readlink, ssize_t, 1892_GL_CXXALIAS_RPL (readlink, ssize_t,
1243 (const char *file, char *buf, size_t bufsize)); 1893 (const char *restrict file,
1894 char *restrict buf, size_t bufsize));
1244# else 1895# else
1245# if !@HAVE_READLINK@ 1896# if !@HAVE_READLINK@
1246_GL_FUNCDECL_SYS (readlink, ssize_t, 1897_GL_FUNCDECL_SYS (readlink, ssize_t,
1247 (const char *file, char *buf, size_t bufsize) 1898 (const char *restrict file,
1899 char *restrict buf, size_t bufsize)
1248 _GL_ARG_NONNULL ((1, 2))); 1900 _GL_ARG_NONNULL ((1, 2)));
1249# endif 1901# endif
1250_GL_CXXALIAS_SYS (readlink, ssize_t, 1902_GL_CXXALIAS_SYS (readlink, ssize_t,
1251 (const char *file, char *buf, size_t bufsize)); 1903 (const char *restrict file,
1904 char *restrict buf, size_t bufsize));
1252# endif 1905# endif
1253_GL_CXXALIASWARN (readlink); 1906_GL_CXXALIASWARN (readlink);
1254#elif defined GNULIB_POSIXCHECK 1907#elif defined GNULIB_POSIXCHECK
@@ -1261,13 +1914,28 @@ _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1261 1914
1262 1915
1263#if @GNULIB_READLINKAT@ 1916#if @GNULIB_READLINKAT@
1264# if !@HAVE_READLINKAT@ 1917# if @REPLACE_READLINKAT@
1918# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1919# define readlinkat rpl_readlinkat
1920# endif
1921_GL_FUNCDECL_RPL (readlinkat, ssize_t,
1922 (int fd, char const *restrict file,
1923 char *restrict buf, size_t len)
1924 _GL_ARG_NONNULL ((2, 3)));
1925_GL_CXXALIAS_RPL (readlinkat, ssize_t,
1926 (int fd, char const *restrict file,
1927 char *restrict buf, size_t len));
1928# else
1929# if !@HAVE_READLINKAT@
1265_GL_FUNCDECL_SYS (readlinkat, ssize_t, 1930_GL_FUNCDECL_SYS (readlinkat, ssize_t,
1266 (int fd, char const *file, char *buf, size_t len) 1931 (int fd, char const *restrict file,
1932 char *restrict buf, size_t len)
1267 _GL_ARG_NONNULL ((2, 3))); 1933 _GL_ARG_NONNULL ((2, 3)));
1268# endif 1934# endif
1269_GL_CXXALIAS_SYS (readlinkat, ssize_t, 1935_GL_CXXALIAS_SYS (readlinkat, ssize_t,
1270 (int fd, char const *file, char *buf, size_t len)); 1936 (int fd, char const *restrict file,
1937 char *restrict buf, size_t len));
1938# endif
1271_GL_CXXALIASWARN (readlinkat); 1939_GL_CXXALIASWARN (readlinkat);
1272#elif defined GNULIB_POSIXCHECK 1940#elif defined GNULIB_POSIXCHECK
1273# undef readlinkat 1941# undef readlinkat
@@ -1286,6 +1954,12 @@ _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1286# endif 1954# endif
1287_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); 1955_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1288_GL_CXXALIAS_RPL (rmdir, int, (char const *name)); 1956_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1957# elif defined _WIN32 && !defined __CYGWIN__
1958# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1959# undef rmdir
1960# define rmdir _rmdir
1961# endif
1962_GL_CXXALIAS_MDA (rmdir, int, (char const *name));
1289# else 1963# else
1290_GL_CXXALIAS_SYS (rmdir, int, (char const *name)); 1964_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1291# endif 1965# endif
@@ -1296,6 +1970,20 @@ _GL_CXXALIASWARN (rmdir);
1296_GL_WARN_ON_USE (rmdir, "rmdir is unportable - " 1970_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1297 "use gnulib module rmdir for portability"); 1971 "use gnulib module rmdir for portability");
1298# endif 1972# endif
1973#elif @GNULIB_MDA_RMDIR@
1974/* On native Windows, map 'rmdir' to '_rmdir', so that -loldnames is not
1975 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1976 platforms by defining GNULIB_NAMESPACE::rmdir always. */
1977# if defined _WIN32 && !defined __CYGWIN__
1978# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1979# undef rmdir
1980# define rmdir _rmdir
1981# endif
1982_GL_CXXALIAS_MDA (rmdir, int, (char const *name));
1983# else
1984_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1985# endif
1986_GL_CXXALIASWARN (rmdir);
1299#endif 1987#endif
1300 1988
1301 1989
@@ -1330,7 +2018,7 @@ _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1330/* Pause the execution of the current thread for N seconds. 2018/* Pause the execution of the current thread for N seconds.
1331 Returns the number of seconds left to sleep. 2019 Returns the number of seconds left to sleep.
1332 See the POSIX:2008 specification 2020 See the POSIX:2008 specification
1333 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */ 2021 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1334# if @REPLACE_SLEEP@ 2022# if @REPLACE_SLEEP@
1335# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2023# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1336# undef sleep 2024# undef sleep
@@ -1354,6 +2042,31 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1354#endif 2042#endif
1355 2043
1356 2044
2045#if @GNULIB_MDA_SWAB@
2046/* On native Windows, map 'swab' to '_swab', so that -loldnames is not
2047 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2048 platforms by defining GNULIB_NAMESPACE::swab always. */
2049# if defined _WIN32 && !defined __CYGWIN__
2050# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2051# undef swab
2052# define swab _swab
2053# endif
2054/* Need to cast, because in old mingw the arguments are
2055 (const char *from, char *to, size_t n). */
2056_GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n));
2057# else
2058# if defined __hpux /* HP-UX */
2059_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
2060# elif defined __sun && (defined __SunOS_5_10 || defined __XOPEN_OR_POSIX) && !defined _XPG4 /* Solaris */
2061_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
2062# else
2063_GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));
2064# endif
2065# endif
2066_GL_CXXALIASWARN (swab);
2067#endif
2068
2069
1357#if @GNULIB_SYMLINK@ 2070#if @GNULIB_SYMLINK@
1358# if @REPLACE_SYMLINK@ 2071# if @REPLACE_SYMLINK@
1359# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2072# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1381,13 +2094,25 @@ _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1381 2094
1382 2095
1383#if @GNULIB_SYMLINKAT@ 2096#if @GNULIB_SYMLINKAT@
1384# if !@HAVE_SYMLINKAT@ 2097# if @REPLACE_SYMLINKAT@
2098# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2099# undef symlinkat
2100# define symlinkat rpl_symlinkat
2101# endif
2102_GL_FUNCDECL_RPL (symlinkat, int,
2103 (char const *contents, int fd, char const *file)
2104 _GL_ARG_NONNULL ((1, 3)));
2105_GL_CXXALIAS_RPL (symlinkat, int,
2106 (char const *contents, int fd, char const *file));
2107# else
2108# if !@HAVE_SYMLINKAT@
1385_GL_FUNCDECL_SYS (symlinkat, int, 2109_GL_FUNCDECL_SYS (symlinkat, int,
1386 (char const *contents, int fd, char const *file) 2110 (char const *contents, int fd, char const *file)
1387 _GL_ARG_NONNULL ((1, 3))); 2111 _GL_ARG_NONNULL ((1, 3)));
1388# endif 2112# endif
1389_GL_CXXALIAS_SYS (symlinkat, int, 2113_GL_CXXALIAS_SYS (symlinkat, int,
1390 (char const *contents, int fd, char const *file)); 2114 (char const *contents, int fd, char const *file));
2115# endif
1391_GL_CXXALIASWARN (symlinkat); 2116_GL_CXXALIASWARN (symlinkat);
1392#elif defined GNULIB_POSIXCHECK 2117#elif defined GNULIB_POSIXCHECK
1393# undef symlinkat 2118# undef symlinkat
@@ -1398,6 +2123,36 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1398#endif 2123#endif
1399 2124
1400 2125
2126#if @GNULIB_TRUNCATE@
2127/* Change the size of the file designated by FILENAME to become equal to LENGTH.
2128 Return 0 if successful, otherwise -1 and errno set.
2129 See the POSIX:2008 specification
2130 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
2131# if @REPLACE_TRUNCATE@
2132# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2133# undef truncate
2134# define truncate rpl_truncate
2135# endif
2136_GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
2137 _GL_ARG_NONNULL ((1)));
2138_GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
2139# else
2140# if !@HAVE_DECL_TRUNCATE@
2141_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
2142 _GL_ARG_NONNULL ((1)));
2143# endif
2144_GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
2145# endif
2146_GL_CXXALIASWARN (truncate);
2147#elif defined GNULIB_POSIXCHECK
2148# undef truncate
2149# if HAVE_RAW_DECL_TRUNCATE
2150_GL_WARN_ON_USE (truncate, "truncate is unportable - "
2151 "use gnulib module truncate for portability");
2152# endif
2153#endif
2154
2155
1401#if @GNULIB_TTYNAME_R@ 2156#if @GNULIB_TTYNAME_R@
1402/* Store at most BUFLEN characters of the pathname of the terminal FD is 2157/* Store at most BUFLEN characters of the pathname of the terminal FD is
1403 open on in BUF. Return 0 on success, otherwise an error number. */ 2158 open on in BUF. Return 0 on success, otherwise an error number. */
@@ -1436,6 +2191,12 @@ _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1436# endif 2191# endif
1437_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); 2192_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1438_GL_CXXALIAS_RPL (unlink, int, (char const *file)); 2193_GL_CXXALIAS_RPL (unlink, int, (char const *file));
2194# elif defined _WIN32 && !defined __CYGWIN__
2195# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2196# undef unlink
2197# define unlink _unlink
2198# endif
2199_GL_CXXALIAS_MDA (unlink, int, (char const *file));
1439# else 2200# else
1440_GL_CXXALIAS_SYS (unlink, int, (char const *file)); 2201_GL_CXXALIAS_SYS (unlink, int, (char const *file));
1441# endif 2202# endif
@@ -1446,6 +2207,20 @@ _GL_CXXALIASWARN (unlink);
1446_GL_WARN_ON_USE (unlink, "unlink is not portable - " 2207_GL_WARN_ON_USE (unlink, "unlink is not portable - "
1447 "use gnulib module unlink for portability"); 2208 "use gnulib module unlink for portability");
1448# endif 2209# endif
2210#elif @GNULIB_MDA_UNLINK@
2211/* On native Windows, map 'unlink' to '_unlink', so that -loldnames is not
2212 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2213 platforms by defining GNULIB_NAMESPACE::unlink always. */
2214# if defined _WIN32 && !defined __CYGWIN__
2215# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2216# undef unlink
2217# define unlink _unlink
2218# endif
2219_GL_CXXALIAS_MDA (unlink, int, (char const *file));
2220# else
2221_GL_CXXALIAS_SYS (unlink, int, (char const *file));
2222# endif
2223_GL_CXXALIASWARN (unlink);
1449#endif 2224#endif
1450 2225
1451 2226
@@ -1470,7 +2245,7 @@ _GL_CXXALIASWARN (unlinkat);
1470# undef unlinkat 2245# undef unlinkat
1471# if HAVE_RAW_DECL_UNLINKAT 2246# if HAVE_RAW_DECL_UNLINKAT
1472_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " 2247_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1473 "use gnulib module openat for portability"); 2248 "use gnulib module unlinkat for portability");
1474# endif 2249# endif
1475#endif 2250#endif
1476 2251
@@ -1479,7 +2254,7 @@ _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1479/* Pause the execution of the current thread for N microseconds. 2254/* Pause the execution of the current thread for N microseconds.
1480 Returns 0 on completion, or -1 on range error. 2255 Returns 0 on completion, or -1 on range error.
1481 See the POSIX:2001 specification 2256 See the POSIX:2001 specification
1482 <http://www.opengroup.org/susv3xsh/usleep.html>. */ 2257 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
1483# if @REPLACE_USLEEP@ 2258# if @REPLACE_USLEEP@
1484# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2259# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1485# undef usleep 2260# undef usleep
@@ -1491,7 +2266,9 @@ _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1491# if !@HAVE_USLEEP@ 2266# if !@HAVE_USLEEP@
1492_GL_FUNCDECL_SYS (usleep, int, (useconds_t n)); 2267_GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1493# endif 2268# endif
1494_GL_CXXALIAS_SYS (usleep, int, (useconds_t n)); 2269/* Need to cast, because on Haiku, the first parameter is
2270 unsigned int n. */
2271_GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n));
1495# endif 2272# endif
1496_GL_CXXALIASWARN (usleep); 2273_GL_CXXALIASWARN (usleep);
1497#elif defined GNULIB_POSIXCHECK 2274#elif defined GNULIB_POSIXCHECK
@@ -1506,7 +2283,7 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1506#if @GNULIB_WRITE@ 2283#if @GNULIB_WRITE@
1507/* Write up to COUNT bytes starting at BUF to file descriptor FD. 2284/* Write up to COUNT bytes starting at BUF to file descriptor FD.
1508 See the POSIX:2008 specification 2285 See the POSIX:2008 specification
1509 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */ 2286 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1510# if @REPLACE_WRITE@ 2287# if @REPLACE_WRITE@
1511# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2288# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1512# undef write 2289# undef write
@@ -1515,11 +2292,32 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1515_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) 2292_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1516 _GL_ARG_NONNULL ((2))); 2293 _GL_ARG_NONNULL ((2)));
1517_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); 2294_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
2295# elif defined _WIN32 && !defined __CYGWIN__
2296# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2297# undef write
2298# define write _write
2299# endif
2300_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, size_t count));
2301# else
2302_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
2303# endif
2304_GL_CXXALIASWARN (write);
2305#elif @GNULIB_MDA_WRITE@
2306/* On native Windows, map 'write' to '_write', so that -loldnames is not
2307 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2308 platforms by defining GNULIB_NAMESPACE::write always. */
2309# if defined _WIN32 && !defined __CYGWIN__
2310# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2311# undef write
2312# define write _write
2313# endif
2314# ifdef __MINGW32__
2315_GL_CXXALIAS_MDA (write, int, (int fd, const void *buf, unsigned int count));
2316# else
2317_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, unsigned int count));
2318# endif
1518# else 2319# else
1519/* Need to cast, because on mingw, the third parameter is 2320_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
1520 unsigned int count
1521 and the return type is 'int'. */
1522_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1523# endif 2321# endif
1524_GL_CXXALIASWARN (write); 2322_GL_CXXALIASWARN (write);
1525#endif 2323#endif
@@ -1527,4 +2325,5 @@ _GL_CXXALIASWARN (write);
1527_GL_INLINE_HEADER_END 2325_GL_INLINE_HEADER_END
1528 2326
1529#endif /* _@GUARD_PREFIX@_UNISTD_H */ 2327#endif /* _@GUARD_PREFIX@_UNISTD_H */
2328#endif /* _GL_INCLUDING_UNISTD_H */
1530#endif /* _@GUARD_PREFIX@_UNISTD_H */ 2329#endif /* _@GUARD_PREFIX@_UNISTD_H */