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.h980
1 files changed, 881 insertions, 99 deletions
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index 2ea9af4..73c882f 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-2021 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,39 @@ _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 !@HAVE_COPY_FILE_RANGE@
419_GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
420 int ofd, off_t *opos,
421 size_t len, unsigned flags));
422_GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
423 int ofd, off_t *opos,
424 size_t len, unsigned flags));
425# endif
426_GL_CXXALIASWARN (copy_file_range);
427#elif defined GNULIB_POSIXCHECK
428# if HAVE_RAW_DECL_COPY_FILE_RANGE
429_GL_WARN_ON_USE (copy_file_range,
430 "copy_file_range is unportable - "
431 "use gnulib module copy_file_range for portability");
432# endif
302#endif 433#endif
303 434
304 435
@@ -309,6 +440,12 @@ _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
309# endif 440# endif
310_GL_FUNCDECL_RPL (dup, int, (int oldfd)); 441_GL_FUNCDECL_RPL (dup, int, (int oldfd));
311_GL_CXXALIAS_RPL (dup, int, (int oldfd)); 442_GL_CXXALIAS_RPL (dup, int, (int oldfd));
443# elif defined _WIN32 && !defined __CYGWIN__
444# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
445# undef dup
446# define dup _dup
447# endif
448_GL_CXXALIAS_MDA (dup, int, (int oldfd));
312# else 449# else
313_GL_CXXALIAS_SYS (dup, int, (int oldfd)); 450_GL_CXXALIAS_SYS (dup, int, (int oldfd));
314# endif 451# endif
@@ -319,6 +456,20 @@ _GL_CXXALIASWARN (dup);
319_GL_WARN_ON_USE (dup, "dup is unportable - " 456_GL_WARN_ON_USE (dup, "dup is unportable - "
320 "use gnulib module dup for portability"); 457 "use gnulib module dup for portability");
321# endif 458# endif
459#elif @GNULIB_MDA_DUP@
460/* On native Windows, map 'dup' to '_dup', so that -loldnames is not
461 required. In C++ with GNULIB_NAMESPACE, avoid differences between
462 platforms by defining GNULIB_NAMESPACE::dup always. */
463# if defined _WIN32 && !defined __CYGWIN__
464# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
465# undef dup
466# define dup _dup
467# endif
468_GL_CXXALIAS_MDA (dup, int, (int oldfd));
469# else
470_GL_CXXALIAS_SYS (dup, int, (int oldfd));
471# endif
472_GL_CXXALIASWARN (dup);
322#endif 473#endif
323 474
324 475
@@ -327,17 +478,20 @@ _GL_WARN_ON_USE (dup, "dup is unportable - "
327 NEWFD = OLDFD, otherwise close NEWFD first if it is open. 478 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
328 Return newfd if successful, otherwise -1 and errno set. 479 Return newfd if successful, otherwise -1 and errno set.
329 See the POSIX:2008 specification 480 See the POSIX:2008 specification
330 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */ 481 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
331# if @REPLACE_DUP2@ 482# if @REPLACE_DUP2@
332# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 483# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
333# define dup2 rpl_dup2 484# define dup2 rpl_dup2
334# endif 485# endif
335_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd)); 486_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
336_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd)); 487_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
337# else 488# elif defined _WIN32 && !defined __CYGWIN__
338# if !@HAVE_DUP2@ 489# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
339_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd)); 490# undef dup2
491# define dup2 _dup2
340# endif 492# endif
493_GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
494# else
341_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd)); 495_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
342# endif 496# endif
343_GL_CXXALIASWARN (dup2); 497_GL_CXXALIASWARN (dup2);
@@ -347,6 +501,20 @@ _GL_CXXALIASWARN (dup2);
347_GL_WARN_ON_USE (dup2, "dup2 is unportable - " 501_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
348 "use gnulib module dup2 for portability"); 502 "use gnulib module dup2 for portability");
349# endif 503# endif
504#elif @GNULIB_MDA_DUP2@
505/* On native Windows, map 'dup2' to '_dup2', so that -loldnames is not
506 required. In C++ with GNULIB_NAMESPACE, avoid differences between
507 platforms by defining GNULIB_NAMESPACE::dup2 always. */
508# if defined _WIN32 && !defined __CYGWIN__
509# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
510# undef dup2
511# define dup2 _dup2
512# endif
513_GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
514# else
515_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
516# endif
517_GL_CXXALIASWARN (dup2);
350#endif 518#endif
351 519
352 520
@@ -358,7 +526,7 @@ _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
358 Close NEWFD first if it is open. 526 Close NEWFD first if it is open.
359 Return newfd if successful, otherwise -1 and errno set. 527 Return newfd if successful, otherwise -1 and errno set.
360 See the Linux man page at 528 See the Linux man page at
361 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */ 529 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
362# if @HAVE_DUP3@ 530# if @HAVE_DUP3@
363# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 531# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
364# define dup3 rpl_dup3 532# define dup3 rpl_dup3
@@ -380,10 +548,23 @@ _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
380 548
381 549
382#if @GNULIB_ENVIRON@ 550#if @GNULIB_ENVIRON@
551# if defined __CYGWIN__ && !defined __i386__
552/* The 'environ' variable is defined in a DLL. Therefore its declaration needs
553 the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
554 This leads to a link error on 64-bit Cygwin when the option
555 -Wl,--disable-auto-import is in use. */
556_GL_EXTERN_C __declspec(dllimport) char **environ;
557# endif
383# if !@HAVE_DECL_ENVIRON@ 558# if !@HAVE_DECL_ENVIRON@
384/* Set of environment variables and values. An array of strings of the form 559/* Set of environment variables and values. An array of strings of the form
385 "VARIABLE=VALUE", terminated with a NULL. */ 560 "VARIABLE=VALUE", terminated with a NULL. */
386# if defined __APPLE__ && defined __MACH__ 561# if defined __APPLE__ && defined __MACH__
562# include <TargetConditionals.h>
563# if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
564# define _GL_USE_CRT_EXTERNS
565# endif
566# endif
567# ifdef _GL_USE_CRT_EXTERNS
387# include <crt_externs.h> 568# include <crt_externs.h>
388# define environ (*_NSGetEnviron ()) 569# define environ (*_NSGetEnviron ())
389# else 570# else
@@ -399,12 +580,12 @@ extern char **environ;
399#elif defined GNULIB_POSIXCHECK 580#elif defined GNULIB_POSIXCHECK
400# if HAVE_RAW_DECL_ENVIRON 581# if HAVE_RAW_DECL_ENVIRON
401_GL_UNISTD_INLINE char *** 582_GL_UNISTD_INLINE char ***
583_GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
584 "use gnulib module environ for portability")
402rpl_environ (void) 585rpl_environ (void)
403{ 586{
404 return &environ; 587 return &environ;
405} 588}
406_GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
407 "use gnulib module environ for portability");
408# undef environ 589# undef environ
409# define environ (*rpl_environ ()) 590# define environ (*rpl_environ ())
410# endif 591# endif
@@ -434,14 +615,302 @@ _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
434#endif 615#endif
435 616
436 617
618#if @GNULIB_EXECL@
619# if @REPLACE_EXECL@
620# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
621# undef execl
622# define execl rpl_execl
623# endif
624_GL_FUNCDECL_RPL (execl, int, (const char *program, const char *arg, ...)
625 _GL_ARG_NONNULL ((1)));
626_GL_CXXALIAS_RPL (execl, int, (const char *program, const char *arg, ...));
627# else
628_GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
629# endif
630_GL_CXXALIASWARN (execl);
631#elif defined GNULIB_POSIXCHECK
632# undef execl
633# if HAVE_RAW_DECL_EXECL
634_GL_WARN_ON_USE (execl, "execl behaves very differently on mingw - "
635 "use gnulib module execl for portability");
636# endif
637#elif @GNULIB_MDA_EXECL@
638/* On native Windows, map 'execl' to '_execl', so that -loldnames is not
639 required. In C++ with GNULIB_NAMESPACE, avoid differences between
640 platforms by defining GNULIB_NAMESPACE::execl always. */
641# if defined _WIN32 && !defined __CYGWIN__
642# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
643# undef execl
644# define execl _execl
645# endif
646_GL_CXXALIAS_MDA (execl, intptr_t, (const char *program, const char *arg, ...));
647# else
648_GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
649# endif
650_GL_CXXALIASWARN (execl);
651#endif
652
653#if @GNULIB_EXECLE@
654# if @REPLACE_EXECLE@
655# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
656# undef execle
657# define execle rpl_execle
658# endif
659_GL_FUNCDECL_RPL (execle, int, (const char *program, const char *arg, ...)
660 _GL_ARG_NONNULL ((1)));
661_GL_CXXALIAS_RPL (execle, int, (const char *program, const char *arg, ...));
662# else
663_GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
664# endif
665_GL_CXXALIASWARN (execle);
666#elif defined GNULIB_POSIXCHECK
667# undef execle
668# if HAVE_RAW_DECL_EXECLE
669_GL_WARN_ON_USE (execle, "execle behaves very differently on mingw - "
670 "use gnulib module execle for portability");
671# endif
672#elif @GNULIB_MDA_EXECLE@
673/* On native Windows, map 'execle' to '_execle', so that -loldnames is not
674 required. In C++ with GNULIB_NAMESPACE, avoid differences between
675 platforms by defining GNULIB_NAMESPACE::execle always. */
676# if defined _WIN32 && !defined __CYGWIN__
677# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
678# undef execle
679# define execle _execle
680# endif
681_GL_CXXALIAS_MDA (execle, intptr_t,
682 (const char *program, const char *arg, ...));
683# else
684_GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
685# endif
686_GL_CXXALIASWARN (execle);
687#endif
688
689#if @GNULIB_EXECLP@
690# if @REPLACE_EXECLP@
691# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
692# undef execlp
693# define execlp rpl_execlp
694# endif
695_GL_FUNCDECL_RPL (execlp, int, (const char *program, const char *arg, ...)
696 _GL_ARG_NONNULL ((1)));
697_GL_CXXALIAS_RPL (execlp, int, (const char *program, const char *arg, ...));
698# else
699_GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
700# endif
701_GL_CXXALIASWARN (execlp);
702#elif defined GNULIB_POSIXCHECK
703# undef execlp
704# if HAVE_RAW_DECL_EXECLP
705_GL_WARN_ON_USE (execlp, "execlp behaves very differently on mingw - "
706 "use gnulib module execlp for portability");
707# endif
708#elif @GNULIB_MDA_EXECLP@
709/* On native Windows, map 'execlp' to '_execlp', so that -loldnames is not
710 required. In C++ with GNULIB_NAMESPACE, avoid differences between
711 platforms by defining GNULIB_NAMESPACE::execlp always. */
712# if defined _WIN32 && !defined __CYGWIN__
713# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
714# undef execlp
715# define execlp _execlp
716# endif
717_GL_CXXALIAS_MDA (execlp, intptr_t,
718 (const char *program, const char *arg, ...));
719# else
720_GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
721# endif
722_GL_CXXALIASWARN (execlp);
723#endif
724
725
726#if @GNULIB_EXECV@
727# if @REPLACE_EXECV@
728# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
729# undef execv
730# define execv rpl_execv
731# endif
732_GL_FUNCDECL_RPL (execv, int, (const char *program, char * const *argv)
733 _GL_ARG_NONNULL ((1, 2)));
734_GL_CXXALIAS_RPL (execv, int, (const char *program, char * const *argv));
735# else
736_GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
737# endif
738_GL_CXXALIASWARN (execv);
739#elif defined GNULIB_POSIXCHECK
740# undef execv
741# if HAVE_RAW_DECL_EXECV
742_GL_WARN_ON_USE (execv, "execv behaves very differently on mingw - "
743 "use gnulib module execv for portability");
744# endif
745#elif @GNULIB_MDA_EXECV@
746/* On native Windows, map 'execv' to '_execv', so that -loldnames is not
747 required. In C++ with GNULIB_NAMESPACE, avoid differences between
748 platforms by defining GNULIB_NAMESPACE::execv always. */
749# if defined _WIN32 && !defined __CYGWIN__
750# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
751# undef execv
752# define execv _execv
753# endif
754_GL_CXXALIAS_MDA_CAST (execv, intptr_t,
755 (const char *program, char * const *argv));
756# else
757_GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
758# endif
759_GL_CXXALIASWARN (execv);
760#endif
761
762#if @GNULIB_EXECVE@
763# if @REPLACE_EXECVE@
764# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
765# undef execve
766# define execve rpl_execve
767# endif
768_GL_FUNCDECL_RPL (execve, int,
769 (const char *program, char * const *argv, char * const *env)
770 _GL_ARG_NONNULL ((1, 2)));
771_GL_CXXALIAS_RPL (execve, int,
772 (const char *program, char * const *argv, char * const *env));
773# else
774_GL_CXXALIAS_SYS (execve, int,
775 (const char *program, char * const *argv, char * const *env));
776# endif
777_GL_CXXALIASWARN (execve);
778#elif defined GNULIB_POSIXCHECK
779# undef execve
780# if HAVE_RAW_DECL_EXECVE
781_GL_WARN_ON_USE (execve, "execve behaves very differently on mingw - "
782 "use gnulib module execve for portability");
783# endif
784#elif @GNULIB_MDA_EXECVE@
785/* On native Windows, map 'execve' to '_execve', so that -loldnames is not
786 required. In C++ with GNULIB_NAMESPACE, avoid differences between
787 platforms by defining GNULIB_NAMESPACE::execve always. */
788# if defined _WIN32 && !defined __CYGWIN__
789# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
790# undef execve
791# define execve _execve
792# endif
793_GL_CXXALIAS_MDA_CAST (execve, intptr_t,
794 (const char *program, char * const *argv,
795 char * const *env));
796# else
797_GL_CXXALIAS_SYS (execve, int,
798 (const char *program, char * const *argv, char * const *env));
799# endif
800_GL_CXXALIASWARN (execve);
801#endif
802
803#if @GNULIB_EXECVP@
804# if @REPLACE_EXECVP@
805# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
806# undef execvp
807# define execvp rpl_execvp
808# endif
809_GL_FUNCDECL_RPL (execvp, int, (const char *program, char * const *argv)
810 _GL_ARG_NONNULL ((1, 2)));
811_GL_CXXALIAS_RPL (execvp, int, (const char *program, char * const *argv));
812# else
813_GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
814# endif
815_GL_CXXALIASWARN (execvp);
816#elif defined GNULIB_POSIXCHECK
817# undef execvp
818# if HAVE_RAW_DECL_EXECVP
819_GL_WARN_ON_USE (execvp, "execvp behaves very differently on mingw - "
820 "use gnulib module execvp for portability");
821# endif
822#elif @GNULIB_MDA_EXECVP@
823/* On native Windows, map 'execvp' to '_execvp', so that -loldnames is not
824 required. In C++ with GNULIB_NAMESPACE, avoid differences between
825 platforms by defining GNULIB_NAMESPACE::execvp always. */
826# if defined _WIN32 && !defined __CYGWIN__
827# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
828# undef execvp
829# define execvp _execvp
830# endif
831_GL_CXXALIAS_MDA_CAST (execvp, intptr_t,
832 (const char *program, char * const *argv));
833# else
834_GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
835# endif
836_GL_CXXALIASWARN (execvp);
837#endif
838
839#if @GNULIB_EXECVPE@
840# if @REPLACE_EXECVPE@
841# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
842# undef execvpe
843# define execvpe rpl_execvpe
844# endif
845_GL_FUNCDECL_RPL (execvpe, int,
846 (const char *program, char * const *argv, char * const *env)
847 _GL_ARG_NONNULL ((1, 2)));
848_GL_CXXALIAS_RPL (execvpe, int,
849 (const char *program, char * const *argv, char * const *env));
850# else
851# if !@HAVE_DECL_EXECVPE@
852_GL_FUNCDECL_SYS (execvpe, int,
853 (const char *program, char * const *argv, char * const *env)
854 _GL_ARG_NONNULL ((1, 2)));
855# endif
856_GL_CXXALIAS_SYS (execvpe, int,
857 (const char *program, char * const *argv, char * const *env));
858# endif
859_GL_CXXALIASWARN (execvpe);
860#elif defined GNULIB_POSIXCHECK
861# undef execvpe
862# if HAVE_RAW_DECL_EXECVPE
863_GL_WARN_ON_USE (execvpe, "execvpe behaves very differently on mingw - "
864 "use gnulib module execvpe for portability");
865# endif
866#elif @GNULIB_MDA_EXECVPE@
867/* On native Windows, map 'execvpe' to '_execvpe', so that -loldnames is not
868 required. In C++ with GNULIB_NAMESPACE, avoid differences between
869 platforms by defining GNULIB_NAMESPACE::execvpe on all platforms that have
870 it. */
871# if defined _WIN32 && !defined __CYGWIN__
872# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
873# undef execvpe
874# define execvpe _execvpe
875# endif
876_GL_CXXALIAS_MDA_CAST (execvpe, intptr_t,
877 (const char *program, char * const *argv,
878 char * const *env));
879# elif @HAVE_EXECVPE@
880# if !@HAVE_DECL_EXECVPE@
881_GL_FUNCDECL_SYS (execvpe, int,
882 (const char *program, char * const *argv, char * const *env)
883 _GL_ARG_NONNULL ((1, 2)));
884# endif
885_GL_CXXALIAS_SYS (execvpe, int,
886 (const char *program, char * const *argv, char * const *env));
887# endif
888# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_EXECVPE@
889_GL_CXXALIASWARN (execvpe);
890# endif
891#endif
892
893
437#if @GNULIB_FACCESSAT@ 894#if @GNULIB_FACCESSAT@
438# if !@HAVE_FACCESSAT@ 895# if @REPLACE_FACCESSAT@
896# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
897# undef faccessat
898# define faccessat rpl_faccessat
899# endif
900_GL_FUNCDECL_RPL (faccessat, int,
901 (int fd, char const *name, int mode, int flag)
902 _GL_ARG_NONNULL ((2)));
903_GL_CXXALIAS_RPL (faccessat, int,
904 (int fd, char const *name, int mode, int flag));
905# else
906# if !@HAVE_FACCESSAT@
439_GL_FUNCDECL_SYS (faccessat, int, 907_GL_FUNCDECL_SYS (faccessat, int,
440 (int fd, char const *file, int mode, int flag) 908 (int fd, char const *file, int mode, int flag)
441 _GL_ARG_NONNULL ((2))); 909 _GL_ARG_NONNULL ((2)));
442# endif 910# endif
443_GL_CXXALIAS_SYS (faccessat, int, 911_GL_CXXALIAS_SYS (faccessat, int,
444 (int fd, char const *file, int mode, int flag)); 912 (int fd, char const *file, int mode, int flag));
913# endif
445_GL_CXXALIASWARN (faccessat); 914_GL_CXXALIASWARN (faccessat);
446#elif defined GNULIB_POSIXCHECK 915#elif defined GNULIB_POSIXCHECK
447# undef faccessat 916# undef faccessat
@@ -457,7 +926,7 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
457 the given file descriptor is open. 926 the given file descriptor is open.
458 Return 0 if successful, otherwise -1 and errno set. 927 Return 0 if successful, otherwise -1 and errno set.
459 See the POSIX:2008 specification 928 See the POSIX:2008 specification
460 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */ 929 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
461# if ! @HAVE_FCHDIR@ 930# if ! @HAVE_FCHDIR@
462_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); 931_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
463 932
@@ -509,7 +978,7 @@ _GL_CXXALIASWARN (fchownat);
509# undef fchownat 978# undef fchownat
510# if HAVE_RAW_DECL_FCHOWNAT 979# if HAVE_RAW_DECL_FCHOWNAT
511_GL_WARN_ON_USE (fchownat, "fchownat is not portable - " 980_GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
512 "use gnulib module openat for portability"); 981 "use gnulib module fchownat for portability");
513# endif 982# endif
514#endif 983#endif
515 984
@@ -518,7 +987,7 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
518/* Synchronize changes to a file. 987/* Synchronize changes to a file.
519 Return 0 if successful, otherwise -1 and errno set. 988 Return 0 if successful, otherwise -1 and errno set.
520 See POSIX:2008 specification 989 See POSIX:2008 specification
521 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */ 990 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
522# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@ 991# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
523_GL_FUNCDECL_SYS (fdatasync, int, (int fd)); 992_GL_FUNCDECL_SYS (fdatasync, int, (int fd));
524# endif 993# endif
@@ -537,7 +1006,7 @@ _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
537/* Synchronize changes, including metadata, to a file. 1006/* Synchronize changes, including metadata, to a file.
538 Return 0 if successful, otherwise -1 and errno set. 1007 Return 0 if successful, otherwise -1 and errno set.
539 See POSIX:2008 specification 1008 See POSIX:2008 specification
540 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */ 1009 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
541# if !@HAVE_FSYNC@ 1010# if !@HAVE_FSYNC@
542_GL_FUNCDECL_SYS (fsync, int, (int fd)); 1011_GL_FUNCDECL_SYS (fsync, int, (int fd));
543# endif 1012# endif
@@ -556,7 +1025,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. 1025/* 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. 1026 Return 0 if successful, otherwise -1 and errno set.
558 See the POSIX:2008 specification 1027 See the POSIX:2008 specification
559 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */ 1028 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
560# if @REPLACE_FTRUNCATE@ 1029# if @REPLACE_FTRUNCATE@
561# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1030# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
562# undef ftruncate 1031# undef ftruncate
@@ -586,7 +1055,7 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
586 Return BUF if successful, or NULL if the directory couldn't be determined 1055 Return BUF if successful, or NULL if the directory couldn't be determined
587 or SIZE was too small. 1056 or SIZE was too small.
588 See the POSIX:2008 specification 1057 See the POSIX:2008 specification
589 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>. 1058 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
590 Additionally, the gnulib module 'getcwd' guarantees the following GNU 1059 Additionally, the gnulib module 'getcwd' guarantees the following GNU
591 extension: If BUF is NULL, an array is allocated with 'malloc'; the array 1060 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 1061 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
@@ -597,6 +1066,12 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
597# endif 1066# endif
598_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); 1067_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
599_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); 1068_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
1069# elif defined _WIN32 && !defined __CYGWIN__
1070# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1071# undef getcwd
1072# define getcwd _getcwd
1073# endif
1074_GL_CXXALIAS_MDA (getcwd, char *, (char *buf, size_t size));
600# else 1075# else
601/* Need to cast, because on mingw, the second parameter is 1076/* Need to cast, because on mingw, the second parameter is
602 int size. */ 1077 int size. */
@@ -609,6 +1084,22 @@ _GL_CXXALIASWARN (getcwd);
609_GL_WARN_ON_USE (getcwd, "getcwd is unportable - " 1084_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
610 "use gnulib module getcwd for portability"); 1085 "use gnulib module getcwd for portability");
611# endif 1086# endif
1087#elif @GNULIB_MDA_GETCWD@
1088/* On native Windows, map 'getcwd' to '_getcwd', so that -loldnames is not
1089 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1090 platforms by defining GNULIB_NAMESPACE::getcwd always. */
1091# if defined _WIN32 && !defined __CYGWIN__
1092# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1093# undef getcwd
1094# define getcwd _getcwd
1095# endif
1096/* Need to cast, because on mingw, the second parameter is either
1097 'int size' or 'size_t size'. */
1098_GL_CXXALIAS_MDA_CAST (getcwd, char *, (char *buf, size_t size));
1099# else
1100_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
1101# endif
1102_GL_CXXALIASWARN (getcwd);
612#endif 1103#endif
613 1104
614 1105
@@ -651,10 +1142,21 @@ _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
651#if @GNULIB_GETDTABLESIZE@ 1142#if @GNULIB_GETDTABLESIZE@
652/* Return the maximum number of file descriptors in the current process. 1143/* Return the maximum number of file descriptors in the current process.
653 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */ 1144 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
654# if !@HAVE_GETDTABLESIZE@ 1145# if @REPLACE_GETDTABLESIZE@
1146# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1147# undef getdtablesize
1148# define getdtablesize rpl_getdtablesize
1149# endif
1150_GL_FUNCDECL_RPL (getdtablesize, int, (void));
1151_GL_CXXALIAS_RPL (getdtablesize, int, (void));
1152# else
1153# if !@HAVE_GETDTABLESIZE@
655_GL_FUNCDECL_SYS (getdtablesize, int, (void)); 1154_GL_FUNCDECL_SYS (getdtablesize, int, (void));
1155# endif
1156/* Need to cast, because on AIX, the parameter list is
1157 (...). */
1158_GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void));
656# endif 1159# endif
657_GL_CXXALIAS_SYS (getdtablesize, int, (void));
658_GL_CXXALIASWARN (getdtablesize); 1160_GL_CXXALIASWARN (getdtablesize);
659#elif defined GNULIB_POSIXCHECK 1161#elif defined GNULIB_POSIXCHECK
660# undef getdtablesize 1162# undef getdtablesize
@@ -665,6 +1167,22 @@ _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
665#endif 1167#endif
666 1168
667 1169
1170#if @GNULIB_GETENTROPY@
1171/* Fill a buffer with random bytes. */
1172# if !@HAVE_GETENTROPY@
1173_GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length));
1174# endif
1175_GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length));
1176_GL_CXXALIASWARN (getentropy);
1177#elif defined GNULIB_POSIXCHECK
1178# undef getentropy
1179# if HAVE_RAW_DECL_GETENTROPY
1180_GL_WARN_ON_USE (getentropy, "getentropy is unportable - "
1181 "use gnulib module getentropy for portability");
1182# endif
1183#endif
1184
1185
668#if @GNULIB_GETGROUPS@ 1186#if @GNULIB_GETGROUPS@
669/* Return the supplemental groups that the current process belongs to. 1187/* Return the supplemental groups that the current process belongs to.
670 It is unspecified whether the effective group id is in the list. 1188 It is unspecified whether the effective group id is in the list.
@@ -737,14 +1255,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, 1255/* Returns the user's login name, or NULL if it cannot be found. Upon error,
738 returns NULL with errno set. 1256 returns NULL with errno set.
739 1257
740 See <http://www.opengroup.org/susv3xsh/getlogin.html>. 1258 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
741 1259
742 Most programs don't need to use this function, because the information is 1260 Most programs don't need to use this function, because the information is
743 available through environment variables: 1261 available through environment variables:
744 ${LOGNAME-$USER} on Unix platforms, 1262 ${LOGNAME-$USER} on Unix platforms,
745 $USERNAME on native Windows platforms. 1263 $USERNAME on native Windows platforms.
746 */ 1264 */
747# if !@HAVE_GETLOGIN@ 1265# if !@HAVE_DECL_GETLOGIN@
748_GL_FUNCDECL_SYS (getlogin, char *, (void)); 1266_GL_FUNCDECL_SYS (getlogin, char *, (void));
749# endif 1267# endif
750_GL_CXXALIAS_SYS (getlogin, char *, (void)); 1268_GL_CXXALIAS_SYS (getlogin, char *, (void));
@@ -766,7 +1284,7 @@ _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
766 the case that the login name cannot be found but no specific error is 1284 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). 1285 provided (this case is hopefully rare but is left open by the POSIX spec).
768 1286
769 See <http://www.opengroup.org/susv3xsh/getlogin.html>. 1287 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
770 1288
771 Most programs don't need to use this function, because the information is 1289 Most programs don't need to use this function, because the information is
772 available through environment variables: 1290 available through environment variables:
@@ -807,6 +1325,11 @@ _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
807_GL_FUNCDECL_RPL (getpagesize, int, (void)); 1325_GL_FUNCDECL_RPL (getpagesize, int, (void));
808_GL_CXXALIAS_RPL (getpagesize, int, (void)); 1326_GL_CXXALIAS_RPL (getpagesize, int, (void));
809# else 1327# else
1328/* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
1329 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */
1330# if defined __hpux
1331_GL_FUNCDECL_SYS (getpagesize, int, (void));
1332# endif
810# if !@HAVE_GETPAGESIZE@ 1333# if !@HAVE_GETPAGESIZE@
811# if !defined getpagesize 1334# if !defined getpagesize
812/* This is for POSIX systems. */ 1335/* This is for POSIX systems. */
@@ -881,6 +1404,53 @@ _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
881#endif 1404#endif
882 1405
883 1406
1407#if @GNULIB_GETPASS@
1408/* Function getpass() from module 'getpass':
1409 Read a password from /dev/tty or stdin.
1410 Function getpass() from module 'getpass-gnu':
1411 Read a password of arbitrary length from /dev/tty or stdin. */
1412# if @REPLACE_GETPASS@
1413# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1414# undef getpass
1415# define getpass rpl_getpass
1416# endif
1417_GL_FUNCDECL_RPL (getpass, char *, (const char *prompt)
1418 _GL_ARG_NONNULL ((1)));
1419_GL_CXXALIAS_RPL (getpass, char *, (const char *prompt));
1420# else
1421# if !@HAVE_GETPASS@
1422_GL_FUNCDECL_SYS (getpass, char *, (const char *prompt)
1423 _GL_ARG_NONNULL ((1)));
1424# endif
1425_GL_CXXALIAS_SYS (getpass, char *, (const char *prompt));
1426# endif
1427_GL_CXXALIASWARN (getpass);
1428#elif defined GNULIB_POSIXCHECK
1429# undef getpass
1430# if HAVE_RAW_DECL_GETPASS
1431_GL_WARN_ON_USE (getpass, "getpass is unportable - "
1432 "use gnulib module getpass or getpass-gnu for portability");
1433# endif
1434#endif
1435
1436
1437#if @GNULIB_MDA_GETPID@
1438/* On native Windows, map 'getpid' to '_getpid', so that -loldnames is not
1439 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1440 platforms by defining GNULIB_NAMESPACE::getpid always. */
1441# if defined _WIN32 && !defined __CYGWIN__
1442# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1443# undef getpid
1444# define getpid _getpid
1445# endif
1446_GL_CXXALIAS_MDA (getpid, int, (void));
1447# else
1448_GL_CXXALIAS_SYS (getpid, pid_t, (void));
1449# endif
1450_GL_CXXALIASWARN (getpid);
1451#endif
1452
1453
884#if @GNULIB_GETUSERSHELL@ 1454#if @GNULIB_GETUSERSHELL@
885/* Return the next valid login shell on the system, or NULL when the end of 1455/* Return the next valid login shell on the system, or NULL when the end of
886 the list has been reached. */ 1456 the list has been reached. */
@@ -951,8 +1521,15 @@ _GL_WARN_ON_USE (group_member, "group_member is unportable - "
951# undef isatty 1521# undef isatty
952# define isatty rpl_isatty 1522# define isatty rpl_isatty
953# endif 1523# endif
1524# define GNULIB_defined_isatty 1
954_GL_FUNCDECL_RPL (isatty, int, (int fd)); 1525_GL_FUNCDECL_RPL (isatty, int, (int fd));
955_GL_CXXALIAS_RPL (isatty, int, (int fd)); 1526_GL_CXXALIAS_RPL (isatty, int, (int fd));
1527# elif defined _WIN32 && !defined __CYGWIN__
1528# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1529# undef isatty
1530# define isatty _isatty
1531# endif
1532_GL_CXXALIAS_MDA (isatty, int, (int fd));
956# else 1533# else
957_GL_CXXALIAS_SYS (isatty, int, (int fd)); 1534_GL_CXXALIAS_SYS (isatty, int, (int fd));
958# endif 1535# endif
@@ -963,6 +1540,20 @@ _GL_CXXALIASWARN (isatty);
963_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - " 1540_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
964 "use gnulib module isatty for portability"); 1541 "use gnulib module isatty for portability");
965# endif 1542# endif
1543#elif @GNULIB_MDA_ISATTY@
1544/* On native Windows, map 'isatty' to '_isatty', so that -loldnames is not
1545 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1546 platforms by defining GNULIB_NAMESPACE::isatty always. */
1547# if defined _WIN32 && !defined __CYGWIN__
1548# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1549# undef isatty
1550# define isatty _isatty
1551# endif
1552_GL_CXXALIAS_MDA (isatty, int, (int fd));
1553# else
1554_GL_CXXALIAS_SYS (isatty, int, (int fd));
1555# endif
1556_GL_CXXALIASWARN (isatty);
966#endif 1557#endif
967 1558
968 1559
@@ -971,7 +1562,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. 1562 to GID (if GID is not -1). Do not follow symbolic links.
972 Return 0 if successful, otherwise -1 and errno set. 1563 Return 0 if successful, otherwise -1 and errno set.
973 See the POSIX:2008 specification 1564 See the POSIX:2008 specification
974 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */ 1565 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
975# if @REPLACE_LCHOWN@ 1566# if @REPLACE_LCHOWN@
976# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1567# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
977# undef lchown 1568# undef lchown
@@ -1001,7 +1592,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. 1592/* Create a new hard link for an existing file.
1002 Return 0 if successful, otherwise -1 and errno set. 1593 Return 0 if successful, otherwise -1 and errno set.
1003 See POSIX:2008 specification 1594 See POSIX:2008 specification
1004 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */ 1595 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1005# if @REPLACE_LINK@ 1596# if @REPLACE_LINK@
1006# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1597# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1007# define link rpl_link 1598# define link rpl_link
@@ -1067,13 +1658,19 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1067/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. 1658/* 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. 1659 Return the new offset if successful, otherwise -1 and errno set.
1069 See the POSIX:2008 specification 1660 See the POSIX:2008 specification
1070 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */ 1661 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1071# if @REPLACE_LSEEK@ 1662# if @REPLACE_LSEEK@
1072# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1663# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1073# define lseek rpl_lseek 1664# define lseek rpl_lseek
1074# endif 1665# endif
1075_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence)); 1666_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)); 1667_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1668# elif defined _WIN32 && !defined __CYGWIN__
1669# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1670# undef lseek
1671# define lseek _lseek
1672# endif
1673_GL_CXXALIAS_MDA (lseek, off_t, (int fd, off_t offset, int whence));
1077# else 1674# else
1078_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence)); 1675_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1079# endif 1676# endif
@@ -1084,6 +1681,20 @@ _GL_CXXALIASWARN (lseek);
1084_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some " 1681_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1085 "systems - use gnulib module lseek for portability"); 1682 "systems - use gnulib module lseek for portability");
1086# endif 1683# endif
1684#elif @GNULIB_MDA_LSEEK@
1685/* On native Windows, map 'lseek' to '_lseek', so that -loldnames is not
1686 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1687 platforms by defining GNULIB_NAMESPACE::lseek always. */
1688# if defined _WIN32 && !defined __CYGWIN__
1689# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1690# undef lseek
1691# define lseek _lseek
1692# endif
1693_GL_CXXALIAS_MDA (lseek, long, (int fd, long offset, int whence));
1694# else
1695_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1696# endif
1697_GL_CXXALIASWARN (lseek);
1087#endif 1698#endif
1088 1699
1089 1700
@@ -1113,7 +1724,7 @@ _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1113 Store the read-end as fd[0] and the write-end as fd[1]. 1724 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. 1725 Return 0 upon success, or -1 with errno set upon failure.
1115 See also the Linux man page at 1726 See also the Linux man page at
1116 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */ 1727 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1117# if @HAVE_PIPE2@ 1728# if @HAVE_PIPE2@
1118# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1729# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1119# define pipe2 rpl_pipe2 1730# define pipe2 rpl_pipe2
@@ -1139,7 +1750,7 @@ _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1139 Return the number of bytes placed into BUF if successful, otherwise 1750 Return the number of bytes placed into BUF if successful, otherwise
1140 set errno and return -1. 0 indicates EOF. 1751 set errno and return -1. 0 indicates EOF.
1141 See the POSIX:2008 specification 1752 See the POSIX:2008 specification
1142 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */ 1753 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1143# if @REPLACE_PREAD@ 1754# if @REPLACE_PREAD@
1144# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1755# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1145# undef pread 1756# undef pread
@@ -1174,7 +1785,7 @@ _GL_WARN_ON_USE (pread, "pread is unportable - "
1174 Return the number of bytes written if successful, otherwise 1785 Return the number of bytes written if successful, otherwise
1175 set errno and return -1. 0 indicates nothing written. See the 1786 set errno and return -1. 0 indicates nothing written. See the
1176 POSIX:2008 specification 1787 POSIX:2008 specification
1177 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */ 1788 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1178# if @REPLACE_PWRITE@ 1789# if @REPLACE_PWRITE@
1179# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1790# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1180# undef pwrite 1791# undef pwrite
@@ -1207,7 +1818,7 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1207#if @GNULIB_READ@ 1818#if @GNULIB_READ@
1208/* Read up to COUNT bytes from file descriptor FD into the buffer starting 1819/* Read up to COUNT bytes from file descriptor FD into the buffer starting
1209 at BUF. See the POSIX:2008 specification 1820 at BUF. See the POSIX:2008 specification
1210 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */ 1821 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1211# if @REPLACE_READ@ 1822# if @REPLACE_READ@
1212# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1823# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1213# undef read 1824# undef read
@@ -1216,11 +1827,32 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1216_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count) 1827_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1217 _GL_ARG_NONNULL ((2))); 1828 _GL_ARG_NONNULL ((2)));
1218_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count)); 1829_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1830# elif defined _WIN32 && !defined __CYGWIN__
1831# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1832# undef read
1833# define read _read
1834# endif
1835_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, size_t count));
1836# else
1837_GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1838# endif
1839_GL_CXXALIASWARN (read);
1840#elif @GNULIB_MDA_READ@
1841/* On native Windows, map 'read' to '_read', so that -loldnames is not
1842 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1843 platforms by defining GNULIB_NAMESPACE::read always. */
1844# if defined _WIN32 && !defined __CYGWIN__
1845# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1846# undef read
1847# define read _read
1848# endif
1849# ifdef __MINGW32__
1850_GL_CXXALIAS_MDA (read, int, (int fd, void *buf, unsigned int count));
1851# else
1852_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, unsigned int count));
1853# endif
1219# else 1854# else
1220/* Need to cast, because on mingw, the third parameter is 1855_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 1856# endif
1225_GL_CXXALIASWARN (read); 1857_GL_CXXALIASWARN (read);
1226#endif 1858#endif
@@ -1231,24 +1863,28 @@ _GL_CXXALIASWARN (read);
1231 bytes of it into BUF. Return the number of bytes placed into BUF if 1863 bytes of it into BUF. Return the number of bytes placed into BUF if
1232 successful, otherwise -1 and errno set. 1864 successful, otherwise -1 and errno set.
1233 See the POSIX:2008 specification 1865 See the POSIX:2008 specification
1234 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */ 1866 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1235# if @REPLACE_READLINK@ 1867# if @REPLACE_READLINK@
1236# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1868# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1237# define readlink rpl_readlink 1869# define readlink rpl_readlink
1238# endif 1870# endif
1239_GL_FUNCDECL_RPL (readlink, ssize_t, 1871_GL_FUNCDECL_RPL (readlink, ssize_t,
1240 (const char *file, char *buf, size_t bufsize) 1872 (const char *restrict file,
1873 char *restrict buf, size_t bufsize)
1241 _GL_ARG_NONNULL ((1, 2))); 1874 _GL_ARG_NONNULL ((1, 2)));
1242_GL_CXXALIAS_RPL (readlink, ssize_t, 1875_GL_CXXALIAS_RPL (readlink, ssize_t,
1243 (const char *file, char *buf, size_t bufsize)); 1876 (const char *restrict file,
1877 char *restrict buf, size_t bufsize));
1244# else 1878# else
1245# if !@HAVE_READLINK@ 1879# if !@HAVE_READLINK@
1246_GL_FUNCDECL_SYS (readlink, ssize_t, 1880_GL_FUNCDECL_SYS (readlink, ssize_t,
1247 (const char *file, char *buf, size_t bufsize) 1881 (const char *restrict file,
1882 char *restrict buf, size_t bufsize)
1248 _GL_ARG_NONNULL ((1, 2))); 1883 _GL_ARG_NONNULL ((1, 2)));
1249# endif 1884# endif
1250_GL_CXXALIAS_SYS (readlink, ssize_t, 1885_GL_CXXALIAS_SYS (readlink, ssize_t,
1251 (const char *file, char *buf, size_t bufsize)); 1886 (const char *restrict file,
1887 char *restrict buf, size_t bufsize));
1252# endif 1888# endif
1253_GL_CXXALIASWARN (readlink); 1889_GL_CXXALIASWARN (readlink);
1254#elif defined GNULIB_POSIXCHECK 1890#elif defined GNULIB_POSIXCHECK
@@ -1261,13 +1897,28 @@ _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1261 1897
1262 1898
1263#if @GNULIB_READLINKAT@ 1899#if @GNULIB_READLINKAT@
1264# if !@HAVE_READLINKAT@ 1900# if @REPLACE_READLINKAT@
1901# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1902# define readlinkat rpl_readlinkat
1903# endif
1904_GL_FUNCDECL_RPL (readlinkat, ssize_t,
1905 (int fd, char const *restrict file,
1906 char *restrict buf, size_t len)
1907 _GL_ARG_NONNULL ((2, 3)));
1908_GL_CXXALIAS_RPL (readlinkat, ssize_t,
1909 (int fd, char const *restrict file,
1910 char *restrict buf, size_t len));
1911# else
1912# if !@HAVE_READLINKAT@
1265_GL_FUNCDECL_SYS (readlinkat, ssize_t, 1913_GL_FUNCDECL_SYS (readlinkat, ssize_t,
1266 (int fd, char const *file, char *buf, size_t len) 1914 (int fd, char const *restrict file,
1915 char *restrict buf, size_t len)
1267 _GL_ARG_NONNULL ((2, 3))); 1916 _GL_ARG_NONNULL ((2, 3)));
1268# endif 1917# endif
1269_GL_CXXALIAS_SYS (readlinkat, ssize_t, 1918_GL_CXXALIAS_SYS (readlinkat, ssize_t,
1270 (int fd, char const *file, char *buf, size_t len)); 1919 (int fd, char const *restrict file,
1920 char *restrict buf, size_t len));
1921# endif
1271_GL_CXXALIASWARN (readlinkat); 1922_GL_CXXALIASWARN (readlinkat);
1272#elif defined GNULIB_POSIXCHECK 1923#elif defined GNULIB_POSIXCHECK
1273# undef readlinkat 1924# undef readlinkat
@@ -1286,6 +1937,12 @@ _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1286# endif 1937# endif
1287_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); 1938_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1288_GL_CXXALIAS_RPL (rmdir, int, (char const *name)); 1939_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1940# elif defined _WIN32 && !defined __CYGWIN__
1941# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1942# undef rmdir
1943# define rmdir _rmdir
1944# endif
1945_GL_CXXALIAS_MDA (rmdir, int, (char const *name));
1289# else 1946# else
1290_GL_CXXALIAS_SYS (rmdir, int, (char const *name)); 1947_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1291# endif 1948# endif
@@ -1296,6 +1953,20 @@ _GL_CXXALIASWARN (rmdir);
1296_GL_WARN_ON_USE (rmdir, "rmdir is unportable - " 1953_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1297 "use gnulib module rmdir for portability"); 1954 "use gnulib module rmdir for portability");
1298# endif 1955# endif
1956#elif @GNULIB_MDA_RMDIR@
1957/* On native Windows, map 'rmdir' to '_rmdir', so that -loldnames is not
1958 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1959 platforms by defining GNULIB_NAMESPACE::rmdir always. */
1960# if defined _WIN32 && !defined __CYGWIN__
1961# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1962# undef rmdir
1963# define rmdir _rmdir
1964# endif
1965_GL_CXXALIAS_MDA (rmdir, int, (char const *name));
1966# else
1967_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1968# endif
1969_GL_CXXALIASWARN (rmdir);
1299#endif 1970#endif
1300 1971
1301 1972
@@ -1330,7 +2001,7 @@ _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1330/* Pause the execution of the current thread for N seconds. 2001/* Pause the execution of the current thread for N seconds.
1331 Returns the number of seconds left to sleep. 2002 Returns the number of seconds left to sleep.
1332 See the POSIX:2008 specification 2003 See the POSIX:2008 specification
1333 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */ 2004 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1334# if @REPLACE_SLEEP@ 2005# if @REPLACE_SLEEP@
1335# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2006# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1336# undef sleep 2007# undef sleep
@@ -1354,6 +2025,31 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1354#endif 2025#endif
1355 2026
1356 2027
2028#if @GNULIB_MDA_SWAB@
2029/* On native Windows, map 'swab' to '_swab', so that -loldnames is not
2030 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2031 platforms by defining GNULIB_NAMESPACE::swab always. */
2032# if defined _WIN32 && !defined __CYGWIN__
2033# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2034# undef swab
2035# define swab _swab
2036# endif
2037/* Need to cast, because in old mingw the arguments are
2038 (const char *from, char *to, size_t n). */
2039_GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n));
2040# else
2041# if defined __hpux /* HP-UX */
2042_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
2043# elif defined __sun && !defined _XPG4 /* Solaris */
2044_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
2045# else
2046_GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));
2047# endif
2048# endif
2049_GL_CXXALIASWARN (swab);
2050#endif
2051
2052
1357#if @GNULIB_SYMLINK@ 2053#if @GNULIB_SYMLINK@
1358# if @REPLACE_SYMLINK@ 2054# if @REPLACE_SYMLINK@
1359# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2055# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1381,13 +2077,25 @@ _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1381 2077
1382 2078
1383#if @GNULIB_SYMLINKAT@ 2079#if @GNULIB_SYMLINKAT@
1384# if !@HAVE_SYMLINKAT@ 2080# if @REPLACE_SYMLINKAT@
2081# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2082# undef symlinkat
2083# define symlinkat rpl_symlinkat
2084# endif
2085_GL_FUNCDECL_RPL (symlinkat, int,
2086 (char const *contents, int fd, char const *file)
2087 _GL_ARG_NONNULL ((1, 3)));
2088_GL_CXXALIAS_RPL (symlinkat, int,
2089 (char const *contents, int fd, char const *file));
2090# else
2091# if !@HAVE_SYMLINKAT@
1385_GL_FUNCDECL_SYS (symlinkat, int, 2092_GL_FUNCDECL_SYS (symlinkat, int,
1386 (char const *contents, int fd, char const *file) 2093 (char const *contents, int fd, char const *file)
1387 _GL_ARG_NONNULL ((1, 3))); 2094 _GL_ARG_NONNULL ((1, 3)));
1388# endif 2095# endif
1389_GL_CXXALIAS_SYS (symlinkat, int, 2096_GL_CXXALIAS_SYS (symlinkat, int,
1390 (char const *contents, int fd, char const *file)); 2097 (char const *contents, int fd, char const *file));
2098# endif
1391_GL_CXXALIASWARN (symlinkat); 2099_GL_CXXALIASWARN (symlinkat);
1392#elif defined GNULIB_POSIXCHECK 2100#elif defined GNULIB_POSIXCHECK
1393# undef symlinkat 2101# undef symlinkat
@@ -1398,6 +2106,36 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1398#endif 2106#endif
1399 2107
1400 2108
2109#if @GNULIB_TRUNCATE@
2110/* Change the size of the file designated by FILENAME to become equal to LENGTH.
2111 Return 0 if successful, otherwise -1 and errno set.
2112 See the POSIX:2008 specification
2113 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
2114# if @REPLACE_TRUNCATE@
2115# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2116# undef truncate
2117# define truncate rpl_truncate
2118# endif
2119_GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
2120 _GL_ARG_NONNULL ((1)));
2121_GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
2122# else
2123# if !@HAVE_DECL_TRUNCATE@
2124_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
2125 _GL_ARG_NONNULL ((1)));
2126# endif
2127_GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
2128# endif
2129_GL_CXXALIASWARN (truncate);
2130#elif defined GNULIB_POSIXCHECK
2131# undef truncate
2132# if HAVE_RAW_DECL_TRUNCATE
2133_GL_WARN_ON_USE (truncate, "truncate is unportable - "
2134 "use gnulib module truncate for portability");
2135# endif
2136#endif
2137
2138
1401#if @GNULIB_TTYNAME_R@ 2139#if @GNULIB_TTYNAME_R@
1402/* Store at most BUFLEN characters of the pathname of the terminal FD is 2140/* 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. */ 2141 open on in BUF. Return 0 on success, otherwise an error number. */
@@ -1436,6 +2174,12 @@ _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1436# endif 2174# endif
1437_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); 2175_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1438_GL_CXXALIAS_RPL (unlink, int, (char const *file)); 2176_GL_CXXALIAS_RPL (unlink, int, (char const *file));
2177# elif defined _WIN32 && !defined __CYGWIN__
2178# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2179# undef unlink
2180# define unlink _unlink
2181# endif
2182_GL_CXXALIAS_MDA (unlink, int, (char const *file));
1439# else 2183# else
1440_GL_CXXALIAS_SYS (unlink, int, (char const *file)); 2184_GL_CXXALIAS_SYS (unlink, int, (char const *file));
1441# endif 2185# endif
@@ -1446,6 +2190,20 @@ _GL_CXXALIASWARN (unlink);
1446_GL_WARN_ON_USE (unlink, "unlink is not portable - " 2190_GL_WARN_ON_USE (unlink, "unlink is not portable - "
1447 "use gnulib module unlink for portability"); 2191 "use gnulib module unlink for portability");
1448# endif 2192# endif
2193#elif @GNULIB_MDA_UNLINK@
2194/* On native Windows, map 'unlink' to '_unlink', so that -loldnames is not
2195 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2196 platforms by defining GNULIB_NAMESPACE::unlink always. */
2197# if defined _WIN32 && !defined __CYGWIN__
2198# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2199# undef unlink
2200# define unlink _unlink
2201# endif
2202_GL_CXXALIAS_MDA (unlink, int, (char const *file));
2203# else
2204_GL_CXXALIAS_SYS (unlink, int, (char const *file));
2205# endif
2206_GL_CXXALIASWARN (unlink);
1449#endif 2207#endif
1450 2208
1451 2209
@@ -1470,7 +2228,7 @@ _GL_CXXALIASWARN (unlinkat);
1470# undef unlinkat 2228# undef unlinkat
1471# if HAVE_RAW_DECL_UNLINKAT 2229# if HAVE_RAW_DECL_UNLINKAT
1472_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " 2230_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1473 "use gnulib module openat for portability"); 2231 "use gnulib module unlinkat for portability");
1474# endif 2232# endif
1475#endif 2233#endif
1476 2234
@@ -1479,7 +2237,7 @@ _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1479/* Pause the execution of the current thread for N microseconds. 2237/* Pause the execution of the current thread for N microseconds.
1480 Returns 0 on completion, or -1 on range error. 2238 Returns 0 on completion, or -1 on range error.
1481 See the POSIX:2001 specification 2239 See the POSIX:2001 specification
1482 <http://www.opengroup.org/susv3xsh/usleep.html>. */ 2240 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
1483# if @REPLACE_USLEEP@ 2241# if @REPLACE_USLEEP@
1484# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2242# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1485# undef usleep 2243# undef usleep
@@ -1491,7 +2249,9 @@ _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1491# if !@HAVE_USLEEP@ 2249# if !@HAVE_USLEEP@
1492_GL_FUNCDECL_SYS (usleep, int, (useconds_t n)); 2250_GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1493# endif 2251# endif
1494_GL_CXXALIAS_SYS (usleep, int, (useconds_t n)); 2252/* Need to cast, because on Haiku, the first parameter is
2253 unsigned int n. */
2254_GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n));
1495# endif 2255# endif
1496_GL_CXXALIASWARN (usleep); 2256_GL_CXXALIASWARN (usleep);
1497#elif defined GNULIB_POSIXCHECK 2257#elif defined GNULIB_POSIXCHECK
@@ -1506,7 +2266,7 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1506#if @GNULIB_WRITE@ 2266#if @GNULIB_WRITE@
1507/* Write up to COUNT bytes starting at BUF to file descriptor FD. 2267/* Write up to COUNT bytes starting at BUF to file descriptor FD.
1508 See the POSIX:2008 specification 2268 See the POSIX:2008 specification
1509 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */ 2269 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1510# if @REPLACE_WRITE@ 2270# if @REPLACE_WRITE@
1511# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2271# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1512# undef write 2272# undef write
@@ -1515,11 +2275,32 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1515_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) 2275_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1516 _GL_ARG_NONNULL ((2))); 2276 _GL_ARG_NONNULL ((2)));
1517_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); 2277_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
2278# elif defined _WIN32 && !defined __CYGWIN__
2279# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2280# undef write
2281# define write _write
2282# endif
2283_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, size_t count));
2284# else
2285_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
2286# endif
2287_GL_CXXALIASWARN (write);
2288#elif @GNULIB_MDA_WRITE@
2289/* On native Windows, map 'write' to '_write', so that -loldnames is not
2290 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2291 platforms by defining GNULIB_NAMESPACE::write always. */
2292# if defined _WIN32 && !defined __CYGWIN__
2293# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2294# undef write
2295# define write _write
2296# endif
2297# ifdef __MINGW32__
2298_GL_CXXALIAS_MDA (write, int, (int fd, const void *buf, unsigned int count));
2299# else
2300_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, unsigned int count));
2301# endif
1518# else 2302# else
1519/* Need to cast, because on mingw, the third parameter is 2303_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 2304# endif
1524_GL_CXXALIASWARN (write); 2305_GL_CXXALIASWARN (write);
1525#endif 2306#endif
@@ -1527,4 +2308,5 @@ _GL_CXXALIASWARN (write);
1527_GL_INLINE_HEADER_END 2308_GL_INLINE_HEADER_END
1528 2309
1529#endif /* _@GUARD_PREFIX@_UNISTD_H */ 2310#endif /* _@GUARD_PREFIX@_UNISTD_H */
2311#endif /* _GL_INCLUDING_UNISTD_H */
1530#endif /* _@GUARD_PREFIX@_UNISTD_H */ 2312#endif /* _@GUARD_PREFIX@_UNISTD_H */