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