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