Update doc for advice changes.
[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). */
0a858ebf
PE
657# if @REPLACE_GETDTABLESIZE@
658# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
659# undef getdtablesize
660# define getdtablesize rpl_getdtablesize
661# endif
662_GL_FUNCDECL_RPL (getdtablesize, int, (void));
663_GL_CXXALIAS_RPL (getdtablesize, int, (void));
664# else
665# if !@HAVE_GETDTABLESIZE@
e275c824 666_GL_FUNCDECL_SYS (getdtablesize, int, (void));
0a858ebf 667# endif
e275c824 668_GL_CXXALIAS_SYS (getdtablesize, int, (void));
0a858ebf 669# endif
e275c824
PE
670_GL_CXXALIASWARN (getdtablesize);
671#elif defined GNULIB_POSIXCHECK
672# undef getdtablesize
673# if HAVE_RAW_DECL_GETDTABLESIZE
674_GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
675 "use gnulib module getdtablesize for portability");
676# endif
677#endif
678
679
680#if @GNULIB_GETGROUPS@
681/* Return the supplemental groups that the current process belongs to.
682 It is unspecified whether the effective group id is in the list.
683 If N is 0, return the group count; otherwise, N describes how many
684 entries are available in GROUPS. Return -1 and set errno if N is
685 not 0 and not large enough. Fails with ENOSYS on some systems. */
686# if @REPLACE_GETGROUPS@
687# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
688# undef getgroups
689# define getgroups rpl_getgroups
690# endif
691_GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
692_GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
693# else
694# if !@HAVE_GETGROUPS@
695_GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
696# endif
697_GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
698# endif
699_GL_CXXALIASWARN (getgroups);
700#elif defined GNULIB_POSIXCHECK
701# undef getgroups
702# if HAVE_RAW_DECL_GETGROUPS
703_GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
704 "use gnulib module getgroups for portability");
705# endif
706#endif
707
708
709#if @GNULIB_GETHOSTNAME@
710/* Return the standard host name of the machine.
711 WARNING! The host name may or may not be fully qualified.
712
713 Put up to LEN bytes of the host name into NAME.
714 Null terminate it if the name is shorter than LEN.
715 If the host name is longer than LEN, set errno = EINVAL and return -1.
716 Return 0 if successful, otherwise set errno and return -1. */
717# if @UNISTD_H_HAVE_WINSOCK2_H@
718# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
719# undef gethostname
720# define gethostname rpl_gethostname
721# endif
722_GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
723 _GL_ARG_NONNULL ((1)));
724_GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
725# else
726# if !@HAVE_GETHOSTNAME@
727_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
728 _GL_ARG_NONNULL ((1)));
729# endif
730/* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
731 parameter is
732 int len. */
733_GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
734# endif
735_GL_CXXALIASWARN (gethostname);
736#elif @UNISTD_H_HAVE_WINSOCK2_H@
737# undef gethostname
738# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
739#elif defined GNULIB_POSIXCHECK
740# undef gethostname
741# if HAVE_RAW_DECL_GETHOSTNAME
742_GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
743 "use gnulib module gethostname for portability");
744# endif
745#endif
746
747
748#if @GNULIB_GETLOGIN@
749/* Returns the user's login name, or NULL if it cannot be found. Upon error,
750 returns NULL with errno set.
751
752 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
753
754 Most programs don't need to use this function, because the information is
755 available through environment variables:
756 ${LOGNAME-$USER} on Unix platforms,
757 $USERNAME on native Windows platforms.
758 */
759# if !@HAVE_GETLOGIN@
760_GL_FUNCDECL_SYS (getlogin, char *, (void));
761# endif
762_GL_CXXALIAS_SYS (getlogin, char *, (void));
763_GL_CXXALIASWARN (getlogin);
764#elif defined GNULIB_POSIXCHECK
765# undef getlogin
766# if HAVE_RAW_DECL_GETLOGIN
767_GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
768 "use gnulib module getlogin for portability");
769# endif
770#endif
771
772
773#if @GNULIB_GETLOGIN_R@
774/* Copies the user's login name to NAME.
775 The array pointed to by NAME has room for SIZE bytes.
776
777 Returns 0 if successful. Upon error, an error number is returned, or -1 in
778 the case that the login name cannot be found but no specific error is
779 provided (this case is hopefully rare but is left open by the POSIX spec).
780
781 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
782
783 Most programs don't need to use this function, because the information is
784 available through environment variables:
785 ${LOGNAME-$USER} on Unix platforms,
786 $USERNAME on native Windows platforms.
787 */
788# if @REPLACE_GETLOGIN_R@
789# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
790# define getlogin_r rpl_getlogin_r
791# endif
792_GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
793 _GL_ARG_NONNULL ((1)));
794_GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
795# else
796# if !@HAVE_DECL_GETLOGIN_R@
797_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
798 _GL_ARG_NONNULL ((1)));
799# endif
800/* Need to cast, because on Solaris 10 systems, the second argument is
801 int size. */
802_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
803# endif
804_GL_CXXALIASWARN (getlogin_r);
805#elif defined GNULIB_POSIXCHECK
806# undef getlogin_r
807# if HAVE_RAW_DECL_GETLOGIN_R
808_GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
809 "use gnulib module getlogin_r for portability");
810# endif
811#endif
812
813
814#if @GNULIB_GETPAGESIZE@
815# if @REPLACE_GETPAGESIZE@
816# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
817# define getpagesize rpl_getpagesize
818# endif
819_GL_FUNCDECL_RPL (getpagesize, int, (void));
820_GL_CXXALIAS_RPL (getpagesize, int, (void));
821# else
822# if !@HAVE_GETPAGESIZE@
823# if !defined getpagesize
824/* This is for POSIX systems. */
825# if !defined _gl_getpagesize && defined _SC_PAGESIZE
826# if ! (defined __VMS && __VMS_VER < 70000000)
827# define _gl_getpagesize() sysconf (_SC_PAGESIZE)
828# endif
829# endif
830/* This is for older VMS. */
831# if !defined _gl_getpagesize && defined __VMS
832# ifdef __ALPHA
833# define _gl_getpagesize() 8192
834# else
835# define _gl_getpagesize() 512
836# endif
837# endif
838/* This is for BeOS. */
839# if !defined _gl_getpagesize && @HAVE_OS_H@
840# include <OS.h>
841# if defined B_PAGE_SIZE
842# define _gl_getpagesize() B_PAGE_SIZE
843# endif
844# endif
845/* This is for AmigaOS4.0. */
846# if !defined _gl_getpagesize && defined __amigaos4__
847# define _gl_getpagesize() 2048
848# endif
849/* This is for older Unix systems. */
850# if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
851# include <sys/param.h>
852# ifdef EXEC_PAGESIZE
853# define _gl_getpagesize() EXEC_PAGESIZE
854# else
855# ifdef NBPG
856# ifndef CLSIZE
857# define CLSIZE 1
858# endif
859# define _gl_getpagesize() (NBPG * CLSIZE)
860# else
861# ifdef NBPC
862# define _gl_getpagesize() NBPC
863# endif
864# endif
865# endif
866# endif
867# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
868# define getpagesize() _gl_getpagesize ()
869# else
59578570 870# if !GNULIB_defined_getpagesize_function
f64898ab 871_GL_UNISTD_INLINE int
e275c824
PE
872getpagesize ()
873{
874 return _gl_getpagesize ();
875}
59578570
PE
876# define GNULIB_defined_getpagesize_function 1
877# endif
e275c824
PE
878# endif
879# endif
880# endif
881/* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
882_GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
883# endif
884# if @HAVE_DECL_GETPAGESIZE@
885_GL_CXXALIASWARN (getpagesize);
886# endif
887#elif defined GNULIB_POSIXCHECK
888# undef getpagesize
889# if HAVE_RAW_DECL_GETPAGESIZE
890_GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
891 "use gnulib module getpagesize for portability");
892# endif
893#endif
894
895
896#if @GNULIB_GETUSERSHELL@
897/* Return the next valid login shell on the system, or NULL when the end of
898 the list has been reached. */
899# if !@HAVE_DECL_GETUSERSHELL@
900_GL_FUNCDECL_SYS (getusershell, char *, (void));
901# endif
902_GL_CXXALIAS_SYS (getusershell, char *, (void));
903_GL_CXXALIASWARN (getusershell);
904#elif defined GNULIB_POSIXCHECK
905# undef getusershell
906# if HAVE_RAW_DECL_GETUSERSHELL
907_GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
908 "use gnulib module getusershell for portability");
909# endif
910#endif
911
912#if @GNULIB_GETUSERSHELL@
913/* Rewind to pointer that is advanced at each getusershell() call. */
914# if !@HAVE_DECL_GETUSERSHELL@
915_GL_FUNCDECL_SYS (setusershell, void, (void));
916# endif
917_GL_CXXALIAS_SYS (setusershell, void, (void));
918_GL_CXXALIASWARN (setusershell);
919#elif defined GNULIB_POSIXCHECK
920# undef setusershell
921# if HAVE_RAW_DECL_SETUSERSHELL
922_GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
923 "use gnulib module getusershell for portability");
924# endif
925#endif
926
927#if @GNULIB_GETUSERSHELL@
928/* Free the pointer that is advanced at each getusershell() call and
929 associated resources. */
930# if !@HAVE_DECL_GETUSERSHELL@
931_GL_FUNCDECL_SYS (endusershell, void, (void));
932# endif
933_GL_CXXALIAS_SYS (endusershell, void, (void));
934_GL_CXXALIASWARN (endusershell);
935#elif defined GNULIB_POSIXCHECK
936# undef endusershell
937# if HAVE_RAW_DECL_ENDUSERSHELL
938_GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
939 "use gnulib module getusershell for portability");
940# endif
941#endif
942
943
1fc5f204
PE
944#if @GNULIB_GROUP_MEMBER@
945/* Determine whether group id is in calling user's group list. */
946# if !@HAVE_GROUP_MEMBER@
947_GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
948# endif
949_GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
950_GL_CXXALIASWARN (group_member);
951#elif defined GNULIB_POSIXCHECK
952# undef group_member
953# if HAVE_RAW_DECL_GROUP_MEMBER
954_GL_WARN_ON_USE (group_member, "group_member is unportable - "
955 "use gnulib module group-member for portability");
956# endif
957#endif
958
959
caf8a9b2
PE
960#if @GNULIB_ISATTY@
961# if @REPLACE_ISATTY@
962# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
963# undef isatty
964# define isatty rpl_isatty
965# endif
966_GL_FUNCDECL_RPL (isatty, int, (int fd));
967_GL_CXXALIAS_RPL (isatty, int, (int fd));
968# else
969_GL_CXXALIAS_SYS (isatty, int, (int fd));
970# endif
971_GL_CXXALIASWARN (isatty);
972#elif defined GNULIB_POSIXCHECK
973# undef isatty
974# if HAVE_RAW_DECL_ISATTY
975_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
976 "use gnulib module isatty for portability");
977# endif
978#endif
979
980
e275c824
PE
981#if @GNULIB_LCHOWN@
982/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
983 to GID (if GID is not -1). Do not follow symbolic links.
984 Return 0 if successful, otherwise -1 and errno set.
316f8af0
PE
985 See the POSIX:2008 specification
986 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
e275c824
PE
987# if @REPLACE_LCHOWN@
988# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
989# undef lchown
990# define lchown rpl_lchown
991# endif
992_GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
993 _GL_ARG_NONNULL ((1)));
994_GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
995# else
996# if !@HAVE_LCHOWN@
997_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
998 _GL_ARG_NONNULL ((1)));
999# endif
1000_GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
1001# endif
1002_GL_CXXALIASWARN (lchown);
1003#elif defined GNULIB_POSIXCHECK
1004# undef lchown
1005# if HAVE_RAW_DECL_LCHOWN
1006_GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1007 "use gnulib module lchown for portability");
1008# endif
1009#endif
1010
1011
1012#if @GNULIB_LINK@
1013/* Create a new hard link for an existing file.
1014 Return 0 if successful, otherwise -1 and errno set.
316f8af0
PE
1015 See POSIX:2008 specification
1016 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
e275c824
PE
1017# if @REPLACE_LINK@
1018# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1019# define link rpl_link
1020# endif
1021_GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
1022 _GL_ARG_NONNULL ((1, 2)));
1023_GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
1024# else
1025# if !@HAVE_LINK@
1026_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
1027 _GL_ARG_NONNULL ((1, 2)));
1028# endif
1029_GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
1030# endif
1031_GL_CXXALIASWARN (link);
1032#elif defined GNULIB_POSIXCHECK
1033# undef link
1034# if HAVE_RAW_DECL_LINK
1035_GL_WARN_ON_USE (link, "link is unportable - "
1036 "use gnulib module link for portability");
1037# endif
1038#endif
1039
1040
1041#if @GNULIB_LINKAT@
1042/* Create a new hard link for an existing file, relative to two
1043 directories. FLAG controls whether symlinks are followed.
1044 Return 0 if successful, otherwise -1 and errno set. */
1045# if @REPLACE_LINKAT@
1046# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1047# undef linkat
1048# define linkat rpl_linkat
1049# endif
1050_GL_FUNCDECL_RPL (linkat, int,
1051 (int fd1, const char *path1, int fd2, const char *path2,
1052 int flag)
1053 _GL_ARG_NONNULL ((2, 4)));
1054_GL_CXXALIAS_RPL (linkat, int,
1055 (int fd1, const char *path1, int fd2, const char *path2,
1056 int flag));
1057# else
1058# if !@HAVE_LINKAT@
1059_GL_FUNCDECL_SYS (linkat, int,
1060 (int fd1, const char *path1, int fd2, const char *path2,
1061 int flag)
1062 _GL_ARG_NONNULL ((2, 4)));
1063# endif
1064_GL_CXXALIAS_SYS (linkat, int,
1065 (int fd1, const char *path1, int fd2, const char *path2,
1066 int flag));
1067# endif
1068_GL_CXXALIASWARN (linkat);
1069#elif defined GNULIB_POSIXCHECK
1070# undef linkat
1071# if HAVE_RAW_DECL_LINKAT
1072_GL_WARN_ON_USE (linkat, "linkat is unportable - "
1073 "use gnulib module linkat for portability");
1074# endif
1075#endif
1076
1077
1078#if @GNULIB_LSEEK@
1079/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1080 Return the new offset if successful, otherwise -1 and errno set.
316f8af0
PE
1081 See the POSIX:2008 specification
1082 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
e275c824
PE
1083# if @REPLACE_LSEEK@
1084# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1085# define lseek rpl_lseek
1086# endif
1087_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1088_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1089# else
1090_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1091# endif
1092_GL_CXXALIASWARN (lseek);
1093#elif defined GNULIB_POSIXCHECK
1094# undef lseek
1095# if HAVE_RAW_DECL_LSEEK
1096_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1097 "systems - use gnulib module lseek for portability");
1098# endif
1099#endif
1100
1101
1102#if @GNULIB_PIPE@
1103/* Create a pipe, defaulting to O_BINARY mode.
1104 Store the read-end as fd[0] and the write-end as fd[1].
1105 Return 0 upon success, or -1 with errno set upon failure. */
1106# if !@HAVE_PIPE@
1107_GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1108# endif
1109_GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1110_GL_CXXALIASWARN (pipe);
1111#elif defined GNULIB_POSIXCHECK
1112# undef pipe
1113# if HAVE_RAW_DECL_PIPE
1114_GL_WARN_ON_USE (pipe, "pipe is unportable - "
1115 "use gnulib module pipe-posix for portability");
1116# endif
1117#endif
1118
1119
1120#if @GNULIB_PIPE2@
1121/* Create a pipe, applying the given flags when opening the read-end of the
1122 pipe and the write-end of the pipe.
1123 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1124 and O_TEXT, O_BINARY (defined in "binary-io.h").
1125 Store the read-end as fd[0] and the write-end as fd[1].
1126 Return 0 upon success, or -1 with errno set upon failure.
1127 See also the Linux man page at
1128 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1129# if @HAVE_PIPE2@
1130# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1131# define pipe2 rpl_pipe2
1132# endif
1133_GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1134_GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1135# else
1136_GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1137_GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1138# endif
1139_GL_CXXALIASWARN (pipe2);
1140#elif defined GNULIB_POSIXCHECK
1141# undef pipe2
1142# if HAVE_RAW_DECL_PIPE2
1143_GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1144 "use gnulib module pipe2 for portability");
1145# endif
1146#endif
1147
1148
1149#if @GNULIB_PREAD@
1150/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1151 Return the number of bytes placed into BUF if successful, otherwise
316f8af0
PE
1152 set errno and return -1. 0 indicates EOF.
1153 See the POSIX:2008 specification
1154 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
e275c824
PE
1155# if @REPLACE_PREAD@
1156# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
add3f049 1157# undef pread
e275c824
PE
1158# define pread rpl_pread
1159# endif
1160_GL_FUNCDECL_RPL (pread, ssize_t,
1161 (int fd, void *buf, size_t bufsize, off_t offset)
1162 _GL_ARG_NONNULL ((2)));
1163_GL_CXXALIAS_RPL (pread, ssize_t,
1164 (int fd, void *buf, size_t bufsize, off_t offset));
1165# else
1166# if !@HAVE_PREAD@
1167_GL_FUNCDECL_SYS (pread, ssize_t,
1168 (int fd, void *buf, size_t bufsize, off_t offset)
1169 _GL_ARG_NONNULL ((2)));
1170# endif
1171_GL_CXXALIAS_SYS (pread, ssize_t,
1172 (int fd, void *buf, size_t bufsize, off_t offset));
1173# endif
1174_GL_CXXALIASWARN (pread);
1175#elif defined GNULIB_POSIXCHECK
1176# undef pread
1177# if HAVE_RAW_DECL_PREAD
1178_GL_WARN_ON_USE (pread, "pread is unportable - "
1179 "use gnulib module pread for portability");
1180# endif
1181#endif
1182
1183
1184#if @GNULIB_PWRITE@
1185/* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1186 Return the number of bytes written if successful, otherwise
1187 set errno and return -1. 0 indicates nothing written. See the
316f8af0
PE
1188 POSIX:2008 specification
1189 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
e275c824
PE
1190# if @REPLACE_PWRITE@
1191# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
add3f049 1192# undef pwrite
e275c824
PE
1193# define pwrite rpl_pwrite
1194# endif
1195_GL_FUNCDECL_RPL (pwrite, ssize_t,
1196 (int fd, const void *buf, size_t bufsize, off_t offset)
1197 _GL_ARG_NONNULL ((2)));
1198_GL_CXXALIAS_RPL (pwrite, ssize_t,
1199 (int fd, const void *buf, size_t bufsize, off_t offset));
1200# else
1201# if !@HAVE_PWRITE@
1202_GL_FUNCDECL_SYS (pwrite, ssize_t,
1203 (int fd, const void *buf, size_t bufsize, off_t offset)
1204 _GL_ARG_NONNULL ((2)));
1205# endif
1206_GL_CXXALIAS_SYS (pwrite, ssize_t,
1207 (int fd, const void *buf, size_t bufsize, off_t offset));
1208# endif
1209_GL_CXXALIASWARN (pwrite);
1210#elif defined GNULIB_POSIXCHECK
1211# undef pwrite
1212# if HAVE_RAW_DECL_PWRITE
1213_GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1214 "use gnulib module pwrite for portability");
1215# endif
1216#endif
1217
1218
cc2e7b46
PE
1219#if @GNULIB_READ@
1220/* Read up to COUNT bytes from file descriptor FD into the buffer starting
316f8af0
PE
1221 at BUF. See the POSIX:2008 specification
1222 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1223# if @REPLACE_READ@
cc2e7b46
PE
1224# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1225# undef read
1226# define read rpl_read
1227# endif
1228_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1229 _GL_ARG_NONNULL ((2)));
1230_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1231# else
1232/* Need to cast, because on mingw, the third parameter is
1233 unsigned int count
1234 and the return type is 'int'. */
1235_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1236# endif
1237_GL_CXXALIASWARN (read);
1238#endif
1239
1240
e275c824
PE
1241#if @GNULIB_READLINK@
1242/* Read the contents of the symbolic link FILE and place the first BUFSIZE
1243 bytes of it into BUF. Return the number of bytes placed into BUF if
1244 successful, otherwise -1 and errno set.
316f8af0
PE
1245 See the POSIX:2008 specification
1246 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
e275c824
PE
1247# if @REPLACE_READLINK@
1248# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1249# define readlink rpl_readlink
1250# endif
1251_GL_FUNCDECL_RPL (readlink, ssize_t,
1252 (const char *file, char *buf, size_t bufsize)
1253 _GL_ARG_NONNULL ((1, 2)));
1254_GL_CXXALIAS_RPL (readlink, ssize_t,
1255 (const char *file, char *buf, size_t bufsize));
1256# else
1257# if !@HAVE_READLINK@
1258_GL_FUNCDECL_SYS (readlink, ssize_t,
1259 (const char *file, char *buf, size_t bufsize)
1260 _GL_ARG_NONNULL ((1, 2)));
1261# endif
1262_GL_CXXALIAS_SYS (readlink, ssize_t,
1263 (const char *file, char *buf, size_t bufsize));
1264# endif
1265_GL_CXXALIASWARN (readlink);
1266#elif defined GNULIB_POSIXCHECK
1267# undef readlink
1268# if HAVE_RAW_DECL_READLINK
1269_GL_WARN_ON_USE (readlink, "readlink is unportable - "
1270 "use gnulib module readlink for portability");
1271# endif
1272#endif
1273
1274
1275#if @GNULIB_READLINKAT@
1276# if !@HAVE_READLINKAT@
1277_GL_FUNCDECL_SYS (readlinkat, ssize_t,
1278 (int fd, char const *file, char *buf, size_t len)
1279 _GL_ARG_NONNULL ((2, 3)));
1280# endif
1281_GL_CXXALIAS_SYS (readlinkat, ssize_t,
1282 (int fd, char const *file, char *buf, size_t len));
1283_GL_CXXALIASWARN (readlinkat);
1284#elif defined GNULIB_POSIXCHECK
1285# undef readlinkat
1286# if HAVE_RAW_DECL_READLINKAT
1287_GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1288 "use gnulib module readlinkat for portability");
1289# endif
1290#endif
1291
1292
1293#if @GNULIB_RMDIR@
1294/* Remove the directory DIR. */
1295# if @REPLACE_RMDIR@
1296# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1297# define rmdir rpl_rmdir
1298# endif
1299_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1300_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1301# else
1302_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1303# endif
1304_GL_CXXALIASWARN (rmdir);
1305#elif defined GNULIB_POSIXCHECK
1306# undef rmdir
1307# if HAVE_RAW_DECL_RMDIR
1308_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1309 "use gnulib module rmdir for portability");
1310# endif
1311#endif
1312
1313
caf8a9b2
PE
1314#if @GNULIB_SETHOSTNAME@
1315/* Set the host name of the machine.
1316 The host name may or may not be fully qualified.
1317
1318 Put LEN bytes of NAME into the host name.
1319 Return 0 if successful, otherwise, set errno and return -1.
1320
1321 Platforms with no ability to set the hostname return -1 and set
1322 errno = ENOSYS. */
1323# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1324_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
1325 _GL_ARG_NONNULL ((1)));
1326# endif
05730648 1327/* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
caf8a9b2
PE
1328 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1329 2011-10, the first parameter is not const. */
1330_GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
1331_GL_CXXALIASWARN (sethostname);
1332#elif defined GNULIB_POSIXCHECK
1333# undef sethostname
1334# if HAVE_RAW_DECL_SETHOSTNAME
1335_GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1336 "use gnulib module sethostname for portability");
1337# endif
1338#endif
1339
1340
e275c824
PE
1341#if @GNULIB_SLEEP@
1342/* Pause the execution of the current thread for N seconds.
1343 Returns the number of seconds left to sleep.
316f8af0
PE
1344 See the POSIX:2008 specification
1345 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
e275c824
PE
1346# if @REPLACE_SLEEP@
1347# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1348# undef sleep
1349# define sleep rpl_sleep
1350# endif
1351_GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1352_GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1353# else
1354# if !@HAVE_SLEEP@
1355_GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1356# endif
1357_GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1358# endif
1359_GL_CXXALIASWARN (sleep);
1360#elif defined GNULIB_POSIXCHECK
1361# undef sleep
1362# if HAVE_RAW_DECL_SLEEP
1363_GL_WARN_ON_USE (sleep, "sleep is unportable - "
1364 "use gnulib module sleep for portability");
1365# endif
1366#endif
1367
1368
1369#if @GNULIB_SYMLINK@
1370# if @REPLACE_SYMLINK@
1371# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1372# undef symlink
1373# define symlink rpl_symlink
1374# endif
1375_GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1376 _GL_ARG_NONNULL ((1, 2)));
1377_GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1378# else
1379# if !@HAVE_SYMLINK@
1380_GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1381 _GL_ARG_NONNULL ((1, 2)));
1382# endif
1383_GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1384# endif
1385_GL_CXXALIASWARN (symlink);
1386#elif defined GNULIB_POSIXCHECK
1387# undef symlink
1388# if HAVE_RAW_DECL_SYMLINK
1389_GL_WARN_ON_USE (symlink, "symlink is not portable - "
1390 "use gnulib module symlink for portability");
1391# endif
1392#endif
1393
1394
1395#if @GNULIB_SYMLINKAT@
1396# if !@HAVE_SYMLINKAT@
1397_GL_FUNCDECL_SYS (symlinkat, int,
1398 (char const *contents, int fd, char const *file)
1399 _GL_ARG_NONNULL ((1, 3)));
1400# endif
1401_GL_CXXALIAS_SYS (symlinkat, int,
1402 (char const *contents, int fd, char const *file));
1403_GL_CXXALIASWARN (symlinkat);
1404#elif defined GNULIB_POSIXCHECK
1405# undef symlinkat
1406# if HAVE_RAW_DECL_SYMLINKAT
1407_GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1408 "use gnulib module symlinkat for portability");
1409# endif
1410#endif
1411
1412
1413#if @GNULIB_TTYNAME_R@
1414/* Store at most BUFLEN characters of the pathname of the terminal FD is
1415 open on in BUF. Return 0 on success, otherwise an error number. */
1416# if @REPLACE_TTYNAME_R@
1417# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1418# undef ttyname_r
1419# define ttyname_r rpl_ttyname_r
1420# endif
1421_GL_FUNCDECL_RPL (ttyname_r, int,
1422 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1423_GL_CXXALIAS_RPL (ttyname_r, int,
1424 (int fd, char *buf, size_t buflen));
1425# else
1426# if !@HAVE_DECL_TTYNAME_R@
1427_GL_FUNCDECL_SYS (ttyname_r, int,
1428 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1429# endif
1430_GL_CXXALIAS_SYS (ttyname_r, int,
1431 (int fd, char *buf, size_t buflen));
1432# endif
1433_GL_CXXALIASWARN (ttyname_r);
1434#elif defined GNULIB_POSIXCHECK
1435# undef ttyname_r
1436# if HAVE_RAW_DECL_TTYNAME_R
1437_GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1438 "use gnulib module ttyname_r for portability");
1439# endif
1440#endif
1441
1442
1443#if @GNULIB_UNLINK@
1444# if @REPLACE_UNLINK@
1445# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1446# undef unlink
1447# define unlink rpl_unlink
1448# endif
1449_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1450_GL_CXXALIAS_RPL (unlink, int, (char const *file));
1451# else
1452_GL_CXXALIAS_SYS (unlink, int, (char const *file));
1453# endif
1454_GL_CXXALIASWARN (unlink);
1455#elif defined GNULIB_POSIXCHECK
1456# undef unlink
1457# if HAVE_RAW_DECL_UNLINK
1458_GL_WARN_ON_USE (unlink, "unlink is not portable - "
1459 "use gnulib module unlink for portability");
1460# endif
1461#endif
1462
1463
1464#if @GNULIB_UNLINKAT@
1465# if @REPLACE_UNLINKAT@
1466# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1467# undef unlinkat
1468# define unlinkat rpl_unlinkat
1469# endif
1470_GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1471 _GL_ARG_NONNULL ((2)));
1472_GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1473# else
1474# if !@HAVE_UNLINKAT@
1475_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1476 _GL_ARG_NONNULL ((2)));
1477# endif
1478_GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1479# endif
1480_GL_CXXALIASWARN (unlinkat);
1481#elif defined GNULIB_POSIXCHECK
1482# undef unlinkat
1483# if HAVE_RAW_DECL_UNLINKAT
1484_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1485 "use gnulib module openat for portability");
1486# endif
1487#endif
1488
1489
1490#if @GNULIB_USLEEP@
1491/* Pause the execution of the current thread for N microseconds.
1492 Returns 0 on completion, or -1 on range error.
1493 See the POSIX:2001 specification
316f8af0 1494 <http://www.opengroup.org/susv3xsh/usleep.html>. */
e275c824
PE
1495# if @REPLACE_USLEEP@
1496# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1497# undef usleep
1498# define usleep rpl_usleep
1499# endif
1500_GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1501_GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1502# else
1503# if !@HAVE_USLEEP@
1504_GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1505# endif
1506_GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1507# endif
1508_GL_CXXALIASWARN (usleep);
1509#elif defined GNULIB_POSIXCHECK
1510# undef usleep
1511# if HAVE_RAW_DECL_USLEEP
1512_GL_WARN_ON_USE (usleep, "usleep is unportable - "
1513 "use gnulib module usleep for portability");
1514# endif
1515#endif
1516
1517
1518#if @GNULIB_WRITE@
1519/* Write up to COUNT bytes starting at BUF to file descriptor FD.
316f8af0
PE
1520 See the POSIX:2008 specification
1521 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1522# if @REPLACE_WRITE@
e275c824
PE
1523# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1524# undef write
1525# define write rpl_write
1526# endif
1527_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1528 _GL_ARG_NONNULL ((2)));
1529_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1530# else
1531/* Need to cast, because on mingw, the third parameter is
1532 unsigned int count
1533 and the return type is 'int'. */
1534_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1535# endif
1536_GL_CXXALIASWARN (write);
1537#endif
1538
f64898ab 1539_GL_INLINE_HEADER_END
e275c824 1540
6a3e57bb
PE
1541#endif /* _@GUARD_PREFIX@_UNISTD_H */
1542#endif /* _@GUARD_PREFIX@_UNISTD_H */