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