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