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