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