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