1*56bb7041Schristos /* Substitute for and wrapper around <unistd.h>.
2*56bb7041Schristos    Copyright (C) 2003-2020 Free Software Foundation, Inc.
3*56bb7041Schristos 
4*56bb7041Schristos    This program is free software; you can redistribute it and/or modify
5*56bb7041Schristos    it under the terms of the GNU General Public License as published by
6*56bb7041Schristos    the Free Software Foundation; either version 3, or (at your option)
7*56bb7041Schristos    any later version.
8*56bb7041Schristos 
9*56bb7041Schristos    This program is distributed in the hope that it will be useful,
10*56bb7041Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
11*56bb7041Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*56bb7041Schristos    GNU General Public License for more details.
13*56bb7041Schristos 
14*56bb7041Schristos    You should have received a copy of the GNU General Public License
15*56bb7041Schristos    along with this program; if not, see <https://www.gnu.org/licenses/>.  */
16*56bb7041Schristos 
17*56bb7041Schristos #ifndef _@GUARD_PREFIX@_UNISTD_H
18*56bb7041Schristos 
19*56bb7041Schristos #if __GNUC__ >= 3
20*56bb7041Schristos @PRAGMA_SYSTEM_HEADER@
21*56bb7041Schristos #endif
22*56bb7041Schristos @PRAGMA_COLUMNS@
23*56bb7041Schristos 
24*56bb7041Schristos #if @HAVE_UNISTD_H@ && defined _GL_INCLUDING_UNISTD_H
25*56bb7041Schristos /* Special invocation convention:
26*56bb7041Schristos    - On Mac OS X 10.3.9 we have a sequence of nested includes
27*56bb7041Schristos      <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>
28*56bb7041Schristos      In this situation, the functions are not yet declared, therefore we cannot
29*56bb7041Schristos      provide the C++ aliases.  */
30*56bb7041Schristos 
31*56bb7041Schristos #@INCLUDE_NEXT@ @NEXT_UNISTD_H@
32*56bb7041Schristos 
33*56bb7041Schristos #else
34*56bb7041Schristos /* Normal invocation convention.  */
35*56bb7041Schristos 
36*56bb7041Schristos /* The include_next requires a split double-inclusion guard.  */
37*56bb7041Schristos #if @HAVE_UNISTD_H@
38*56bb7041Schristos # define _GL_INCLUDING_UNISTD_H
39*56bb7041Schristos # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
40*56bb7041Schristos # undef _GL_INCLUDING_UNISTD_H
41*56bb7041Schristos #endif
42*56bb7041Schristos 
43*56bb7041Schristos /* Get all possible declarations of gethostname().  */
44*56bb7041Schristos #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
45*56bb7041Schristos   && !defined _GL_INCLUDING_WINSOCK2_H
46*56bb7041Schristos # define _GL_INCLUDING_WINSOCK2_H
47*56bb7041Schristos # include <winsock2.h>
48*56bb7041Schristos # undef _GL_INCLUDING_WINSOCK2_H
49*56bb7041Schristos #endif
50*56bb7041Schristos 
51*56bb7041Schristos #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
52*56bb7041Schristos #define _@GUARD_PREFIX@_UNISTD_H
53*56bb7041Schristos 
54*56bb7041Schristos /* NetBSD 5.0 mis-defines NULL.  Also get size_t.  */
55*56bb7041Schristos /* But avoid namespace pollution on glibc systems.  */
56*56bb7041Schristos #ifndef __GLIBC__
57*56bb7041Schristos # include <stddef.h>
58*56bb7041Schristos #endif
59*56bb7041Schristos 
60*56bb7041Schristos /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>.  */
61*56bb7041Schristos /* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>.  We must include
62*56bb7041Schristos    it before we  #define unlink rpl_unlink.  */
63*56bb7041Schristos /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>.  */
64*56bb7041Schristos /* But avoid namespace pollution on glibc systems.  */
65*56bb7041Schristos #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
66*56bb7041Schristos      || ((@GNULIB_UNLINK@ || defined GNULIB_POSIXCHECK) \
67*56bb7041Schristos          && (defined _WIN32 && ! defined __CYGWIN__)) \
68*56bb7041Schristos      || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
69*56bb7041Schristos          && defined __CYGWIN__)) \
70*56bb7041Schristos     && ! defined __GLIBC__
71*56bb7041Schristos # include <stdio.h>
72*56bb7041Schristos #endif
73*56bb7041Schristos 
74*56bb7041Schristos /* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
75*56bb7041Schristos    <unistd.h>.  */
76*56bb7041Schristos /* But avoid namespace pollution on glibc systems.  */
77*56bb7041Schristos #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
78*56bb7041Schristos     && (defined __CYGWIN__ || defined __ANDROID__) \
79*56bb7041Schristos     && ! defined __GLIBC__
80*56bb7041Schristos # include <fcntl.h>
81*56bb7041Schristos #endif
82*56bb7041Schristos 
83*56bb7041Schristos /* mingw fails to declare _exit in <unistd.h>.  */
84*56bb7041Schristos /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
85*56bb7041Schristos    <unistd.h>.  */
86*56bb7041Schristos /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>.  */
87*56bb7041Schristos /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
88*56bb7041Schristos    included here.  */
89*56bb7041Schristos /* But avoid namespace pollution on glibc systems.  */
90*56bb7041Schristos #if !defined __GLIBC__ && !defined __osf__
91*56bb7041Schristos # define __need_system_stdlib_h
92*56bb7041Schristos # include <stdlib.h>
93*56bb7041Schristos # undef __need_system_stdlib_h
94*56bb7041Schristos #endif
95*56bb7041Schristos 
96*56bb7041Schristos /* Native Windows platforms declare chdir, getcwd, rmdir in
97*56bb7041Schristos    <io.h> and/or <direct.h>, not in <unistd.h>.
98*56bb7041Schristos    They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
99*56bb7041Schristos    lseek(), read(), unlink(), write() in <io.h>.  */
100*56bb7041Schristos #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
101*56bb7041Schristos       || defined GNULIB_POSIXCHECK) \
102*56bb7041Schristos      && (defined _WIN32 && ! defined __CYGWIN__))
103*56bb7041Schristos # include <io.h>     /* mingw32, mingw64 */
104*56bb7041Schristos # include <direct.h> /* mingw64, MSVC 9 */
105*56bb7041Schristos #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
106*56bb7041Schristos        || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
107*56bb7041Schristos        || defined GNULIB_POSIXCHECK) \
108*56bb7041Schristos       && (defined _WIN32 && ! defined __CYGWIN__)
109*56bb7041Schristos # include <io.h>
110*56bb7041Schristos #endif
111*56bb7041Schristos 
112*56bb7041Schristos /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
113*56bb7041Schristos    NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>.  */
114*56bb7041Schristos /* But avoid namespace pollution on glibc systems.  */
115*56bb7041Schristos #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
116*56bb7041Schristos      || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
117*56bb7041Schristos     && !defined __GLIBC__
118*56bb7041Schristos # include <netdb.h>
119*56bb7041Schristos #endif
120*56bb7041Schristos 
121*56bb7041Schristos /* Mac OS X 10.13, Solaris 11.4, and Android 9.0 declare getentropy in
122*56bb7041Schristos    <sys/random.h>, not in <unistd.h>.  */
123*56bb7041Schristos /* But avoid namespace pollution on glibc systems.  */
124*56bb7041Schristos #if (@GNULIB_GETENTROPY@ || defined GNULIB_POSIXCHECK) \
125*56bb7041Schristos     && ((defined __APPLE__ && defined __MACH__) || defined __sun \
126*56bb7041Schristos         || defined __ANDROID__) \
127*56bb7041Schristos     && @UNISTD_H_HAVE_SYS_RANDOM_H@ \
128*56bb7041Schristos     && !defined __GLIBC__
129*56bb7041Schristos # include <sys/random.h>
130*56bb7041Schristos #endif
131*56bb7041Schristos 
132*56bb7041Schristos /* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>.  */
133*56bb7041Schristos /* But avoid namespace pollution on glibc systems.  */
134*56bb7041Schristos #if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
135*56bb7041Schristos     && !defined __GLIBC__
136*56bb7041Schristos # include <sys/stat.h>
137*56bb7041Schristos #endif
138*56bb7041Schristos 
139*56bb7041Schristos /* MSVC defines off_t in <sys/types.h>.
140*56bb7041Schristos    May also define off_t to a 64-bit type on native Windows.  */
141*56bb7041Schristos /* But avoid namespace pollution on glibc systems.  */
142*56bb7041Schristos #ifndef __GLIBC__
143*56bb7041Schristos /* Get off_t, ssize_t.  */
144*56bb7041Schristos # include <sys/types.h>
145*56bb7041Schristos #endif
146*56bb7041Schristos 
147*56bb7041Schristos /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
148*56bb7041Schristos 
149*56bb7041Schristos /* The definition of _GL_ARG_NONNULL is copied here.  */
150*56bb7041Schristos 
151*56bb7041Schristos /* The definition of _GL_WARN_ON_USE is copied here.  */
152*56bb7041Schristos 
153*56bb7041Schristos 
154*56bb7041Schristos /* Get getopt(), optarg, optind, opterr, optopt.  */
155*56bb7041Schristos #if @GNULIB_GETOPT_POSIX@ && @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
156*56bb7041Schristos # include <getopt-cdefs.h>
157*56bb7041Schristos # include <getopt-pfx-core.h>
158*56bb7041Schristos #endif
159*56bb7041Schristos 
160*56bb7041Schristos #ifndef _GL_INLINE_HEADER_BEGIN
161*56bb7041Schristos  #error "Please include config.h first."
162*56bb7041Schristos #endif
163*56bb7041Schristos _GL_INLINE_HEADER_BEGIN
164*56bb7041Schristos #ifndef _GL_UNISTD_INLINE
165*56bb7041Schristos # define _GL_UNISTD_INLINE _GL_INLINE
166*56bb7041Schristos #endif
167*56bb7041Schristos 
168*56bb7041Schristos /* Hide some function declarations from <winsock2.h>.  */
169*56bb7041Schristos 
170*56bb7041Schristos #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
171*56bb7041Schristos # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
172*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
173*56bb7041Schristos #   undef socket
174*56bb7041Schristos #   define socket              socket_used_without_including_sys_socket_h
175*56bb7041Schristos #   undef connect
176*56bb7041Schristos #   define connect             connect_used_without_including_sys_socket_h
177*56bb7041Schristos #   undef accept
178*56bb7041Schristos #   define accept              accept_used_without_including_sys_socket_h
179*56bb7041Schristos #   undef bind
180*56bb7041Schristos #   define bind                bind_used_without_including_sys_socket_h
181*56bb7041Schristos #   undef getpeername
182*56bb7041Schristos #   define getpeername         getpeername_used_without_including_sys_socket_h
183*56bb7041Schristos #   undef getsockname
184*56bb7041Schristos #   define getsockname         getsockname_used_without_including_sys_socket_h
185*56bb7041Schristos #   undef getsockopt
186*56bb7041Schristos #   define getsockopt          getsockopt_used_without_including_sys_socket_h
187*56bb7041Schristos #   undef listen
188*56bb7041Schristos #   define listen              listen_used_without_including_sys_socket_h
189*56bb7041Schristos #   undef recv
190*56bb7041Schristos #   define recv                recv_used_without_including_sys_socket_h
191*56bb7041Schristos #   undef send
192*56bb7041Schristos #   define send                send_used_without_including_sys_socket_h
193*56bb7041Schristos #   undef recvfrom
194*56bb7041Schristos #   define recvfrom            recvfrom_used_without_including_sys_socket_h
195*56bb7041Schristos #   undef sendto
196*56bb7041Schristos #   define sendto              sendto_used_without_including_sys_socket_h
197*56bb7041Schristos #   undef setsockopt
198*56bb7041Schristos #   define setsockopt          setsockopt_used_without_including_sys_socket_h
199*56bb7041Schristos #   undef shutdown
200*56bb7041Schristos #   define shutdown            shutdown_used_without_including_sys_socket_h
201*56bb7041Schristos #  else
202*56bb7041Schristos     _GL_WARN_ON_USE (socket,
203*56bb7041Schristos                      "socket() used without including <sys/socket.h>");
204*56bb7041Schristos     _GL_WARN_ON_USE (connect,
205*56bb7041Schristos                      "connect() used without including <sys/socket.h>");
206*56bb7041Schristos     _GL_WARN_ON_USE (accept,
207*56bb7041Schristos                      "accept() used without including <sys/socket.h>");
208*56bb7041Schristos     _GL_WARN_ON_USE (bind,
209*56bb7041Schristos                      "bind() used without including <sys/socket.h>");
210*56bb7041Schristos     _GL_WARN_ON_USE (getpeername,
211*56bb7041Schristos                      "getpeername() used without including <sys/socket.h>");
212*56bb7041Schristos     _GL_WARN_ON_USE (getsockname,
213*56bb7041Schristos                      "getsockname() used without including <sys/socket.h>");
214*56bb7041Schristos     _GL_WARN_ON_USE (getsockopt,
215*56bb7041Schristos                      "getsockopt() used without including <sys/socket.h>");
216*56bb7041Schristos     _GL_WARN_ON_USE (listen,
217*56bb7041Schristos                      "listen() used without including <sys/socket.h>");
218*56bb7041Schristos     _GL_WARN_ON_USE (recv,
219*56bb7041Schristos                      "recv() used without including <sys/socket.h>");
220*56bb7041Schristos     _GL_WARN_ON_USE (send,
221*56bb7041Schristos                      "send() used without including <sys/socket.h>");
222*56bb7041Schristos     _GL_WARN_ON_USE (recvfrom,
223*56bb7041Schristos                      "recvfrom() used without including <sys/socket.h>");
224*56bb7041Schristos     _GL_WARN_ON_USE (sendto,
225*56bb7041Schristos                      "sendto() used without including <sys/socket.h>");
226*56bb7041Schristos     _GL_WARN_ON_USE (setsockopt,
227*56bb7041Schristos                      "setsockopt() used without including <sys/socket.h>");
228*56bb7041Schristos     _GL_WARN_ON_USE (shutdown,
229*56bb7041Schristos                      "shutdown() used without including <sys/socket.h>");
230*56bb7041Schristos #  endif
231*56bb7041Schristos # endif
232*56bb7041Schristos # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
233*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
234*56bb7041Schristos #   undef select
235*56bb7041Schristos #   define select              select_used_without_including_sys_select_h
236*56bb7041Schristos #  else
237*56bb7041Schristos     _GL_WARN_ON_USE (select,
238*56bb7041Schristos                      "select() used without including <sys/select.h>");
239*56bb7041Schristos #  endif
240*56bb7041Schristos # endif
241*56bb7041Schristos #endif
242*56bb7041Schristos 
243*56bb7041Schristos 
244*56bb7041Schristos /* OS/2 EMX lacks these macros.  */
245*56bb7041Schristos #ifndef STDIN_FILENO
246*56bb7041Schristos # define STDIN_FILENO 0
247*56bb7041Schristos #endif
248*56bb7041Schristos #ifndef STDOUT_FILENO
249*56bb7041Schristos # define STDOUT_FILENO 1
250*56bb7041Schristos #endif
251*56bb7041Schristos #ifndef STDERR_FILENO
252*56bb7041Schristos # define STDERR_FILENO 2
253*56bb7041Schristos #endif
254*56bb7041Schristos 
255*56bb7041Schristos /* Ensure *_OK macros exist.  */
256*56bb7041Schristos #ifndef F_OK
257*56bb7041Schristos # define F_OK 0
258*56bb7041Schristos # define X_OK 1
259*56bb7041Schristos # define W_OK 2
260*56bb7041Schristos # define R_OK 4
261*56bb7041Schristos #endif
262*56bb7041Schristos 
263*56bb7041Schristos 
264*56bb7041Schristos /* Declare overridden functions.  */
265*56bb7041Schristos 
266*56bb7041Schristos 
267*56bb7041Schristos #if @GNULIB_ACCESS@
268*56bb7041Schristos # if @REPLACE_ACCESS@
269*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
270*56bb7041Schristos #   undef access
271*56bb7041Schristos #   define access rpl_access
272*56bb7041Schristos #  endif
273*56bb7041Schristos _GL_FUNCDECL_RPL (access, int, (const char *file, int mode)
274*56bb7041Schristos                                _GL_ARG_NONNULL ((1)));
275*56bb7041Schristos _GL_CXXALIAS_RPL (access, int, (const char *file, int mode));
276*56bb7041Schristos # else
277*56bb7041Schristos _GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
278*56bb7041Schristos # endif
279*56bb7041Schristos _GL_CXXALIASWARN (access);
280*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
281*56bb7041Schristos # undef access
282*56bb7041Schristos # if HAVE_RAW_DECL_ACCESS
283*56bb7041Schristos /* The access() function is a security risk.  */
284*56bb7041Schristos _GL_WARN_ON_USE (access, "access does not always support X_OK - "
285*56bb7041Schristos                  "use gnulib module access for portability; "
286*56bb7041Schristos                  "also, this function is a security risk - "
287*56bb7041Schristos                  "use the gnulib module faccessat instead");
288*56bb7041Schristos # endif
289*56bb7041Schristos #endif
290*56bb7041Schristos 
291*56bb7041Schristos 
292*56bb7041Schristos #if @GNULIB_CHDIR@
293*56bb7041Schristos _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
294*56bb7041Schristos _GL_CXXALIASWARN (chdir);
295*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
296*56bb7041Schristos # undef chdir
297*56bb7041Schristos # if HAVE_RAW_DECL_CHDIR
298*56bb7041Schristos _GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
299*56bb7041Schristos                  "use gnulib module chdir for portability");
300*56bb7041Schristos # endif
301*56bb7041Schristos #endif
302*56bb7041Schristos 
303*56bb7041Schristos 
304*56bb7041Schristos #if @GNULIB_CHOWN@
305*56bb7041Schristos /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
306*56bb7041Schristos    to GID (if GID is not -1).  Follow symbolic links.
307*56bb7041Schristos    Return 0 if successful, otherwise -1 and errno set.
308*56bb7041Schristos    See the POSIX:2008 specification
309*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html.  */
310*56bb7041Schristos # if @REPLACE_CHOWN@
311*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
312*56bb7041Schristos #   undef chown
313*56bb7041Schristos #   define chown rpl_chown
314*56bb7041Schristos #  endif
315*56bb7041Schristos _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
316*56bb7041Schristos                               _GL_ARG_NONNULL ((1)));
317*56bb7041Schristos _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
318*56bb7041Schristos # else
319*56bb7041Schristos #  if !@HAVE_CHOWN@
320*56bb7041Schristos _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
321*56bb7041Schristos                               _GL_ARG_NONNULL ((1)));
322*56bb7041Schristos #  endif
323*56bb7041Schristos _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
324*56bb7041Schristos # endif
325*56bb7041Schristos _GL_CXXALIASWARN (chown);
326*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
327*56bb7041Schristos # undef chown
328*56bb7041Schristos # if HAVE_RAW_DECL_CHOWN
329*56bb7041Schristos _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
330*56bb7041Schristos                  "doesn't treat a uid or gid of -1 on some systems - "
331*56bb7041Schristos                  "use gnulib module chown for portability");
332*56bb7041Schristos # endif
333*56bb7041Schristos #endif
334*56bb7041Schristos 
335*56bb7041Schristos 
336*56bb7041Schristos #if @GNULIB_CLOSE@
337*56bb7041Schristos # if @REPLACE_CLOSE@
338*56bb7041Schristos /* Automatically included by modules that need a replacement for close.  */
339*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
340*56bb7041Schristos #   undef close
341*56bb7041Schristos #   define close rpl_close
342*56bb7041Schristos #  endif
343*56bb7041Schristos _GL_FUNCDECL_RPL (close, int, (int fd));
344*56bb7041Schristos _GL_CXXALIAS_RPL (close, int, (int fd));
345*56bb7041Schristos # else
346*56bb7041Schristos _GL_CXXALIAS_SYS (close, int, (int fd));
347*56bb7041Schristos # endif
348*56bb7041Schristos _GL_CXXALIASWARN (close);
349*56bb7041Schristos #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
350*56bb7041Schristos # undef close
351*56bb7041Schristos # define close close_used_without_requesting_gnulib_module_close
352*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
353*56bb7041Schristos # undef close
354*56bb7041Schristos /* Assume close is always declared.  */
355*56bb7041Schristos _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
356*56bb7041Schristos                  "use gnulib module close for portability");
357*56bb7041Schristos #endif
358*56bb7041Schristos 
359*56bb7041Schristos 
360*56bb7041Schristos #if @GNULIB_COPY_FILE_RANGE@
361*56bb7041Schristos # if !@HAVE_COPY_FILE_RANGE@
362*56bb7041Schristos _GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
363*56bb7041Schristos                                              int ofd, off_t *opos,
364*56bb7041Schristos                                              size_t len, unsigned flags));
365*56bb7041Schristos _GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
366*56bb7041Schristos                                              int ofd, off_t *opos,
367*56bb7041Schristos                                              size_t len, unsigned flags));
368*56bb7041Schristos # endif
369*56bb7041Schristos _GL_CXXALIASWARN (copy_file_range);
370*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
371*56bb7041Schristos /* Assume copy_file_range is always declared.  */
372*56bb7041Schristos _GL_WARN_ON_USE (copy_file_range,
373*56bb7041Schristos                  "copy_file_range is unportable - "
374*56bb7041Schristos                  "use gnulib module copy_file_range for portability");
375*56bb7041Schristos #endif
376*56bb7041Schristos 
377*56bb7041Schristos 
378*56bb7041Schristos #if @GNULIB_DUP@
379*56bb7041Schristos # if @REPLACE_DUP@
380*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
381*56bb7041Schristos #   define dup rpl_dup
382*56bb7041Schristos #  endif
383*56bb7041Schristos _GL_FUNCDECL_RPL (dup, int, (int oldfd));
384*56bb7041Schristos _GL_CXXALIAS_RPL (dup, int, (int oldfd));
385*56bb7041Schristos # else
386*56bb7041Schristos _GL_CXXALIAS_SYS (dup, int, (int oldfd));
387*56bb7041Schristos # endif
388*56bb7041Schristos _GL_CXXALIASWARN (dup);
389*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
390*56bb7041Schristos # undef dup
391*56bb7041Schristos # if HAVE_RAW_DECL_DUP
392*56bb7041Schristos _GL_WARN_ON_USE (dup, "dup is unportable - "
393*56bb7041Schristos                  "use gnulib module dup for portability");
394*56bb7041Schristos # endif
395*56bb7041Schristos #endif
396*56bb7041Schristos 
397*56bb7041Schristos 
398*56bb7041Schristos #if @GNULIB_DUP2@
399*56bb7041Schristos /* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
400*56bb7041Schristos    NEWFD = OLDFD, otherwise close NEWFD first if it is open.
401*56bb7041Schristos    Return newfd if successful, otherwise -1 and errno set.
402*56bb7041Schristos    See the POSIX:2008 specification
403*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>.  */
404*56bb7041Schristos # if @REPLACE_DUP2@
405*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
406*56bb7041Schristos #   define dup2 rpl_dup2
407*56bb7041Schristos #  endif
408*56bb7041Schristos _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
409*56bb7041Schristos _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
410*56bb7041Schristos # else
411*56bb7041Schristos #  if !@HAVE_DUP2@
412*56bb7041Schristos _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
413*56bb7041Schristos #  endif
414*56bb7041Schristos _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
415*56bb7041Schristos # endif
416*56bb7041Schristos _GL_CXXALIASWARN (dup2);
417*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
418*56bb7041Schristos # undef dup2
419*56bb7041Schristos # if HAVE_RAW_DECL_DUP2
420*56bb7041Schristos _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
421*56bb7041Schristos                  "use gnulib module dup2 for portability");
422*56bb7041Schristos # endif
423*56bb7041Schristos #endif
424*56bb7041Schristos 
425*56bb7041Schristos 
426*56bb7041Schristos #if @GNULIB_DUP3@
427*56bb7041Schristos /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
428*56bb7041Schristos    specified flags.
429*56bb7041Schristos    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
430*56bb7041Schristos    and O_TEXT, O_BINARY (defined in "binary-io.h").
431*56bb7041Schristos    Close NEWFD first if it is open.
432*56bb7041Schristos    Return newfd if successful, otherwise -1 and errno set.
433*56bb7041Schristos    See the Linux man page at
434*56bb7041Schristos    <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */
435*56bb7041Schristos # if @HAVE_DUP3@
436*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
437*56bb7041Schristos #   define dup3 rpl_dup3
438*56bb7041Schristos #  endif
439*56bb7041Schristos _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
440*56bb7041Schristos _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
441*56bb7041Schristos # else
442*56bb7041Schristos _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
443*56bb7041Schristos _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
444*56bb7041Schristos # endif
445*56bb7041Schristos _GL_CXXALIASWARN (dup3);
446*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
447*56bb7041Schristos # undef dup3
448*56bb7041Schristos # if HAVE_RAW_DECL_DUP3
449*56bb7041Schristos _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
450*56bb7041Schristos                  "use gnulib module dup3 for portability");
451*56bb7041Schristos # endif
452*56bb7041Schristos #endif
453*56bb7041Schristos 
454*56bb7041Schristos 
455*56bb7041Schristos #if @GNULIB_ENVIRON@
456*56bb7041Schristos # if defined __CYGWIN__ && !defined __i386__
457*56bb7041Schristos /* The 'environ' variable is defined in a DLL. Therefore its declaration needs
458*56bb7041Schristos    the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
459*56bb7041Schristos    This leads to a link error on 64-bit Cygwin when the option
460*56bb7041Schristos    -Wl,--disable-auto-import is in use.  */
461*56bb7041Schristos _GL_EXTERN_C __declspec(dllimport) char **environ;
462*56bb7041Schristos # endif
463*56bb7041Schristos # if !@HAVE_DECL_ENVIRON@
464*56bb7041Schristos /* Set of environment variables and values.  An array of strings of the form
465*56bb7041Schristos    "VARIABLE=VALUE", terminated with a NULL.  */
466*56bb7041Schristos #  if defined __APPLE__ && defined __MACH__
467*56bb7041Schristos #   include <TargetConditionals.h>
468*56bb7041Schristos #   if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
469*56bb7041Schristos #    define _GL_USE_CRT_EXTERNS
470*56bb7041Schristos #   endif
471*56bb7041Schristos #  endif
472*56bb7041Schristos #  ifdef _GL_USE_CRT_EXTERNS
473*56bb7041Schristos #   include <crt_externs.h>
474*56bb7041Schristos #   define environ (*_NSGetEnviron ())
475*56bb7041Schristos #  else
476*56bb7041Schristos #   ifdef __cplusplus
477*56bb7041Schristos extern "C" {
478*56bb7041Schristos #   endif
479*56bb7041Schristos extern char **environ;
480*56bb7041Schristos #   ifdef __cplusplus
481*56bb7041Schristos }
482*56bb7041Schristos #   endif
483*56bb7041Schristos #  endif
484*56bb7041Schristos # endif
485*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
486*56bb7041Schristos # if HAVE_RAW_DECL_ENVIRON
487*56bb7041Schristos _GL_UNISTD_INLINE char ***
488*56bb7041Schristos _GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
489*56bb7041Schristos                            "use gnulib module environ for portability")
490*56bb7041Schristos rpl_environ (void)
491*56bb7041Schristos {
492*56bb7041Schristos   return &environ;
493*56bb7041Schristos }
494*56bb7041Schristos #  undef environ
495*56bb7041Schristos #  define environ (*rpl_environ ())
496*56bb7041Schristos # endif
497*56bb7041Schristos #endif
498*56bb7041Schristos 
499*56bb7041Schristos 
500*56bb7041Schristos #if @GNULIB_EUIDACCESS@
501*56bb7041Schristos /* Like access(), except that it uses the effective user id and group id of
502*56bb7041Schristos    the current process.  */
503*56bb7041Schristos # if !@HAVE_EUIDACCESS@
504*56bb7041Schristos _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
505*56bb7041Schristos                                    _GL_ARG_NONNULL ((1)));
506*56bb7041Schristos # endif
507*56bb7041Schristos _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
508*56bb7041Schristos _GL_CXXALIASWARN (euidaccess);
509*56bb7041Schristos # if defined GNULIB_POSIXCHECK
510*56bb7041Schristos /* Like access(), this function is a security risk.  */
511*56bb7041Schristos _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
512*56bb7041Schristos                  "use the gnulib module faccessat instead");
513*56bb7041Schristos # endif
514*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
515*56bb7041Schristos # undef euidaccess
516*56bb7041Schristos # if HAVE_RAW_DECL_EUIDACCESS
517*56bb7041Schristos _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
518*56bb7041Schristos                  "use gnulib module euidaccess for portability");
519*56bb7041Schristos # endif
520*56bb7041Schristos #endif
521*56bb7041Schristos 
522*56bb7041Schristos 
523*56bb7041Schristos #if @GNULIB_FACCESSAT@
524*56bb7041Schristos # if @REPLACE_FACCESSAT@
525*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
526*56bb7041Schristos #   undef faccessat
527*56bb7041Schristos #   define faccessat rpl_faccessat
528*56bb7041Schristos #  endif
529*56bb7041Schristos _GL_FUNCDECL_RPL (faccessat, int,
530*56bb7041Schristos                   (int fd, char const *name, int mode, int flag)
531*56bb7041Schristos                   _GL_ARG_NONNULL ((2)));
532*56bb7041Schristos _GL_CXXALIAS_RPL (faccessat, int,
533*56bb7041Schristos                   (int fd, char const *name, int mode, int flag));
534*56bb7041Schristos # else
535*56bb7041Schristos #  if !@HAVE_FACCESSAT@
536*56bb7041Schristos _GL_FUNCDECL_SYS (faccessat, int,
537*56bb7041Schristos                   (int fd, char const *file, int mode, int flag)
538*56bb7041Schristos                   _GL_ARG_NONNULL ((2)));
539*56bb7041Schristos #  endif
540*56bb7041Schristos _GL_CXXALIAS_SYS (faccessat, int,
541*56bb7041Schristos                   (int fd, char const *file, int mode, int flag));
542*56bb7041Schristos # endif
543*56bb7041Schristos _GL_CXXALIASWARN (faccessat);
544*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
545*56bb7041Schristos # undef faccessat
546*56bb7041Schristos # if HAVE_RAW_DECL_FACCESSAT
547*56bb7041Schristos _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
548*56bb7041Schristos                  "use gnulib module faccessat for portability");
549*56bb7041Schristos # endif
550*56bb7041Schristos #endif
551*56bb7041Schristos 
552*56bb7041Schristos 
553*56bb7041Schristos #if @GNULIB_FCHDIR@
554*56bb7041Schristos /* Change the process' current working directory to the directory on which
555*56bb7041Schristos    the given file descriptor is open.
556*56bb7041Schristos    Return 0 if successful, otherwise -1 and errno set.
557*56bb7041Schristos    See the POSIX:2008 specification
558*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>.  */
559*56bb7041Schristos # if ! @HAVE_FCHDIR@
560*56bb7041Schristos _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
561*56bb7041Schristos 
562*56bb7041Schristos /* Gnulib internal hooks needed to maintain the fchdir metadata.  */
563*56bb7041Schristos _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
564*56bb7041Schristos      _GL_ARG_NONNULL ((2));
565*56bb7041Schristos _GL_EXTERN_C void _gl_unregister_fd (int fd);
566*56bb7041Schristos _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
567*56bb7041Schristos _GL_EXTERN_C const char *_gl_directory_name (int fd);
568*56bb7041Schristos 
569*56bb7041Schristos # else
570*56bb7041Schristos #  if !@HAVE_DECL_FCHDIR@
571*56bb7041Schristos _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
572*56bb7041Schristos #  endif
573*56bb7041Schristos # endif
574*56bb7041Schristos _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
575*56bb7041Schristos _GL_CXXALIASWARN (fchdir);
576*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
577*56bb7041Schristos # undef fchdir
578*56bb7041Schristos # if HAVE_RAW_DECL_FCHDIR
579*56bb7041Schristos _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
580*56bb7041Schristos                  "use gnulib module fchdir for portability");
581*56bb7041Schristos # endif
582*56bb7041Schristos #endif
583*56bb7041Schristos 
584*56bb7041Schristos 
585*56bb7041Schristos #if @GNULIB_FCHOWNAT@
586*56bb7041Schristos # if @REPLACE_FCHOWNAT@
587*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
588*56bb7041Schristos #   undef fchownat
589*56bb7041Schristos #   define fchownat rpl_fchownat
590*56bb7041Schristos #  endif
591*56bb7041Schristos _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
592*56bb7041Schristos                                   uid_t owner, gid_t group, int flag)
593*56bb7041Schristos                                  _GL_ARG_NONNULL ((2)));
594*56bb7041Schristos _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
595*56bb7041Schristos                                   uid_t owner, gid_t group, int flag));
596*56bb7041Schristos # else
597*56bb7041Schristos #  if !@HAVE_FCHOWNAT@
598*56bb7041Schristos _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
599*56bb7041Schristos                                   uid_t owner, gid_t group, int flag)
600*56bb7041Schristos                                  _GL_ARG_NONNULL ((2)));
601*56bb7041Schristos #  endif
602*56bb7041Schristos _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
603*56bb7041Schristos                                   uid_t owner, gid_t group, int flag));
604*56bb7041Schristos # endif
605*56bb7041Schristos _GL_CXXALIASWARN (fchownat);
606*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
607*56bb7041Schristos # undef fchownat
608*56bb7041Schristos # if HAVE_RAW_DECL_FCHOWNAT
609*56bb7041Schristos _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
610*56bb7041Schristos                  "use gnulib module openat for portability");
611*56bb7041Schristos # endif
612*56bb7041Schristos #endif
613*56bb7041Schristos 
614*56bb7041Schristos 
615*56bb7041Schristos #if @GNULIB_FDATASYNC@
616*56bb7041Schristos /* Synchronize changes to a file.
617*56bb7041Schristos    Return 0 if successful, otherwise -1 and errno set.
618*56bb7041Schristos    See POSIX:2008 specification
619*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>.  */
620*56bb7041Schristos # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
621*56bb7041Schristos _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
622*56bb7041Schristos # endif
623*56bb7041Schristos _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
624*56bb7041Schristos _GL_CXXALIASWARN (fdatasync);
625*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
626*56bb7041Schristos # undef fdatasync
627*56bb7041Schristos # if HAVE_RAW_DECL_FDATASYNC
628*56bb7041Schristos _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
629*56bb7041Schristos                  "use gnulib module fdatasync for portability");
630*56bb7041Schristos # endif
631*56bb7041Schristos #endif
632*56bb7041Schristos 
633*56bb7041Schristos 
634*56bb7041Schristos #if @GNULIB_FSYNC@
635*56bb7041Schristos /* Synchronize changes, including metadata, to a file.
636*56bb7041Schristos    Return 0 if successful, otherwise -1 and errno set.
637*56bb7041Schristos    See POSIX:2008 specification
638*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>.  */
639*56bb7041Schristos # if !@HAVE_FSYNC@
640*56bb7041Schristos _GL_FUNCDECL_SYS (fsync, int, (int fd));
641*56bb7041Schristos # endif
642*56bb7041Schristos _GL_CXXALIAS_SYS (fsync, int, (int fd));
643*56bb7041Schristos _GL_CXXALIASWARN (fsync);
644*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
645*56bb7041Schristos # undef fsync
646*56bb7041Schristos # if HAVE_RAW_DECL_FSYNC
647*56bb7041Schristos _GL_WARN_ON_USE (fsync, "fsync is unportable - "
648*56bb7041Schristos                  "use gnulib module fsync for portability");
649*56bb7041Schristos # endif
650*56bb7041Schristos #endif
651*56bb7041Schristos 
652*56bb7041Schristos 
653*56bb7041Schristos #if @GNULIB_FTRUNCATE@
654*56bb7041Schristos /* Change the size of the file to which FD is opened to become equal to LENGTH.
655*56bb7041Schristos    Return 0 if successful, otherwise -1 and errno set.
656*56bb7041Schristos    See the POSIX:2008 specification
657*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>.  */
658*56bb7041Schristos # if @REPLACE_FTRUNCATE@
659*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
660*56bb7041Schristos #   undef ftruncate
661*56bb7041Schristos #   define ftruncate rpl_ftruncate
662*56bb7041Schristos #  endif
663*56bb7041Schristos _GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
664*56bb7041Schristos _GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
665*56bb7041Schristos # else
666*56bb7041Schristos #  if !@HAVE_FTRUNCATE@
667*56bb7041Schristos _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
668*56bb7041Schristos #  endif
669*56bb7041Schristos _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
670*56bb7041Schristos # endif
671*56bb7041Schristos _GL_CXXALIASWARN (ftruncate);
672*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
673*56bb7041Schristos # undef ftruncate
674*56bb7041Schristos # if HAVE_RAW_DECL_FTRUNCATE
675*56bb7041Schristos _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
676*56bb7041Schristos                  "use gnulib module ftruncate for portability");
677*56bb7041Schristos # endif
678*56bb7041Schristos #endif
679*56bb7041Schristos 
680*56bb7041Schristos 
681*56bb7041Schristos #if @GNULIB_GETCWD@
682*56bb7041Schristos /* Get the name of the current working directory, and put it in SIZE bytes
683*56bb7041Schristos    of BUF.
684*56bb7041Schristos    Return BUF if successful, or NULL if the directory couldn't be determined
685*56bb7041Schristos    or SIZE was too small.
686*56bb7041Schristos    See the POSIX:2008 specification
687*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
688*56bb7041Schristos    Additionally, the gnulib module 'getcwd' guarantees the following GNU
689*56bb7041Schristos    extension: If BUF is NULL, an array is allocated with 'malloc'; the array
690*56bb7041Schristos    is SIZE bytes long, unless SIZE == 0, in which case it is as big as
691*56bb7041Schristos    necessary.  */
692*56bb7041Schristos # if @REPLACE_GETCWD@
693*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
694*56bb7041Schristos #   define getcwd rpl_getcwd
695*56bb7041Schristos #  endif
696*56bb7041Schristos _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
697*56bb7041Schristos _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
698*56bb7041Schristos # else
699*56bb7041Schristos /* Need to cast, because on mingw, the second parameter is
700*56bb7041Schristos                                                    int size.  */
701*56bb7041Schristos _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
702*56bb7041Schristos # endif
703*56bb7041Schristos _GL_CXXALIASWARN (getcwd);
704*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
705*56bb7041Schristos # undef getcwd
706*56bb7041Schristos # if HAVE_RAW_DECL_GETCWD
707*56bb7041Schristos _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
708*56bb7041Schristos                  "use gnulib module getcwd for portability");
709*56bb7041Schristos # endif
710*56bb7041Schristos #endif
711*56bb7041Schristos 
712*56bb7041Schristos 
713*56bb7041Schristos #if @GNULIB_GETDOMAINNAME@
714*56bb7041Schristos /* Return the NIS domain name of the machine.
715*56bb7041Schristos    WARNING! The NIS domain name is unrelated to the fully qualified host name
716*56bb7041Schristos             of the machine.  It is also unrelated to email addresses.
717*56bb7041Schristos    WARNING! The NIS domain name is usually the empty string or "(none)" when
718*56bb7041Schristos             not using NIS.
719*56bb7041Schristos 
720*56bb7041Schristos    Put up to LEN bytes of the NIS domain name into NAME.
721*56bb7041Schristos    Null terminate it if the name is shorter than LEN.
722*56bb7041Schristos    If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
723*56bb7041Schristos    Return 0 if successful, otherwise set errno and return -1.  */
724*56bb7041Schristos # if @REPLACE_GETDOMAINNAME@
725*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
726*56bb7041Schristos #   undef getdomainname
727*56bb7041Schristos #   define getdomainname rpl_getdomainname
728*56bb7041Schristos #  endif
729*56bb7041Schristos _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
730*56bb7041Schristos                                       _GL_ARG_NONNULL ((1)));
731*56bb7041Schristos _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
732*56bb7041Schristos # else
733*56bb7041Schristos #  if !@HAVE_DECL_GETDOMAINNAME@
734*56bb7041Schristos _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
735*56bb7041Schristos                                       _GL_ARG_NONNULL ((1)));
736*56bb7041Schristos #  endif
737*56bb7041Schristos _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
738*56bb7041Schristos # endif
739*56bb7041Schristos _GL_CXXALIASWARN (getdomainname);
740*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
741*56bb7041Schristos # undef getdomainname
742*56bb7041Schristos # if HAVE_RAW_DECL_GETDOMAINNAME
743*56bb7041Schristos _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
744*56bb7041Schristos                  "use gnulib module getdomainname for portability");
745*56bb7041Schristos # endif
746*56bb7041Schristos #endif
747*56bb7041Schristos 
748*56bb7041Schristos 
749*56bb7041Schristos #if @GNULIB_GETDTABLESIZE@
750*56bb7041Schristos /* Return the maximum number of file descriptors in the current process.
751*56bb7041Schristos    In POSIX, this is same as sysconf (_SC_OPEN_MAX).  */
752*56bb7041Schristos # if @REPLACE_GETDTABLESIZE@
753*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
754*56bb7041Schristos #   undef getdtablesize
755*56bb7041Schristos #   define getdtablesize rpl_getdtablesize
756*56bb7041Schristos #  endif
757*56bb7041Schristos _GL_FUNCDECL_RPL (getdtablesize, int, (void));
758*56bb7041Schristos _GL_CXXALIAS_RPL (getdtablesize, int, (void));
759*56bb7041Schristos # else
760*56bb7041Schristos #  if !@HAVE_GETDTABLESIZE@
761*56bb7041Schristos _GL_FUNCDECL_SYS (getdtablesize, int, (void));
762*56bb7041Schristos #  endif
763*56bb7041Schristos /* Need to cast, because on AIX, the parameter list is
764*56bb7041Schristos                                            (...).  */
765*56bb7041Schristos _GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void));
766*56bb7041Schristos # endif
767*56bb7041Schristos _GL_CXXALIASWARN (getdtablesize);
768*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
769*56bb7041Schristos # undef getdtablesize
770*56bb7041Schristos # if HAVE_RAW_DECL_GETDTABLESIZE
771*56bb7041Schristos _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
772*56bb7041Schristos                  "use gnulib module getdtablesize for portability");
773*56bb7041Schristos # endif
774*56bb7041Schristos #endif
775*56bb7041Schristos 
776*56bb7041Schristos 
777*56bb7041Schristos #if @GNULIB_GETENTROPY@
778*56bb7041Schristos /* Fill a buffer with random bytes.  */
779*56bb7041Schristos # if !@HAVE_GETENTROPY@
780*56bb7041Schristos _GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length));
781*56bb7041Schristos # endif
782*56bb7041Schristos _GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length));
783*56bb7041Schristos _GL_CXXALIASWARN (getentropy);
784*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
785*56bb7041Schristos # undef getentropy
786*56bb7041Schristos # if HAVE_RAW_DECL_GETENTROPY
787*56bb7041Schristos _GL_WARN_ON_USE (getentropy, "getentropy is unportable - "
788*56bb7041Schristos                  "use gnulib module getentropy for portability");
789*56bb7041Schristos # endif
790*56bb7041Schristos #endif
791*56bb7041Schristos 
792*56bb7041Schristos 
793*56bb7041Schristos #if @GNULIB_GETGROUPS@
794*56bb7041Schristos /* Return the supplemental groups that the current process belongs to.
795*56bb7041Schristos    It is unspecified whether the effective group id is in the list.
796*56bb7041Schristos    If N is 0, return the group count; otherwise, N describes how many
797*56bb7041Schristos    entries are available in GROUPS.  Return -1 and set errno if N is
798*56bb7041Schristos    not 0 and not large enough.  Fails with ENOSYS on some systems.  */
799*56bb7041Schristos # if @REPLACE_GETGROUPS@
800*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
801*56bb7041Schristos #   undef getgroups
802*56bb7041Schristos #   define getgroups rpl_getgroups
803*56bb7041Schristos #  endif
804*56bb7041Schristos _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
805*56bb7041Schristos _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
806*56bb7041Schristos # else
807*56bb7041Schristos #  if !@HAVE_GETGROUPS@
808*56bb7041Schristos _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
809*56bb7041Schristos #  endif
810*56bb7041Schristos _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
811*56bb7041Schristos # endif
812*56bb7041Schristos _GL_CXXALIASWARN (getgroups);
813*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
814*56bb7041Schristos # undef getgroups
815*56bb7041Schristos # if HAVE_RAW_DECL_GETGROUPS
816*56bb7041Schristos _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
817*56bb7041Schristos                  "use gnulib module getgroups for portability");
818*56bb7041Schristos # endif
819*56bb7041Schristos #endif
820*56bb7041Schristos 
821*56bb7041Schristos 
822*56bb7041Schristos #if @GNULIB_GETHOSTNAME@
823*56bb7041Schristos /* Return the standard host name of the machine.
824*56bb7041Schristos    WARNING! The host name may or may not be fully qualified.
825*56bb7041Schristos 
826*56bb7041Schristos    Put up to LEN bytes of the host name into NAME.
827*56bb7041Schristos    Null terminate it if the name is shorter than LEN.
828*56bb7041Schristos    If the host name is longer than LEN, set errno = EINVAL and return -1.
829*56bb7041Schristos    Return 0 if successful, otherwise set errno and return -1.  */
830*56bb7041Schristos # if @UNISTD_H_HAVE_WINSOCK2_H@
831*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
832*56bb7041Schristos #   undef gethostname
833*56bb7041Schristos #   define gethostname rpl_gethostname
834*56bb7041Schristos #  endif
835*56bb7041Schristos _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
836*56bb7041Schristos                                     _GL_ARG_NONNULL ((1)));
837*56bb7041Schristos _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
838*56bb7041Schristos # else
839*56bb7041Schristos #  if !@HAVE_GETHOSTNAME@
840*56bb7041Schristos _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
841*56bb7041Schristos                                     _GL_ARG_NONNULL ((1)));
842*56bb7041Schristos #  endif
843*56bb7041Schristos /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
844*56bb7041Schristos    parameter is
845*56bb7041Schristos                                                       int len.  */
846*56bb7041Schristos _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
847*56bb7041Schristos # endif
848*56bb7041Schristos _GL_CXXALIASWARN (gethostname);
849*56bb7041Schristos #elif @UNISTD_H_HAVE_WINSOCK2_H@
850*56bb7041Schristos # undef gethostname
851*56bb7041Schristos # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
852*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
853*56bb7041Schristos # undef gethostname
854*56bb7041Schristos # if HAVE_RAW_DECL_GETHOSTNAME
855*56bb7041Schristos _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
856*56bb7041Schristos                  "use gnulib module gethostname for portability");
857*56bb7041Schristos # endif
858*56bb7041Schristos #endif
859*56bb7041Schristos 
860*56bb7041Schristos 
861*56bb7041Schristos #if @GNULIB_GETLOGIN@
862*56bb7041Schristos /* Returns the user's login name, or NULL if it cannot be found.  Upon error,
863*56bb7041Schristos    returns NULL with errno set.
864*56bb7041Schristos 
865*56bb7041Schristos    See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
866*56bb7041Schristos 
867*56bb7041Schristos    Most programs don't need to use this function, because the information is
868*56bb7041Schristos    available through environment variables:
869*56bb7041Schristos      ${LOGNAME-$USER}        on Unix platforms,
870*56bb7041Schristos      $USERNAME               on native Windows platforms.
871*56bb7041Schristos  */
872*56bb7041Schristos # if !@HAVE_DECL_GETLOGIN@
873*56bb7041Schristos _GL_FUNCDECL_SYS (getlogin, char *, (void));
874*56bb7041Schristos # endif
875*56bb7041Schristos _GL_CXXALIAS_SYS (getlogin, char *, (void));
876*56bb7041Schristos _GL_CXXALIASWARN (getlogin);
877*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
878*56bb7041Schristos # undef getlogin
879*56bb7041Schristos # if HAVE_RAW_DECL_GETLOGIN
880*56bb7041Schristos _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
881*56bb7041Schristos                  "use gnulib module getlogin for portability");
882*56bb7041Schristos # endif
883*56bb7041Schristos #endif
884*56bb7041Schristos 
885*56bb7041Schristos 
886*56bb7041Schristos #if @GNULIB_GETLOGIN_R@
887*56bb7041Schristos /* Copies the user's login name to NAME.
888*56bb7041Schristos    The array pointed to by NAME has room for SIZE bytes.
889*56bb7041Schristos 
890*56bb7041Schristos    Returns 0 if successful.  Upon error, an error number is returned, or -1 in
891*56bb7041Schristos    the case that the login name cannot be found but no specific error is
892*56bb7041Schristos    provided (this case is hopefully rare but is left open by the POSIX spec).
893*56bb7041Schristos 
894*56bb7041Schristos    See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
895*56bb7041Schristos 
896*56bb7041Schristos    Most programs don't need to use this function, because the information is
897*56bb7041Schristos    available through environment variables:
898*56bb7041Schristos      ${LOGNAME-$USER}        on Unix platforms,
899*56bb7041Schristos      $USERNAME               on native Windows platforms.
900*56bb7041Schristos  */
901*56bb7041Schristos # if @REPLACE_GETLOGIN_R@
902*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
903*56bb7041Schristos #   define getlogin_r rpl_getlogin_r
904*56bb7041Schristos #  endif
905*56bb7041Schristos _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
906*56bb7041Schristos                                    _GL_ARG_NONNULL ((1)));
907*56bb7041Schristos _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
908*56bb7041Schristos # else
909*56bb7041Schristos #  if !@HAVE_DECL_GETLOGIN_R@
910*56bb7041Schristos _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
911*56bb7041Schristos                                    _GL_ARG_NONNULL ((1)));
912*56bb7041Schristos #  endif
913*56bb7041Schristos /* Need to cast, because on Solaris 10 systems, the second argument is
914*56bb7041Schristos                                                      int size.  */
915*56bb7041Schristos _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
916*56bb7041Schristos # endif
917*56bb7041Schristos _GL_CXXALIASWARN (getlogin_r);
918*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
919*56bb7041Schristos # undef getlogin_r
920*56bb7041Schristos # if HAVE_RAW_DECL_GETLOGIN_R
921*56bb7041Schristos _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
922*56bb7041Schristos                  "use gnulib module getlogin_r for portability");
923*56bb7041Schristos # endif
924*56bb7041Schristos #endif
925*56bb7041Schristos 
926*56bb7041Schristos 
927*56bb7041Schristos #if @GNULIB_GETPAGESIZE@
928*56bb7041Schristos # if @REPLACE_GETPAGESIZE@
929*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
930*56bb7041Schristos #   define getpagesize rpl_getpagesize
931*56bb7041Schristos #  endif
932*56bb7041Schristos _GL_FUNCDECL_RPL (getpagesize, int, (void));
933*56bb7041Schristos _GL_CXXALIAS_RPL (getpagesize, int, (void));
934*56bb7041Schristos # else
935*56bb7041Schristos /* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
936*56bb7041Schristos    the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used.  */
937*56bb7041Schristos #  if defined __hpux
938*56bb7041Schristos _GL_FUNCDECL_SYS (getpagesize, int, (void));
939*56bb7041Schristos #  endif
940*56bb7041Schristos #  if !@HAVE_GETPAGESIZE@
941*56bb7041Schristos #   if !defined getpagesize
942*56bb7041Schristos /* This is for POSIX systems.  */
943*56bb7041Schristos #    if !defined _gl_getpagesize && defined _SC_PAGESIZE
944*56bb7041Schristos #     if ! (defined __VMS && __VMS_VER < 70000000)
945*56bb7041Schristos #      define _gl_getpagesize() sysconf (_SC_PAGESIZE)
946*56bb7041Schristos #     endif
947*56bb7041Schristos #    endif
948*56bb7041Schristos /* This is for older VMS.  */
949*56bb7041Schristos #    if !defined _gl_getpagesize && defined __VMS
950*56bb7041Schristos #     ifdef __ALPHA
951*56bb7041Schristos #      define _gl_getpagesize() 8192
952*56bb7041Schristos #     else
953*56bb7041Schristos #      define _gl_getpagesize() 512
954*56bb7041Schristos #     endif
955*56bb7041Schristos #    endif
956*56bb7041Schristos /* This is for BeOS.  */
957*56bb7041Schristos #    if !defined _gl_getpagesize && @HAVE_OS_H@
958*56bb7041Schristos #     include <OS.h>
959*56bb7041Schristos #     if defined B_PAGE_SIZE
960*56bb7041Schristos #      define _gl_getpagesize() B_PAGE_SIZE
961*56bb7041Schristos #     endif
962*56bb7041Schristos #    endif
963*56bb7041Schristos /* This is for AmigaOS4.0.  */
964*56bb7041Schristos #    if !defined _gl_getpagesize && defined __amigaos4__
965*56bb7041Schristos #     define _gl_getpagesize() 2048
966*56bb7041Schristos #    endif
967*56bb7041Schristos /* This is for older Unix systems.  */
968*56bb7041Schristos #    if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
969*56bb7041Schristos #     include <sys/param.h>
970*56bb7041Schristos #     ifdef EXEC_PAGESIZE
971*56bb7041Schristos #      define _gl_getpagesize() EXEC_PAGESIZE
972*56bb7041Schristos #     else
973*56bb7041Schristos #      ifdef NBPG
974*56bb7041Schristos #       ifndef CLSIZE
975*56bb7041Schristos #        define CLSIZE 1
976*56bb7041Schristos #       endif
977*56bb7041Schristos #       define _gl_getpagesize() (NBPG * CLSIZE)
978*56bb7041Schristos #      else
979*56bb7041Schristos #       ifdef NBPC
980*56bb7041Schristos #        define _gl_getpagesize() NBPC
981*56bb7041Schristos #       endif
982*56bb7041Schristos #      endif
983*56bb7041Schristos #     endif
984*56bb7041Schristos #    endif
985*56bb7041Schristos #    if !(defined __cplusplus && defined GNULIB_NAMESPACE)
986*56bb7041Schristos #     define getpagesize() _gl_getpagesize ()
987*56bb7041Schristos #    else
988*56bb7041Schristos #     if !GNULIB_defined_getpagesize_function
989*56bb7041Schristos _GL_UNISTD_INLINE int
990*56bb7041Schristos getpagesize ()
991*56bb7041Schristos {
992*56bb7041Schristos   return _gl_getpagesize ();
993*56bb7041Schristos }
994*56bb7041Schristos #      define GNULIB_defined_getpagesize_function 1
995*56bb7041Schristos #     endif
996*56bb7041Schristos #    endif
997*56bb7041Schristos #   endif
998*56bb7041Schristos #  endif
999*56bb7041Schristos /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t.  */
1000*56bb7041Schristos _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
1001*56bb7041Schristos # endif
1002*56bb7041Schristos # if @HAVE_DECL_GETPAGESIZE@
1003*56bb7041Schristos _GL_CXXALIASWARN (getpagesize);
1004*56bb7041Schristos # endif
1005*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1006*56bb7041Schristos # undef getpagesize
1007*56bb7041Schristos # if HAVE_RAW_DECL_GETPAGESIZE
1008*56bb7041Schristos _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
1009*56bb7041Schristos                  "use gnulib module getpagesize for portability");
1010*56bb7041Schristos # endif
1011*56bb7041Schristos #endif
1012*56bb7041Schristos 
1013*56bb7041Schristos 
1014*56bb7041Schristos #if @GNULIB_GETPASS@
1015*56bb7041Schristos /* Function getpass() from module 'getpass':
1016*56bb7041Schristos      Read a password from /dev/tty or stdin.
1017*56bb7041Schristos    Function getpass() from module 'getpass-gnu':
1018*56bb7041Schristos      Read a password of arbitrary length from /dev/tty or stdin.  */
1019*56bb7041Schristos # if @REPLACE_GETPASS@
1020*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1021*56bb7041Schristos #   undef getpass
1022*56bb7041Schristos #   define getpass rpl_getpass
1023*56bb7041Schristos #  endif
1024*56bb7041Schristos _GL_FUNCDECL_RPL (getpass, char *, (const char *prompt)
1025*56bb7041Schristos                                    _GL_ARG_NONNULL ((1)));
1026*56bb7041Schristos _GL_CXXALIAS_RPL (getpass, char *, (const char *prompt));
1027*56bb7041Schristos # else
1028*56bb7041Schristos #  if !@HAVE_GETPASS@
1029*56bb7041Schristos _GL_FUNCDECL_SYS (getpass, char *, (const char *prompt)
1030*56bb7041Schristos                                    _GL_ARG_NONNULL ((1)));
1031*56bb7041Schristos #  endif
1032*56bb7041Schristos _GL_CXXALIAS_SYS (getpass, char *, (const char *prompt));
1033*56bb7041Schristos # endif
1034*56bb7041Schristos _GL_CXXALIASWARN (getpass);
1035*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1036*56bb7041Schristos # undef getpass
1037*56bb7041Schristos # if HAVE_RAW_DECL_GETPASS
1038*56bb7041Schristos _GL_WARN_ON_USE (getpass, "getpass is unportable - "
1039*56bb7041Schristos                  "use gnulib module getpass or getpass-gnu for portability");
1040*56bb7041Schristos # endif
1041*56bb7041Schristos #endif
1042*56bb7041Schristos 
1043*56bb7041Schristos 
1044*56bb7041Schristos #if @GNULIB_GETUSERSHELL@
1045*56bb7041Schristos /* Return the next valid login shell on the system, or NULL when the end of
1046*56bb7041Schristos    the list has been reached.  */
1047*56bb7041Schristos # if !@HAVE_DECL_GETUSERSHELL@
1048*56bb7041Schristos _GL_FUNCDECL_SYS (getusershell, char *, (void));
1049*56bb7041Schristos # endif
1050*56bb7041Schristos _GL_CXXALIAS_SYS (getusershell, char *, (void));
1051*56bb7041Schristos _GL_CXXALIASWARN (getusershell);
1052*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1053*56bb7041Schristos # undef getusershell
1054*56bb7041Schristos # if HAVE_RAW_DECL_GETUSERSHELL
1055*56bb7041Schristos _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
1056*56bb7041Schristos                  "use gnulib module getusershell for portability");
1057*56bb7041Schristos # endif
1058*56bb7041Schristos #endif
1059*56bb7041Schristos 
1060*56bb7041Schristos #if @GNULIB_GETUSERSHELL@
1061*56bb7041Schristos /* Rewind to pointer that is advanced at each getusershell() call.  */
1062*56bb7041Schristos # if !@HAVE_DECL_GETUSERSHELL@
1063*56bb7041Schristos _GL_FUNCDECL_SYS (setusershell, void, (void));
1064*56bb7041Schristos # endif
1065*56bb7041Schristos _GL_CXXALIAS_SYS (setusershell, void, (void));
1066*56bb7041Schristos _GL_CXXALIASWARN (setusershell);
1067*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1068*56bb7041Schristos # undef setusershell
1069*56bb7041Schristos # if HAVE_RAW_DECL_SETUSERSHELL
1070*56bb7041Schristos _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
1071*56bb7041Schristos                  "use gnulib module getusershell for portability");
1072*56bb7041Schristos # endif
1073*56bb7041Schristos #endif
1074*56bb7041Schristos 
1075*56bb7041Schristos #if @GNULIB_GETUSERSHELL@
1076*56bb7041Schristos /* Free the pointer that is advanced at each getusershell() call and
1077*56bb7041Schristos    associated resources.  */
1078*56bb7041Schristos # if !@HAVE_DECL_GETUSERSHELL@
1079*56bb7041Schristos _GL_FUNCDECL_SYS (endusershell, void, (void));
1080*56bb7041Schristos # endif
1081*56bb7041Schristos _GL_CXXALIAS_SYS (endusershell, void, (void));
1082*56bb7041Schristos _GL_CXXALIASWARN (endusershell);
1083*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1084*56bb7041Schristos # undef endusershell
1085*56bb7041Schristos # if HAVE_RAW_DECL_ENDUSERSHELL
1086*56bb7041Schristos _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
1087*56bb7041Schristos                  "use gnulib module getusershell for portability");
1088*56bb7041Schristos # endif
1089*56bb7041Schristos #endif
1090*56bb7041Schristos 
1091*56bb7041Schristos 
1092*56bb7041Schristos #if @GNULIB_GROUP_MEMBER@
1093*56bb7041Schristos /* Determine whether group id is in calling user's group list.  */
1094*56bb7041Schristos # if !@HAVE_GROUP_MEMBER@
1095*56bb7041Schristos _GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
1096*56bb7041Schristos # endif
1097*56bb7041Schristos _GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
1098*56bb7041Schristos _GL_CXXALIASWARN (group_member);
1099*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1100*56bb7041Schristos # undef group_member
1101*56bb7041Schristos # if HAVE_RAW_DECL_GROUP_MEMBER
1102*56bb7041Schristos _GL_WARN_ON_USE (group_member, "group_member is unportable - "
1103*56bb7041Schristos                  "use gnulib module group-member for portability");
1104*56bb7041Schristos # endif
1105*56bb7041Schristos #endif
1106*56bb7041Schristos 
1107*56bb7041Schristos 
1108*56bb7041Schristos #if @GNULIB_ISATTY@
1109*56bb7041Schristos # if @REPLACE_ISATTY@
1110*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1111*56bb7041Schristos #   undef isatty
1112*56bb7041Schristos #   define isatty rpl_isatty
1113*56bb7041Schristos #  endif
1114*56bb7041Schristos _GL_FUNCDECL_RPL (isatty, int, (int fd));
1115*56bb7041Schristos _GL_CXXALIAS_RPL (isatty, int, (int fd));
1116*56bb7041Schristos # else
1117*56bb7041Schristos _GL_CXXALIAS_SYS (isatty, int, (int fd));
1118*56bb7041Schristos # endif
1119*56bb7041Schristos _GL_CXXALIASWARN (isatty);
1120*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1121*56bb7041Schristos # undef isatty
1122*56bb7041Schristos # if HAVE_RAW_DECL_ISATTY
1123*56bb7041Schristos _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
1124*56bb7041Schristos                  "use gnulib module isatty for portability");
1125*56bb7041Schristos # endif
1126*56bb7041Schristos #endif
1127*56bb7041Schristos 
1128*56bb7041Schristos 
1129*56bb7041Schristos #if @GNULIB_LCHOWN@
1130*56bb7041Schristos /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1131*56bb7041Schristos    to GID (if GID is not -1).  Do not follow symbolic links.
1132*56bb7041Schristos    Return 0 if successful, otherwise -1 and errno set.
1133*56bb7041Schristos    See the POSIX:2008 specification
1134*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>.  */
1135*56bb7041Schristos # if @REPLACE_LCHOWN@
1136*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1137*56bb7041Schristos #   undef lchown
1138*56bb7041Schristos #   define lchown rpl_lchown
1139*56bb7041Schristos #  endif
1140*56bb7041Schristos _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
1141*56bb7041Schristos                                _GL_ARG_NONNULL ((1)));
1142*56bb7041Schristos _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
1143*56bb7041Schristos # else
1144*56bb7041Schristos #  if !@HAVE_LCHOWN@
1145*56bb7041Schristos _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
1146*56bb7041Schristos                                _GL_ARG_NONNULL ((1)));
1147*56bb7041Schristos #  endif
1148*56bb7041Schristos _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
1149*56bb7041Schristos # endif
1150*56bb7041Schristos _GL_CXXALIASWARN (lchown);
1151*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1152*56bb7041Schristos # undef lchown
1153*56bb7041Schristos # if HAVE_RAW_DECL_LCHOWN
1154*56bb7041Schristos _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1155*56bb7041Schristos                  "use gnulib module lchown for portability");
1156*56bb7041Schristos # endif
1157*56bb7041Schristos #endif
1158*56bb7041Schristos 
1159*56bb7041Schristos 
1160*56bb7041Schristos #if @GNULIB_LINK@
1161*56bb7041Schristos /* Create a new hard link for an existing file.
1162*56bb7041Schristos    Return 0 if successful, otherwise -1 and errno set.
1163*56bb7041Schristos    See POSIX:2008 specification
1164*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>.  */
1165*56bb7041Schristos # if @REPLACE_LINK@
1166*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1167*56bb7041Schristos #   define link rpl_link
1168*56bb7041Schristos #  endif
1169*56bb7041Schristos _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
1170*56bb7041Schristos                              _GL_ARG_NONNULL ((1, 2)));
1171*56bb7041Schristos _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
1172*56bb7041Schristos # else
1173*56bb7041Schristos #  if !@HAVE_LINK@
1174*56bb7041Schristos _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
1175*56bb7041Schristos                              _GL_ARG_NONNULL ((1, 2)));
1176*56bb7041Schristos #  endif
1177*56bb7041Schristos _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
1178*56bb7041Schristos # endif
1179*56bb7041Schristos _GL_CXXALIASWARN (link);
1180*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1181*56bb7041Schristos # undef link
1182*56bb7041Schristos # if HAVE_RAW_DECL_LINK
1183*56bb7041Schristos _GL_WARN_ON_USE (link, "link is unportable - "
1184*56bb7041Schristos                  "use gnulib module link for portability");
1185*56bb7041Schristos # endif
1186*56bb7041Schristos #endif
1187*56bb7041Schristos 
1188*56bb7041Schristos 
1189*56bb7041Schristos #if @GNULIB_LINKAT@
1190*56bb7041Schristos /* Create a new hard link for an existing file, relative to two
1191*56bb7041Schristos    directories.  FLAG controls whether symlinks are followed.
1192*56bb7041Schristos    Return 0 if successful, otherwise -1 and errno set.  */
1193*56bb7041Schristos # if @REPLACE_LINKAT@
1194*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1195*56bb7041Schristos #   undef linkat
1196*56bb7041Schristos #   define linkat rpl_linkat
1197*56bb7041Schristos #  endif
1198*56bb7041Schristos _GL_FUNCDECL_RPL (linkat, int,
1199*56bb7041Schristos                   (int fd1, const char *path1, int fd2, const char *path2,
1200*56bb7041Schristos                    int flag)
1201*56bb7041Schristos                   _GL_ARG_NONNULL ((2, 4)));
1202*56bb7041Schristos _GL_CXXALIAS_RPL (linkat, int,
1203*56bb7041Schristos                   (int fd1, const char *path1, int fd2, const char *path2,
1204*56bb7041Schristos                    int flag));
1205*56bb7041Schristos # else
1206*56bb7041Schristos #  if !@HAVE_LINKAT@
1207*56bb7041Schristos _GL_FUNCDECL_SYS (linkat, int,
1208*56bb7041Schristos                   (int fd1, const char *path1, int fd2, const char *path2,
1209*56bb7041Schristos                    int flag)
1210*56bb7041Schristos                   _GL_ARG_NONNULL ((2, 4)));
1211*56bb7041Schristos #  endif
1212*56bb7041Schristos _GL_CXXALIAS_SYS (linkat, int,
1213*56bb7041Schristos                   (int fd1, const char *path1, int fd2, const char *path2,
1214*56bb7041Schristos                    int flag));
1215*56bb7041Schristos # endif
1216*56bb7041Schristos _GL_CXXALIASWARN (linkat);
1217*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1218*56bb7041Schristos # undef linkat
1219*56bb7041Schristos # if HAVE_RAW_DECL_LINKAT
1220*56bb7041Schristos _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1221*56bb7041Schristos                  "use gnulib module linkat for portability");
1222*56bb7041Schristos # endif
1223*56bb7041Schristos #endif
1224*56bb7041Schristos 
1225*56bb7041Schristos 
1226*56bb7041Schristos #if @GNULIB_LSEEK@
1227*56bb7041Schristos /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1228*56bb7041Schristos    Return the new offset if successful, otherwise -1 and errno set.
1229*56bb7041Schristos    See the POSIX:2008 specification
1230*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>.  */
1231*56bb7041Schristos # if @REPLACE_LSEEK@
1232*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1233*56bb7041Schristos #   define lseek rpl_lseek
1234*56bb7041Schristos #  endif
1235*56bb7041Schristos _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1236*56bb7041Schristos _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1237*56bb7041Schristos # else
1238*56bb7041Schristos _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1239*56bb7041Schristos # endif
1240*56bb7041Schristos _GL_CXXALIASWARN (lseek);
1241*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1242*56bb7041Schristos # undef lseek
1243*56bb7041Schristos # if HAVE_RAW_DECL_LSEEK
1244*56bb7041Schristos _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1245*56bb7041Schristos                  "systems - use gnulib module lseek for portability");
1246*56bb7041Schristos # endif
1247*56bb7041Schristos #endif
1248*56bb7041Schristos 
1249*56bb7041Schristos 
1250*56bb7041Schristos #if @GNULIB_PIPE@
1251*56bb7041Schristos /* Create a pipe, defaulting to O_BINARY mode.
1252*56bb7041Schristos    Store the read-end as fd[0] and the write-end as fd[1].
1253*56bb7041Schristos    Return 0 upon success, or -1 with errno set upon failure.  */
1254*56bb7041Schristos # if !@HAVE_PIPE@
1255*56bb7041Schristos _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1256*56bb7041Schristos # endif
1257*56bb7041Schristos _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1258*56bb7041Schristos _GL_CXXALIASWARN (pipe);
1259*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1260*56bb7041Schristos # undef pipe
1261*56bb7041Schristos # if HAVE_RAW_DECL_PIPE
1262*56bb7041Schristos _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1263*56bb7041Schristos                  "use gnulib module pipe-posix for portability");
1264*56bb7041Schristos # endif
1265*56bb7041Schristos #endif
1266*56bb7041Schristos 
1267*56bb7041Schristos 
1268*56bb7041Schristos #if @GNULIB_PIPE2@
1269*56bb7041Schristos /* Create a pipe, applying the given flags when opening the read-end of the
1270*56bb7041Schristos    pipe and the write-end of the pipe.
1271*56bb7041Schristos    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1272*56bb7041Schristos    and O_TEXT, O_BINARY (defined in "binary-io.h").
1273*56bb7041Schristos    Store the read-end as fd[0] and the write-end as fd[1].
1274*56bb7041Schristos    Return 0 upon success, or -1 with errno set upon failure.
1275*56bb7041Schristos    See also the Linux man page at
1276*56bb7041Schristos    <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
1277*56bb7041Schristos # if @HAVE_PIPE2@
1278*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1279*56bb7041Schristos #   define pipe2 rpl_pipe2
1280*56bb7041Schristos #  endif
1281*56bb7041Schristos _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1282*56bb7041Schristos _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1283*56bb7041Schristos # else
1284*56bb7041Schristos _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1285*56bb7041Schristos _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1286*56bb7041Schristos # endif
1287*56bb7041Schristos _GL_CXXALIASWARN (pipe2);
1288*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1289*56bb7041Schristos # undef pipe2
1290*56bb7041Schristos # if HAVE_RAW_DECL_PIPE2
1291*56bb7041Schristos _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1292*56bb7041Schristos                  "use gnulib module pipe2 for portability");
1293*56bb7041Schristos # endif
1294*56bb7041Schristos #endif
1295*56bb7041Schristos 
1296*56bb7041Schristos 
1297*56bb7041Schristos #if @GNULIB_PREAD@
1298*56bb7041Schristos /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1299*56bb7041Schristos    Return the number of bytes placed into BUF if successful, otherwise
1300*56bb7041Schristos    set errno and return -1.  0 indicates EOF.
1301*56bb7041Schristos    See the POSIX:2008 specification
1302*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>.  */
1303*56bb7041Schristos # if @REPLACE_PREAD@
1304*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1305*56bb7041Schristos #   undef pread
1306*56bb7041Schristos #   define pread rpl_pread
1307*56bb7041Schristos #  endif
1308*56bb7041Schristos _GL_FUNCDECL_RPL (pread, ssize_t,
1309*56bb7041Schristos                   (int fd, void *buf, size_t bufsize, off_t offset)
1310*56bb7041Schristos                   _GL_ARG_NONNULL ((2)));
1311*56bb7041Schristos _GL_CXXALIAS_RPL (pread, ssize_t,
1312*56bb7041Schristos                   (int fd, void *buf, size_t bufsize, off_t offset));
1313*56bb7041Schristos # else
1314*56bb7041Schristos #  if !@HAVE_PREAD@
1315*56bb7041Schristos _GL_FUNCDECL_SYS (pread, ssize_t,
1316*56bb7041Schristos                   (int fd, void *buf, size_t bufsize, off_t offset)
1317*56bb7041Schristos                   _GL_ARG_NONNULL ((2)));
1318*56bb7041Schristos #  endif
1319*56bb7041Schristos _GL_CXXALIAS_SYS (pread, ssize_t,
1320*56bb7041Schristos                   (int fd, void *buf, size_t bufsize, off_t offset));
1321*56bb7041Schristos # endif
1322*56bb7041Schristos _GL_CXXALIASWARN (pread);
1323*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1324*56bb7041Schristos # undef pread
1325*56bb7041Schristos # if HAVE_RAW_DECL_PREAD
1326*56bb7041Schristos _GL_WARN_ON_USE (pread, "pread is unportable - "
1327*56bb7041Schristos                  "use gnulib module pread for portability");
1328*56bb7041Schristos # endif
1329*56bb7041Schristos #endif
1330*56bb7041Schristos 
1331*56bb7041Schristos 
1332*56bb7041Schristos #if @GNULIB_PWRITE@
1333*56bb7041Schristos /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1334*56bb7041Schristos    Return the number of bytes written if successful, otherwise
1335*56bb7041Schristos    set errno and return -1.  0 indicates nothing written.  See the
1336*56bb7041Schristos    POSIX:2008 specification
1337*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>.  */
1338*56bb7041Schristos # if @REPLACE_PWRITE@
1339*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1340*56bb7041Schristos #   undef pwrite
1341*56bb7041Schristos #   define pwrite rpl_pwrite
1342*56bb7041Schristos #  endif
1343*56bb7041Schristos _GL_FUNCDECL_RPL (pwrite, ssize_t,
1344*56bb7041Schristos                   (int fd, const void *buf, size_t bufsize, off_t offset)
1345*56bb7041Schristos                   _GL_ARG_NONNULL ((2)));
1346*56bb7041Schristos _GL_CXXALIAS_RPL (pwrite, ssize_t,
1347*56bb7041Schristos                   (int fd, const void *buf, size_t bufsize, off_t offset));
1348*56bb7041Schristos # else
1349*56bb7041Schristos #  if !@HAVE_PWRITE@
1350*56bb7041Schristos _GL_FUNCDECL_SYS (pwrite, ssize_t,
1351*56bb7041Schristos                   (int fd, const void *buf, size_t bufsize, off_t offset)
1352*56bb7041Schristos                   _GL_ARG_NONNULL ((2)));
1353*56bb7041Schristos #  endif
1354*56bb7041Schristos _GL_CXXALIAS_SYS (pwrite, ssize_t,
1355*56bb7041Schristos                   (int fd, const void *buf, size_t bufsize, off_t offset));
1356*56bb7041Schristos # endif
1357*56bb7041Schristos _GL_CXXALIASWARN (pwrite);
1358*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1359*56bb7041Schristos # undef pwrite
1360*56bb7041Schristos # if HAVE_RAW_DECL_PWRITE
1361*56bb7041Schristos _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1362*56bb7041Schristos                  "use gnulib module pwrite for portability");
1363*56bb7041Schristos # endif
1364*56bb7041Schristos #endif
1365*56bb7041Schristos 
1366*56bb7041Schristos 
1367*56bb7041Schristos #if @GNULIB_READ@
1368*56bb7041Schristos /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1369*56bb7041Schristos    at BUF.  See the POSIX:2008 specification
1370*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>.  */
1371*56bb7041Schristos # if @REPLACE_READ@
1372*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1373*56bb7041Schristos #   undef read
1374*56bb7041Schristos #   define read rpl_read
1375*56bb7041Schristos #  endif
1376*56bb7041Schristos _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1377*56bb7041Schristos                                  _GL_ARG_NONNULL ((2)));
1378*56bb7041Schristos _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1379*56bb7041Schristos # else
1380*56bb7041Schristos /* Need to cast, because on mingw, the third parameter is
1381*56bb7041Schristos                                                           unsigned int count
1382*56bb7041Schristos    and the return type is 'int'.  */
1383*56bb7041Schristos _GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1384*56bb7041Schristos # endif
1385*56bb7041Schristos _GL_CXXALIASWARN (read);
1386*56bb7041Schristos #endif
1387*56bb7041Schristos 
1388*56bb7041Schristos 
1389*56bb7041Schristos #if @GNULIB_READLINK@
1390*56bb7041Schristos /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1391*56bb7041Schristos    bytes of it into BUF.  Return the number of bytes placed into BUF if
1392*56bb7041Schristos    successful, otherwise -1 and errno set.
1393*56bb7041Schristos    See the POSIX:2008 specification
1394*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>.  */
1395*56bb7041Schristos # if @REPLACE_READLINK@
1396*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1397*56bb7041Schristos #   define readlink rpl_readlink
1398*56bb7041Schristos #  endif
1399*56bb7041Schristos _GL_FUNCDECL_RPL (readlink, ssize_t,
1400*56bb7041Schristos                   (const char *restrict file,
1401*56bb7041Schristos                    char *restrict buf, size_t bufsize)
1402*56bb7041Schristos                   _GL_ARG_NONNULL ((1, 2)));
1403*56bb7041Schristos _GL_CXXALIAS_RPL (readlink, ssize_t,
1404*56bb7041Schristos                   (const char *restrict file,
1405*56bb7041Schristos                    char *restrict buf, size_t bufsize));
1406*56bb7041Schristos # else
1407*56bb7041Schristos #  if !@HAVE_READLINK@
1408*56bb7041Schristos _GL_FUNCDECL_SYS (readlink, ssize_t,
1409*56bb7041Schristos                   (const char *restrict file,
1410*56bb7041Schristos                    char *restrict buf, size_t bufsize)
1411*56bb7041Schristos                   _GL_ARG_NONNULL ((1, 2)));
1412*56bb7041Schristos #  endif
1413*56bb7041Schristos _GL_CXXALIAS_SYS (readlink, ssize_t,
1414*56bb7041Schristos                   (const char *restrict file,
1415*56bb7041Schristos                    char *restrict buf, size_t bufsize));
1416*56bb7041Schristos # endif
1417*56bb7041Schristos _GL_CXXALIASWARN (readlink);
1418*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1419*56bb7041Schristos # undef readlink
1420*56bb7041Schristos # if HAVE_RAW_DECL_READLINK
1421*56bb7041Schristos _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1422*56bb7041Schristos                  "use gnulib module readlink for portability");
1423*56bb7041Schristos # endif
1424*56bb7041Schristos #endif
1425*56bb7041Schristos 
1426*56bb7041Schristos 
1427*56bb7041Schristos #if @GNULIB_READLINKAT@
1428*56bb7041Schristos # if @REPLACE_READLINKAT@
1429*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1430*56bb7041Schristos #   define readlinkat rpl_readlinkat
1431*56bb7041Schristos #  endif
1432*56bb7041Schristos _GL_FUNCDECL_RPL (readlinkat, ssize_t,
1433*56bb7041Schristos                   (int fd, char const *restrict file,
1434*56bb7041Schristos                    char *restrict buf, size_t len)
1435*56bb7041Schristos                   _GL_ARG_NONNULL ((2, 3)));
1436*56bb7041Schristos _GL_CXXALIAS_RPL (readlinkat, ssize_t,
1437*56bb7041Schristos                   (int fd, char const *restrict file,
1438*56bb7041Schristos                    char *restrict buf, size_t len));
1439*56bb7041Schristos # else
1440*56bb7041Schristos #  if !@HAVE_READLINKAT@
1441*56bb7041Schristos _GL_FUNCDECL_SYS (readlinkat, ssize_t,
1442*56bb7041Schristos                   (int fd, char const *restrict file,
1443*56bb7041Schristos                    char *restrict buf, size_t len)
1444*56bb7041Schristos                   _GL_ARG_NONNULL ((2, 3)));
1445*56bb7041Schristos #  endif
1446*56bb7041Schristos _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1447*56bb7041Schristos                   (int fd, char const *restrict file,
1448*56bb7041Schristos                    char *restrict buf, size_t len));
1449*56bb7041Schristos # endif
1450*56bb7041Schristos _GL_CXXALIASWARN (readlinkat);
1451*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1452*56bb7041Schristos # undef readlinkat
1453*56bb7041Schristos # if HAVE_RAW_DECL_READLINKAT
1454*56bb7041Schristos _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1455*56bb7041Schristos                  "use gnulib module readlinkat for portability");
1456*56bb7041Schristos # endif
1457*56bb7041Schristos #endif
1458*56bb7041Schristos 
1459*56bb7041Schristos 
1460*56bb7041Schristos #if @GNULIB_RMDIR@
1461*56bb7041Schristos /* Remove the directory DIR.  */
1462*56bb7041Schristos # if @REPLACE_RMDIR@
1463*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1464*56bb7041Schristos #   define rmdir rpl_rmdir
1465*56bb7041Schristos #  endif
1466*56bb7041Schristos _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1467*56bb7041Schristos _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1468*56bb7041Schristos # else
1469*56bb7041Schristos _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1470*56bb7041Schristos # endif
1471*56bb7041Schristos _GL_CXXALIASWARN (rmdir);
1472*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1473*56bb7041Schristos # undef rmdir
1474*56bb7041Schristos # if HAVE_RAW_DECL_RMDIR
1475*56bb7041Schristos _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1476*56bb7041Schristos                  "use gnulib module rmdir for portability");
1477*56bb7041Schristos # endif
1478*56bb7041Schristos #endif
1479*56bb7041Schristos 
1480*56bb7041Schristos 
1481*56bb7041Schristos #if @GNULIB_SETHOSTNAME@
1482*56bb7041Schristos /* Set the host name of the machine.
1483*56bb7041Schristos    The host name may or may not be fully qualified.
1484*56bb7041Schristos 
1485*56bb7041Schristos    Put LEN bytes of NAME into the host name.
1486*56bb7041Schristos    Return 0 if successful, otherwise, set errno and return -1.
1487*56bb7041Schristos 
1488*56bb7041Schristos    Platforms with no ability to set the hostname return -1 and set
1489*56bb7041Schristos    errno = ENOSYS.  */
1490*56bb7041Schristos # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1491*56bb7041Schristos _GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
1492*56bb7041Schristos                                     _GL_ARG_NONNULL ((1)));
1493*56bb7041Schristos # endif
1494*56bb7041Schristos /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1495*56bb7041Schristos    and FreeBSD 6.4 the second parameter is int.  On Solaris 11
1496*56bb7041Schristos    2011-10, the first parameter is not const.  */
1497*56bb7041Schristos _GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
1498*56bb7041Schristos _GL_CXXALIASWARN (sethostname);
1499*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1500*56bb7041Schristos # undef sethostname
1501*56bb7041Schristos # if HAVE_RAW_DECL_SETHOSTNAME
1502*56bb7041Schristos _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1503*56bb7041Schristos                  "use gnulib module sethostname for portability");
1504*56bb7041Schristos # endif
1505*56bb7041Schristos #endif
1506*56bb7041Schristos 
1507*56bb7041Schristos 
1508*56bb7041Schristos #if @GNULIB_SLEEP@
1509*56bb7041Schristos /* Pause the execution of the current thread for N seconds.
1510*56bb7041Schristos    Returns the number of seconds left to sleep.
1511*56bb7041Schristos    See the POSIX:2008 specification
1512*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>.  */
1513*56bb7041Schristos # if @REPLACE_SLEEP@
1514*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1515*56bb7041Schristos #   undef sleep
1516*56bb7041Schristos #   define sleep rpl_sleep
1517*56bb7041Schristos #  endif
1518*56bb7041Schristos _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1519*56bb7041Schristos _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1520*56bb7041Schristos # else
1521*56bb7041Schristos #  if !@HAVE_SLEEP@
1522*56bb7041Schristos _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1523*56bb7041Schristos #  endif
1524*56bb7041Schristos _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1525*56bb7041Schristos # endif
1526*56bb7041Schristos _GL_CXXALIASWARN (sleep);
1527*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1528*56bb7041Schristos # undef sleep
1529*56bb7041Schristos # if HAVE_RAW_DECL_SLEEP
1530*56bb7041Schristos _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1531*56bb7041Schristos                  "use gnulib module sleep for portability");
1532*56bb7041Schristos # endif
1533*56bb7041Schristos #endif
1534*56bb7041Schristos 
1535*56bb7041Schristos 
1536*56bb7041Schristos #if @GNULIB_SYMLINK@
1537*56bb7041Schristos # if @REPLACE_SYMLINK@
1538*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1539*56bb7041Schristos #   undef symlink
1540*56bb7041Schristos #   define symlink rpl_symlink
1541*56bb7041Schristos #  endif
1542*56bb7041Schristos _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1543*56bb7041Schristos                                 _GL_ARG_NONNULL ((1, 2)));
1544*56bb7041Schristos _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1545*56bb7041Schristos # else
1546*56bb7041Schristos #  if !@HAVE_SYMLINK@
1547*56bb7041Schristos _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1548*56bb7041Schristos                                 _GL_ARG_NONNULL ((1, 2)));
1549*56bb7041Schristos #  endif
1550*56bb7041Schristos _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1551*56bb7041Schristos # endif
1552*56bb7041Schristos _GL_CXXALIASWARN (symlink);
1553*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1554*56bb7041Schristos # undef symlink
1555*56bb7041Schristos # if HAVE_RAW_DECL_SYMLINK
1556*56bb7041Schristos _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1557*56bb7041Schristos                  "use gnulib module symlink for portability");
1558*56bb7041Schristos # endif
1559*56bb7041Schristos #endif
1560*56bb7041Schristos 
1561*56bb7041Schristos 
1562*56bb7041Schristos #if @GNULIB_SYMLINKAT@
1563*56bb7041Schristos # if @REPLACE_SYMLINKAT@
1564*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1565*56bb7041Schristos #   undef symlinkat
1566*56bb7041Schristos #   define symlinkat rpl_symlinkat
1567*56bb7041Schristos #  endif
1568*56bb7041Schristos _GL_FUNCDECL_RPL (symlinkat, int,
1569*56bb7041Schristos                   (char const *contents, int fd, char const *file)
1570*56bb7041Schristos                   _GL_ARG_NONNULL ((1, 3)));
1571*56bb7041Schristos _GL_CXXALIAS_RPL (symlinkat, int,
1572*56bb7041Schristos                   (char const *contents, int fd, char const *file));
1573*56bb7041Schristos # else
1574*56bb7041Schristos #  if !@HAVE_SYMLINKAT@
1575*56bb7041Schristos _GL_FUNCDECL_SYS (symlinkat, int,
1576*56bb7041Schristos                   (char const *contents, int fd, char const *file)
1577*56bb7041Schristos                   _GL_ARG_NONNULL ((1, 3)));
1578*56bb7041Schristos #  endif
1579*56bb7041Schristos _GL_CXXALIAS_SYS (symlinkat, int,
1580*56bb7041Schristos                   (char const *contents, int fd, char const *file));
1581*56bb7041Schristos # endif
1582*56bb7041Schristos _GL_CXXALIASWARN (symlinkat);
1583*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1584*56bb7041Schristos # undef symlinkat
1585*56bb7041Schristos # if HAVE_RAW_DECL_SYMLINKAT
1586*56bb7041Schristos _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1587*56bb7041Schristos                  "use gnulib module symlinkat for portability");
1588*56bb7041Schristos # endif
1589*56bb7041Schristos #endif
1590*56bb7041Schristos 
1591*56bb7041Schristos 
1592*56bb7041Schristos #if @GNULIB_TRUNCATE@
1593*56bb7041Schristos /* Change the size of the file designated by FILENAME to become equal to LENGTH.
1594*56bb7041Schristos    Return 0 if successful, otherwise -1 and errno set.
1595*56bb7041Schristos    See the POSIX:2008 specification
1596*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>.  */
1597*56bb7041Schristos # if @REPLACE_TRUNCATE@
1598*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1599*56bb7041Schristos #   undef truncate
1600*56bb7041Schristos #   define truncate rpl_truncate
1601*56bb7041Schristos #  endif
1602*56bb7041Schristos _GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
1603*56bb7041Schristos                                  _GL_ARG_NONNULL ((1)));
1604*56bb7041Schristos _GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
1605*56bb7041Schristos # else
1606*56bb7041Schristos #  if !@HAVE_DECL_TRUNCATE@
1607*56bb7041Schristos _GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
1608*56bb7041Schristos                                  _GL_ARG_NONNULL ((1)));
1609*56bb7041Schristos #  endif
1610*56bb7041Schristos _GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
1611*56bb7041Schristos # endif
1612*56bb7041Schristos _GL_CXXALIASWARN (truncate);
1613*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1614*56bb7041Schristos # undef truncate
1615*56bb7041Schristos # if HAVE_RAW_DECL_TRUNCATE
1616*56bb7041Schristos _GL_WARN_ON_USE (truncate, "truncate is unportable - "
1617*56bb7041Schristos                  "use gnulib module truncate for portability");
1618*56bb7041Schristos # endif
1619*56bb7041Schristos #endif
1620*56bb7041Schristos 
1621*56bb7041Schristos 
1622*56bb7041Schristos #if @GNULIB_TTYNAME_R@
1623*56bb7041Schristos /* Store at most BUFLEN characters of the pathname of the terminal FD is
1624*56bb7041Schristos    open on in BUF.  Return 0 on success, otherwise an error number.  */
1625*56bb7041Schristos # if @REPLACE_TTYNAME_R@
1626*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1627*56bb7041Schristos #   undef ttyname_r
1628*56bb7041Schristos #   define ttyname_r rpl_ttyname_r
1629*56bb7041Schristos #  endif
1630*56bb7041Schristos _GL_FUNCDECL_RPL (ttyname_r, int,
1631*56bb7041Schristos                   (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1632*56bb7041Schristos _GL_CXXALIAS_RPL (ttyname_r, int,
1633*56bb7041Schristos                   (int fd, char *buf, size_t buflen));
1634*56bb7041Schristos # else
1635*56bb7041Schristos #  if !@HAVE_DECL_TTYNAME_R@
1636*56bb7041Schristos _GL_FUNCDECL_SYS (ttyname_r, int,
1637*56bb7041Schristos                   (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1638*56bb7041Schristos #  endif
1639*56bb7041Schristos _GL_CXXALIAS_SYS (ttyname_r, int,
1640*56bb7041Schristos                   (int fd, char *buf, size_t buflen));
1641*56bb7041Schristos # endif
1642*56bb7041Schristos _GL_CXXALIASWARN (ttyname_r);
1643*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1644*56bb7041Schristos # undef ttyname_r
1645*56bb7041Schristos # if HAVE_RAW_DECL_TTYNAME_R
1646*56bb7041Schristos _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1647*56bb7041Schristos                  "use gnulib module ttyname_r for portability");
1648*56bb7041Schristos # endif
1649*56bb7041Schristos #endif
1650*56bb7041Schristos 
1651*56bb7041Schristos 
1652*56bb7041Schristos #if @GNULIB_UNLINK@
1653*56bb7041Schristos # if @REPLACE_UNLINK@
1654*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1655*56bb7041Schristos #   undef unlink
1656*56bb7041Schristos #   define unlink rpl_unlink
1657*56bb7041Schristos #  endif
1658*56bb7041Schristos _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1659*56bb7041Schristos _GL_CXXALIAS_RPL (unlink, int, (char const *file));
1660*56bb7041Schristos # else
1661*56bb7041Schristos _GL_CXXALIAS_SYS (unlink, int, (char const *file));
1662*56bb7041Schristos # endif
1663*56bb7041Schristos _GL_CXXALIASWARN (unlink);
1664*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1665*56bb7041Schristos # undef unlink
1666*56bb7041Schristos # if HAVE_RAW_DECL_UNLINK
1667*56bb7041Schristos _GL_WARN_ON_USE (unlink, "unlink is not portable - "
1668*56bb7041Schristos                  "use gnulib module unlink for portability");
1669*56bb7041Schristos # endif
1670*56bb7041Schristos #endif
1671*56bb7041Schristos 
1672*56bb7041Schristos 
1673*56bb7041Schristos #if @GNULIB_UNLINKAT@
1674*56bb7041Schristos # if @REPLACE_UNLINKAT@
1675*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1676*56bb7041Schristos #   undef unlinkat
1677*56bb7041Schristos #   define unlinkat rpl_unlinkat
1678*56bb7041Schristos #  endif
1679*56bb7041Schristos _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1680*56bb7041Schristos                                  _GL_ARG_NONNULL ((2)));
1681*56bb7041Schristos _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1682*56bb7041Schristos # else
1683*56bb7041Schristos #  if !@HAVE_UNLINKAT@
1684*56bb7041Schristos _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1685*56bb7041Schristos                                  _GL_ARG_NONNULL ((2)));
1686*56bb7041Schristos #  endif
1687*56bb7041Schristos _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1688*56bb7041Schristos # endif
1689*56bb7041Schristos _GL_CXXALIASWARN (unlinkat);
1690*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1691*56bb7041Schristos # undef unlinkat
1692*56bb7041Schristos # if HAVE_RAW_DECL_UNLINKAT
1693*56bb7041Schristos _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1694*56bb7041Schristos                  "use gnulib module openat for portability");
1695*56bb7041Schristos # endif
1696*56bb7041Schristos #endif
1697*56bb7041Schristos 
1698*56bb7041Schristos 
1699*56bb7041Schristos #if @GNULIB_USLEEP@
1700*56bb7041Schristos /* Pause the execution of the current thread for N microseconds.
1701*56bb7041Schristos    Returns 0 on completion, or -1 on range error.
1702*56bb7041Schristos    See the POSIX:2001 specification
1703*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>.  */
1704*56bb7041Schristos # if @REPLACE_USLEEP@
1705*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1706*56bb7041Schristos #   undef usleep
1707*56bb7041Schristos #   define usleep rpl_usleep
1708*56bb7041Schristos #  endif
1709*56bb7041Schristos _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1710*56bb7041Schristos _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1711*56bb7041Schristos # else
1712*56bb7041Schristos #  if !@HAVE_USLEEP@
1713*56bb7041Schristos _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1714*56bb7041Schristos #  endif
1715*56bb7041Schristos /* Need to cast, because on Haiku, the first parameter is
1716*56bb7041Schristos                                      unsigned int n.  */
1717*56bb7041Schristos _GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n));
1718*56bb7041Schristos # endif
1719*56bb7041Schristos _GL_CXXALIASWARN (usleep);
1720*56bb7041Schristos #elif defined GNULIB_POSIXCHECK
1721*56bb7041Schristos # undef usleep
1722*56bb7041Schristos # if HAVE_RAW_DECL_USLEEP
1723*56bb7041Schristos _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1724*56bb7041Schristos                  "use gnulib module usleep for portability");
1725*56bb7041Schristos # endif
1726*56bb7041Schristos #endif
1727*56bb7041Schristos 
1728*56bb7041Schristos 
1729*56bb7041Schristos #if @GNULIB_WRITE@
1730*56bb7041Schristos /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1731*56bb7041Schristos    See the POSIX:2008 specification
1732*56bb7041Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>.  */
1733*56bb7041Schristos # if @REPLACE_WRITE@
1734*56bb7041Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1735*56bb7041Schristos #   undef write
1736*56bb7041Schristos #   define write rpl_write
1737*56bb7041Schristos #  endif
1738*56bb7041Schristos _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1739*56bb7041Schristos                                   _GL_ARG_NONNULL ((2)));
1740*56bb7041Schristos _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1741*56bb7041Schristos # else
1742*56bb7041Schristos /* Need to cast, because on mingw, the third parameter is
1743*56bb7041Schristos                                                              unsigned int count
1744*56bb7041Schristos    and the return type is 'int'.  */
1745*56bb7041Schristos _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1746*56bb7041Schristos # endif
1747*56bb7041Schristos _GL_CXXALIASWARN (write);
1748*56bb7041Schristos #endif
1749*56bb7041Schristos 
1750*56bb7041Schristos _GL_INLINE_HEADER_END
1751*56bb7041Schristos 
1752*56bb7041Schristos #endif /* _@GUARD_PREFIX@_UNISTD_H */
1753*56bb7041Schristos #endif /* _GL_INCLUDING_UNISTD_H */
1754*56bb7041Schristos #endif /* _@GUARD_PREFIX@_UNISTD_H */
1755