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