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