1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2014 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 <crt_externs.h>
405 # define environ (*_NSGetEnviron ())
410 extern char **environ
;
416 #elif defined GNULIB_POSIXCHECK
417 # if HAVE_RAW_DECL_ENVIRON
418 _GL_UNISTD_INLINE
char ***
423 _GL_WARN_ON_USE (rpl_environ
, "environ is unportable - "
424 "use gnulib module environ for portability");
426 # define environ (*rpl_environ ())
431 #if @GNULIB_EUIDACCESS@
432 /* Like access(), except that it uses the effective user id and group id of
433 the current process. */
434 # if !@HAVE_EUIDACCESS@
435 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
436 _GL_ARG_NONNULL ((1)));
438 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
439 _GL_CXXALIASWARN (euidaccess
);
440 # if defined GNULIB_POSIXCHECK
441 /* Like access(), this function is a security risk. */
442 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
443 "use the gnulib module faccessat instead");
445 #elif defined GNULIB_POSIXCHECK
447 # if HAVE_RAW_DECL_EUIDACCESS
448 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
449 "use gnulib module euidaccess for portability");
454 #if @GNULIB_FACCESSAT@
455 # if !@HAVE_FACCESSAT@
456 _GL_FUNCDECL_SYS (faccessat
, int,
457 (int fd
, char const *file
, int mode
, int flag
)
458 _GL_ARG_NONNULL ((2)));
460 _GL_CXXALIAS_SYS (faccessat
, int,
461 (int fd
, char const *file
, int mode
, int flag
));
462 _GL_CXXALIASWARN (faccessat
);
463 #elif defined GNULIB_POSIXCHECK
465 # if HAVE_RAW_DECL_FACCESSAT
466 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
467 "use gnulib module faccessat for portability");
473 /* Change the process' current working directory to the directory on which
474 the given file descriptor is open.
475 Return 0 if successful, otherwise -1 and errno set.
476 See the POSIX:2008 specification
477 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
479 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
481 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
482 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
483 _GL_ARG_NONNULL ((2));
484 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
485 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
486 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
489 # if !@HAVE_DECL_FCHDIR@
490 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
493 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
494 _GL_CXXALIASWARN (fchdir
);
495 #elif defined GNULIB_POSIXCHECK
497 # if HAVE_RAW_DECL_FCHDIR
498 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
499 "use gnulib module fchdir for portability");
504 #if @GNULIB_FCHOWNAT@
505 # if @REPLACE_FCHOWNAT@
506 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
508 # define fchownat rpl_fchownat
510 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
511 uid_t owner
, gid_t group
, int flag
)
512 _GL_ARG_NONNULL ((2)));
513 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
514 uid_t owner
, gid_t group
, int flag
));
516 # if !@HAVE_FCHOWNAT@
517 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
518 uid_t owner
, gid_t group
, int flag
)
519 _GL_ARG_NONNULL ((2)));
521 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
522 uid_t owner
, gid_t group
, int flag
));
524 _GL_CXXALIASWARN (fchownat
);
525 #elif defined GNULIB_POSIXCHECK
527 # if HAVE_RAW_DECL_FCHOWNAT
528 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
529 "use gnulib module openat for portability");
534 #if @GNULIB_FDATASYNC@
535 /* Synchronize changes to a file.
536 Return 0 if successful, otherwise -1 and errno set.
537 See POSIX:2008 specification
538 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
539 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
540 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
542 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
543 _GL_CXXALIASWARN (fdatasync
);
544 #elif defined GNULIB_POSIXCHECK
546 # if HAVE_RAW_DECL_FDATASYNC
547 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
548 "use gnulib module fdatasync for portability");
554 /* Synchronize changes, including metadata, to a file.
555 Return 0 if successful, otherwise -1 and errno set.
556 See POSIX:2008 specification
557 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
559 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
561 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
562 _GL_CXXALIASWARN (fsync
);
563 #elif defined GNULIB_POSIXCHECK
565 # if HAVE_RAW_DECL_FSYNC
566 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
567 "use gnulib module fsync for portability");
572 #if @GNULIB_FTRUNCATE@
573 /* Change the size of the file to which FD is opened to become equal to LENGTH.
574 Return 0 if successful, otherwise -1 and errno set.
575 See the POSIX:2008 specification
576 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
577 # if @REPLACE_FTRUNCATE@
578 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
580 # define ftruncate rpl_ftruncate
582 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
583 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
585 # if !@HAVE_FTRUNCATE@
586 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
588 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
590 _GL_CXXALIASWARN (ftruncate
);
591 #elif defined GNULIB_POSIXCHECK
593 # if HAVE_RAW_DECL_FTRUNCATE
594 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
595 "use gnulib module ftruncate for portability");
601 /* Get the name of the current working directory, and put it in SIZE bytes
603 Return BUF if successful, or NULL if the directory couldn't be determined
604 or SIZE was too small.
605 See the POSIX:2008 specification
606 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
607 Additionally, the gnulib module 'getcwd' guarantees the following GNU
608 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
609 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
611 # if @REPLACE_GETCWD@
612 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
613 # define getcwd rpl_getcwd
615 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
616 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
618 /* Need to cast, because on mingw, the second parameter is
620 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
622 _GL_CXXALIASWARN (getcwd
);
623 #elif defined GNULIB_POSIXCHECK
625 # if HAVE_RAW_DECL_GETCWD
626 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
627 "use gnulib module getcwd for portability");
632 #if @GNULIB_GETDOMAINNAME@
633 /* Return the NIS domain name of the machine.
634 WARNING! The NIS domain name is unrelated to the fully qualified host name
635 of the machine. It is also unrelated to email addresses.
636 WARNING! The NIS domain name is usually the empty string or "(none)" when
639 Put up to LEN bytes of the NIS domain name into NAME.
640 Null terminate it if the name is shorter than LEN.
641 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
642 Return 0 if successful, otherwise set errno and return -1. */
643 # if @REPLACE_GETDOMAINNAME@
644 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
645 # undef getdomainname
646 # define getdomainname rpl_getdomainname
648 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
649 _GL_ARG_NONNULL ((1)));
650 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
652 # if !@HAVE_DECL_GETDOMAINNAME@
653 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
654 _GL_ARG_NONNULL ((1)));
656 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
658 _GL_CXXALIASWARN (getdomainname
);
659 #elif defined GNULIB_POSIXCHECK
660 # undef getdomainname
661 # if HAVE_RAW_DECL_GETDOMAINNAME
662 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
663 "use gnulib module getdomainname for portability");
668 #if @GNULIB_GETDTABLESIZE@
669 /* Return the maximum number of file descriptors in the current process.
670 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
671 # if @REPLACE_GETDTABLESIZE@
672 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
673 # undef getdtablesize
674 # define getdtablesize rpl_getdtablesize
676 _GL_FUNCDECL_RPL (getdtablesize
, int, (void));
677 _GL_CXXALIAS_RPL (getdtablesize
, int, (void));
679 # if !@HAVE_GETDTABLESIZE@
680 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
682 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
684 _GL_CXXALIASWARN (getdtablesize
);
685 #elif defined GNULIB_POSIXCHECK
686 # undef getdtablesize
687 # if HAVE_RAW_DECL_GETDTABLESIZE
688 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
689 "use gnulib module getdtablesize for portability");
694 #if @GNULIB_GETGROUPS@
695 /* Return the supplemental groups that the current process belongs to.
696 It is unspecified whether the effective group id is in the list.
697 If N is 0, return the group count; otherwise, N describes how many
698 entries are available in GROUPS. Return -1 and set errno if N is
699 not 0 and not large enough. Fails with ENOSYS on some systems. */
700 # if @REPLACE_GETGROUPS@
701 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
703 # define getgroups rpl_getgroups
705 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
706 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
708 # if !@HAVE_GETGROUPS@
709 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
711 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
713 _GL_CXXALIASWARN (getgroups
);
714 #elif defined GNULIB_POSIXCHECK
716 # if HAVE_RAW_DECL_GETGROUPS
717 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
718 "use gnulib module getgroups for portability");
723 #if @GNULIB_GETHOSTNAME@
724 /* Return the standard host name of the machine.
725 WARNING! The host name may or may not be fully qualified.
727 Put up to LEN bytes of the host name into NAME.
728 Null terminate it if the name is shorter than LEN.
729 If the host name is longer than LEN, set errno = EINVAL and return -1.
730 Return 0 if successful, otherwise set errno and return -1. */
731 # if @UNISTD_H_HAVE_WINSOCK2_H@
732 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
734 # define gethostname rpl_gethostname
736 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
737 _GL_ARG_NONNULL ((1)));
738 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
740 # if !@HAVE_GETHOSTNAME@
741 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
742 _GL_ARG_NONNULL ((1)));
744 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
747 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
749 _GL_CXXALIASWARN (gethostname
);
750 #elif @UNISTD_H_HAVE_WINSOCK2_H@
752 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
753 #elif defined GNULIB_POSIXCHECK
755 # if HAVE_RAW_DECL_GETHOSTNAME
756 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
757 "use gnulib module gethostname for portability");
762 #if @GNULIB_GETLOGIN@
763 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
764 returns NULL with errno set.
766 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
768 Most programs don't need to use this function, because the information is
769 available through environment variables:
770 ${LOGNAME-$USER} on Unix platforms,
771 $USERNAME on native Windows platforms.
773 # if !@HAVE_GETLOGIN@
774 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
776 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
777 _GL_CXXALIASWARN (getlogin
);
778 #elif defined GNULIB_POSIXCHECK
780 # if HAVE_RAW_DECL_GETLOGIN
781 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
782 "use gnulib module getlogin for portability");
787 #if @GNULIB_GETLOGIN_R@
788 /* Copies the user's login name to NAME.
789 The array pointed to by NAME has room for SIZE bytes.
791 Returns 0 if successful. Upon error, an error number is returned, or -1 in
792 the case that the login name cannot be found but no specific error is
793 provided (this case is hopefully rare but is left open by the POSIX spec).
795 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
797 Most programs don't need to use this function, because the information is
798 available through environment variables:
799 ${LOGNAME-$USER} on Unix platforms,
800 $USERNAME on native Windows platforms.
802 # if @REPLACE_GETLOGIN_R@
803 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
804 # define getlogin_r rpl_getlogin_r
806 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
807 _GL_ARG_NONNULL ((1)));
808 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
810 # if !@HAVE_DECL_GETLOGIN_R@
811 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
812 _GL_ARG_NONNULL ((1)));
814 /* Need to cast, because on Solaris 10 systems, the second argument is
816 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
818 _GL_CXXALIASWARN (getlogin_r
);
819 #elif defined GNULIB_POSIXCHECK
821 # if HAVE_RAW_DECL_GETLOGIN_R
822 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
823 "use gnulib module getlogin_r for portability");
828 #if @GNULIB_GETPAGESIZE@
829 # if @REPLACE_GETPAGESIZE@
830 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
831 # define getpagesize rpl_getpagesize
833 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
834 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
836 # if !@HAVE_GETPAGESIZE@
837 # if !defined getpagesize
838 /* This is for POSIX systems. */
839 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
840 # if ! (defined __VMS && __VMS_VER < 70000000)
841 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
844 /* This is for older VMS. */
845 # if !defined _gl_getpagesize && defined __VMS
847 # define _gl_getpagesize() 8192
849 # define _gl_getpagesize() 512
852 /* This is for BeOS. */
853 # if !defined _gl_getpagesize && @HAVE_OS_H@
855 # if defined B_PAGE_SIZE
856 # define _gl_getpagesize() B_PAGE_SIZE
859 /* This is for AmigaOS4.0. */
860 # if !defined _gl_getpagesize && defined __amigaos4__
861 # define _gl_getpagesize() 2048
863 /* This is for older Unix systems. */
864 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
865 # include <sys/param.h>
866 # ifdef EXEC_PAGESIZE
867 # define _gl_getpagesize() EXEC_PAGESIZE
873 # define _gl_getpagesize() (NBPG * CLSIZE)
876 # define _gl_getpagesize() NBPC
881 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
882 # define getpagesize() _gl_getpagesize ()
884 # if !GNULIB_defined_getpagesize_function
885 _GL_UNISTD_INLINE
int
888 return _gl_getpagesize ();
890 # define GNULIB_defined_getpagesize_function 1
895 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
896 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
898 # if @HAVE_DECL_GETPAGESIZE@
899 _GL_CXXALIASWARN (getpagesize
);
901 #elif defined GNULIB_POSIXCHECK
903 # if HAVE_RAW_DECL_GETPAGESIZE
904 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
905 "use gnulib module getpagesize for portability");
910 #if @GNULIB_GETUSERSHELL@
911 /* Return the next valid login shell on the system, or NULL when the end of
912 the list has been reached. */
913 # if !@HAVE_DECL_GETUSERSHELL@
914 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
916 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
917 _GL_CXXALIASWARN (getusershell
);
918 #elif defined GNULIB_POSIXCHECK
920 # if HAVE_RAW_DECL_GETUSERSHELL
921 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
922 "use gnulib module getusershell for portability");
926 #if @GNULIB_GETUSERSHELL@
927 /* Rewind to pointer that is advanced at each getusershell() call. */
928 # if !@HAVE_DECL_GETUSERSHELL@
929 _GL_FUNCDECL_SYS (setusershell
, void, (void));
931 _GL_CXXALIAS_SYS (setusershell
, void, (void));
932 _GL_CXXALIASWARN (setusershell
);
933 #elif defined GNULIB_POSIXCHECK
935 # if HAVE_RAW_DECL_SETUSERSHELL
936 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
937 "use gnulib module getusershell for portability");
941 #if @GNULIB_GETUSERSHELL@
942 /* Free the pointer that is advanced at each getusershell() call and
943 associated resources. */
944 # if !@HAVE_DECL_GETUSERSHELL@
945 _GL_FUNCDECL_SYS (endusershell
, void, (void));
947 _GL_CXXALIAS_SYS (endusershell
, void, (void));
948 _GL_CXXALIASWARN (endusershell
);
949 #elif defined GNULIB_POSIXCHECK
951 # if HAVE_RAW_DECL_ENDUSERSHELL
952 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
953 "use gnulib module getusershell for portability");
958 #if @GNULIB_GROUP_MEMBER@
959 /* Determine whether group id is in calling user's group list. */
960 # if !@HAVE_GROUP_MEMBER@
961 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
963 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
964 _GL_CXXALIASWARN (group_member
);
965 #elif defined GNULIB_POSIXCHECK
967 # if HAVE_RAW_DECL_GROUP_MEMBER
968 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
969 "use gnulib module group-member for portability");
975 # if @REPLACE_ISATTY@
976 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
978 # define isatty rpl_isatty
980 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
981 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
983 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
985 _GL_CXXALIASWARN (isatty
);
986 #elif defined GNULIB_POSIXCHECK
988 # if HAVE_RAW_DECL_ISATTY
989 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
990 "use gnulib module isatty for portability");
996 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
997 to GID (if GID is not -1). Do not follow symbolic links.
998 Return 0 if successful, otherwise -1 and errno set.
999 See the POSIX:2008 specification
1000 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1001 # if @REPLACE_LCHOWN@
1002 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1004 # define lchown rpl_lchown
1006 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1007 _GL_ARG_NONNULL ((1)));
1008 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1011 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1012 _GL_ARG_NONNULL ((1)));
1014 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1016 _GL_CXXALIASWARN (lchown
);
1017 #elif defined GNULIB_POSIXCHECK
1019 # if HAVE_RAW_DECL_LCHOWN
1020 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1021 "use gnulib module lchown for portability");
1027 /* Create a new hard link for an existing file.
1028 Return 0 if successful, otherwise -1 and errno set.
1029 See POSIX:2008 specification
1030 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1032 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1033 # define link rpl_link
1035 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1036 _GL_ARG_NONNULL ((1, 2)));
1037 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1040 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1041 _GL_ARG_NONNULL ((1, 2)));
1043 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1045 _GL_CXXALIASWARN (link
);
1046 #elif defined GNULIB_POSIXCHECK
1048 # if HAVE_RAW_DECL_LINK
1049 _GL_WARN_ON_USE (link
, "link is unportable - "
1050 "use gnulib module link for portability");
1056 /* Create a new hard link for an existing file, relative to two
1057 directories. FLAG controls whether symlinks are followed.
1058 Return 0 if successful, otherwise -1 and errno set. */
1059 # if @REPLACE_LINKAT@
1060 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1062 # define linkat rpl_linkat
1064 _GL_FUNCDECL_RPL (linkat
, int,
1065 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1067 _GL_ARG_NONNULL ((2, 4)));
1068 _GL_CXXALIAS_RPL (linkat
, int,
1069 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1073 _GL_FUNCDECL_SYS (linkat
, int,
1074 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1076 _GL_ARG_NONNULL ((2, 4)));
1078 _GL_CXXALIAS_SYS (linkat
, int,
1079 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1082 _GL_CXXALIASWARN (linkat
);
1083 #elif defined GNULIB_POSIXCHECK
1085 # if HAVE_RAW_DECL_LINKAT
1086 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1087 "use gnulib module linkat for portability");
1093 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1094 Return the new offset if successful, otherwise -1 and errno set.
1095 See the POSIX:2008 specification
1096 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1097 # if @REPLACE_LSEEK@
1098 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1099 # define lseek rpl_lseek
1101 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1102 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1104 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1106 _GL_CXXALIASWARN (lseek
);
1107 #elif defined GNULIB_POSIXCHECK
1109 # if HAVE_RAW_DECL_LSEEK
1110 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1111 "systems - use gnulib module lseek for portability");
1117 /* Create a pipe, defaulting to O_BINARY mode.
1118 Store the read-end as fd[0] and the write-end as fd[1].
1119 Return 0 upon success, or -1 with errno set upon failure. */
1121 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1123 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1124 _GL_CXXALIASWARN (pipe
);
1125 #elif defined GNULIB_POSIXCHECK
1127 # if HAVE_RAW_DECL_PIPE
1128 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1129 "use gnulib module pipe-posix for portability");
1135 /* Create a pipe, applying the given flags when opening the read-end of the
1136 pipe and the write-end of the pipe.
1137 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1138 and O_TEXT, O_BINARY (defined in "binary-io.h").
1139 Store the read-end as fd[0] and the write-end as fd[1].
1140 Return 0 upon success, or -1 with errno set upon failure.
1141 See also the Linux man page at
1142 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1144 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1145 # define pipe2 rpl_pipe2
1147 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1148 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1150 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1151 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1153 _GL_CXXALIASWARN (pipe2
);
1154 #elif defined GNULIB_POSIXCHECK
1156 # if HAVE_RAW_DECL_PIPE2
1157 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1158 "use gnulib module pipe2 for portability");
1164 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1165 Return the number of bytes placed into BUF if successful, otherwise
1166 set errno and return -1. 0 indicates EOF.
1167 See the POSIX:2008 specification
1168 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1169 # if @REPLACE_PREAD@
1170 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1172 # define pread rpl_pread
1174 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1175 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1176 _GL_ARG_NONNULL ((2)));
1177 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1178 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1181 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1182 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1183 _GL_ARG_NONNULL ((2)));
1185 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1186 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1188 _GL_CXXALIASWARN (pread
);
1189 #elif defined GNULIB_POSIXCHECK
1191 # if HAVE_RAW_DECL_PREAD
1192 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1193 "use gnulib module pread for portability");
1199 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1200 Return the number of bytes written if successful, otherwise
1201 set errno and return -1. 0 indicates nothing written. See the
1202 POSIX:2008 specification
1203 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1204 # if @REPLACE_PWRITE@
1205 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1207 # define pwrite rpl_pwrite
1209 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1210 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1211 _GL_ARG_NONNULL ((2)));
1212 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1213 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1216 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1217 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1218 _GL_ARG_NONNULL ((2)));
1220 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1221 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1223 _GL_CXXALIASWARN (pwrite
);
1224 #elif defined GNULIB_POSIXCHECK
1226 # if HAVE_RAW_DECL_PWRITE
1227 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1228 "use gnulib module pwrite for portability");
1234 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1235 at BUF. See the POSIX:2008 specification
1236 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1238 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1240 # define read rpl_read
1242 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1243 _GL_ARG_NONNULL ((2)));
1244 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1246 /* Need to cast, because on mingw, the third parameter is
1248 and the return type is 'int'. */
1249 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1251 _GL_CXXALIASWARN (read
);
1255 #if @GNULIB_READLINK@
1256 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1257 bytes of it into BUF. Return the number of bytes placed into BUF if
1258 successful, otherwise -1 and errno set.
1259 See the POSIX:2008 specification
1260 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1261 # if @REPLACE_READLINK@
1262 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1263 # define readlink rpl_readlink
1265 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1266 (const char *file
, char *buf
, size_t bufsize
)
1267 _GL_ARG_NONNULL ((1, 2)));
1268 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1269 (const char *file
, char *buf
, size_t bufsize
));
1271 # if !@HAVE_READLINK@
1272 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1273 (const char *file
, char *buf
, size_t bufsize
)
1274 _GL_ARG_NONNULL ((1, 2)));
1276 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1277 (const char *file
, char *buf
, size_t bufsize
));
1279 _GL_CXXALIASWARN (readlink
);
1280 #elif defined GNULIB_POSIXCHECK
1282 # if HAVE_RAW_DECL_READLINK
1283 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1284 "use gnulib module readlink for portability");
1289 #if @GNULIB_READLINKAT@
1290 # if !@HAVE_READLINKAT@
1291 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1292 (int fd
, char const *file
, char *buf
, size_t len
)
1293 _GL_ARG_NONNULL ((2, 3)));
1295 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1296 (int fd
, char const *file
, char *buf
, size_t len
));
1297 _GL_CXXALIASWARN (readlinkat
);
1298 #elif defined GNULIB_POSIXCHECK
1300 # if HAVE_RAW_DECL_READLINKAT
1301 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1302 "use gnulib module readlinkat for portability");
1308 /* Remove the directory DIR. */
1309 # if @REPLACE_RMDIR@
1310 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1311 # define rmdir rpl_rmdir
1313 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1314 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1316 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1318 _GL_CXXALIASWARN (rmdir
);
1319 #elif defined GNULIB_POSIXCHECK
1321 # if HAVE_RAW_DECL_RMDIR
1322 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1323 "use gnulib module rmdir for portability");
1328 #if @GNULIB_SETHOSTNAME@
1329 /* Set the host name of the machine.
1330 The host name may or may not be fully qualified.
1332 Put LEN bytes of NAME into the host name.
1333 Return 0 if successful, otherwise, set errno and return -1.
1335 Platforms with no ability to set the hostname return -1 and set
1337 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1338 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1339 _GL_ARG_NONNULL ((1)));
1341 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1342 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1343 2011-10, the first parameter is not const. */
1344 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1345 _GL_CXXALIASWARN (sethostname
);
1346 #elif defined GNULIB_POSIXCHECK
1348 # if HAVE_RAW_DECL_SETHOSTNAME
1349 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1350 "use gnulib module sethostname for portability");
1356 /* Pause the execution of the current thread for N seconds.
1357 Returns the number of seconds left to sleep.
1358 See the POSIX:2008 specification
1359 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1360 # if @REPLACE_SLEEP@
1361 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1363 # define sleep rpl_sleep
1365 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1366 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1369 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1371 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1373 _GL_CXXALIASWARN (sleep
);
1374 #elif defined GNULIB_POSIXCHECK
1376 # if HAVE_RAW_DECL_SLEEP
1377 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1378 "use gnulib module sleep for portability");
1383 #if @GNULIB_SYMLINK@
1384 # if @REPLACE_SYMLINK@
1385 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1387 # define symlink rpl_symlink
1389 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1390 _GL_ARG_NONNULL ((1, 2)));
1391 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1393 # if !@HAVE_SYMLINK@
1394 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1395 _GL_ARG_NONNULL ((1, 2)));
1397 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1399 _GL_CXXALIASWARN (symlink
);
1400 #elif defined GNULIB_POSIXCHECK
1402 # if HAVE_RAW_DECL_SYMLINK
1403 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1404 "use gnulib module symlink for portability");
1409 #if @GNULIB_SYMLINKAT@
1410 # if !@HAVE_SYMLINKAT@
1411 _GL_FUNCDECL_SYS (symlinkat
, int,
1412 (char const *contents
, int fd
, char const *file
)
1413 _GL_ARG_NONNULL ((1, 3)));
1415 _GL_CXXALIAS_SYS (symlinkat
, int,
1416 (char const *contents
, int fd
, char const *file
));
1417 _GL_CXXALIASWARN (symlinkat
);
1418 #elif defined GNULIB_POSIXCHECK
1420 # if HAVE_RAW_DECL_SYMLINKAT
1421 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1422 "use gnulib module symlinkat for portability");
1427 #if @GNULIB_TTYNAME_R@
1428 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1429 open on in BUF. Return 0 on success, otherwise an error number. */
1430 # if @REPLACE_TTYNAME_R@
1431 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1433 # define ttyname_r rpl_ttyname_r
1435 _GL_FUNCDECL_RPL (ttyname_r
, int,
1436 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1437 _GL_CXXALIAS_RPL (ttyname_r
, int,
1438 (int fd
, char *buf
, size_t buflen
));
1440 # if !@HAVE_DECL_TTYNAME_R@
1441 _GL_FUNCDECL_SYS (ttyname_r
, int,
1442 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1444 _GL_CXXALIAS_SYS (ttyname_r
, int,
1445 (int fd
, char *buf
, size_t buflen
));
1447 _GL_CXXALIASWARN (ttyname_r
);
1448 #elif defined GNULIB_POSIXCHECK
1450 # if HAVE_RAW_DECL_TTYNAME_R
1451 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1452 "use gnulib module ttyname_r for portability");
1458 # if @REPLACE_UNLINK@
1459 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1461 # define unlink rpl_unlink
1463 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1464 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1466 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1468 _GL_CXXALIASWARN (unlink
);
1469 #elif defined GNULIB_POSIXCHECK
1471 # if HAVE_RAW_DECL_UNLINK
1472 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1473 "use gnulib module unlink for portability");
1478 #if @GNULIB_UNLINKAT@
1479 # if @REPLACE_UNLINKAT@
1480 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1482 # define unlinkat rpl_unlinkat
1484 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1485 _GL_ARG_NONNULL ((2)));
1486 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1488 # if !@HAVE_UNLINKAT@
1489 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1490 _GL_ARG_NONNULL ((2)));
1492 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1494 _GL_CXXALIASWARN (unlinkat
);
1495 #elif defined GNULIB_POSIXCHECK
1497 # if HAVE_RAW_DECL_UNLINKAT
1498 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1499 "use gnulib module openat for portability");
1505 /* Pause the execution of the current thread for N microseconds.
1506 Returns 0 on completion, or -1 on range error.
1507 See the POSIX:2001 specification
1508 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1509 # if @REPLACE_USLEEP@
1510 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1512 # define usleep rpl_usleep
1514 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1515 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1518 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1520 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1522 _GL_CXXALIASWARN (usleep
);
1523 #elif defined GNULIB_POSIXCHECK
1525 # if HAVE_RAW_DECL_USLEEP
1526 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1527 "use gnulib module usleep for portability");
1533 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1534 See the POSIX:2008 specification
1535 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1536 # if @REPLACE_WRITE@
1537 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1539 # define write rpl_write
1541 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1542 _GL_ARG_NONNULL ((2)));
1543 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1545 /* Need to cast, because on mingw, the third parameter is
1547 and the return type is 'int'. */
1548 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1550 _GL_CXXALIASWARN (write
);
1553 _GL_INLINE_HEADER_END
1555 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1556 #endif /* _GL_INCLUDING_UNISTD_H */
1557 #endif /* _@GUARD_PREFIX@_UNISTD_H */