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