1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2016 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 #ifndef _@GUARD_PREFIX@_UNISTD_H
20 @PRAGMA_SYSTEM_HEADER@
24 #ifdef _GL_INCLUDING_UNISTD_H
25 /* Special invocation convention:
26 - On Mac OS X 10.3.9 we have a sequence of nested includes
27 <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>
28 In this situation, the functions are not yet declared, therefore we cannot
29 provide the C++ aliases. */
31 #@INCLUDE_NEXT@ @NEXT_UNISTD_H@
34 /* Normal invocation convention. */
36 /* The include_next requires a split double-inclusion guard. */
38 # define _GL_INCLUDING_UNISTD_H
39 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
40 # undef _GL_INCLUDING_UNISTD_H
43 /* Get all possible declarations of gethostname(). */
44 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
45 && !defined _GL_INCLUDING_WINSOCK2_H
46 # define _GL_INCLUDING_WINSOCK2_H
47 # include <winsock2.h>
48 # undef _GL_INCLUDING_WINSOCK2_H
51 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
52 #define _@GUARD_PREFIX@_UNISTD_H
54 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
57 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
58 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
59 /* But avoid namespace pollution on glibc systems. */
60 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
61 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
62 && defined __CYGWIN__)) \
63 && ! defined __GLIBC__
67 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
68 /* But avoid namespace pollution on glibc systems. */
69 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
70 && ! defined __GLIBC__
74 /* mingw fails to declare _exit in <unistd.h>. */
75 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
77 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
78 /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
80 /* But avoid namespace pollution on glibc systems. */
81 #if !defined __GLIBC__ && !defined __osf__
82 # define __need_system_stdlib_h
84 # undef __need_system_stdlib_h
87 /* Native Windows platforms declare chdir, getcwd, rmdir in
88 <io.h> and/or <direct.h>, not in <unistd.h>.
89 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
90 lseek(), read(), unlink(), write() in <io.h>. */
91 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
92 || defined GNULIB_POSIXCHECK) \
93 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
94 # include <io.h> /* mingw32, mingw64 */
95 # include <direct.h> /* mingw64, MSVC 9 */
96 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
97 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
98 || defined GNULIB_POSIXCHECK) \
99 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
103 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
104 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
105 /* But avoid namespace pollution on glibc systems. */
106 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
107 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
108 && !defined __GLIBC__
112 /* MSVC defines off_t in <sys/types.h>.
113 May also define off_t to a 64-bit type on native Windows. */
114 #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
116 # include <sys/types.h>
119 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
120 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
121 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
123 # include <sys/types.h>
126 /* Get getopt(), optarg, optind, opterr, optopt.
127 But avoid namespace pollution on glibc systems. */
128 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
129 # define __need_getopt
133 #ifndef _GL_INLINE_HEADER_BEGIN
134 #error "Please include config.h first."
136 _GL_INLINE_HEADER_BEGIN
137 #ifndef _GL_UNISTD_INLINE
138 # define _GL_UNISTD_INLINE _GL_INLINE
141 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
143 /* The definition of _GL_ARG_NONNULL is copied here. */
145 /* The definition of _GL_WARN_ON_USE is copied here. */
148 /* Hide some function declarations from <winsock2.h>. */
150 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
151 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
152 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
154 # define socket socket_used_without_including_sys_socket_h
156 # define connect connect_used_without_including_sys_socket_h
158 # define accept accept_used_without_including_sys_socket_h
160 # define bind bind_used_without_including_sys_socket_h
162 # define getpeername getpeername_used_without_including_sys_socket_h
164 # define getsockname getsockname_used_without_including_sys_socket_h
166 # define getsockopt getsockopt_used_without_including_sys_socket_h
168 # define listen listen_used_without_including_sys_socket_h
170 # define recv recv_used_without_including_sys_socket_h
172 # define send send_used_without_including_sys_socket_h
174 # define recvfrom recvfrom_used_without_including_sys_socket_h
176 # define sendto sendto_used_without_including_sys_socket_h
178 # define setsockopt setsockopt_used_without_including_sys_socket_h
180 # define shutdown shutdown_used_without_including_sys_socket_h
182 _GL_WARN_ON_USE (socket
,
183 "socket() used without including <sys/socket.h>");
184 _GL_WARN_ON_USE (connect
,
185 "connect() used without including <sys/socket.h>");
186 _GL_WARN_ON_USE (accept
,
187 "accept() used without including <sys/socket.h>");
188 _GL_WARN_ON_USE (bind
,
189 "bind() used without including <sys/socket.h>");
190 _GL_WARN_ON_USE (getpeername
,
191 "getpeername() used without including <sys/socket.h>");
192 _GL_WARN_ON_USE (getsockname
,
193 "getsockname() used without including <sys/socket.h>");
194 _GL_WARN_ON_USE (getsockopt
,
195 "getsockopt() used without including <sys/socket.h>");
196 _GL_WARN_ON_USE (listen
,
197 "listen() used without including <sys/socket.h>");
198 _GL_WARN_ON_USE (recv
,
199 "recv() used without including <sys/socket.h>");
200 _GL_WARN_ON_USE (send
,
201 "send() used without including <sys/socket.h>");
202 _GL_WARN_ON_USE (recvfrom
,
203 "recvfrom() used without including <sys/socket.h>");
204 _GL_WARN_ON_USE (sendto
,
205 "sendto() used without including <sys/socket.h>");
206 _GL_WARN_ON_USE (setsockopt
,
207 "setsockopt() used without including <sys/socket.h>");
208 _GL_WARN_ON_USE (shutdown
,
209 "shutdown() used without including <sys/socket.h>");
212 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
213 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
215 # define select select_used_without_including_sys_select_h
217 _GL_WARN_ON_USE (select
,
218 "select() used without including <sys/select.h>");
224 /* OS/2 EMX lacks these macros. */
226 # define STDIN_FILENO 0
228 #ifndef STDOUT_FILENO
229 # define STDOUT_FILENO 1
231 #ifndef STDERR_FILENO
232 # define STDERR_FILENO 2
235 /* Ensure *_OK macros exist. */
244 /* Declare overridden functions. */
247 #if defined GNULIB_POSIXCHECK
248 /* The access() function is a security risk. */
249 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
250 "use the gnulib module faccessat instead");
255 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
256 _GL_CXXALIASWARN (chdir
);
257 #elif defined GNULIB_POSIXCHECK
259 # if HAVE_RAW_DECL_CHDIR
260 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
261 "use gnulib module chdir for portability");
267 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
268 to GID (if GID is not -1). Follow symbolic links.
269 Return 0 if successful, otherwise -1 and errno set.
270 See the POSIX:2008 specification
271 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
273 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
275 # define chown rpl_chown
277 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
278 _GL_ARG_NONNULL ((1)));
279 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
282 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
283 _GL_ARG_NONNULL ((1)));
285 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
287 _GL_CXXALIASWARN (chown
);
288 #elif defined GNULIB_POSIXCHECK
290 # if HAVE_RAW_DECL_CHOWN
291 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
292 "doesn't treat a uid or gid of -1 on some systems - "
293 "use gnulib module chown for portability");
300 /* Automatically included by modules that need a replacement for close. */
301 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
303 # define close rpl_close
305 _GL_FUNCDECL_RPL (close
, int, (int fd
));
306 _GL_CXXALIAS_RPL (close
, int, (int fd
));
308 _GL_CXXALIAS_SYS (close
, int, (int fd
));
310 _GL_CXXALIASWARN (close
);
311 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
313 # define close close_used_without_requesting_gnulib_module_close
314 #elif defined GNULIB_POSIXCHECK
316 /* Assume close is always declared. */
317 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
318 "use gnulib module close for portability");
324 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
327 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
328 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
330 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
332 _GL_CXXALIASWARN (dup
);
333 #elif defined GNULIB_POSIXCHECK
335 # if HAVE_RAW_DECL_DUP
336 _GL_WARN_ON_USE (dup
, "dup is unportable - "
337 "use gnulib module dup for portability");
343 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
344 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
345 Return newfd if successful, otherwise -1 and errno set.
346 See the POSIX:2008 specification
347 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
349 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
350 # define dup2 rpl_dup2
352 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
353 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
356 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
358 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
360 _GL_CXXALIASWARN (dup2
);
361 #elif defined GNULIB_POSIXCHECK
363 # if HAVE_RAW_DECL_DUP2
364 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
365 "use gnulib module dup2 for portability");
371 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
373 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
374 and O_TEXT, O_BINARY (defined in "binary-io.h").
375 Close NEWFD first if it is open.
376 Return newfd if successful, otherwise -1 and errno set.
377 See the Linux man page at
378 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
380 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
381 # define dup3 rpl_dup3
383 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
384 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
386 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
387 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
389 _GL_CXXALIASWARN (dup3
);
390 #elif defined GNULIB_POSIXCHECK
392 # if HAVE_RAW_DECL_DUP3
393 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
394 "use gnulib module dup3 for portability");
400 # if !@HAVE_DECL_ENVIRON@
401 /* Set of environment variables and values. An array of strings of the form
402 "VARIABLE=VALUE", terminated with a NULL. */
403 # if defined __APPLE__ && defined __MACH__
404 # include <TargetConditionals.h>
405 # if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
406 # define _GL_USE_CRT_EXTERNS
409 # ifdef _GL_USE_CRT_EXTERNS
410 # include <crt_externs.h>
411 # define environ (*_NSGetEnviron ())
416 extern char **environ
;
422 #elif defined GNULIB_POSIXCHECK
423 # if HAVE_RAW_DECL_ENVIRON
424 _GL_UNISTD_INLINE
char ***
429 _GL_WARN_ON_USE (rpl_environ
, "environ is unportable - "
430 "use gnulib module environ for portability");
432 # define environ (*rpl_environ ())
437 #if @GNULIB_EUIDACCESS@
438 /* Like access(), except that it uses the effective user id and group id of
439 the current process. */
440 # if !@HAVE_EUIDACCESS@
441 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
442 _GL_ARG_NONNULL ((1)));
444 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
445 _GL_CXXALIASWARN (euidaccess
);
446 # if defined GNULIB_POSIXCHECK
447 /* Like access(), this function is a security risk. */
448 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
449 "use the gnulib module faccessat instead");
451 #elif defined GNULIB_POSIXCHECK
453 # if HAVE_RAW_DECL_EUIDACCESS
454 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
455 "use gnulib module euidaccess for portability");
460 #if @GNULIB_FACCESSAT@
461 # if !@HAVE_FACCESSAT@
462 _GL_FUNCDECL_SYS (faccessat
, int,
463 (int fd
, char const *file
, int mode
, int flag
)
464 _GL_ARG_NONNULL ((2)));
466 _GL_CXXALIAS_SYS (faccessat
, int,
467 (int fd
, char const *file
, int mode
, int flag
));
468 _GL_CXXALIASWARN (faccessat
);
469 #elif defined GNULIB_POSIXCHECK
471 # if HAVE_RAW_DECL_FACCESSAT
472 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
473 "use gnulib module faccessat for portability");
479 /* Change the process' current working directory to the directory on which
480 the given file descriptor is open.
481 Return 0 if successful, otherwise -1 and errno set.
482 See the POSIX:2008 specification
483 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
485 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
487 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
488 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
489 _GL_ARG_NONNULL ((2));
490 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
491 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
492 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
495 # if !@HAVE_DECL_FCHDIR@
496 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
499 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
500 _GL_CXXALIASWARN (fchdir
);
501 #elif defined GNULIB_POSIXCHECK
503 # if HAVE_RAW_DECL_FCHDIR
504 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
505 "use gnulib module fchdir for portability");
510 #if @GNULIB_FCHOWNAT@
511 # if @REPLACE_FCHOWNAT@
512 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
514 # define fchownat rpl_fchownat
516 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
517 uid_t owner
, gid_t group
, int flag
)
518 _GL_ARG_NONNULL ((2)));
519 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
520 uid_t owner
, gid_t group
, int flag
));
522 # if !@HAVE_FCHOWNAT@
523 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
524 uid_t owner
, gid_t group
, int flag
)
525 _GL_ARG_NONNULL ((2)));
527 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
528 uid_t owner
, gid_t group
, int flag
));
530 _GL_CXXALIASWARN (fchownat
);
531 #elif defined GNULIB_POSIXCHECK
533 # if HAVE_RAW_DECL_FCHOWNAT
534 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
535 "use gnulib module openat for portability");
540 #if @GNULIB_FDATASYNC@
541 /* Synchronize changes to a file.
542 Return 0 if successful, otherwise -1 and errno set.
543 See POSIX:2008 specification
544 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
545 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
546 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
548 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
549 _GL_CXXALIASWARN (fdatasync
);
550 #elif defined GNULIB_POSIXCHECK
552 # if HAVE_RAW_DECL_FDATASYNC
553 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
554 "use gnulib module fdatasync for portability");
560 /* Synchronize changes, including metadata, to a file.
561 Return 0 if successful, otherwise -1 and errno set.
562 See POSIX:2008 specification
563 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
565 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
567 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
568 _GL_CXXALIASWARN (fsync
);
569 #elif defined GNULIB_POSIXCHECK
571 # if HAVE_RAW_DECL_FSYNC
572 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
573 "use gnulib module fsync for portability");
578 #if @GNULIB_FTRUNCATE@
579 /* Change the size of the file to which FD is opened to become equal to LENGTH.
580 Return 0 if successful, otherwise -1 and errno set.
581 See the POSIX:2008 specification
582 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
583 # if @REPLACE_FTRUNCATE@
584 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
586 # define ftruncate rpl_ftruncate
588 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
589 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
591 # if !@HAVE_FTRUNCATE@
592 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
594 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
596 _GL_CXXALIASWARN (ftruncate
);
597 #elif defined GNULIB_POSIXCHECK
599 # if HAVE_RAW_DECL_FTRUNCATE
600 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
601 "use gnulib module ftruncate for portability");
607 /* Get the name of the current working directory, and put it in SIZE bytes
609 Return BUF if successful, or NULL if the directory couldn't be determined
610 or SIZE was too small.
611 See the POSIX:2008 specification
612 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
613 Additionally, the gnulib module 'getcwd' guarantees the following GNU
614 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
615 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
617 # if @REPLACE_GETCWD@
618 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
619 # define getcwd rpl_getcwd
621 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
622 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
624 /* Need to cast, because on mingw, the second parameter is
626 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
628 _GL_CXXALIASWARN (getcwd
);
629 #elif defined GNULIB_POSIXCHECK
631 # if HAVE_RAW_DECL_GETCWD
632 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
633 "use gnulib module getcwd for portability");
638 #if @GNULIB_GETDOMAINNAME@
639 /* Return the NIS domain name of the machine.
640 WARNING! The NIS domain name is unrelated to the fully qualified host name
641 of the machine. It is also unrelated to email addresses.
642 WARNING! The NIS domain name is usually the empty string or "(none)" when
645 Put up to LEN bytes of the NIS domain name into NAME.
646 Null terminate it if the name is shorter than LEN.
647 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
648 Return 0 if successful, otherwise set errno and return -1. */
649 # if @REPLACE_GETDOMAINNAME@
650 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
651 # undef getdomainname
652 # define getdomainname rpl_getdomainname
654 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
655 _GL_ARG_NONNULL ((1)));
656 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
658 # if !@HAVE_DECL_GETDOMAINNAME@
659 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
660 _GL_ARG_NONNULL ((1)));
662 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
664 _GL_CXXALIASWARN (getdomainname
);
665 #elif defined GNULIB_POSIXCHECK
666 # undef getdomainname
667 # if HAVE_RAW_DECL_GETDOMAINNAME
668 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
669 "use gnulib module getdomainname for portability");
674 #if @GNULIB_GETDTABLESIZE@
675 /* Return the maximum number of file descriptors in the current process.
676 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
677 # if @REPLACE_GETDTABLESIZE@
678 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
679 # undef getdtablesize
680 # define getdtablesize rpl_getdtablesize
682 _GL_FUNCDECL_RPL (getdtablesize
, int, (void));
683 _GL_CXXALIAS_RPL (getdtablesize
, int, (void));
685 # if !@HAVE_GETDTABLESIZE@
686 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
688 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
690 _GL_CXXALIASWARN (getdtablesize
);
691 #elif defined GNULIB_POSIXCHECK
692 # undef getdtablesize
693 # if HAVE_RAW_DECL_GETDTABLESIZE
694 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
695 "use gnulib module getdtablesize for portability");
700 #if @GNULIB_GETGROUPS@
701 /* Return the supplemental groups that the current process belongs to.
702 It is unspecified whether the effective group id is in the list.
703 If N is 0, return the group count; otherwise, N describes how many
704 entries are available in GROUPS. Return -1 and set errno if N is
705 not 0 and not large enough. Fails with ENOSYS on some systems. */
706 # if @REPLACE_GETGROUPS@
707 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
709 # define getgroups rpl_getgroups
711 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
712 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
714 # if !@HAVE_GETGROUPS@
715 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
717 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
719 _GL_CXXALIASWARN (getgroups
);
720 #elif defined GNULIB_POSIXCHECK
722 # if HAVE_RAW_DECL_GETGROUPS
723 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
724 "use gnulib module getgroups for portability");
729 #if @GNULIB_GETHOSTNAME@
730 /* Return the standard host name of the machine.
731 WARNING! The host name may or may not be fully qualified.
733 Put up to LEN bytes of the host name into NAME.
734 Null terminate it if the name is shorter than LEN.
735 If the host name is longer than LEN, set errno = EINVAL and return -1.
736 Return 0 if successful, otherwise set errno and return -1. */
737 # if @UNISTD_H_HAVE_WINSOCK2_H@
738 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
740 # define gethostname rpl_gethostname
742 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
743 _GL_ARG_NONNULL ((1)));
744 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
746 # if !@HAVE_GETHOSTNAME@
747 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
748 _GL_ARG_NONNULL ((1)));
750 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
753 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
755 _GL_CXXALIASWARN (gethostname
);
756 #elif @UNISTD_H_HAVE_WINSOCK2_H@
758 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
759 #elif defined GNULIB_POSIXCHECK
761 # if HAVE_RAW_DECL_GETHOSTNAME
762 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
763 "use gnulib module gethostname for portability");
768 #if @GNULIB_GETLOGIN@
769 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
770 returns NULL with errno set.
772 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
774 Most programs don't need to use this function, because the information is
775 available through environment variables:
776 ${LOGNAME-$USER} on Unix platforms,
777 $USERNAME on native Windows platforms.
779 # if !@HAVE_GETLOGIN@
780 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
782 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
783 _GL_CXXALIASWARN (getlogin
);
784 #elif defined GNULIB_POSIXCHECK
786 # if HAVE_RAW_DECL_GETLOGIN
787 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
788 "use gnulib module getlogin for portability");
793 #if @GNULIB_GETLOGIN_R@
794 /* Copies the user's login name to NAME.
795 The array pointed to by NAME has room for SIZE bytes.
797 Returns 0 if successful. Upon error, an error number is returned, or -1 in
798 the case that the login name cannot be found but no specific error is
799 provided (this case is hopefully rare but is left open by the POSIX spec).
801 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
803 Most programs don't need to use this function, because the information is
804 available through environment variables:
805 ${LOGNAME-$USER} on Unix platforms,
806 $USERNAME on native Windows platforms.
808 # if @REPLACE_GETLOGIN_R@
809 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
810 # define getlogin_r rpl_getlogin_r
812 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
813 _GL_ARG_NONNULL ((1)));
814 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
816 # if !@HAVE_DECL_GETLOGIN_R@
817 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
818 _GL_ARG_NONNULL ((1)));
820 /* Need to cast, because on Solaris 10 systems, the second argument is
822 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
824 _GL_CXXALIASWARN (getlogin_r
);
825 #elif defined GNULIB_POSIXCHECK
827 # if HAVE_RAW_DECL_GETLOGIN_R
828 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
829 "use gnulib module getlogin_r for portability");
834 #if @GNULIB_GETPAGESIZE@
835 # if @REPLACE_GETPAGESIZE@
836 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
837 # define getpagesize rpl_getpagesize
839 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
840 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
842 # if !@HAVE_GETPAGESIZE@
843 # if !defined getpagesize
844 /* This is for POSIX systems. */
845 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
846 # if ! (defined __VMS && __VMS_VER < 70000000)
847 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
850 /* This is for older VMS. */
851 # if !defined _gl_getpagesize && defined __VMS
853 # define _gl_getpagesize() 8192
855 # define _gl_getpagesize() 512
858 /* This is for BeOS. */
859 # if !defined _gl_getpagesize && @HAVE_OS_H@
861 # if defined B_PAGE_SIZE
862 # define _gl_getpagesize() B_PAGE_SIZE
865 /* This is for AmigaOS4.0. */
866 # if !defined _gl_getpagesize && defined __amigaos4__
867 # define _gl_getpagesize() 2048
869 /* This is for older Unix systems. */
870 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
871 # include <sys/param.h>
872 # ifdef EXEC_PAGESIZE
873 # define _gl_getpagesize() EXEC_PAGESIZE
879 # define _gl_getpagesize() (NBPG * CLSIZE)
882 # define _gl_getpagesize() NBPC
887 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
888 # define getpagesize() _gl_getpagesize ()
890 # if !GNULIB_defined_getpagesize_function
891 _GL_UNISTD_INLINE
int
894 return _gl_getpagesize ();
896 # define GNULIB_defined_getpagesize_function 1
901 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
902 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
904 # if @HAVE_DECL_GETPAGESIZE@
905 _GL_CXXALIASWARN (getpagesize
);
907 #elif defined GNULIB_POSIXCHECK
909 # if HAVE_RAW_DECL_GETPAGESIZE
910 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
911 "use gnulib module getpagesize for portability");
916 #if @GNULIB_GETUSERSHELL@
917 /* Return the next valid login shell on the system, or NULL when the end of
918 the list has been reached. */
919 # if !@HAVE_DECL_GETUSERSHELL@
920 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
922 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
923 _GL_CXXALIASWARN (getusershell
);
924 #elif defined GNULIB_POSIXCHECK
926 # if HAVE_RAW_DECL_GETUSERSHELL
927 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
928 "use gnulib module getusershell for portability");
932 #if @GNULIB_GETUSERSHELL@
933 /* Rewind to pointer that is advanced at each getusershell() call. */
934 # if !@HAVE_DECL_GETUSERSHELL@
935 _GL_FUNCDECL_SYS (setusershell
, void, (void));
937 _GL_CXXALIAS_SYS (setusershell
, void, (void));
938 _GL_CXXALIASWARN (setusershell
);
939 #elif defined GNULIB_POSIXCHECK
941 # if HAVE_RAW_DECL_SETUSERSHELL
942 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
943 "use gnulib module getusershell for portability");
947 #if @GNULIB_GETUSERSHELL@
948 /* Free the pointer that is advanced at each getusershell() call and
949 associated resources. */
950 # if !@HAVE_DECL_GETUSERSHELL@
951 _GL_FUNCDECL_SYS (endusershell
, void, (void));
953 _GL_CXXALIAS_SYS (endusershell
, void, (void));
954 _GL_CXXALIASWARN (endusershell
);
955 #elif defined GNULIB_POSIXCHECK
957 # if HAVE_RAW_DECL_ENDUSERSHELL
958 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
959 "use gnulib module getusershell for portability");
964 #if @GNULIB_GROUP_MEMBER@
965 /* Determine whether group id is in calling user's group list. */
966 # if !@HAVE_GROUP_MEMBER@
967 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
969 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
970 _GL_CXXALIASWARN (group_member
);
971 #elif defined GNULIB_POSIXCHECK
973 # if HAVE_RAW_DECL_GROUP_MEMBER
974 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
975 "use gnulib module group-member for portability");
981 # if @REPLACE_ISATTY@
982 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
984 # define isatty rpl_isatty
986 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
987 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
989 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
991 _GL_CXXALIASWARN (isatty
);
992 #elif defined GNULIB_POSIXCHECK
994 # if HAVE_RAW_DECL_ISATTY
995 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
996 "use gnulib module isatty for portability");
1002 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1003 to GID (if GID is not -1). Do not follow symbolic links.
1004 Return 0 if successful, otherwise -1 and errno set.
1005 See the POSIX:2008 specification
1006 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1007 # if @REPLACE_LCHOWN@
1008 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1010 # define lchown rpl_lchown
1012 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1013 _GL_ARG_NONNULL ((1)));
1014 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1017 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1018 _GL_ARG_NONNULL ((1)));
1020 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1022 _GL_CXXALIASWARN (lchown
);
1023 #elif defined GNULIB_POSIXCHECK
1025 # if HAVE_RAW_DECL_LCHOWN
1026 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1027 "use gnulib module lchown for portability");
1033 /* Create a new hard link for an existing file.
1034 Return 0 if successful, otherwise -1 and errno set.
1035 See POSIX:2008 specification
1036 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1038 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1039 # define link rpl_link
1041 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1042 _GL_ARG_NONNULL ((1, 2)));
1043 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1046 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1047 _GL_ARG_NONNULL ((1, 2)));
1049 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1051 _GL_CXXALIASWARN (link
);
1052 #elif defined GNULIB_POSIXCHECK
1054 # if HAVE_RAW_DECL_LINK
1055 _GL_WARN_ON_USE (link
, "link is unportable - "
1056 "use gnulib module link for portability");
1062 /* Create a new hard link for an existing file, relative to two
1063 directories. FLAG controls whether symlinks are followed.
1064 Return 0 if successful, otherwise -1 and errno set. */
1065 # if @REPLACE_LINKAT@
1066 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1068 # define linkat rpl_linkat
1070 _GL_FUNCDECL_RPL (linkat
, int,
1071 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1073 _GL_ARG_NONNULL ((2, 4)));
1074 _GL_CXXALIAS_RPL (linkat
, int,
1075 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1079 _GL_FUNCDECL_SYS (linkat
, int,
1080 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1082 _GL_ARG_NONNULL ((2, 4)));
1084 _GL_CXXALIAS_SYS (linkat
, int,
1085 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1088 _GL_CXXALIASWARN (linkat
);
1089 #elif defined GNULIB_POSIXCHECK
1091 # if HAVE_RAW_DECL_LINKAT
1092 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1093 "use gnulib module linkat for portability");
1099 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1100 Return the new offset if successful, otherwise -1 and errno set.
1101 See the POSIX:2008 specification
1102 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1103 # if @REPLACE_LSEEK@
1104 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1105 # define lseek rpl_lseek
1107 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1108 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1110 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1112 _GL_CXXALIASWARN (lseek
);
1113 #elif defined GNULIB_POSIXCHECK
1115 # if HAVE_RAW_DECL_LSEEK
1116 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1117 "systems - use gnulib module lseek for portability");
1123 /* Create a pipe, defaulting to O_BINARY mode.
1124 Store the read-end as fd[0] and the write-end as fd[1].
1125 Return 0 upon success, or -1 with errno set upon failure. */
1127 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1129 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1130 _GL_CXXALIASWARN (pipe
);
1131 #elif defined GNULIB_POSIXCHECK
1133 # if HAVE_RAW_DECL_PIPE
1134 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1135 "use gnulib module pipe-posix for portability");
1141 /* Create a pipe, applying the given flags when opening the read-end of the
1142 pipe and the write-end of the pipe.
1143 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1144 and O_TEXT, O_BINARY (defined in "binary-io.h").
1145 Store the read-end as fd[0] and the write-end as fd[1].
1146 Return 0 upon success, or -1 with errno set upon failure.
1147 See also the Linux man page at
1148 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1150 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1151 # define pipe2 rpl_pipe2
1153 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1154 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1156 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1157 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1159 _GL_CXXALIASWARN (pipe2
);
1160 #elif defined GNULIB_POSIXCHECK
1162 # if HAVE_RAW_DECL_PIPE2
1163 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1164 "use gnulib module pipe2 for portability");
1170 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1171 Return the number of bytes placed into BUF if successful, otherwise
1172 set errno and return -1. 0 indicates EOF.
1173 See the POSIX:2008 specification
1174 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1175 # if @REPLACE_PREAD@
1176 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1178 # define pread rpl_pread
1180 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1181 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1182 _GL_ARG_NONNULL ((2)));
1183 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1184 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1187 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1188 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1189 _GL_ARG_NONNULL ((2)));
1191 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1192 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1194 _GL_CXXALIASWARN (pread
);
1195 #elif defined GNULIB_POSIXCHECK
1197 # if HAVE_RAW_DECL_PREAD
1198 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1199 "use gnulib module pread for portability");
1205 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1206 Return the number of bytes written if successful, otherwise
1207 set errno and return -1. 0 indicates nothing written. See the
1208 POSIX:2008 specification
1209 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1210 # if @REPLACE_PWRITE@
1211 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1213 # define pwrite rpl_pwrite
1215 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1216 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1217 _GL_ARG_NONNULL ((2)));
1218 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1219 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1222 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1223 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1224 _GL_ARG_NONNULL ((2)));
1226 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1227 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1229 _GL_CXXALIASWARN (pwrite
);
1230 #elif defined GNULIB_POSIXCHECK
1232 # if HAVE_RAW_DECL_PWRITE
1233 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1234 "use gnulib module pwrite for portability");
1240 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1241 at BUF. See the POSIX:2008 specification
1242 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1244 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1246 # define read rpl_read
1248 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1249 _GL_ARG_NONNULL ((2)));
1250 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1252 /* Need to cast, because on mingw, the third parameter is
1254 and the return type is 'int'. */
1255 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1257 _GL_CXXALIASWARN (read
);
1261 #if @GNULIB_READLINK@
1262 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1263 bytes of it into BUF. Return the number of bytes placed into BUF if
1264 successful, otherwise -1 and errno set.
1265 See the POSIX:2008 specification
1266 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1267 # if @REPLACE_READLINK@
1268 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1269 # define readlink rpl_readlink
1271 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1272 (const char *file
, char *buf
, size_t bufsize
)
1273 _GL_ARG_NONNULL ((1, 2)));
1274 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1275 (const char *file
, char *buf
, size_t bufsize
));
1277 # if !@HAVE_READLINK@
1278 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1279 (const char *file
, char *buf
, size_t bufsize
)
1280 _GL_ARG_NONNULL ((1, 2)));
1282 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1283 (const char *file
, char *buf
, size_t bufsize
));
1285 _GL_CXXALIASWARN (readlink
);
1286 #elif defined GNULIB_POSIXCHECK
1288 # if HAVE_RAW_DECL_READLINK
1289 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1290 "use gnulib module readlink for portability");
1295 #if @GNULIB_READLINKAT@
1296 # if @REPLACE_READLINKAT@
1297 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1298 # define readlinkat rpl_readlinkat
1300 _GL_FUNCDECL_RPL (readlinkat
, ssize_t
,
1301 (int fd
, char const *file
, char *buf
, size_t len
)
1302 _GL_ARG_NONNULL ((2, 3)));
1303 _GL_CXXALIAS_RPL (readlinkat
, ssize_t
,
1304 (int fd
, char const *file
, char *buf
, size_t len
));
1306 # if !@HAVE_READLINKAT@
1307 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1308 (int fd
, char const *file
, char *buf
, size_t len
)
1309 _GL_ARG_NONNULL ((2, 3)));
1311 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1312 (int fd
, char const *file
, char *buf
, size_t len
));
1314 _GL_CXXALIASWARN (readlinkat
);
1315 #elif defined GNULIB_POSIXCHECK
1317 # if HAVE_RAW_DECL_READLINKAT
1318 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1319 "use gnulib module readlinkat for portability");
1325 /* Remove the directory DIR. */
1326 # if @REPLACE_RMDIR@
1327 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1328 # define rmdir rpl_rmdir
1330 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1331 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1333 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1335 _GL_CXXALIASWARN (rmdir
);
1336 #elif defined GNULIB_POSIXCHECK
1338 # if HAVE_RAW_DECL_RMDIR
1339 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1340 "use gnulib module rmdir for portability");
1345 #if @GNULIB_SETHOSTNAME@
1346 /* Set the host name of the machine.
1347 The host name may or may not be fully qualified.
1349 Put LEN bytes of NAME into the host name.
1350 Return 0 if successful, otherwise, set errno and return -1.
1352 Platforms with no ability to set the hostname return -1 and set
1354 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1355 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1356 _GL_ARG_NONNULL ((1)));
1358 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1359 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1360 2011-10, the first parameter is not const. */
1361 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1362 _GL_CXXALIASWARN (sethostname
);
1363 #elif defined GNULIB_POSIXCHECK
1365 # if HAVE_RAW_DECL_SETHOSTNAME
1366 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1367 "use gnulib module sethostname for portability");
1373 /* Pause the execution of the current thread for N seconds.
1374 Returns the number of seconds left to sleep.
1375 See the POSIX:2008 specification
1376 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1377 # if @REPLACE_SLEEP@
1378 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1380 # define sleep rpl_sleep
1382 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1383 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1386 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1388 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1390 _GL_CXXALIASWARN (sleep
);
1391 #elif defined GNULIB_POSIXCHECK
1393 # if HAVE_RAW_DECL_SLEEP
1394 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1395 "use gnulib module sleep for portability");
1400 #if @GNULIB_SYMLINK@
1401 # if @REPLACE_SYMLINK@
1402 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1404 # define symlink rpl_symlink
1406 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1407 _GL_ARG_NONNULL ((1, 2)));
1408 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1410 # if !@HAVE_SYMLINK@
1411 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1412 _GL_ARG_NONNULL ((1, 2)));
1414 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1416 _GL_CXXALIASWARN (symlink
);
1417 #elif defined GNULIB_POSIXCHECK
1419 # if HAVE_RAW_DECL_SYMLINK
1420 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1421 "use gnulib module symlink for portability");
1426 #if @GNULIB_SYMLINKAT@
1427 # if @REPLACE_SYMLINKAT@
1428 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1430 # define symlinkat rpl_symlinkat
1432 _GL_FUNCDECL_RPL (symlinkat
, int,
1433 (char const *contents
, int fd
, char const *file
)
1434 _GL_ARG_NONNULL ((1, 3)));
1435 _GL_CXXALIAS_RPL (symlinkat
, int,
1436 (char const *contents
, int fd
, char const *file
));
1438 # if !@HAVE_SYMLINKAT@
1439 _GL_FUNCDECL_SYS (symlinkat
, int,
1440 (char const *contents
, int fd
, char const *file
)
1441 _GL_ARG_NONNULL ((1, 3)));
1443 _GL_CXXALIAS_SYS (symlinkat
, int,
1444 (char const *contents
, int fd
, char const *file
));
1446 _GL_CXXALIASWARN (symlinkat
);
1447 #elif defined GNULIB_POSIXCHECK
1449 # if HAVE_RAW_DECL_SYMLINKAT
1450 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1451 "use gnulib module symlinkat for portability");
1456 #if @GNULIB_TTYNAME_R@
1457 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1458 open on in BUF. Return 0 on success, otherwise an error number. */
1459 # if @REPLACE_TTYNAME_R@
1460 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1462 # define ttyname_r rpl_ttyname_r
1464 _GL_FUNCDECL_RPL (ttyname_r
, int,
1465 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1466 _GL_CXXALIAS_RPL (ttyname_r
, int,
1467 (int fd
, char *buf
, size_t buflen
));
1469 # if !@HAVE_DECL_TTYNAME_R@
1470 _GL_FUNCDECL_SYS (ttyname_r
, int,
1471 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1473 _GL_CXXALIAS_SYS (ttyname_r
, int,
1474 (int fd
, char *buf
, size_t buflen
));
1476 _GL_CXXALIASWARN (ttyname_r
);
1477 #elif defined GNULIB_POSIXCHECK
1479 # if HAVE_RAW_DECL_TTYNAME_R
1480 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1481 "use gnulib module ttyname_r for portability");
1487 # if @REPLACE_UNLINK@
1488 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1490 # define unlink rpl_unlink
1492 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1493 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1495 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1497 _GL_CXXALIASWARN (unlink
);
1498 #elif defined GNULIB_POSIXCHECK
1500 # if HAVE_RAW_DECL_UNLINK
1501 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1502 "use gnulib module unlink for portability");
1507 #if @GNULIB_UNLINKAT@
1508 # if @REPLACE_UNLINKAT@
1509 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1511 # define unlinkat rpl_unlinkat
1513 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1514 _GL_ARG_NONNULL ((2)));
1515 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1517 # if !@HAVE_UNLINKAT@
1518 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1519 _GL_ARG_NONNULL ((2)));
1521 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1523 _GL_CXXALIASWARN (unlinkat
);
1524 #elif defined GNULIB_POSIXCHECK
1526 # if HAVE_RAW_DECL_UNLINKAT
1527 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1528 "use gnulib module openat for portability");
1534 /* Pause the execution of the current thread for N microseconds.
1535 Returns 0 on completion, or -1 on range error.
1536 See the POSIX:2001 specification
1537 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1538 # if @REPLACE_USLEEP@
1539 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1541 # define usleep rpl_usleep
1543 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1544 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1547 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1549 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1551 _GL_CXXALIASWARN (usleep
);
1552 #elif defined GNULIB_POSIXCHECK
1554 # if HAVE_RAW_DECL_USLEEP
1555 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1556 "use gnulib module usleep for portability");
1562 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1563 See the POSIX:2008 specification
1564 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1565 # if @REPLACE_WRITE@
1566 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1568 # define write rpl_write
1570 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1571 _GL_ARG_NONNULL ((2)));
1572 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1574 /* Need to cast, because on mingw, the third parameter is
1576 and the return type is 'int'. */
1577 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1579 _GL_CXXALIASWARN (write
);
1582 _GL_INLINE_HEADER_END
1584 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1585 #endif /* _GL_INCLUDING_UNISTD_H */
1586 #endif /* _@GUARD_PREFIX@_UNISTD_H */