* movemail.c (getenv): Remove decl (unused since 1994).
[bpt/emacs.git] / lib / unistd.in.h
CommitLineData
e275c824 1/* Substitute for and wrapper around <unistd.h>.
9ff99d22 2 Copyright (C) 2003-2013 Free Software Foundation, Inc.
e275c824
PE
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
caf8a9b2 15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
e275c824 16
ea78b882
PE
17#ifndef _@GUARD_PREFIX@_UNISTD_H
18
e275c824
PE
19#if __GNUC__ >= 3
20@PRAGMA_SYSTEM_HEADER@
21#endif
22@PRAGMA_COLUMNS@
23
e275c824
PE
24/* The include_next requires a split double-inclusion guard. */
25#if @HAVE_UNISTD_H@
26# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
27#endif
28
29/* Get all possible declarations of gethostname(). */
30#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
e765a388
PE
31 && !defined _GL_INCLUDING_WINSOCK2_H
32# define _GL_INCLUDING_WINSOCK2_H
e275c824 33# include <winsock2.h>
e765a388 34# undef _GL_INCLUDING_WINSOCK2_H
e275c824
PE
35#endif
36
6a3e57bb
PE
37#if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
38#define _@GUARD_PREFIX@_UNISTD_H
e275c824
PE
39
40/* NetBSD 5.0 mis-defines NULL. Also get size_t. */
41#include <stddef.h>
42
43/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
44/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
45/* But avoid namespace pollution on glibc systems. */
46#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
47 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
48 && defined __CYGWIN__)) \
49 && ! defined __GLIBC__
50# include <stdio.h>
51#endif
52
53/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
54/* But avoid namespace pollution on glibc systems. */
55#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
56 && ! defined __GLIBC__
57# include <fcntl.h>
58#endif
59
60/* mingw fails to declare _exit in <unistd.h>. */
316f8af0
PE
61/* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
62 <unistd.h>. */
e275c824
PE
63/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
64/* But avoid namespace pollution on glibc systems. */
65#ifndef __GLIBC__
6466e676 66# define __need_system_stdlib_h
e275c824 67# include <stdlib.h>
6466e676 68# undef __need_system_stdlib_h
e275c824
PE
69#endif
70
316f8af0 71/* Native Windows platforms declare chdir, getcwd, rmdir in
caf8a9b2
PE
72 <io.h> and/or <direct.h>, not in <unistd.h>.
73 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
74 lseek(), read(), unlink(), write() in <io.h>. */
316f8af0
PE
75#if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
76 || defined GNULIB_POSIXCHECK) \
e275c824 77 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
7f59d9c8 78# include <io.h> /* mingw32, mingw64 */
316f8af0 79# include <direct.h> /* mingw64, MSVC 9 */
caf8a9b2
PE
80#elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
81 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
82 || defined GNULIB_POSIXCHECK) \
83 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
84# include <io.h>
e275c824
PE
85#endif
86
87/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
88 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
89/* But avoid namespace pollution on glibc systems. */
90#if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
91 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
92 && !defined __GLIBC__
93# include <netdb.h>
94#endif
95
caf8a9b2
PE
96/* MSVC defines off_t in <sys/types.h>.
97 May also define off_t to a 64-bit type on native Windows. */
98#if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
316f8af0
PE
99/* Get off_t. */
100# include <sys/types.h>
101#endif
102
cc2e7b46
PE
103#if (@GNULIB_READ@ || @GNULIB_WRITE@ \
104 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
e275c824
PE
105 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
106/* Get ssize_t. */
107# include <sys/types.h>
108#endif
109
110/* Get getopt(), optarg, optind, opterr, optopt.
111 But avoid namespace pollution on glibc systems. */
112#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
113# include <getopt.h>
114#endif
115
f64898ab
PE
116_GL_INLINE_HEADER_BEGIN
117#ifndef _GL_UNISTD_INLINE
118# define _GL_UNISTD_INLINE _GL_INLINE
119#endif
120
e275c824
PE
121/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
122
123/* The definition of _GL_ARG_NONNULL is copied here. */
124
125/* The definition of _GL_WARN_ON_USE is copied here. */
126
127
4a621aae
PE
128/* Hide some function declarations from <winsock2.h>. */
129
130#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
131# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
132# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
133# undef socket
134# define socket socket_used_without_including_sys_socket_h
135# undef connect
136# define connect connect_used_without_including_sys_socket_h
137# undef accept
138# define accept accept_used_without_including_sys_socket_h
139# undef bind
140# define bind bind_used_without_including_sys_socket_h
141# undef getpeername
142# define getpeername getpeername_used_without_including_sys_socket_h
143# undef getsockname
144# define getsockname getsockname_used_without_including_sys_socket_h
145# undef getsockopt
146# define getsockopt getsockopt_used_without_including_sys_socket_h
147# undef listen
148# define listen listen_used_without_including_sys_socket_h
149# undef recv
150# define recv recv_used_without_including_sys_socket_h
151# undef send
152# define send send_used_without_including_sys_socket_h
153# undef recvfrom
154# define recvfrom recvfrom_used_without_including_sys_socket_h
155# undef sendto
156# define sendto sendto_used_without_including_sys_socket_h
157# undef setsockopt
158# define setsockopt setsockopt_used_without_including_sys_socket_h
159# undef shutdown
160# define shutdown shutdown_used_without_including_sys_socket_h
161# else
162 _GL_WARN_ON_USE (socket,
163 "socket() used without including <sys/socket.h>");
164 _GL_WARN_ON_USE (connect,
165 "connect() used without including <sys/socket.h>");
166 _GL_WARN_ON_USE (accept,
167 "accept() used without including <sys/socket.h>");
168 _GL_WARN_ON_USE (bind,
169 "bind() used without including <sys/socket.h>");
170 _GL_WARN_ON_USE (getpeername,
171 "getpeername() used without including <sys/socket.h>");
172 _GL_WARN_ON_USE (getsockname,
173 "getsockname() used without including <sys/socket.h>");
174 _GL_WARN_ON_USE (getsockopt,
175 "getsockopt() used without including <sys/socket.h>");
176 _GL_WARN_ON_USE (listen,
177 "listen() used without including <sys/socket.h>");
178 _GL_WARN_ON_USE (recv,
179 "recv() used without including <sys/socket.h>");
180 _GL_WARN_ON_USE (send,
181 "send() used without including <sys/socket.h>");
182 _GL_WARN_ON_USE (recvfrom,
183 "recvfrom() used without including <sys/socket.h>");
184 _GL_WARN_ON_USE (sendto,
185 "sendto() used without including <sys/socket.h>");
186 _GL_WARN_ON_USE (setsockopt,
187 "setsockopt() used without including <sys/socket.h>");
188 _GL_WARN_ON_USE (shutdown,
189 "shutdown() used without including <sys/socket.h>");
e275c824 190# endif
4a621aae
PE
191# endif
192# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
193# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
194# undef select
195# define select select_used_without_including_sys_select_h
196# else
197 _GL_WARN_ON_USE (select,
198 "select() used without including <sys/select.h>");
e275c824
PE
199# endif
200# endif
201#endif
202
203
204/* OS/2 EMX lacks these macros. */
205#ifndef STDIN_FILENO
206# define STDIN_FILENO 0
207#endif
208#ifndef STDOUT_FILENO
209# define STDOUT_FILENO 1
210#endif
211#ifndef STDERR_FILENO
212# define STDERR_FILENO 2
213#endif
214
215/* Ensure *_OK macros exist. */
216#ifndef F_OK
217# define F_OK 0
218# define X_OK 1
219# define W_OK 2
220# define R_OK 4
221#endif
222
223
224/* Declare overridden functions. */
225
226
227#if defined GNULIB_POSIXCHECK
228/* The access() function is a security risk. */
229_GL_WARN_ON_USE (access, "the access function is a security risk - "
230 "use the gnulib module faccessat instead");
231#endif
232
233
316f8af0
PE
234#if @GNULIB_CHDIR@
235_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
236_GL_CXXALIASWARN (chdir);
237#elif defined GNULIB_POSIXCHECK
238# undef chdir
239# if HAVE_RAW_DECL_CHDIR
240_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
241 "use gnulib module chdir for portability");
242# endif
243#endif
244
245
e275c824
PE
246#if @GNULIB_CHOWN@
247/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
248 to GID (if GID is not -1). Follow symbolic links.
249 Return 0 if successful, otherwise -1 and errno set.
316f8af0
PE
250 See the POSIX:2008 specification
251 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
e275c824
PE
252# if @REPLACE_CHOWN@
253# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
254# undef chown
255# define chown rpl_chown
256# endif
257_GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
258 _GL_ARG_NONNULL ((1)));
259_GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
260# else
261# if !@HAVE_CHOWN@
262_GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
263 _GL_ARG_NONNULL ((1)));
264# endif
265_GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
266# endif
267_GL_CXXALIASWARN (chown);
268#elif defined GNULIB_POSIXCHECK
269# undef chown
270# if HAVE_RAW_DECL_CHOWN
271_GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
272 "doesn't treat a uid or gid of -1 on some systems - "
273 "use gnulib module chown for portability");
274# endif
275#endif
276
277
278#if @GNULIB_CLOSE@
279# if @REPLACE_CLOSE@
280/* Automatically included by modules that need a replacement for close. */
281# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
282# undef close
283# define close rpl_close
284# endif
285_GL_FUNCDECL_RPL (close, int, (int fd));
286_GL_CXXALIAS_RPL (close, int, (int fd));
287# else
288_GL_CXXALIAS_SYS (close, int, (int fd));
289# endif
290_GL_CXXALIASWARN (close);
291#elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
292# undef close
293# define close close_used_without_requesting_gnulib_module_close
294#elif defined GNULIB_POSIXCHECK
295# undef close
296/* Assume close is always declared. */
297_GL_WARN_ON_USE (close, "close does not portably work on sockets - "
298 "use gnulib module close for portability");
299#endif
300
301
316f8af0
PE
302#if @GNULIB_DUP@
303# if @REPLACE_DUP@
304# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
305# define dup rpl_dup
306# endif
e275c824
PE
307_GL_FUNCDECL_RPL (dup, int, (int oldfd));
308_GL_CXXALIAS_RPL (dup, int, (int oldfd));
316f8af0 309# else
e275c824 310_GL_CXXALIAS_SYS (dup, int, (int oldfd));
316f8af0 311# endif
e275c824 312_GL_CXXALIASWARN (dup);
316f8af0
PE
313#elif defined GNULIB_POSIXCHECK
314# undef dup
315# if HAVE_RAW_DECL_DUP
316_GL_WARN_ON_USE (dup, "dup is unportable - "
317 "use gnulib module dup for portability");
318# endif
319#endif
e275c824
PE
320
321
322#if @GNULIB_DUP2@
323/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
324 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
325 Return newfd if successful, otherwise -1 and errno set.
316f8af0
PE
326 See the POSIX:2008 specification
327 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
e275c824
PE
328# if @REPLACE_DUP2@
329# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
330# define dup2 rpl_dup2
331# endif
332_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
333_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
334# else
335# if !@HAVE_DUP2@
336_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
337# endif
338_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
339# endif
340_GL_CXXALIASWARN (dup2);
341#elif defined GNULIB_POSIXCHECK
342# undef dup2
343# if HAVE_RAW_DECL_DUP2
344_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
345 "use gnulib module dup2 for portability");
346# endif
347#endif
348
349
350#if @GNULIB_DUP3@
351/* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
352 specified flags.
353 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
354 and O_TEXT, O_BINARY (defined in "binary-io.h").
355 Close NEWFD first if it is open.
356 Return newfd if successful, otherwise -1 and errno set.
357 See the Linux man page at
358 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
359# if @HAVE_DUP3@
360# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
361# define dup3 rpl_dup3
362# endif
363_GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
364_GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
365# else
366_GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
367_GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
368# endif
369_GL_CXXALIASWARN (dup3);
370#elif defined GNULIB_POSIXCHECK
371# undef dup3
372# if HAVE_RAW_DECL_DUP3
373_GL_WARN_ON_USE (dup3, "dup3 is unportable - "
374 "use gnulib module dup3 for portability");
375# endif
376#endif
377
378
379#if @GNULIB_ENVIRON@
380# if !@HAVE_DECL_ENVIRON@
381/* Set of environment variables and values. An array of strings of the form
382 "VARIABLE=VALUE", terminated with a NULL. */
383# if defined __APPLE__ && defined __MACH__
384# include <crt_externs.h>
385# define environ (*_NSGetEnviron ())
386# else
387# ifdef __cplusplus
388extern "C" {
389# endif
390extern char **environ;
391# ifdef __cplusplus
392}
393# endif
394# endif
395# endif
396#elif defined GNULIB_POSIXCHECK
397# if HAVE_RAW_DECL_ENVIRON
f64898ab 398_GL_UNISTD_INLINE char ***
e275c824
PE
399rpl_environ (void)
400{
401 return &environ;
402}
403_GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
404 "use gnulib module environ for portability");
405# undef environ
406# define environ (*rpl_environ ())
407# endif
408#endif
409
410
411#if @GNULIB_EUIDACCESS@
412/* Like access(), except that it uses the effective user id and group id of
413 the current process. */
414# if !@HAVE_EUIDACCESS@
415_GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
416 _GL_ARG_NONNULL ((1)));
417# endif
418_GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
419_GL_CXXALIASWARN (euidaccess);
420# if defined GNULIB_POSIXCHECK
421/* Like access(), this function is a security risk. */
422_GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
423 "use the gnulib module faccessat instead");
424# endif
425#elif defined GNULIB_POSIXCHECK
426# undef euidaccess
427# if HAVE_RAW_DECL_EUIDACCESS
428_GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
429 "use gnulib module euidaccess for portability");
430# endif
431#endif
432
433
434#if @GNULIB_FACCESSAT@
435# if !@HAVE_FACCESSAT@
436_GL_FUNCDECL_SYS (faccessat, int,
437 (int fd, char const *file, int mode, int flag)
438 _GL_ARG_NONNULL ((2)));
439# endif
440_GL_CXXALIAS_SYS (faccessat, int,
441 (int fd, char const *file, int mode, int flag));
442_GL_CXXALIASWARN (faccessat);
443#elif defined GNULIB_POSIXCHECK
444# undef faccessat
445# if HAVE_RAW_DECL_FACCESSAT
446_GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
447 "use gnulib module faccessat for portability");
448# endif
449#endif
450
451
452#if @GNULIB_FCHDIR@
453/* Change the process' current working directory to the directory on which
454 the given file descriptor is open.
455 Return 0 if successful, otherwise -1 and errno set.
316f8af0
PE
456 See the POSIX:2008 specification
457 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
e275c824
PE
458# if ! @HAVE_FCHDIR@
459_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
460
461/* Gnulib internal hooks needed to maintain the fchdir metadata. */
462_GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
463 _GL_ARG_NONNULL ((2));
464_GL_EXTERN_C void _gl_unregister_fd (int fd);
465_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
466_GL_EXTERN_C const char *_gl_directory_name (int fd);
467
468# else
469# if !@HAVE_DECL_FCHDIR@
470_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
471# endif
472# endif
473_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
474_GL_CXXALIASWARN (fchdir);
475#elif defined GNULIB_POSIXCHECK
476# undef fchdir
477# if HAVE_RAW_DECL_FCHDIR
478_GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
479 "use gnulib module fchdir for portability");
480# endif
481#endif
482
483
484#if @GNULIB_FCHOWNAT@
485# if @REPLACE_FCHOWNAT@
486# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
487# undef fchownat
488# define fchownat rpl_fchownat
489# endif
490_GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
491 uid_t owner, gid_t group, int flag)
492 _GL_ARG_NONNULL ((2)));
493_GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
494 uid_t owner, gid_t group, int flag));
495# else
496# if !@HAVE_FCHOWNAT@
497_GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
498 uid_t owner, gid_t group, int flag)
499 _GL_ARG_NONNULL ((2)));
500# endif
501_GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
502 uid_t owner, gid_t group, int flag));
503# endif
504_GL_CXXALIASWARN (fchownat);
505#elif defined GNULIB_POSIXCHECK
506# undef fchownat
507# if HAVE_RAW_DECL_FCHOWNAT
508_GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
509 "use gnulib module openat for portability");
510# endif
511#endif
512
513
316f8af0 514#if @GNULIB_FDATASYNC@
e275c824
PE
515/* Synchronize changes to a file.
516 Return 0 if successful, otherwise -1 and errno set.
316f8af0
PE
517 See POSIX:2008 specification
518 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
519# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
520_GL_FUNCDECL_SYS (fdatasync, int, (int fd));
521# endif
522_GL_CXXALIAS_SYS (fdatasync, int, (int fd));
523_GL_CXXALIASWARN (fdatasync);
524#elif defined GNULIB_POSIXCHECK
525# undef fdatasync
526# if HAVE_RAW_DECL_FDATASYNC
527_GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
528 "use gnulib module fdatasync for portability");
529# endif
530#endif
531
532
533#if @GNULIB_FSYNC@
534/* Synchronize changes, including metadata, to a file.
535 Return 0 if successful, otherwise -1 and errno set.
536 See POSIX:2008 specification
537 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
e275c824
PE
538# if !@HAVE_FSYNC@
539_GL_FUNCDECL_SYS (fsync, int, (int fd));
540# endif
541_GL_CXXALIAS_SYS (fsync, int, (int fd));
542_GL_CXXALIASWARN (fsync);
543#elif defined GNULIB_POSIXCHECK
544# undef fsync
545# if HAVE_RAW_DECL_FSYNC
546_GL_WARN_ON_USE (fsync, "fsync is unportable - "
547 "use gnulib module fsync for portability");
548# endif
549#endif
550
551
552#if @GNULIB_FTRUNCATE@
553/* Change the size of the file to which FD is opened to become equal to LENGTH.
554 Return 0 if successful, otherwise -1 and errno set.
316f8af0
PE
555 See the POSIX:2008 specification
556 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
caf8a9b2
PE
557# if @REPLACE_FTRUNCATE@
558# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
559# undef ftruncate
560# define ftruncate rpl_ftruncate
561# endif
562_GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
563_GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
564# else
565# if !@HAVE_FTRUNCATE@
e275c824 566_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
caf8a9b2 567# endif
e275c824 568_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
caf8a9b2 569# endif
e275c824
PE
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.
316f8af0
PE
585 See the POSIX:2008 specification
586 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
e275c824
PE
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
59578570 855# if !GNULIB_defined_getpagesize_function
f64898ab 856_GL_UNISTD_INLINE int
e275c824
PE
857getpagesize ()
858{
859 return _gl_getpagesize ();
860}
59578570
PE
861# define GNULIB_defined_getpagesize_function 1
862# endif
e275c824
PE
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
1fc5f204
PE
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
caf8a9b2
PE
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
e275c824
PE
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.
316f8af0
PE
970 See the POSIX:2008 specification
971 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
e275c824
PE
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.
316f8af0
PE
1000 See POSIX:2008 specification
1001 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
e275c824
PE
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.
316f8af0
PE
1066 See the POSIX:2008 specification
1067 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
e275c824
PE
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
316f8af0
PE
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>. */
e275c824
PE
1140# if @REPLACE_PREAD@
1141# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
add3f049 1142# undef pread
e275c824
PE
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
316f8af0
PE
1173 POSIX:2008 specification
1174 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
e275c824
PE
1175# if @REPLACE_PWRITE@
1176# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
add3f049 1177# undef pwrite
e275c824
PE
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
cc2e7b46
PE
1204#if @GNULIB_READ@
1205/* Read up to COUNT bytes from file descriptor FD into the buffer starting
316f8af0
PE
1206 at BUF. See the POSIX:2008 specification
1207 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1208# if @REPLACE_READ@
cc2e7b46
PE
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
e275c824
PE
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.
316f8af0
PE
1230 See the POSIX:2008 specification
1231 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
e275c824
PE
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
caf8a9b2
PE
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
05730648 1312/* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
caf8a9b2
PE
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
e275c824
PE
1326#if @GNULIB_SLEEP@
1327/* Pause the execution of the current thread for N seconds.
1328 Returns the number of seconds left to sleep.
316f8af0
PE
1329 See the POSIX:2008 specification
1330 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
e275c824
PE
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
316f8af0 1479 <http://www.opengroup.org/susv3xsh/usleep.html>. */
e275c824
PE
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.
316f8af0
PE
1505 See the POSIX:2008 specification
1506 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1507# if @REPLACE_WRITE@
e275c824
PE
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
f64898ab 1524_GL_INLINE_HEADER_END
e275c824 1525
6a3e57bb
PE
1526#endif /* _@GUARD_PREFIX@_UNISTD_H */
1527#endif /* _@GUARD_PREFIX@_UNISTD_H */