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