summaryrefslogtreecommitdiffstats
path: root/gl/unistd.in.h
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-08 01:11:46 (GMT)
committerThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-13 01:26:35 (GMT)
commit74da141e618ef99959d509cb2e7be35a348a39db (patch)
tree88ebc38b381a1021fc2d74864a71e230ae591c3d /gl/unistd.in.h
parentc63a4f726a0b6ad8cf6040f947754a81fd4683bb (diff)
downloadmonitoring-plugins-74da141e618ef99959d509cb2e7be35a348a39db.tar.gz
Sync with the latest Gnulib code (177f525)
Signed-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca>
Diffstat (limited to 'gl/unistd.in.h')
-rw-r--r--gl/unistd.in.h1182
1 files changed, 941 insertions, 241 deletions
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index fa8d84a..45fc5dc 100644
--- a/gl/unistd.in.h
+++ b/gl/unistd.in.h
@@ -1,5 +1,5 @@
1/* Substitute for and wrapper around <unistd.h>. 1/* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2009 Free Software Foundation, Inc. 2 Copyright (C) 2003-2010 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -15,77 +15,171 @@
15 along with this program; if not, write to the Free Software Foundation, 15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 17
18#ifndef _GL_UNISTD_H
19
20#if __GNUC__ >= 3 18#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
22#endif 20#endif
23 21
22/* Special invocation convention:
23 - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
24 but we need to ensure that both the system <unistd.h> and <winsock2.h>
25 are completely included before we replace gethostname. */
26#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
27 && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
28/* <unistd.h> is being indirectly included for the first time from
29 <winsock2.h>; avoid declaring any overrides. */
30# if @HAVE_UNISTD_H@
31# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
32# else
33# error unexpected; report this to bug-gnulib@gnu.org
34# endif
35# define _GL_WINSOCK2_H_WITNESS
36
37/* Normal invocation. */
38#elif !defined _GL_UNISTD_H
39
24/* The include_next requires a split double-inclusion guard. */ 40/* The include_next requires a split double-inclusion guard. */
25#if @HAVE_UNISTD_H@ 41#if @HAVE_UNISTD_H@
26# @INCLUDE_NEXT@ @NEXT_UNISTD_H@ 42# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
27#endif 43#endif
28 44
29#ifndef _GL_UNISTD_H 45/* Get all possible declarations of gethostname(). */
46#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
47 && !defined _GL_INCLUDING_WINSOCK2_H
48# define _GL_INCLUDING_WINSOCK2_H
49# include <winsock2.h>
50# undef _GL_INCLUDING_WINSOCK2_H
51#endif
52
53#if !defined _GL_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
30#define _GL_UNISTD_H 54#define _GL_UNISTD_H
31 55
56/* NetBSD 5.0 mis-defines NULL. Also get size_t. */
57#include <stddef.h>
58
32/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */ 59/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
33#if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) 60/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
61/* But avoid namespace pollution on glibc systems. */
62#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
63 || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \
64 && ! defined __GLIBC__
34# include <stdio.h> 65# include <stdio.h>
35#endif 66#endif
36 67
68/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
69/* But avoid namespace pollution on glibc systems. */
70#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
71# include <fcntl.h>
72#endif
73
37/* mingw fails to declare _exit in <unistd.h>. */ 74/* mingw fails to declare _exit in <unistd.h>. */
38/* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */ 75/* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
39#include <stdlib.h> 76/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
77/* But avoid namespace pollution on glibc systems. */
78#ifndef __GLIBC__
79# include <stdlib.h>
80#endif
40 81
41#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@ 82/* mingw declares getcwd in <io.h>, not in <unistd.h>. */
83#if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
84 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
85# include <io.h>
86#endif
87
88#if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
89 || @GNULIB_PREAD@ || defined GNULIB_POSIXCHECK)
42/* Get ssize_t. */ 90/* Get ssize_t. */
43# include <sys/types.h> 91# include <sys/types.h>
44#endif 92#endif
45 93
94/* Get getopt(), optarg, optind, opterr, optopt.
95 But avoid namespace pollution on glibc systems. */
96#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
97# include <getopt.h>
98#endif
99
100/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
101
102/* The definition of _GL_ARG_NONNULL is copied here. */
103
104/* The definition of _GL_WARN_ON_USE is copied here. */
105
106
46#if @GNULIB_GETHOSTNAME@ 107#if @GNULIB_GETHOSTNAME@
47/* Get all possible declarations of gethostname(). */ 108/* Get all possible declarations of gethostname(). */
48# if @UNISTD_H_HAVE_WINSOCK2_H@ 109# if @UNISTD_H_HAVE_WINSOCK2_H@
49# include <winsock2.h>
50# if !defined _GL_SYS_SOCKET_H 110# if !defined _GL_SYS_SOCKET_H
51# undef socket 111# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
52# define socket socket_used_without_including_sys_socket_h 112# undef socket
53# undef connect 113# define socket socket_used_without_including_sys_socket_h
54# define connect connect_used_without_including_sys_socket_h 114# undef connect
55# undef accept 115# define connect connect_used_without_including_sys_socket_h
56# define accept accept_used_without_including_sys_socket_h 116# undef accept
57# undef bind 117# define accept accept_used_without_including_sys_socket_h
58# define bind bind_used_without_including_sys_socket_h 118# undef bind
59# undef getpeername 119# define bind bind_used_without_including_sys_socket_h
60# define getpeername getpeername_used_without_including_sys_socket_h 120# undef getpeername
61# undef getsockname 121# define getpeername getpeername_used_without_including_sys_socket_h
62# define getsockname getsockname_used_without_including_sys_socket_h 122# undef getsockname
63# undef getsockopt 123# define getsockname getsockname_used_without_including_sys_socket_h
64# define getsockopt getsockopt_used_without_including_sys_socket_h 124# undef getsockopt
65# undef listen 125# define getsockopt getsockopt_used_without_including_sys_socket_h
66# define listen listen_used_without_including_sys_socket_h 126# undef listen
67# undef recv 127# define listen listen_used_without_including_sys_socket_h
68# define recv recv_used_without_including_sys_socket_h 128# undef recv
69# undef send 129# define recv recv_used_without_including_sys_socket_h
70# define send send_used_without_including_sys_socket_h 130# undef send
71# undef recvfrom 131# define send send_used_without_including_sys_socket_h
72# define recvfrom recvfrom_used_without_including_sys_socket_h 132# undef recvfrom
73# undef sendto 133# define recvfrom recvfrom_used_without_including_sys_socket_h
74# define sendto sendto_used_without_including_sys_socket_h 134# undef sendto
75# undef setsockopt 135# define sendto sendto_used_without_including_sys_socket_h
76# define setsockopt setsockopt_used_without_including_sys_socket_h 136# undef setsockopt
77# undef shutdown 137# define setsockopt setsockopt_used_without_including_sys_socket_h
78# define shutdown shutdown_used_without_including_sys_socket_h 138# undef shutdown
139# define shutdown shutdown_used_without_including_sys_socket_h
140# else
141 _GL_WARN_ON_USE (socket,
142 "socket() used without including <sys/socket.h>");
143 _GL_WARN_ON_USE (connect,
144 "connect() used without including <sys/socket.h>");
145 _GL_WARN_ON_USE (accept,
146 "accept() used without including <sys/socket.h>");
147 _GL_WARN_ON_USE (bind,
148 "bind() used without including <sys/socket.h>");
149 _GL_WARN_ON_USE (getpeername,
150 "getpeername() used without including <sys/socket.h>");
151 _GL_WARN_ON_USE (getsockname,
152 "getsockname() used without including <sys/socket.h>");
153 _GL_WARN_ON_USE (getsockopt,
154 "getsockopt() used without including <sys/socket.h>");
155 _GL_WARN_ON_USE (listen,
156 "listen() used without including <sys/socket.h>");
157 _GL_WARN_ON_USE (recv,
158 "recv() used without including <sys/socket.h>");
159 _GL_WARN_ON_USE (send,
160 "send() used without including <sys/socket.h>");
161 _GL_WARN_ON_USE (recvfrom,
162 "recvfrom() used without including <sys/socket.h>");
163 _GL_WARN_ON_USE (sendto,
164 "sendto() used without including <sys/socket.h>");
165 _GL_WARN_ON_USE (setsockopt,
166 "setsockopt() used without including <sys/socket.h>");
167 _GL_WARN_ON_USE (shutdown,
168 "shutdown() used without including <sys/socket.h>");
169# endif
79# endif 170# endif
80# if !defined _GL_SYS_SELECT_H 171# if !defined _GL_SYS_SELECT_H
81# undef select 172# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
82# define select select_used_without_including_sys_select_h 173# undef select
174# define select select_used_without_including_sys_select_h
175# else
176 _GL_WARN_ON_USE (select,
177 "select() used without including <sys/select.h>");
178# endif
83# endif 179# endif
84# endif 180# endif
85#endif 181#endif
86 182
87/* The definition of GL_LINK_WARNING is copied here. */
88
89 183
90/* OS/2 EMX lacks these macros. */ 184/* OS/2 EMX lacks these macros. */
91#ifndef STDIN_FILENO 185#ifndef STDIN_FILENO
@@ -98,72 +192,147 @@
98# define STDERR_FILENO 2 192# define STDERR_FILENO 2
99#endif 193#endif
100 194
195/* Ensure *_OK macros exist. */
196#ifndef F_OK
197# define F_OK 0
198# define X_OK 1
199# define W_OK 2
200# define R_OK 4
201#endif
202
203
101/* Declare overridden functions. */ 204/* Declare overridden functions. */
102 205
103#ifdef __cplusplus 206
104extern "C" { 207#if defined GNULIB_POSIXCHECK
208/* The access() function is a security risk. */
209_GL_WARN_ON_USE (access, "the access function is a security risk - "
210 "use the gnulib module faccessat instead");
105#endif 211#endif
106 212
107 213
108#if @GNULIB_CHOWN@ 214#if @GNULIB_CHOWN@
109# if @REPLACE_CHOWN@
110# ifndef REPLACE_CHOWN
111# define REPLACE_CHOWN 1
112# endif
113# if REPLACE_CHOWN
114/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE 215/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
115 to GID (if GID is not -1). Follow symbolic links. 216 to GID (if GID is not -1). Follow symbolic links.
116 Return 0 if successful, otherwise -1 and errno set. 217 Return 0 if successful, otherwise -1 and errno set.
117 See the POSIX:2001 specification 218 See the POSIX:2001 specification
118 <http://www.opengroup.org/susv3xsh/chown.html>. */ 219 <http://www.opengroup.org/susv3xsh/chown.html>. */
220# if @REPLACE_CHOWN@
221# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
222# undef chown
119# define chown rpl_chown 223# define chown rpl_chown
120extern int chown (const char *file, uid_t uid, gid_t gid);
121# endif 224# endif
225_GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
226 _GL_ARG_NONNULL ((1)));
227_GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
228# else
229# if !@HAVE_CHOWN@
230_GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
231 _GL_ARG_NONNULL ((1)));
232# endif
233_GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
122# endif 234# endif
235_GL_CXXALIASWARN (chown);
123#elif defined GNULIB_POSIXCHECK 236#elif defined GNULIB_POSIXCHECK
124# undef chown 237# undef chown
125# define chown(f,u,g) \ 238# if HAVE_RAW_DECL_CHOWN
126 (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \ 239_GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
127 "doesn't treat a uid or gid of -1 on some systems - " \ 240 "doesn't treat a uid or gid of -1 on some systems - "
128 "use gnulib module chown for portability"), \ 241 "use gnulib module chown for portability");
129 chown (f, u, g)) 242# endif
130#endif 243#endif
131 244
132 245
133#if @GNULIB_CLOSE@ 246#if @GNULIB_CLOSE@
134# if @REPLACE_CLOSE@ 247# if @REPLACE_CLOSE@
135/* Automatically included by modules that need a replacement for close. */ 248/* Automatically included by modules that need a replacement for close. */
136# undef close 249# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
137# define close rpl_close 250# undef close
138extern int close (int); 251# define close rpl_close
252# endif
253_GL_FUNCDECL_RPL (close, int, (int fd));
254_GL_CXXALIAS_RPL (close, int, (int fd));
255# else
256_GL_CXXALIAS_SYS (close, int, (int fd));
139# endif 257# endif
140#elif @UNISTD_H_HAVE_WINSOCK2_H@ 258_GL_CXXALIASWARN (close);
259#elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
141# undef close 260# undef close
142# define close close_used_without_requesting_gnulib_module_close 261# define close close_used_without_requesting_gnulib_module_close
143#elif defined GNULIB_POSIXCHECK 262#elif defined GNULIB_POSIXCHECK
144# undef close 263# undef close
145# define close(f) \ 264/* Assume close is always declared. */
146 (GL_LINK_WARNING ("close does not portably work on sockets - " \ 265_GL_WARN_ON_USE (close, "close does not portably work on sockets - "
147 "use gnulib module close for portability"), \ 266 "use gnulib module close for portability");
148 close (f)) 267#endif
268
269
270#if @REPLACE_DUP@
271# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
272# define dup rpl_dup
273# endif
274_GL_FUNCDECL_RPL (dup, int, (int oldfd));
275_GL_CXXALIAS_RPL (dup, int, (int oldfd));
276#else
277_GL_CXXALIAS_SYS (dup, int, (int oldfd));
149#endif 278#endif
279_GL_CXXALIASWARN (dup);
150 280
151 281
152#if @GNULIB_DUP2@ 282#if @GNULIB_DUP2@
153# if !@HAVE_DUP2@
154/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if 283/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
155 NEWFD = OLDFD, otherwise close NEWFD first if it is open. 284 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
156 Return 0 if successful, otherwise -1 and errno set. 285 Return newfd if successful, otherwise -1 and errno set.
157 See the POSIX:2001 specification 286 See the POSIX:2001 specification
158 <http://www.opengroup.org/susv3xsh/dup2.html>. */ 287 <http://www.opengroup.org/susv3xsh/dup2.html>. */
159extern int dup2 (int oldfd, int newfd); 288# if @REPLACE_DUP2@
289# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
290# define dup2 rpl_dup2
291# endif
292_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
293_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
294# else
295# if !@HAVE_DUP2@
296_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
297# endif
298_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
160# endif 299# endif
300_GL_CXXALIASWARN (dup2);
161#elif defined GNULIB_POSIXCHECK 301#elif defined GNULIB_POSIXCHECK
162# undef dup2 302# undef dup2
163# define dup2(o,n) \ 303# if HAVE_RAW_DECL_DUP2
164 (GL_LINK_WARNING ("dup2 is unportable - " \ 304_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
165 "use gnulib module dup2 for portability"), \ 305 "use gnulib module dup2 for portability");
166 dup2 (o, n)) 306# endif
307#endif
308
309
310#if @GNULIB_DUP3@
311/* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
312 specified flags.
313 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
314 and O_TEXT, O_BINARY (defined in "binary-io.h").
315 Close NEWFD first if it is open.
316 Return newfd if successful, otherwise -1 and errno set.
317 See the Linux man page at
318 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
319# if @HAVE_DUP3@
320# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
321# define dup3 rpl_dup3
322# endif
323_GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
324_GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
325# else
326_GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
327_GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
328# endif
329_GL_CXXALIASWARN (dup3);
330#elif defined GNULIB_POSIXCHECK
331# undef dup3
332# if HAVE_RAW_DECL_DUP3
333_GL_WARN_ON_USE (dup3, "dup3 is unportable - "
334 "use gnulib module dup3 for portability");
335# endif
167#endif 336#endif
168 337
169 338
@@ -175,55 +344,126 @@ extern int dup2 (int oldfd, int newfd);
175# include <crt_externs.h> 344# include <crt_externs.h>
176# define environ (*_NSGetEnviron ()) 345# define environ (*_NSGetEnviron ())
177# else 346# else
347# ifdef __cplusplus
348extern "C" {
349# endif
178extern char **environ; 350extern char **environ;
351# ifdef __cplusplus
352}
353# endif
179# endif 354# endif
180# endif 355# endif
181#elif defined GNULIB_POSIXCHECK 356#elif defined GNULIB_POSIXCHECK
182# undef environ 357# if HAVE_RAW_DECL_ENVIRON
183# define environ \ 358static inline char ***
184 (GL_LINK_WARNING ("environ is unportable - " \ 359rpl_environ (void)
185 "use gnulib module environ for portability"), \ 360{
186 environ) 361 return &environ;
362}
363_GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
364 "use gnulib module environ for portability");
365# undef environ
366# define environ (*rpl_environ ())
367# endif
187#endif 368#endif
188 369
189 370
190#if @GNULIB_EUIDACCESS@ 371#if @GNULIB_EUIDACCESS@
191# if !@HAVE_EUIDACCESS@ 372/* Like access(), except that it uses the effective user id and group id of
192/* Like access(), except that is uses the effective user id and group id of
193 the current process. */ 373 the current process. */
194extern int euidaccess (const char *filename, int mode); 374# if !@HAVE_EUIDACCESS@
375_GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
376 _GL_ARG_NONNULL ((1)));
377# endif
378_GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
379_GL_CXXALIASWARN (euidaccess);
380# if defined GNULIB_POSIXCHECK
381/* Like access(), this function is a security risk. */
382_GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
383 "use the gnulib module faccessat instead");
195# endif 384# endif
196#elif defined GNULIB_POSIXCHECK 385#elif defined GNULIB_POSIXCHECK
197# undef euidaccess 386# undef euidaccess
198# define euidaccess(f,m) \ 387# if HAVE_RAW_DECL_EUIDACCESS
199 (GL_LINK_WARNING ("euidaccess is unportable - " \ 388_GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
200 "use gnulib module euidaccess for portability"), \ 389 "use gnulib module euidaccess for portability");
201 euidaccess (f, m)) 390# endif
202#endif 391#endif
203 392
204 393
205#if @GNULIB_FCHDIR@ 394#if @GNULIB_FACCESSAT@
206# if @REPLACE_FCHDIR@ 395# if !@HAVE_FACCESSAT@
396_GL_FUNCDECL_SYS (faccessat, int,
397 (int fd, char const *file, int mode, int flag)
398 _GL_ARG_NONNULL ((2)));
399# endif
400_GL_CXXALIAS_SYS (faccessat, int,
401 (int fd, char const *file, int mode, int flag));
402_GL_CXXALIASWARN (faccessat);
403#elif defined GNULIB_POSIXCHECK
404# undef faccessat
405# if HAVE_RAW_DECL_FACCESSAT
406_GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
407 "use gnulib module faccessat for portability");
408# endif
409#endif
207 410
411
412#if @GNULIB_FCHDIR@
208/* Change the process' current working directory to the directory on which 413/* Change the process' current working directory to the directory on which
209 the given file descriptor is open. 414 the given file descriptor is open.
210 Return 0 if successful, otherwise -1 and errno set. 415 Return 0 if successful, otherwise -1 and errno set.
211 See the POSIX:2001 specification 416 See the POSIX:2001 specification
212 <http://www.opengroup.org/susv3xsh/fchdir.html>. */ 417 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
213extern int fchdir (int /*fd*/); 418# if ! @HAVE_FCHDIR@
419_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
214 420
215# define dup rpl_dup 421/* Gnulib internal hooks needed to maintain the fchdir metadata. */
216extern int dup (int); 422_GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
217# define dup2 rpl_dup2 423 _GL_ARG_NONNULL ((2));
218extern int dup2 (int, int); 424_GL_EXTERN_C void _gl_unregister_fd (int fd);
425_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
426_GL_EXTERN_C const char *_gl_directory_name (int fd);
219 427
220# endif 428# endif
429_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
430_GL_CXXALIASWARN (fchdir);
221#elif defined GNULIB_POSIXCHECK 431#elif defined GNULIB_POSIXCHECK
222# undef fchdir 432# undef fchdir
223# define fchdir(f) \ 433# if HAVE_RAW_DECL_FCHDIR
224 (GL_LINK_WARNING ("fchdir is unportable - " \ 434_GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
225 "use gnulib module fchdir for portability"), \ 435 "use gnulib module fchdir for portability");
226 fchdir (f)) 436# endif
437#endif
438
439
440#if @GNULIB_FCHOWNAT@
441# if @REPLACE_FCHOWNAT@
442# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
443# undef fchownat
444# define fchownat rpl_fchownat
445# endif
446_GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
447 uid_t owner, gid_t group, int flag)
448 _GL_ARG_NONNULL ((2)));
449_GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
450 uid_t owner, gid_t group, int flag));
451# else
452# if !@HAVE_FCHOWNAT@
453_GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
454 uid_t owner, gid_t group, int flag)
455 _GL_ARG_NONNULL ((2)));
456# endif
457_GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
458 uid_t owner, gid_t group, int flag));
459# endif
460_GL_CXXALIASWARN (fchownat);
461#elif defined GNULIB_POSIXCHECK
462# undef fchownat
463# if HAVE_RAW_DECL_FCHOWNAT
464_GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
465 "use gnulib module openat for portability");
466# endif
227#endif 467#endif
228 468
229 469
@@ -233,39 +473,39 @@ extern int dup2 (int, int);
233 See POSIX:2001 specification 473 See POSIX:2001 specification
234 <http://www.opengroup.org/susv3xsh/fsync.html>. */ 474 <http://www.opengroup.org/susv3xsh/fsync.html>. */
235# if !@HAVE_FSYNC@ 475# if !@HAVE_FSYNC@
236extern int fsync (int fd); 476_GL_FUNCDECL_SYS (fsync, int, (int fd));
237# endif 477# endif
478_GL_CXXALIAS_SYS (fsync, int, (int fd));
479_GL_CXXALIASWARN (fsync);
238#elif defined GNULIB_POSIXCHECK 480#elif defined GNULIB_POSIXCHECK
239# undef fsync 481# undef fsync
240# define fsync(fd) \ 482# if HAVE_RAW_DECL_FSYNC
241 (GL_LINK_WARNING ("fsync is unportable - " \ 483_GL_WARN_ON_USE (fsync, "fsync is unportable - "
242 "use gnulib module fsync for portability"), \ 484 "use gnulib module fsync for portability");
243 fsync (fd)) 485# endif
244#endif 486#endif
245 487
246 488
247#if @GNULIB_FTRUNCATE@ 489#if @GNULIB_FTRUNCATE@
248# if !@HAVE_FTRUNCATE@
249/* Change the size of the file to which FD is opened to become equal to LENGTH. 490/* Change the size of the file to which FD is opened to become equal to LENGTH.
250 Return 0 if successful, otherwise -1 and errno set. 491 Return 0 if successful, otherwise -1 and errno set.
251 See the POSIX:2001 specification 492 See the POSIX:2001 specification
252 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */ 493 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
253extern int ftruncate (int fd, off_t length); 494# if !@HAVE_FTRUNCATE@
495_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
254# endif 496# endif
497_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
498_GL_CXXALIASWARN (ftruncate);
255#elif defined GNULIB_POSIXCHECK 499#elif defined GNULIB_POSIXCHECK
256# undef ftruncate 500# undef ftruncate
257# define ftruncate(f,l) \ 501# if HAVE_RAW_DECL_FTRUNCATE
258 (GL_LINK_WARNING ("ftruncate is unportable - " \ 502_GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
259 "use gnulib module ftruncate for portability"), \ 503 "use gnulib module ftruncate for portability");
260 ftruncate (f, l)) 504# endif
261#endif 505#endif
262 506
263 507
264#if @GNULIB_GETCWD@ 508#if @GNULIB_GETCWD@
265/* Include the headers that might declare getcwd so that they will not
266 cause confusion if included after this file. */
267# include <stdlib.h>
268# if @REPLACE_GETCWD@
269/* Get the name of the current working directory, and put it in SIZE bytes 509/* Get the name of the current working directory, and put it in SIZE bytes
270 of BUF. 510 of BUF.
271 Return BUF if successful, or NULL if the directory couldn't be determined 511 Return BUF if successful, or NULL if the directory couldn't be determined
@@ -276,15 +516,24 @@ extern int ftruncate (int fd, off_t length);
276 extension: If BUF is NULL, an array is allocated with 'malloc'; the array 516 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
277 is SIZE bytes long, unless SIZE == 0, in which case it is as big as 517 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
278 necessary. */ 518 necessary. */
279# define getcwd rpl_getcwd 519# if @REPLACE_GETCWD@
280extern char * getcwd (char *buf, size_t size); 520# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
521# define getcwd rpl_getcwd
522# endif
523_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
524_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
525# else
526/* Need to cast, because on mingw, the second parameter is
527 int size. */
528_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
281# endif 529# endif
530_GL_CXXALIASWARN (getcwd);
282#elif defined GNULIB_POSIXCHECK 531#elif defined GNULIB_POSIXCHECK
283# undef getcwd 532# undef getcwd
284# define getcwd(b,s) \ 533# if HAVE_RAW_DECL_GETCWD
285 (GL_LINK_WARNING ("getcwd is unportable - " \ 534_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
286 "use gnulib module getcwd for portability"), \ 535 "use gnulib module getcwd for portability");
287 getcwd (b, s)) 536# endif
288#endif 537#endif
289 538
290 539
@@ -300,28 +549,65 @@ extern char * getcwd (char *buf, size_t size);
300 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1. 549 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
301 Return 0 if successful, otherwise set errno and return -1. */ 550 Return 0 if successful, otherwise set errno and return -1. */
302# if !@HAVE_GETDOMAINNAME@ 551# if !@HAVE_GETDOMAINNAME@
303extern int getdomainname(char *name, size_t len); 552_GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
553 _GL_ARG_NONNULL ((1)));
304# endif 554# endif
555/* Need to cast, because on MacOS X 10.5 systems, the second parameter is
556 int len. */
557_GL_CXXALIAS_SYS_CAST (getdomainname, int, (char *name, size_t len));
558_GL_CXXALIASWARN (getdomainname);
305#elif defined GNULIB_POSIXCHECK 559#elif defined GNULIB_POSIXCHECK
306# undef getdomainname 560# undef getdomainname
307# define getdomainname(n,l) \ 561# if HAVE_RAW_DECL_GETDOMAINNAME
308 (GL_LINK_WARNING ("getdomainname is unportable - " \ 562_GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
309 "use gnulib module getdomainname for portability"), \ 563 "use gnulib module getdomainname for portability");
310 getdomainname (n, l)) 564# endif
311#endif 565#endif
312 566
313 567
314#if @GNULIB_GETDTABLESIZE@ 568#if @GNULIB_GETDTABLESIZE@
569/* Return the maximum number of file descriptors in the current process.
570 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
315# if !@HAVE_GETDTABLESIZE@ 571# if !@HAVE_GETDTABLESIZE@
316/* Return the maximum number of file descriptors in the current process. */ 572_GL_FUNCDECL_SYS (getdtablesize, int, (void));
317extern int getdtablesize (void);
318# endif 573# endif
574_GL_CXXALIAS_SYS (getdtablesize, int, (void));
575_GL_CXXALIASWARN (getdtablesize);
319#elif defined GNULIB_POSIXCHECK 576#elif defined GNULIB_POSIXCHECK
320# undef getdtablesize 577# undef getdtablesize
321# define getdtablesize() \ 578# if HAVE_RAW_DECL_GETDTABLESIZE
322 (GL_LINK_WARNING ("getdtablesize is unportable - " \ 579_GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
323 "use gnulib module getdtablesize for portability"), \ 580 "use gnulib module getdtablesize for portability");
324 getdtablesize ()) 581# endif
582#endif
583
584
585#if @GNULIB_GETGROUPS@
586/* Return the supplemental groups that the current process belongs to.
587 It is unspecified whether the effective group id is in the list.
588 If N is 0, return the group count; otherwise, N describes how many
589 entries are available in GROUPS. Return -1 and set errno if N is
590 not 0 and not large enough. Fails with ENOSYS on some systems. */
591# if @REPLACE_GETGROUPS@
592# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
593# undef getgroups
594# define getgroups rpl_getgroups
595# endif
596_GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
597_GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
598# else
599# if !@HAVE_GETGROUPS@
600_GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
601# endif
602_GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
603# endif
604_GL_CXXALIASWARN (getgroups);
605#elif defined GNULIB_POSIXCHECK
606# undef getgroups
607# if HAVE_RAW_DECL_GETGROUPS
608_GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
609 "use gnulib module getgroups for portability");
610# endif
325#endif 611#endif
326 612
327 613
@@ -334,21 +620,57 @@ extern int getdtablesize (void);
334 If the host name is longer than LEN, set errno = EINVAL and return -1. 620 If the host name is longer than LEN, set errno = EINVAL and return -1.
335 Return 0 if successful, otherwise set errno and return -1. */ 621 Return 0 if successful, otherwise set errno and return -1. */
336# if @UNISTD_H_HAVE_WINSOCK2_H@ 622# if @UNISTD_H_HAVE_WINSOCK2_H@
337# undef gethostname 623# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
338# define gethostname rpl_gethostname 624# undef gethostname
339# endif 625# define gethostname rpl_gethostname
340# if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@ 626# endif
341extern int gethostname(char *name, size_t len); 627_GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
628 _GL_ARG_NONNULL ((1)));
629_GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
630# else
631# if !@HAVE_GETHOSTNAME@
632_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
633 _GL_ARG_NONNULL ((1)));
634# endif
635/* Need to cast, because on Solaris 10 systems, the second parameter is
636 int len. */
637_GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
342# endif 638# endif
639_GL_CXXALIASWARN (gethostname);
343#elif @UNISTD_H_HAVE_WINSOCK2_H@ 640#elif @UNISTD_H_HAVE_WINSOCK2_H@
344# undef gethostname 641# undef gethostname
345# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname 642# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
346#elif defined GNULIB_POSIXCHECK 643#elif defined GNULIB_POSIXCHECK
347# undef gethostname 644# undef gethostname
348# define gethostname(n,l) \ 645# if HAVE_RAW_DECL_GETHOSTNAME
349 (GL_LINK_WARNING ("gethostname is unportable - " \ 646_GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
350 "use gnulib module gethostname for portability"), \ 647 "use gnulib module gethostname for portability");
351 gethostname (n, l)) 648# endif
649#endif
650
651
652#if @GNULIB_GETLOGIN@
653/* Returns the user's login name, or NULL if it cannot be found. Upon error,
654 returns NULL with errno set.
655
656 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
657
658 Most programs don't need to use this function, because the information is
659 available through environment variables:
660 ${LOGNAME-$USER} on Unix platforms,
661 $USERNAME on native Windows platforms.
662 */
663# if !@HAVE_GETLOGIN@
664_GL_FUNCDECL_SYS (getlogin, char *, (void));
665# endif
666_GL_CXXALIAS_SYS (getlogin, char *, (void));
667_GL_CXXALIASWARN (getlogin);
668#elif defined GNULIB_POSIXCHECK
669# undef getlogin
670# if HAVE_RAW_DECL_GETLOGIN
671_GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
672 "use gnulib module getlogin for portability");
673# endif
352#endif 674#endif
353 675
354 676
@@ -361,124 +683,184 @@ extern int gethostname(char *name, size_t len);
361 provided (this case is hopefully rare but is left open by the POSIX spec). 683 provided (this case is hopefully rare but is left open by the POSIX spec).
362 684
363 See <http://www.opengroup.org/susv3xsh/getlogin.html>. 685 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
686
687 Most programs don't need to use this function, because the information is
688 available through environment variables:
689 ${LOGNAME-$USER} on Unix platforms,
690 $USERNAME on native Windows platforms.
364 */ 691 */
365# if !@HAVE_DECL_GETLOGIN_R@ 692# if !@HAVE_DECL_GETLOGIN_R@
366# include <stddef.h> 693_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
367extern int getlogin_r (char *name, size_t size); 694 _GL_ARG_NONNULL ((1)));
368# endif 695# endif
696/* Need to cast, because on Solaris 10 systems, the second argument is
697 int size. */
698_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
699_GL_CXXALIASWARN (getlogin_r);
369#elif defined GNULIB_POSIXCHECK 700#elif defined GNULIB_POSIXCHECK
370# undef getlogin_r 701# undef getlogin_r
371# define getlogin_r(n,s) \ 702# if HAVE_RAW_DECL_GETLOGIN_R
372 (GL_LINK_WARNING ("getlogin_r is unportable - " \ 703_GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
373 "use gnulib module getlogin_r for portability"), \ 704 "use gnulib module getlogin_r for portability");
374 getlogin_r (n, s)) 705# endif
375#endif 706#endif
376 707
377 708
378#if @GNULIB_GETPAGESIZE@ 709#if @GNULIB_GETPAGESIZE@
379# if @REPLACE_GETPAGESIZE@ 710# if @REPLACE_GETPAGESIZE@
380# define getpagesize rpl_getpagesize 711# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
381extern int getpagesize (void); 712# define getpagesize rpl_getpagesize
382# elif !@HAVE_GETPAGESIZE@
383/* This is for POSIX systems. */
384# if !defined getpagesize && defined _SC_PAGESIZE
385# if ! (defined __VMS && __VMS_VER < 70000000)
386# define getpagesize() sysconf (_SC_PAGESIZE)
387# endif
388# endif 713# endif
714_GL_FUNCDECL_RPL (getpagesize, int, (void));
715_GL_CXXALIAS_RPL (getpagesize, int, (void));
716# else
717# if !@HAVE_GETPAGESIZE@
718# if !defined getpagesize
719/* This is for POSIX systems. */
720# if !defined _gl_getpagesize && defined _SC_PAGESIZE
721# if ! (defined __VMS && __VMS_VER < 70000000)
722# define _gl_getpagesize() sysconf (_SC_PAGESIZE)
723# endif
724# endif
389/* This is for older VMS. */ 725/* This is for older VMS. */
390# if !defined getpagesize && defined __VMS 726# if !defined _gl_getpagesize && defined __VMS
391# ifdef __ALPHA 727# ifdef __ALPHA
392# define getpagesize() 8192 728# define _gl_getpagesize() 8192
393# else 729# else
394# define getpagesize() 512 730# define _gl_getpagesize() 512
395# endif 731# endif
396# endif 732# endif
397/* This is for BeOS. */ 733/* This is for BeOS. */
398# if !defined getpagesize && @HAVE_OS_H@ 734# if !defined _gl_getpagesize && @HAVE_OS_H@
399# include <OS.h> 735# include <OS.h>
400# if defined B_PAGE_SIZE 736# if defined B_PAGE_SIZE
401# define getpagesize() B_PAGE_SIZE 737# define _gl_getpagesize() B_PAGE_SIZE
402# endif 738# endif
403# endif 739# endif
404/* This is for AmigaOS4.0. */ 740/* This is for AmigaOS4.0. */
405# if !defined getpagesize && defined __amigaos4__ 741# if !defined _gl_getpagesize && defined __amigaos4__
406# define getpagesize() 2048 742# define _gl_getpagesize() 2048
407# endif 743# endif
408/* This is for older Unix systems. */ 744/* This is for older Unix systems. */
409# if !defined getpagesize && @HAVE_SYS_PARAM_H@ 745# if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
410# include <sys/param.h> 746# include <sys/param.h>
411# ifdef EXEC_PAGESIZE 747# ifdef EXEC_PAGESIZE
412# define getpagesize() EXEC_PAGESIZE 748# define _gl_getpagesize() EXEC_PAGESIZE
413# else 749# else
414# ifdef NBPG 750# ifdef NBPG
415# ifndef CLSIZE 751# ifndef CLSIZE
416# define CLSIZE 1 752# define CLSIZE 1
753# endif
754# define _gl_getpagesize() (NBPG * CLSIZE)
755# else
756# ifdef NBPC
757# define _gl_getpagesize() NBPC
758# endif
759# endif
417# endif 760# endif
418# define getpagesize() (NBPG * CLSIZE) 761# endif
762# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
763# define getpagesize() _gl_getpagesize ()
419# else 764# else
420# ifdef NBPC 765static inline int
421# define getpagesize() NBPC 766getpagesize ()
422# endif 767{
768 return _gl_getpagesize ();
769}
423# endif 770# endif
424# endif 771# endif
425# endif 772# endif
773/* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
774_GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
775# endif
776# if @HAVE_DECL_GETPAGESIZE@
777_GL_CXXALIASWARN (getpagesize);
426# endif 778# endif
427#elif defined GNULIB_POSIXCHECK 779#elif defined GNULIB_POSIXCHECK
428# undef getpagesize 780# undef getpagesize
429# define getpagesize() \ 781# if HAVE_RAW_DECL_GETPAGESIZE
430 (GL_LINK_WARNING ("getpagesize is unportable - " \ 782_GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
431 "use gnulib module getpagesize for portability"), \ 783 "use gnulib module getpagesize for portability");
432 getpagesize ()) 784# endif
433#endif 785#endif
434 786
435 787
436#if @GNULIB_GETUSERSHELL@ 788#if @GNULIB_GETUSERSHELL@
437# if !@HAVE_GETUSERSHELL@
438/* Return the next valid login shell on the system, or NULL when the end of 789/* Return the next valid login shell on the system, or NULL when the end of
439 the list has been reached. */ 790 the list has been reached. */
440extern char *getusershell (void); 791# if !@HAVE_DECL_GETUSERSHELL@
792_GL_FUNCDECL_SYS (getusershell, char *, (void));
793# endif
794_GL_CXXALIAS_SYS (getusershell, char *, (void));
795_GL_CXXALIASWARN (getusershell);
796#elif defined GNULIB_POSIXCHECK
797# undef getusershell
798# if HAVE_RAW_DECL_GETUSERSHELL
799_GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
800 "use gnulib module getusershell for portability");
801# endif
802#endif
803
804#if @GNULIB_GETUSERSHELL@
441/* Rewind to pointer that is advanced at each getusershell() call. */ 805/* Rewind to pointer that is advanced at each getusershell() call. */
442extern void setusershell (void); 806# if !@HAVE_DECL_GETUSERSHELL@
807_GL_FUNCDECL_SYS (setusershell, void, (void));
808# endif
809_GL_CXXALIAS_SYS (setusershell, void, (void));
810_GL_CXXALIASWARN (setusershell);
811#elif defined GNULIB_POSIXCHECK
812# undef setusershell
813# if HAVE_RAW_DECL_SETUSERSHELL
814_GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
815 "use gnulib module getusershell for portability");
816# endif
817#endif
818
819#if @GNULIB_GETUSERSHELL@
443/* Free the pointer that is advanced at each getusershell() call and 820/* Free the pointer that is advanced at each getusershell() call and
444 associated resources. */ 821 associated resources. */
445extern void endusershell (void); 822# if !@HAVE_DECL_GETUSERSHELL@
823_GL_FUNCDECL_SYS (endusershell, void, (void));
446# endif 824# endif
825_GL_CXXALIAS_SYS (endusershell, void, (void));
826_GL_CXXALIASWARN (endusershell);
447#elif defined GNULIB_POSIXCHECK 827#elif defined GNULIB_POSIXCHECK
448# undef getusershell
449# define getusershell() \
450 (GL_LINK_WARNING ("getusershell is unportable - " \
451 "use gnulib module getusershell for portability"), \
452 getusershell ())
453# undef setusershell
454# define setusershell() \
455 (GL_LINK_WARNING ("setusershell is unportable - " \
456 "use gnulib module getusershell for portability"), \
457 setusershell ())
458# undef endusershell 828# undef endusershell
459# define endusershell() \ 829# if HAVE_RAW_DECL_ENDUSERSHELL
460 (GL_LINK_WARNING ("endusershell is unportable - " \ 830_GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
461 "use gnulib module getusershell for portability"), \ 831 "use gnulib module getusershell for portability");
462 endusershell ()) 832# endif
463#endif 833#endif
464 834
465 835
466#if @GNULIB_LCHOWN@ 836#if @GNULIB_LCHOWN@
467# if @REPLACE_LCHOWN@
468/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE 837/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
469 to GID (if GID is not -1). Do not follow symbolic links. 838 to GID (if GID is not -1). Do not follow symbolic links.
470 Return 0 if successful, otherwise -1 and errno set. 839 Return 0 if successful, otherwise -1 and errno set.
471 See the POSIX:2001 specification 840 See the POSIX:2001 specification
472 <http://www.opengroup.org/susv3xsh/lchown.html>. */ 841 <http://www.opengroup.org/susv3xsh/lchown.html>. */
473# define lchown rpl_lchown 842# if @REPLACE_LCHOWN@
474extern int lchown (char const *file, uid_t owner, gid_t group); 843# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
844# undef lchown
845# define lchown rpl_lchown
846# endif
847_GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
848 _GL_ARG_NONNULL ((1)));
849_GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
850# else
851# if !@HAVE_LCHOWN@
852_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
853 _GL_ARG_NONNULL ((1)));
854# endif
855_GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
475# endif 856# endif
857_GL_CXXALIASWARN (lchown);
476#elif defined GNULIB_POSIXCHECK 858#elif defined GNULIB_POSIXCHECK
477# undef lchown 859# undef lchown
478# define lchown(f,u,g) \ 860# if HAVE_RAW_DECL_LCHOWN
479 (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \ 861_GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
480 "systems - use gnulib module lchown for portability"), \ 862 "use gnulib module lchown for portability");
481 lchown (f, u, g)) 863# endif
482#endif 864#endif
483 865
484 866
@@ -487,33 +869,150 @@ extern int lchown (char const *file, uid_t owner, gid_t group);
487 Return 0 if successful, otherwise -1 and errno set. 869 Return 0 if successful, otherwise -1 and errno set.
488 See POSIX:2001 specification 870 See POSIX:2001 specification
489 <http://www.opengroup.org/susv3xsh/link.html>. */ 871 <http://www.opengroup.org/susv3xsh/link.html>. */
490# if !@HAVE_LINK@ 872# if @REPLACE_LINK@
491extern int link (const char *path1, const char *path2); 873# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
874# define link rpl_link
875# endif
876_GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
877 _GL_ARG_NONNULL ((1, 2)));
878_GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
879# else
880# if !@HAVE_LINK@
881_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
882 _GL_ARG_NONNULL ((1, 2)));
883# endif
884_GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
492# endif 885# endif
886_GL_CXXALIASWARN (link);
493#elif defined GNULIB_POSIXCHECK 887#elif defined GNULIB_POSIXCHECK
494# undef link 888# undef link
495# define link(path1,path2) \ 889# if HAVE_RAW_DECL_LINK
496 (GL_LINK_WARNING ("link is unportable - " \ 890_GL_WARN_ON_USE (link, "link is unportable - "
497 "use gnulib module link for portability"), \ 891 "use gnulib module link for portability");
498 link (path1, path2)) 892# endif
893#endif
894
895
896#if @GNULIB_LINKAT@
897/* Create a new hard link for an existing file, relative to two
898 directories. FLAG controls whether symlinks are followed.
899 Return 0 if successful, otherwise -1 and errno set. */
900# if @REPLACE_LINKAT@
901# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
902# undef linkat
903# define linkat rpl_linkat
904# endif
905_GL_FUNCDECL_RPL (linkat, int,
906 (int fd1, const char *path1, int fd2, const char *path2,
907 int flag)
908 _GL_ARG_NONNULL ((2, 4)));
909_GL_CXXALIAS_RPL (linkat, int,
910 (int fd1, const char *path1, int fd2, const char *path2,
911 int flag));
912# else
913# if !@HAVE_LINKAT@
914_GL_FUNCDECL_SYS (linkat, int,
915 (int fd1, const char *path1, int fd2, const char *path2,
916 int flag)
917 _GL_ARG_NONNULL ((2, 4)));
918# endif
919_GL_CXXALIAS_SYS (linkat, int,
920 (int fd1, const char *path1, int fd2, const char *path2,
921 int flag));
922# endif
923_GL_CXXALIASWARN (linkat);
924#elif defined GNULIB_POSIXCHECK
925# undef linkat
926# if HAVE_RAW_DECL_LINKAT
927_GL_WARN_ON_USE (linkat, "linkat is unportable - "
928 "use gnulib module linkat for portability");
929# endif
499#endif 930#endif
500 931
501 932
502#if @GNULIB_LSEEK@ 933#if @GNULIB_LSEEK@
503# if @REPLACE_LSEEK@
504/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. 934/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
505 Return the new offset if successful, otherwise -1 and errno set. 935 Return the new offset if successful, otherwise -1 and errno set.
506 See the POSIX:2001 specification 936 See the POSIX:2001 specification
507 <http://www.opengroup.org/susv3xsh/lseek.html>. */ 937 <http://www.opengroup.org/susv3xsh/lseek.html>. */
508# define lseek rpl_lseek 938# if @REPLACE_LSEEK@
509 extern off_t lseek (int fd, off_t offset, int whence); 939# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
940# define lseek rpl_lseek
941# endif
942_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
943_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
944# else
945_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
510# endif 946# endif
947_GL_CXXALIASWARN (lseek);
511#elif defined GNULIB_POSIXCHECK 948#elif defined GNULIB_POSIXCHECK
512# undef lseek 949# undef lseek
513# define lseek(f,o,w) \ 950# if HAVE_RAW_DECL_LSEEK
514 (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \ 951_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
515 "systems - use gnulib module lseek for portability"), \ 952 "systems - use gnulib module lseek for portability");
516 lseek (f, o, w)) 953# endif
954#endif
955
956
957#if @GNULIB_PIPE2@
958/* Create a pipe, applying the given flags when opening the read-end of the
959 pipe and the write-end of the pipe.
960 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
961 and O_TEXT, O_BINARY (defined in "binary-io.h").
962 Store the read-end as fd[0] and the write-end as fd[1].
963 Return 0 upon success, or -1 with errno set upon failure.
964 See also the Linux man page at
965 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
966# if @HAVE_PIPE2@
967# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
968# define pipe2 rpl_pipe2
969# endif
970_GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
971_GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
972# else
973_GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
974_GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
975# endif
976_GL_CXXALIASWARN (pipe2);
977#elif defined GNULIB_POSIXCHECK
978# undef pipe2
979# if HAVE_RAW_DECL_PIPE2
980_GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
981 "use gnulib module pipe2 for portability");
982# endif
983#endif
984
985
986#if @GNULIB_PREAD@
987/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
988 Return the number of bytes placed into BUF if successful, otherwise
989 set errno and return -1. 0 indicates EOF. See the POSIX:2001
990 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
991# if @REPLACE_PREAD@
992# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
993# define pread rpl_pread
994# endif
995_GL_FUNCDECL_RPL (pread, ssize_t,
996 (int fd, void *buf, size_t bufsize, off_t offset)
997 _GL_ARG_NONNULL ((2)));
998_GL_CXXALIAS_RPL (pread, ssize_t,
999 (int fd, void *buf, size_t bufsize, off_t offset));
1000# else
1001# if !@HAVE_PREAD@
1002_GL_FUNCDECL_SYS (pread, ssize_t,
1003 (int fd, void *buf, size_t bufsize, off_t offset)
1004 _GL_ARG_NONNULL ((2)));
1005# endif
1006_GL_CXXALIAS_SYS (pread, ssize_t,
1007 (int fd, void *buf, size_t bufsize, off_t offset));
1008# endif
1009_GL_CXXALIASWARN (pread);
1010#elif defined GNULIB_POSIXCHECK
1011# undef pread
1012# if HAVE_RAW_DECL_PREAD
1013_GL_WARN_ON_USE (pread, "pread is unportable - "
1014 "use gnulib module pread for portability");
1015# endif
517#endif 1016#endif
518 1017
519 1018
@@ -523,16 +1022,70 @@ extern int link (const char *path1, const char *path2);
523 successful, otherwise -1 and errno set. 1022 successful, otherwise -1 and errno set.
524 See the POSIX:2001 specification 1023 See the POSIX:2001 specification
525 <http://www.opengroup.org/susv3xsh/readlink.html>. */ 1024 <http://www.opengroup.org/susv3xsh/readlink.html>. */
526# if !@HAVE_READLINK@ 1025# if @REPLACE_READLINK@
527# include <stddef.h> 1026# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
528extern int readlink (const char *file, char *buf, size_t bufsize); 1027# define readlink rpl_readlink
1028# endif
1029_GL_FUNCDECL_RPL (readlink, ssize_t,
1030 (const char *file, char *buf, size_t bufsize)
1031 _GL_ARG_NONNULL ((1, 2)));
1032_GL_CXXALIAS_RPL (readlink, ssize_t,
1033 (const char *file, char *buf, size_t bufsize));
1034# else
1035# if !@HAVE_READLINK@
1036_GL_FUNCDECL_SYS (readlink, ssize_t,
1037 (const char *file, char *buf, size_t bufsize)
1038 _GL_ARG_NONNULL ((1, 2)));
1039# endif
1040_GL_CXXALIAS_SYS (readlink, ssize_t,
1041 (const char *file, char *buf, size_t bufsize));
529# endif 1042# endif
1043_GL_CXXALIASWARN (readlink);
530#elif defined GNULIB_POSIXCHECK 1044#elif defined GNULIB_POSIXCHECK
531# undef readlink 1045# undef readlink
532# define readlink(f,b,s) \ 1046# if HAVE_RAW_DECL_READLINK
533 (GL_LINK_WARNING ("readlink is unportable - " \ 1047_GL_WARN_ON_USE (readlink, "readlink is unportable - "
534 "use gnulib module readlink for portability"), \ 1048 "use gnulib module readlink for portability");
535 readlink (f, b, s)) 1049# endif
1050#endif
1051
1052
1053#if @GNULIB_READLINKAT@
1054# if !@HAVE_READLINKAT@
1055_GL_FUNCDECL_SYS (readlinkat, ssize_t,
1056 (int fd, char const *file, char *buf, size_t len)
1057 _GL_ARG_NONNULL ((2, 3)));
1058# endif
1059_GL_CXXALIAS_SYS (readlinkat, ssize_t,
1060 (int fd, char const *file, char *buf, size_t len));
1061_GL_CXXALIASWARN (readlinkat);
1062#elif defined GNULIB_POSIXCHECK
1063# undef readlinkat
1064# if HAVE_RAW_DECL_READLINKAT
1065_GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1066 "use gnulib module symlinkat for portability");
1067# endif
1068#endif
1069
1070
1071#if @GNULIB_RMDIR@
1072/* Remove the directory DIR. */
1073# if @REPLACE_RMDIR@
1074# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1075# define rmdir rpl_rmdir
1076# endif
1077_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1078_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1079# else
1080_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1081# endif
1082_GL_CXXALIASWARN (rmdir);
1083#elif defined GNULIB_POSIXCHECK
1084# undef rmdir
1085# if HAVE_RAW_DECL_RMDIR
1086_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1087 "use gnulib module rmdir for portability");
1088# endif
536#endif 1089#endif
537 1090
538 1091
@@ -541,36 +1094,183 @@ extern int readlink (const char *file, char *buf, size_t bufsize);
541 Returns the number of seconds left to sleep. 1094 Returns the number of seconds left to sleep.
542 See the POSIX:2001 specification 1095 See the POSIX:2001 specification
543 <http://www.opengroup.org/susv3xsh/sleep.html>. */ 1096 <http://www.opengroup.org/susv3xsh/sleep.html>. */
544# if !@HAVE_SLEEP@ 1097# if @REPLACE_SLEEP@
545extern unsigned int sleep (unsigned int n); 1098# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1099# undef sleep
1100# define sleep rpl_sleep
1101# endif
1102_GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1103_GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1104# else
1105# if !@HAVE_SLEEP@
1106_GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1107# endif
1108_GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
546# endif 1109# endif
1110_GL_CXXALIASWARN (sleep);
547#elif defined GNULIB_POSIXCHECK 1111#elif defined GNULIB_POSIXCHECK
548# undef sleep 1112# undef sleep
549# define sleep(n) \ 1113# if HAVE_RAW_DECL_SLEEP
550 (GL_LINK_WARNING ("sleep is unportable - " \ 1114_GL_WARN_ON_USE (sleep, "sleep is unportable - "
551 "use gnulib module sleep for portability"), \ 1115 "use gnulib module sleep for portability");
552 sleep (n)) 1116# endif
553#endif 1117#endif
554 1118
555 1119
556#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@ 1120#if @GNULIB_SYMLINK@
557/* Write up to COUNT bytes starting at BUF to file descriptor FD. 1121# if @REPLACE_SYMLINK@
558 See the POSIX:2001 specification 1122# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
559 <http://www.opengroup.org/susv3xsh/write.html>. */ 1123# undef symlink
560# undef write 1124# define symlink rpl_symlink
561# define write rpl_write 1125# endif
562extern ssize_t write (int fd, const void *buf, size_t count); 1126_GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1127 _GL_ARG_NONNULL ((1, 2)));
1128_GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1129# else
1130# if !@HAVE_SYMLINK@
1131_GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1132 _GL_ARG_NONNULL ((1, 2)));
1133# endif
1134_GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1135# endif
1136_GL_CXXALIASWARN (symlink);
1137#elif defined GNULIB_POSIXCHECK
1138# undef symlink
1139# if HAVE_RAW_DECL_SYMLINK
1140_GL_WARN_ON_USE (symlink, "symlink is not portable - "
1141 "use gnulib module symlink for portability");
1142# endif
563#endif 1143#endif
564 1144
565 1145
566#ifdef FCHDIR_REPLACEMENT 1146#if @GNULIB_SYMLINKAT@
567/* gnulib internal function. */ 1147# if !@HAVE_SYMLINKAT@
568extern void _gl_unregister_fd (int fd); 1148_GL_FUNCDECL_SYS (symlinkat, int,
1149 (char const *contents, int fd, char const *file)
1150 _GL_ARG_NONNULL ((1, 3)));
1151# endif
1152_GL_CXXALIAS_SYS (symlinkat, int,
1153 (char const *contents, int fd, char const *file));
1154_GL_CXXALIASWARN (symlinkat);
1155#elif defined GNULIB_POSIXCHECK
1156# undef symlinkat
1157# if HAVE_RAW_DECL_SYMLINKAT
1158_GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1159 "use gnulib module symlinkat for portability");
1160# endif
569#endif 1161#endif
570 1162
571 1163
572#ifdef __cplusplus 1164#if @GNULIB_TTYNAME_R@
573} 1165/* Store at most BUFLEN characters of the pathname of the terminal FD is
1166 open on in BUF. Return 0 on success, otherwise an error number. */
1167# if !@HAVE_TTYNAME_R@
1168_GL_FUNCDECL_SYS (ttyname_r, int,
1169 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1170# endif
1171_GL_CXXALIAS_SYS (ttyname_r, int,
1172 (int fd, char *buf, size_t buflen));
1173_GL_CXXALIASWARN (ttyname_r);
1174#elif defined GNULIB_POSIXCHECK
1175# undef ttyname_r
1176# if HAVE_RAW_DECL_TTYNAME_R
1177_GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1178 "use gnulib module ttyname_r for portability");
1179# endif
1180#endif
1181
1182
1183#if @GNULIB_UNLINK@
1184# if @REPLACE_UNLINK@
1185# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1186# undef unlink
1187# define unlink rpl_unlink
1188# endif
1189_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1190_GL_CXXALIAS_RPL (unlink, int, (char const *file));
1191# else
1192_GL_CXXALIAS_SYS (unlink, int, (char const *file));
1193# endif
1194_GL_CXXALIASWARN (unlink);
1195#elif defined GNULIB_POSIXCHECK
1196# undef unlink
1197# if HAVE_RAW_DECL_UNLINK
1198_GL_WARN_ON_USE (unlink, "unlink is not portable - "
1199 "use gnulib module unlink for portability");
1200# endif
1201#endif
1202
1203
1204#if @GNULIB_UNLINKAT@
1205# if @REPLACE_UNLINKAT@
1206# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1207# undef unlinkat
1208# define unlinkat rpl_unlinkat
1209# endif
1210_GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1211 _GL_ARG_NONNULL ((2)));
1212_GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1213# else
1214# if !@HAVE_UNLINKAT@
1215_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1216 _GL_ARG_NONNULL ((2)));
1217# endif
1218_GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1219# endif
1220_GL_CXXALIASWARN (unlinkat);
1221#elif defined GNULIB_POSIXCHECK
1222# undef unlinkat
1223# if HAVE_RAW_DECL_UNLINKAT
1224_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1225 "use gnulib module openat for portability");
1226# endif
1227#endif
1228
1229
1230#if @GNULIB_USLEEP@
1231/* Pause the execution of the current thread for N microseconds.
1232 Returns 0 on completion, or -1 on range error.
1233 See the POSIX:2001 specification
1234 <http://www.opengroup.org/susv3xsh/sleep.html>. */
1235# if @REPLACE_USLEEP@
1236# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1237# undef usleep
1238# define usleep rpl_usleep
1239# endif
1240_GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1241_GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1242# else
1243# if !@HAVE_USLEEP@
1244_GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1245# endif
1246_GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1247# endif
1248_GL_CXXALIASWARN (usleep);
1249#elif defined GNULIB_POSIXCHECK
1250# undef usleep
1251# if HAVE_RAW_DECL_USLEEP
1252_GL_WARN_ON_USE (usleep, "usleep is unportable - "
1253 "use gnulib module usleep for portability");
1254# endif
1255#endif
1256
1257
1258#if @GNULIB_WRITE@
1259/* Write up to COUNT bytes starting at BUF to file descriptor FD.
1260 See the POSIX:2001 specification
1261 <http://www.opengroup.org/susv3xsh/write.html>. */
1262# if @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
1263# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1264# undef write
1265# define write rpl_write
1266# endif
1267_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1268 _GL_ARG_NONNULL ((2)));
1269_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1270# else
1271_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
1272# endif
1273_GL_CXXALIASWARN (write);
574#endif 1274#endif
575 1275
576 1276