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