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.h995
1 files changed, 896 insertions, 99 deletions
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index 2ea9af43..57df09ec 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-2022 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
@@ -651,10 +1156,21 @@ _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
651#if @GNULIB_GETDTABLESIZE@ 1156#if @GNULIB_GETDTABLESIZE@
652/* Return the maximum number of file descriptors in the current process. 1157/* Return the maximum number of file descriptors in the current process.
653 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */ 1158 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
654# if !@HAVE_GETDTABLESIZE@ 1159# if @REPLACE_GETDTABLESIZE@
1160# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1161# undef getdtablesize
1162# define getdtablesize rpl_getdtablesize
1163# endif
1164_GL_FUNCDECL_RPL (getdtablesize, int, (void));
1165_GL_CXXALIAS_RPL (getdtablesize, int, (void));
1166# else
1167# if !@HAVE_GETDTABLESIZE@
655_GL_FUNCDECL_SYS (getdtablesize, int, (void)); 1168_GL_FUNCDECL_SYS (getdtablesize, int, (void));
1169# endif
1170/* Need to cast, because on AIX, the parameter list is
1171 (...). */
1172_GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void));
656# endif 1173# endif
657_GL_CXXALIAS_SYS (getdtablesize, int, (void));
658_GL_CXXALIASWARN (getdtablesize); 1174_GL_CXXALIASWARN (getdtablesize);
659#elif defined GNULIB_POSIXCHECK 1175#elif defined GNULIB_POSIXCHECK
660# undef getdtablesize 1176# undef getdtablesize
@@ -665,6 +1181,22 @@ _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
665#endif 1181#endif
666 1182
667 1183
1184#if @GNULIB_GETENTROPY@
1185/* Fill a buffer with random bytes. */
1186# if !@HAVE_GETENTROPY@
1187_GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length));
1188# endif
1189_GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length));
1190_GL_CXXALIASWARN (getentropy);
1191#elif defined GNULIB_POSIXCHECK
1192# undef getentropy
1193# if HAVE_RAW_DECL_GETENTROPY
1194_GL_WARN_ON_USE (getentropy, "getentropy is unportable - "
1195 "use gnulib module getentropy for portability");
1196# endif
1197#endif
1198
1199
668#if @GNULIB_GETGROUPS@ 1200#if @GNULIB_GETGROUPS@
669/* Return the supplemental groups that the current process belongs to. 1201/* Return the supplemental groups that the current process belongs to.
670 It is unspecified whether the effective group id is in the list. 1202 It is unspecified whether the effective group id is in the list.
@@ -737,14 +1269,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, 1269/* Returns the user's login name, or NULL if it cannot be found. Upon error,
738 returns NULL with errno set. 1270 returns NULL with errno set.
739 1271
740 See <http://www.opengroup.org/susv3xsh/getlogin.html>. 1272 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
741 1273
742 Most programs don't need to use this function, because the information is 1274 Most programs don't need to use this function, because the information is
743 available through environment variables: 1275 available through environment variables:
744 ${LOGNAME-$USER} on Unix platforms, 1276 ${LOGNAME-$USER} on Unix platforms,
745 $USERNAME on native Windows platforms. 1277 $USERNAME on native Windows platforms.
746 */ 1278 */
747# if !@HAVE_GETLOGIN@ 1279# if !@HAVE_DECL_GETLOGIN@
748_GL_FUNCDECL_SYS (getlogin, char *, (void)); 1280_GL_FUNCDECL_SYS (getlogin, char *, (void));
749# endif 1281# endif
750_GL_CXXALIAS_SYS (getlogin, char *, (void)); 1282_GL_CXXALIAS_SYS (getlogin, char *, (void));
@@ -766,7 +1298,7 @@ _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
766 the case that the login name cannot be found but no specific error is 1298 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). 1299 provided (this case is hopefully rare but is left open by the POSIX spec).
768 1300
769 See <http://www.opengroup.org/susv3xsh/getlogin.html>. 1301 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
770 1302
771 Most programs don't need to use this function, because the information is 1303 Most programs don't need to use this function, because the information is
772 available through environment variables: 1304 available through environment variables:
@@ -807,6 +1339,11 @@ _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
807_GL_FUNCDECL_RPL (getpagesize, int, (void)); 1339_GL_FUNCDECL_RPL (getpagesize, int, (void));
808_GL_CXXALIAS_RPL (getpagesize, int, (void)); 1340_GL_CXXALIAS_RPL (getpagesize, int, (void));
809# else 1341# else
1342/* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
1343 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */
1344# if defined __hpux
1345_GL_FUNCDECL_SYS (getpagesize, int, (void));
1346# endif
810# if !@HAVE_GETPAGESIZE@ 1347# if !@HAVE_GETPAGESIZE@
811# if !defined getpagesize 1348# if !defined getpagesize
812/* This is for POSIX systems. */ 1349/* This is for POSIX systems. */
@@ -881,6 +1418,54 @@ _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
881#endif 1418#endif
882 1419
883 1420
1421#if @GNULIB_GETPASS@
1422/* Function getpass() from module 'getpass':
1423 Read a password from /dev/tty or stdin.
1424 Function getpass() from module 'getpass-gnu':
1425 Read a password of arbitrary length from /dev/tty or stdin. */
1426# if (@GNULIB_GETPASS@ && @REPLACE_GETPASS@) \
1427 || (@GNULIB_GETPASS_GNU@ && @REPLACE_GETPASS_FOR_GETPASS_GNU@)
1428# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1429# undef getpass
1430# define getpass rpl_getpass
1431# endif
1432_GL_FUNCDECL_RPL (getpass, char *, (const char *prompt)
1433 _GL_ARG_NONNULL ((1)));
1434_GL_CXXALIAS_RPL (getpass, char *, (const char *prompt));
1435# else
1436# if !@HAVE_GETPASS@
1437_GL_FUNCDECL_SYS (getpass, char *, (const char *prompt)
1438 _GL_ARG_NONNULL ((1)));
1439# endif
1440_GL_CXXALIAS_SYS (getpass, char *, (const char *prompt));
1441# endif
1442_GL_CXXALIASWARN (getpass);
1443#elif defined GNULIB_POSIXCHECK
1444# undef getpass
1445# if HAVE_RAW_DECL_GETPASS
1446_GL_WARN_ON_USE (getpass, "getpass is unportable - "
1447 "use gnulib module getpass or getpass-gnu for portability");
1448# endif
1449#endif
1450
1451
1452#if @GNULIB_MDA_GETPID@
1453/* On native Windows, map 'getpid' to '_getpid', so that -loldnames is not
1454 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1455 platforms by defining GNULIB_NAMESPACE::getpid always. */
1456# if defined _WIN32 && !defined __CYGWIN__
1457# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1458# undef getpid
1459# define getpid _getpid
1460# endif
1461_GL_CXXALIAS_MDA (getpid, int, (void));
1462# else
1463_GL_CXXALIAS_SYS (getpid, pid_t, (void));
1464# endif
1465_GL_CXXALIASWARN (getpid);
1466#endif
1467
1468
884#if @GNULIB_GETUSERSHELL@ 1469#if @GNULIB_GETUSERSHELL@
885/* Return the next valid login shell on the system, or NULL when the end of 1470/* Return the next valid login shell on the system, or NULL when the end of
886 the list has been reached. */ 1471 the list has been reached. */
@@ -951,8 +1536,15 @@ _GL_WARN_ON_USE (group_member, "group_member is unportable - "
951# undef isatty 1536# undef isatty
952# define isatty rpl_isatty 1537# define isatty rpl_isatty
953# endif 1538# endif
1539# define GNULIB_defined_isatty 1
954_GL_FUNCDECL_RPL (isatty, int, (int fd)); 1540_GL_FUNCDECL_RPL (isatty, int, (int fd));
955_GL_CXXALIAS_RPL (isatty, int, (int fd)); 1541_GL_CXXALIAS_RPL (isatty, int, (int fd));
1542# elif defined _WIN32 && !defined __CYGWIN__
1543# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1544# undef isatty
1545# define isatty _isatty
1546# endif
1547_GL_CXXALIAS_MDA (isatty, int, (int fd));
956# else 1548# else
957_GL_CXXALIAS_SYS (isatty, int, (int fd)); 1549_GL_CXXALIAS_SYS (isatty, int, (int fd));
958# endif 1550# endif
@@ -963,6 +1555,20 @@ _GL_CXXALIASWARN (isatty);
963_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - " 1555_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
964 "use gnulib module isatty for portability"); 1556 "use gnulib module isatty for portability");
965# endif 1557# endif
1558#elif @GNULIB_MDA_ISATTY@
1559/* On native Windows, map 'isatty' to '_isatty', so that -loldnames is not
1560 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1561 platforms by defining GNULIB_NAMESPACE::isatty always. */
1562# if defined _WIN32 && !defined __CYGWIN__
1563# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1564# undef isatty
1565# define isatty _isatty
1566# endif
1567_GL_CXXALIAS_MDA (isatty, int, (int fd));
1568# else
1569_GL_CXXALIAS_SYS (isatty, int, (int fd));
1570# endif
1571_GL_CXXALIASWARN (isatty);
966#endif 1572#endif
967 1573
968 1574
@@ -971,7 +1577,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. 1577 to GID (if GID is not -1). Do not follow symbolic links.
972 Return 0 if successful, otherwise -1 and errno set. 1578 Return 0 if successful, otherwise -1 and errno set.
973 See the POSIX:2008 specification 1579 See the POSIX:2008 specification
974 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */ 1580 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
975# if @REPLACE_LCHOWN@ 1581# if @REPLACE_LCHOWN@
976# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1582# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
977# undef lchown 1583# undef lchown
@@ -1001,7 +1607,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. 1607/* Create a new hard link for an existing file.
1002 Return 0 if successful, otherwise -1 and errno set. 1608 Return 0 if successful, otherwise -1 and errno set.
1003 See POSIX:2008 specification 1609 See POSIX:2008 specification
1004 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */ 1610 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1005# if @REPLACE_LINK@ 1611# if @REPLACE_LINK@
1006# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1612# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1007# define link rpl_link 1613# define link rpl_link
@@ -1067,13 +1673,19 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1067/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. 1673/* 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. 1674 Return the new offset if successful, otherwise -1 and errno set.
1069 See the POSIX:2008 specification 1675 See the POSIX:2008 specification
1070 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */ 1676 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1071# if @REPLACE_LSEEK@ 1677# if @REPLACE_LSEEK@
1072# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1678# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1073# define lseek rpl_lseek 1679# define lseek rpl_lseek
1074# endif 1680# endif
1075_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence)); 1681_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)); 1682_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1683# elif defined _WIN32 && !defined __CYGWIN__
1684# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1685# undef lseek
1686# define lseek _lseek
1687# endif
1688_GL_CXXALIAS_MDA (lseek, off_t, (int fd, off_t offset, int whence));
1077# else 1689# else
1078_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence)); 1690_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1079# endif 1691# endif
@@ -1084,6 +1696,20 @@ _GL_CXXALIASWARN (lseek);
1084_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some " 1696_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1085 "systems - use gnulib module lseek for portability"); 1697 "systems - use gnulib module lseek for portability");
1086# endif 1698# endif
1699#elif @GNULIB_MDA_LSEEK@
1700/* On native Windows, map 'lseek' to '_lseek', so that -loldnames is not
1701 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1702 platforms by defining GNULIB_NAMESPACE::lseek always. */
1703# if defined _WIN32 && !defined __CYGWIN__
1704# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1705# undef lseek
1706# define lseek _lseek
1707# endif
1708_GL_CXXALIAS_MDA (lseek, long, (int fd, long offset, int whence));
1709# else
1710_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1711# endif
1712_GL_CXXALIASWARN (lseek);
1087#endif 1713#endif
1088 1714
1089 1715
@@ -1113,7 +1739,7 @@ _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1113 Store the read-end as fd[0] and the write-end as fd[1]. 1739 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. 1740 Return 0 upon success, or -1 with errno set upon failure.
1115 See also the Linux man page at 1741 See also the Linux man page at
1116 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */ 1742 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1117# if @HAVE_PIPE2@ 1743# if @HAVE_PIPE2@
1118# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1744# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1119# define pipe2 rpl_pipe2 1745# define pipe2 rpl_pipe2
@@ -1139,7 +1765,7 @@ _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1139 Return the number of bytes placed into BUF if successful, otherwise 1765 Return the number of bytes placed into BUF if successful, otherwise
1140 set errno and return -1. 0 indicates EOF. 1766 set errno and return -1. 0 indicates EOF.
1141 See the POSIX:2008 specification 1767 See the POSIX:2008 specification
1142 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */ 1768 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1143# if @REPLACE_PREAD@ 1769# if @REPLACE_PREAD@
1144# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1770# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1145# undef pread 1771# undef pread
@@ -1174,7 +1800,7 @@ _GL_WARN_ON_USE (pread, "pread is unportable - "
1174 Return the number of bytes written if successful, otherwise 1800 Return the number of bytes written if successful, otherwise
1175 set errno and return -1. 0 indicates nothing written. See the 1801 set errno and return -1. 0 indicates nothing written. See the
1176 POSIX:2008 specification 1802 POSIX:2008 specification
1177 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */ 1803 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1178# if @REPLACE_PWRITE@ 1804# if @REPLACE_PWRITE@
1179# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1805# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1180# undef pwrite 1806# undef pwrite
@@ -1207,7 +1833,7 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1207#if @GNULIB_READ@ 1833#if @GNULIB_READ@
1208/* Read up to COUNT bytes from file descriptor FD into the buffer starting 1834/* Read up to COUNT bytes from file descriptor FD into the buffer starting
1209 at BUF. See the POSIX:2008 specification 1835 at BUF. See the POSIX:2008 specification
1210 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */ 1836 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1211# if @REPLACE_READ@ 1837# if @REPLACE_READ@
1212# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1838# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1213# undef read 1839# undef read
@@ -1216,11 +1842,32 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1216_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count) 1842_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1217 _GL_ARG_NONNULL ((2))); 1843 _GL_ARG_NONNULL ((2)));
1218_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count)); 1844_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1845# elif defined _WIN32 && !defined __CYGWIN__
1846# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1847# undef read
1848# define read _read
1849# endif
1850_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, size_t count));
1851# else
1852_GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1853# endif
1854_GL_CXXALIASWARN (read);
1855#elif @GNULIB_MDA_READ@
1856/* On native Windows, map 'read' to '_read', so that -loldnames is not
1857 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1858 platforms by defining GNULIB_NAMESPACE::read always. */
1859# if defined _WIN32 && !defined __CYGWIN__
1860# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1861# undef read
1862# define read _read
1863# endif
1864# ifdef __MINGW32__
1865_GL_CXXALIAS_MDA (read, int, (int fd, void *buf, unsigned int count));
1866# else
1867_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, unsigned int count));
1868# endif
1219# else 1869# else
1220/* Need to cast, because on mingw, the third parameter is 1870_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 1871# endif
1225_GL_CXXALIASWARN (read); 1872_GL_CXXALIASWARN (read);
1226#endif 1873#endif
@@ -1231,24 +1878,28 @@ _GL_CXXALIASWARN (read);
1231 bytes of it into BUF. Return the number of bytes placed into BUF if 1878 bytes of it into BUF. Return the number of bytes placed into BUF if
1232 successful, otherwise -1 and errno set. 1879 successful, otherwise -1 and errno set.
1233 See the POSIX:2008 specification 1880 See the POSIX:2008 specification
1234 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */ 1881 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1235# if @REPLACE_READLINK@ 1882# if @REPLACE_READLINK@
1236# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1883# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1237# define readlink rpl_readlink 1884# define readlink rpl_readlink
1238# endif 1885# endif
1239_GL_FUNCDECL_RPL (readlink, ssize_t, 1886_GL_FUNCDECL_RPL (readlink, ssize_t,
1240 (const char *file, char *buf, size_t bufsize) 1887 (const char *restrict file,
1888 char *restrict buf, size_t bufsize)
1241 _GL_ARG_NONNULL ((1, 2))); 1889 _GL_ARG_NONNULL ((1, 2)));
1242_GL_CXXALIAS_RPL (readlink, ssize_t, 1890_GL_CXXALIAS_RPL (readlink, ssize_t,
1243 (const char *file, char *buf, size_t bufsize)); 1891 (const char *restrict file,
1892 char *restrict buf, size_t bufsize));
1244# else 1893# else
1245# if !@HAVE_READLINK@ 1894# if !@HAVE_READLINK@
1246_GL_FUNCDECL_SYS (readlink, ssize_t, 1895_GL_FUNCDECL_SYS (readlink, ssize_t,
1247 (const char *file, char *buf, size_t bufsize) 1896 (const char *restrict file,
1897 char *restrict buf, size_t bufsize)
1248 _GL_ARG_NONNULL ((1, 2))); 1898 _GL_ARG_NONNULL ((1, 2)));
1249# endif 1899# endif
1250_GL_CXXALIAS_SYS (readlink, ssize_t, 1900_GL_CXXALIAS_SYS (readlink, ssize_t,
1251 (const char *file, char *buf, size_t bufsize)); 1901 (const char *restrict file,
1902 char *restrict buf, size_t bufsize));
1252# endif 1903# endif
1253_GL_CXXALIASWARN (readlink); 1904_GL_CXXALIASWARN (readlink);
1254#elif defined GNULIB_POSIXCHECK 1905#elif defined GNULIB_POSIXCHECK
@@ -1261,13 +1912,28 @@ _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1261 1912
1262 1913
1263#if @GNULIB_READLINKAT@ 1914#if @GNULIB_READLINKAT@
1264# if !@HAVE_READLINKAT@ 1915# if @REPLACE_READLINKAT@
1916# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1917# define readlinkat rpl_readlinkat
1918# endif
1919_GL_FUNCDECL_RPL (readlinkat, ssize_t,
1920 (int fd, char const *restrict file,
1921 char *restrict buf, size_t len)
1922 _GL_ARG_NONNULL ((2, 3)));
1923_GL_CXXALIAS_RPL (readlinkat, ssize_t,
1924 (int fd, char const *restrict file,
1925 char *restrict buf, size_t len));
1926# else
1927# if !@HAVE_READLINKAT@
1265_GL_FUNCDECL_SYS (readlinkat, ssize_t, 1928_GL_FUNCDECL_SYS (readlinkat, ssize_t,
1266 (int fd, char const *file, char *buf, size_t len) 1929 (int fd, char const *restrict file,
1930 char *restrict buf, size_t len)
1267 _GL_ARG_NONNULL ((2, 3))); 1931 _GL_ARG_NONNULL ((2, 3)));
1268# endif 1932# endif
1269_GL_CXXALIAS_SYS (readlinkat, ssize_t, 1933_GL_CXXALIAS_SYS (readlinkat, ssize_t,
1270 (int fd, char const *file, char *buf, size_t len)); 1934 (int fd, char const *restrict file,
1935 char *restrict buf, size_t len));
1936# endif
1271_GL_CXXALIASWARN (readlinkat); 1937_GL_CXXALIASWARN (readlinkat);
1272#elif defined GNULIB_POSIXCHECK 1938#elif defined GNULIB_POSIXCHECK
1273# undef readlinkat 1939# undef readlinkat
@@ -1286,6 +1952,12 @@ _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1286# endif 1952# endif
1287_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); 1953_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1288_GL_CXXALIAS_RPL (rmdir, int, (char const *name)); 1954_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1955# elif defined _WIN32 && !defined __CYGWIN__
1956# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1957# undef rmdir
1958# define rmdir _rmdir
1959# endif
1960_GL_CXXALIAS_MDA (rmdir, int, (char const *name));
1289# else 1961# else
1290_GL_CXXALIAS_SYS (rmdir, int, (char const *name)); 1962_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1291# endif 1963# endif
@@ -1296,6 +1968,20 @@ _GL_CXXALIASWARN (rmdir);
1296_GL_WARN_ON_USE (rmdir, "rmdir is unportable - " 1968_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1297 "use gnulib module rmdir for portability"); 1969 "use gnulib module rmdir for portability");
1298# endif 1970# endif
1971#elif @GNULIB_MDA_RMDIR@
1972/* On native Windows, map 'rmdir' to '_rmdir', so that -loldnames is not
1973 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1974 platforms by defining GNULIB_NAMESPACE::rmdir always. */
1975# if defined _WIN32 && !defined __CYGWIN__
1976# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1977# undef rmdir
1978# define rmdir _rmdir
1979# endif
1980_GL_CXXALIAS_MDA (rmdir, int, (char const *name));
1981# else
1982_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1983# endif
1984_GL_CXXALIASWARN (rmdir);
1299#endif 1985#endif
1300 1986
1301 1987
@@ -1330,7 +2016,7 @@ _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1330/* Pause the execution of the current thread for N seconds. 2016/* Pause the execution of the current thread for N seconds.
1331 Returns the number of seconds left to sleep. 2017 Returns the number of seconds left to sleep.
1332 See the POSIX:2008 specification 2018 See the POSIX:2008 specification
1333 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */ 2019 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1334# if @REPLACE_SLEEP@ 2020# if @REPLACE_SLEEP@
1335# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2021# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1336# undef sleep 2022# undef sleep
@@ -1354,6 +2040,31 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1354#endif 2040#endif
1355 2041
1356 2042
2043#if @GNULIB_MDA_SWAB@
2044/* On native Windows, map 'swab' to '_swab', so that -loldnames is not
2045 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2046 platforms by defining GNULIB_NAMESPACE::swab always. */
2047# if defined _WIN32 && !defined __CYGWIN__
2048# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2049# undef swab
2050# define swab _swab
2051# endif
2052/* Need to cast, because in old mingw the arguments are
2053 (const char *from, char *to, size_t n). */
2054_GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n));
2055# else
2056# if defined __hpux /* HP-UX */
2057_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
2058# elif defined __sun && !defined _XPG4 /* Solaris */
2059_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
2060# else
2061_GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));
2062# endif
2063# endif
2064_GL_CXXALIASWARN (swab);
2065#endif
2066
2067
1357#if @GNULIB_SYMLINK@ 2068#if @GNULIB_SYMLINK@
1358# if @REPLACE_SYMLINK@ 2069# if @REPLACE_SYMLINK@
1359# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2070# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1381,13 +2092,25 @@ _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1381 2092
1382 2093
1383#if @GNULIB_SYMLINKAT@ 2094#if @GNULIB_SYMLINKAT@
1384# if !@HAVE_SYMLINKAT@ 2095# if @REPLACE_SYMLINKAT@
2096# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2097# undef symlinkat
2098# define symlinkat rpl_symlinkat
2099# endif
2100_GL_FUNCDECL_RPL (symlinkat, int,
2101 (char const *contents, int fd, char const *file)
2102 _GL_ARG_NONNULL ((1, 3)));
2103_GL_CXXALIAS_RPL (symlinkat, int,
2104 (char const *contents, int fd, char const *file));
2105# else
2106# if !@HAVE_SYMLINKAT@
1385_GL_FUNCDECL_SYS (symlinkat, int, 2107_GL_FUNCDECL_SYS (symlinkat, int,
1386 (char const *contents, int fd, char const *file) 2108 (char const *contents, int fd, char const *file)
1387 _GL_ARG_NONNULL ((1, 3))); 2109 _GL_ARG_NONNULL ((1, 3)));
1388# endif 2110# endif
1389_GL_CXXALIAS_SYS (symlinkat, int, 2111_GL_CXXALIAS_SYS (symlinkat, int,
1390 (char const *contents, int fd, char const *file)); 2112 (char const *contents, int fd, char const *file));
2113# endif
1391_GL_CXXALIASWARN (symlinkat); 2114_GL_CXXALIASWARN (symlinkat);
1392#elif defined GNULIB_POSIXCHECK 2115#elif defined GNULIB_POSIXCHECK
1393# undef symlinkat 2116# undef symlinkat
@@ -1398,6 +2121,36 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1398#endif 2121#endif
1399 2122
1400 2123
2124#if @GNULIB_TRUNCATE@
2125/* Change the size of the file designated by FILENAME to become equal to LENGTH.
2126 Return 0 if successful, otherwise -1 and errno set.
2127 See the POSIX:2008 specification
2128 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
2129# if @REPLACE_TRUNCATE@
2130# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2131# undef truncate
2132# define truncate rpl_truncate
2133# endif
2134_GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
2135 _GL_ARG_NONNULL ((1)));
2136_GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
2137# else
2138# if !@HAVE_DECL_TRUNCATE@
2139_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
2140 _GL_ARG_NONNULL ((1)));
2141# endif
2142_GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
2143# endif
2144_GL_CXXALIASWARN (truncate);
2145#elif defined GNULIB_POSIXCHECK
2146# undef truncate
2147# if HAVE_RAW_DECL_TRUNCATE
2148_GL_WARN_ON_USE (truncate, "truncate is unportable - "
2149 "use gnulib module truncate for portability");
2150# endif
2151#endif
2152
2153
1401#if @GNULIB_TTYNAME_R@ 2154#if @GNULIB_TTYNAME_R@
1402/* Store at most BUFLEN characters of the pathname of the terminal FD is 2155/* 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. */ 2156 open on in BUF. Return 0 on success, otherwise an error number. */
@@ -1436,6 +2189,12 @@ _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1436# endif 2189# endif
1437_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); 2190_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1438_GL_CXXALIAS_RPL (unlink, int, (char const *file)); 2191_GL_CXXALIAS_RPL (unlink, int, (char const *file));
2192# elif defined _WIN32 && !defined __CYGWIN__
2193# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2194# undef unlink
2195# define unlink _unlink
2196# endif
2197_GL_CXXALIAS_MDA (unlink, int, (char const *file));
1439# else 2198# else
1440_GL_CXXALIAS_SYS (unlink, int, (char const *file)); 2199_GL_CXXALIAS_SYS (unlink, int, (char const *file));
1441# endif 2200# endif
@@ -1446,6 +2205,20 @@ _GL_CXXALIASWARN (unlink);
1446_GL_WARN_ON_USE (unlink, "unlink is not portable - " 2205_GL_WARN_ON_USE (unlink, "unlink is not portable - "
1447 "use gnulib module unlink for portability"); 2206 "use gnulib module unlink for portability");
1448# endif 2207# endif
2208#elif @GNULIB_MDA_UNLINK@
2209/* On native Windows, map 'unlink' to '_unlink', so that -loldnames is not
2210 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2211 platforms by defining GNULIB_NAMESPACE::unlink always. */
2212# if defined _WIN32 && !defined __CYGWIN__
2213# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2214# undef unlink
2215# define unlink _unlink
2216# endif
2217_GL_CXXALIAS_MDA (unlink, int, (char const *file));
2218# else
2219_GL_CXXALIAS_SYS (unlink, int, (char const *file));
2220# endif
2221_GL_CXXALIASWARN (unlink);
1449#endif 2222#endif
1450 2223
1451 2224
@@ -1470,7 +2243,7 @@ _GL_CXXALIASWARN (unlinkat);
1470# undef unlinkat 2243# undef unlinkat
1471# if HAVE_RAW_DECL_UNLINKAT 2244# if HAVE_RAW_DECL_UNLINKAT
1472_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " 2245_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1473 "use gnulib module openat for portability"); 2246 "use gnulib module unlinkat for portability");
1474# endif 2247# endif
1475#endif 2248#endif
1476 2249
@@ -1479,7 +2252,7 @@ _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1479/* Pause the execution of the current thread for N microseconds. 2252/* Pause the execution of the current thread for N microseconds.
1480 Returns 0 on completion, or -1 on range error. 2253 Returns 0 on completion, or -1 on range error.
1481 See the POSIX:2001 specification 2254 See the POSIX:2001 specification
1482 <http://www.opengroup.org/susv3xsh/usleep.html>. */ 2255 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
1483# if @REPLACE_USLEEP@ 2256# if @REPLACE_USLEEP@
1484# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2257# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1485# undef usleep 2258# undef usleep
@@ -1491,7 +2264,9 @@ _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1491# if !@HAVE_USLEEP@ 2264# if !@HAVE_USLEEP@
1492_GL_FUNCDECL_SYS (usleep, int, (useconds_t n)); 2265_GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1493# endif 2266# endif
1494_GL_CXXALIAS_SYS (usleep, int, (useconds_t n)); 2267/* Need to cast, because on Haiku, the first parameter is
2268 unsigned int n. */
2269_GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n));
1495# endif 2270# endif
1496_GL_CXXALIASWARN (usleep); 2271_GL_CXXALIASWARN (usleep);
1497#elif defined GNULIB_POSIXCHECK 2272#elif defined GNULIB_POSIXCHECK
@@ -1506,7 +2281,7 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1506#if @GNULIB_WRITE@ 2281#if @GNULIB_WRITE@
1507/* Write up to COUNT bytes starting at BUF to file descriptor FD. 2282/* Write up to COUNT bytes starting at BUF to file descriptor FD.
1508 See the POSIX:2008 specification 2283 See the POSIX:2008 specification
1509 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */ 2284 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1510# if @REPLACE_WRITE@ 2285# if @REPLACE_WRITE@
1511# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2286# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1512# undef write 2287# undef write
@@ -1515,11 +2290,32 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1515_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) 2290_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1516 _GL_ARG_NONNULL ((2))); 2291 _GL_ARG_NONNULL ((2)));
1517_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); 2292_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
2293# elif defined _WIN32 && !defined __CYGWIN__
2294# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2295# undef write
2296# define write _write
2297# endif
2298_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, size_t count));
2299# else
2300_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
2301# endif
2302_GL_CXXALIASWARN (write);
2303#elif @GNULIB_MDA_WRITE@
2304/* On native Windows, map 'write' to '_write', so that -loldnames is not
2305 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2306 platforms by defining GNULIB_NAMESPACE::write always. */
2307# if defined _WIN32 && !defined __CYGWIN__
2308# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2309# undef write
2310# define write _write
2311# endif
2312# ifdef __MINGW32__
2313_GL_CXXALIAS_MDA (write, int, (int fd, const void *buf, unsigned int count));
2314# else
2315_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, unsigned int count));
2316# endif
1518# else 2317# else
1519/* Need to cast, because on mingw, the third parameter is 2318_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 2319# endif
1524_GL_CXXALIASWARN (write); 2320_GL_CXXALIASWARN (write);
1525#endif 2321#endif
@@ -1527,4 +2323,5 @@ _GL_CXXALIASWARN (write);
1527_GL_INLINE_HEADER_END 2323_GL_INLINE_HEADER_END
1528 2324
1529#endif /* _@GUARD_PREFIX@_UNISTD_H */ 2325#endif /* _@GUARD_PREFIX@_UNISTD_H */
2326#endif /* _GL_INCLUDING_UNISTD_H */
1530#endif /* _@GUARD_PREFIX@_UNISTD_H */ 2327#endif /* _@GUARD_PREFIX@_UNISTD_H */