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