1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2013 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 /* The include_next requires a split double-inclusion guard. */
26 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
29 /* Get all possible declarations of gethostname(). */
30 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
31 && !defined _GL_INCLUDING_WINSOCK2_H
32 # define _GL_INCLUDING_WINSOCK2_H
33 # include <winsock2.h>
34 # undef _GL_INCLUDING_WINSOCK2_H
37 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
38 #define _@GUARD_PREFIX@_UNISTD_H
40 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
43 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
44 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
45 /* But avoid namespace pollution on glibc systems. */
46 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
47 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
48 && defined __CYGWIN__)) \
49 && ! defined __GLIBC__
53 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
54 /* But avoid namespace pollution on glibc systems. */
55 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
56 && ! defined __GLIBC__
60 /* mingw fails to declare _exit in <unistd.h>. */
61 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
63 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
64 /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
66 /* But avoid namespace pollution on glibc systems. */
67 #if !defined __GLIBC__ && !defined __osf__
68 # define __need_system_stdlib_h
70 # undef __need_system_stdlib_h
73 /* Native Windows platforms declare chdir, getcwd, rmdir in
74 <io.h> and/or <direct.h>, not in <unistd.h>.
75 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
76 lseek(), read(), unlink(), write() in <io.h>. */
77 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
78 || defined GNULIB_POSIXCHECK) \
79 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
80 # include <io.h> /* mingw32, mingw64 */
81 # include <direct.h> /* mingw64, MSVC 9 */
82 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
83 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
84 || defined GNULIB_POSIXCHECK) \
85 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
89 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
90 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
91 /* But avoid namespace pollution on glibc systems. */
92 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
93 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
98 /* MSVC defines off_t in <sys/types.h>.
99 May also define off_t to a 64-bit type on native Windows. */
100 #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
102 # include <sys/types.h>
105 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
106 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
107 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
109 # include <sys/types.h>
112 /* Get getopt(), optarg, optind, opterr, optopt.
113 But avoid namespace pollution on glibc systems. */
114 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
115 # define __need_getopt
119 #ifndef _GL_INLINE_HEADER_BEGIN
120 #error "Please include config.h first."
122 _GL_INLINE_HEADER_BEGIN
123 #ifndef _GL_UNISTD_INLINE
124 # define _GL_UNISTD_INLINE _GL_INLINE
127 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
129 /* The definition of _GL_ARG_NONNULL is copied here. */
131 /* The definition of _GL_WARN_ON_USE is copied here. */
134 /* Hide some function declarations from <winsock2.h>. */
136 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
137 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
138 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
140 # define socket socket_used_without_including_sys_socket_h
142 # define connect connect_used_without_including_sys_socket_h
144 # define accept accept_used_without_including_sys_socket_h
146 # define bind bind_used_without_including_sys_socket_h
148 # define getpeername getpeername_used_without_including_sys_socket_h
150 # define getsockname getsockname_used_without_including_sys_socket_h
152 # define getsockopt getsockopt_used_without_including_sys_socket_h
154 # define listen listen_used_without_including_sys_socket_h
156 # define recv recv_used_without_including_sys_socket_h
158 # define send send_used_without_including_sys_socket_h
160 # define recvfrom recvfrom_used_without_including_sys_socket_h
162 # define sendto sendto_used_without_including_sys_socket_h
164 # define setsockopt setsockopt_used_without_including_sys_socket_h
166 # define shutdown shutdown_used_without_including_sys_socket_h
168 _GL_WARN_ON_USE (socket
,
169 "socket() used without including <sys/socket.h>");
170 _GL_WARN_ON_USE (connect
,
171 "connect() used without including <sys/socket.h>");
172 _GL_WARN_ON_USE (accept
,
173 "accept() used without including <sys/socket.h>");
174 _GL_WARN_ON_USE (bind
,
175 "bind() used without including <sys/socket.h>");
176 _GL_WARN_ON_USE (getpeername
,
177 "getpeername() used without including <sys/socket.h>");
178 _GL_WARN_ON_USE (getsockname
,
179 "getsockname() used without including <sys/socket.h>");
180 _GL_WARN_ON_USE (getsockopt
,
181 "getsockopt() used without including <sys/socket.h>");
182 _GL_WARN_ON_USE (listen
,
183 "listen() used without including <sys/socket.h>");
184 _GL_WARN_ON_USE (recv
,
185 "recv() used without including <sys/socket.h>");
186 _GL_WARN_ON_USE (send
,
187 "send() used without including <sys/socket.h>");
188 _GL_WARN_ON_USE (recvfrom
,
189 "recvfrom() used without including <sys/socket.h>");
190 _GL_WARN_ON_USE (sendto
,
191 "sendto() used without including <sys/socket.h>");
192 _GL_WARN_ON_USE (setsockopt
,
193 "setsockopt() used without including <sys/socket.h>");
194 _GL_WARN_ON_USE (shutdown
,
195 "shutdown() used without including <sys/socket.h>");
198 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
199 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
201 # define select select_used_without_including_sys_select_h
203 _GL_WARN_ON_USE (select
,
204 "select() used without including <sys/select.h>");
210 /* OS/2 EMX lacks these macros. */
212 # define STDIN_FILENO 0
214 #ifndef STDOUT_FILENO
215 # define STDOUT_FILENO 1
217 #ifndef STDERR_FILENO
218 # define STDERR_FILENO 2
221 /* Ensure *_OK macros exist. */
230 /* Declare overridden functions. */
233 #if defined GNULIB_POSIXCHECK
234 /* The access() function is a security risk. */
235 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
236 "use the gnulib module faccessat instead");
241 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
242 _GL_CXXALIASWARN (chdir
);
243 #elif defined GNULIB_POSIXCHECK
245 # if HAVE_RAW_DECL_CHDIR
246 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
247 "use gnulib module chdir for portability");
253 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
254 to GID (if GID is not -1). Follow symbolic links.
255 Return 0 if successful, otherwise -1 and errno set.
256 See the POSIX:2008 specification
257 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
259 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
261 # define chown rpl_chown
263 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
264 _GL_ARG_NONNULL ((1)));
265 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
268 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
269 _GL_ARG_NONNULL ((1)));
271 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
273 _GL_CXXALIASWARN (chown
);
274 #elif defined GNULIB_POSIXCHECK
276 # if HAVE_RAW_DECL_CHOWN
277 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
278 "doesn't treat a uid or gid of -1 on some systems - "
279 "use gnulib module chown for portability");
286 /* Automatically included by modules that need a replacement for close. */
287 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
289 # define close rpl_close
291 _GL_FUNCDECL_RPL (close
, int, (int fd
));
292 _GL_CXXALIAS_RPL (close
, int, (int fd
));
294 _GL_CXXALIAS_SYS (close
, int, (int fd
));
296 _GL_CXXALIASWARN (close
);
297 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
299 # define close close_used_without_requesting_gnulib_module_close
300 #elif defined GNULIB_POSIXCHECK
302 /* Assume close is always declared. */
303 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
304 "use gnulib module close for portability");
310 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
313 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
314 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
316 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
318 _GL_CXXALIASWARN (dup
);
319 #elif defined GNULIB_POSIXCHECK
321 # if HAVE_RAW_DECL_DUP
322 _GL_WARN_ON_USE (dup
, "dup is unportable - "
323 "use gnulib module dup for portability");
329 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
330 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
331 Return newfd if successful, otherwise -1 and errno set.
332 See the POSIX:2008 specification
333 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
335 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
336 # define dup2 rpl_dup2
338 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
339 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
342 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
344 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
346 _GL_CXXALIASWARN (dup2
);
347 #elif defined GNULIB_POSIXCHECK
349 # if HAVE_RAW_DECL_DUP2
350 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
351 "use gnulib module dup2 for portability");
357 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
359 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
360 and O_TEXT, O_BINARY (defined in "binary-io.h").
361 Close NEWFD first if it is open.
362 Return newfd if successful, otherwise -1 and errno set.
363 See the Linux man page at
364 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
366 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
367 # define dup3 rpl_dup3
369 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
370 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
372 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
373 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
375 _GL_CXXALIASWARN (dup3
);
376 #elif defined GNULIB_POSIXCHECK
378 # if HAVE_RAW_DECL_DUP3
379 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
380 "use gnulib module dup3 for portability");
386 # if !@HAVE_DECL_ENVIRON@
387 /* Set of environment variables and values. An array of strings of the form
388 "VARIABLE=VALUE", terminated with a NULL. */
389 # if defined __APPLE__ && defined __MACH__
390 # include <crt_externs.h>
391 # define environ (*_NSGetEnviron ())
396 extern char **environ
;
402 #elif defined GNULIB_POSIXCHECK
403 # if HAVE_RAW_DECL_ENVIRON
404 _GL_UNISTD_INLINE
char ***
409 _GL_WARN_ON_USE (rpl_environ
, "environ is unportable - "
410 "use gnulib module environ for portability");
412 # define environ (*rpl_environ ())
417 #if @GNULIB_EUIDACCESS@
418 /* Like access(), except that it uses the effective user id and group id of
419 the current process. */
420 # if !@HAVE_EUIDACCESS@
421 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
422 _GL_ARG_NONNULL ((1)));
424 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
425 _GL_CXXALIASWARN (euidaccess
);
426 # if defined GNULIB_POSIXCHECK
427 /* Like access(), this function is a security risk. */
428 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
429 "use the gnulib module faccessat instead");
431 #elif defined GNULIB_POSIXCHECK
433 # if HAVE_RAW_DECL_EUIDACCESS
434 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
435 "use gnulib module euidaccess for portability");
440 #if @GNULIB_FACCESSAT@
441 # if !@HAVE_FACCESSAT@
442 _GL_FUNCDECL_SYS (faccessat
, int,
443 (int fd
, char const *file
, int mode
, int flag
)
444 _GL_ARG_NONNULL ((2)));
446 _GL_CXXALIAS_SYS (faccessat
, int,
447 (int fd
, char const *file
, int mode
, int flag
));
448 _GL_CXXALIASWARN (faccessat
);
449 #elif defined GNULIB_POSIXCHECK
451 # if HAVE_RAW_DECL_FACCESSAT
452 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
453 "use gnulib module faccessat for portability");
459 /* Change the process' current working directory to the directory on which
460 the given file descriptor is open.
461 Return 0 if successful, otherwise -1 and errno set.
462 See the POSIX:2008 specification
463 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
465 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
467 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
468 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
469 _GL_ARG_NONNULL ((2));
470 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
471 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
472 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
475 # if !@HAVE_DECL_FCHDIR@
476 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
479 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
480 _GL_CXXALIASWARN (fchdir
);
481 #elif defined GNULIB_POSIXCHECK
483 # if HAVE_RAW_DECL_FCHDIR
484 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
485 "use gnulib module fchdir for portability");
490 #if @GNULIB_FCHOWNAT@
491 # if @REPLACE_FCHOWNAT@
492 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
494 # define fchownat rpl_fchownat
496 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
497 uid_t owner
, gid_t group
, int flag
)
498 _GL_ARG_NONNULL ((2)));
499 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
500 uid_t owner
, gid_t group
, int flag
));
502 # if !@HAVE_FCHOWNAT@
503 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
504 uid_t owner
, gid_t group
, int flag
)
505 _GL_ARG_NONNULL ((2)));
507 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
508 uid_t owner
, gid_t group
, int flag
));
510 _GL_CXXALIASWARN (fchownat
);
511 #elif defined GNULIB_POSIXCHECK
513 # if HAVE_RAW_DECL_FCHOWNAT
514 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
515 "use gnulib module openat for portability");
520 #if @GNULIB_FDATASYNC@
521 /* Synchronize changes to a file.
522 Return 0 if successful, otherwise -1 and errno set.
523 See POSIX:2008 specification
524 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
525 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
526 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
528 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
529 _GL_CXXALIASWARN (fdatasync
);
530 #elif defined GNULIB_POSIXCHECK
532 # if HAVE_RAW_DECL_FDATASYNC
533 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
534 "use gnulib module fdatasync for portability");
540 /* Synchronize changes, including metadata, to a file.
541 Return 0 if successful, otherwise -1 and errno set.
542 See POSIX:2008 specification
543 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
545 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
547 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
548 _GL_CXXALIASWARN (fsync
);
549 #elif defined GNULIB_POSIXCHECK
551 # if HAVE_RAW_DECL_FSYNC
552 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
553 "use gnulib module fsync for portability");
558 #if @GNULIB_FTRUNCATE@
559 /* Change the size of the file to which FD is opened to become equal to LENGTH.
560 Return 0 if successful, otherwise -1 and errno set.
561 See the POSIX:2008 specification
562 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
563 # if @REPLACE_FTRUNCATE@
564 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
566 # define ftruncate rpl_ftruncate
568 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
569 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
571 # if !@HAVE_FTRUNCATE@
572 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
574 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
576 _GL_CXXALIASWARN (ftruncate
);
577 #elif defined GNULIB_POSIXCHECK
579 # if HAVE_RAW_DECL_FTRUNCATE
580 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
581 "use gnulib module ftruncate for portability");
587 /* Get the name of the current working directory, and put it in SIZE bytes
589 Return BUF if successful, or NULL if the directory couldn't be determined
590 or SIZE was too small.
591 See the POSIX:2008 specification
592 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
593 Additionally, the gnulib module 'getcwd' guarantees the following GNU
594 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
595 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
597 # if @REPLACE_GETCWD@
598 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
599 # define getcwd rpl_getcwd
601 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
602 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
604 /* Need to cast, because on mingw, the second parameter is
606 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
608 _GL_CXXALIASWARN (getcwd
);
609 #elif defined GNULIB_POSIXCHECK
611 # if HAVE_RAW_DECL_GETCWD
612 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
613 "use gnulib module getcwd for portability");
618 #if @GNULIB_GETDOMAINNAME@
619 /* Return the NIS domain name of the machine.
620 WARNING! The NIS domain name is unrelated to the fully qualified host name
621 of the machine. It is also unrelated to email addresses.
622 WARNING! The NIS domain name is usually the empty string or "(none)" when
625 Put up to LEN bytes of the NIS domain name into NAME.
626 Null terminate it if the name is shorter than LEN.
627 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
628 Return 0 if successful, otherwise set errno and return -1. */
629 # if @REPLACE_GETDOMAINNAME@
630 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
631 # undef getdomainname
632 # define getdomainname rpl_getdomainname
634 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
635 _GL_ARG_NONNULL ((1)));
636 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
638 # if !@HAVE_DECL_GETDOMAINNAME@
639 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
640 _GL_ARG_NONNULL ((1)));
642 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
644 _GL_CXXALIASWARN (getdomainname
);
645 #elif defined GNULIB_POSIXCHECK
646 # undef getdomainname
647 # if HAVE_RAW_DECL_GETDOMAINNAME
648 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
649 "use gnulib module getdomainname for portability");
654 #if @GNULIB_GETDTABLESIZE@
655 /* Return the maximum number of file descriptors in the current process.
656 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
657 # if @REPLACE_GETDTABLESIZE@
658 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
659 # undef getdtablesize
660 # define getdtablesize rpl_getdtablesize
662 _GL_FUNCDECL_RPL (getdtablesize
, int, (void));
663 _GL_CXXALIAS_RPL (getdtablesize
, int, (void));
665 # if !@HAVE_GETDTABLESIZE@
666 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
668 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
670 _GL_CXXALIASWARN (getdtablesize
);
671 #elif defined GNULIB_POSIXCHECK
672 # undef getdtablesize
673 # if HAVE_RAW_DECL_GETDTABLESIZE
674 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
675 "use gnulib module getdtablesize for portability");
680 #if @GNULIB_GETGROUPS@
681 /* Return the supplemental groups that the current process belongs to.
682 It is unspecified whether the effective group id is in the list.
683 If N is 0, return the group count; otherwise, N describes how many
684 entries are available in GROUPS. Return -1 and set errno if N is
685 not 0 and not large enough. Fails with ENOSYS on some systems. */
686 # if @REPLACE_GETGROUPS@
687 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
689 # define getgroups rpl_getgroups
691 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
692 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
694 # if !@HAVE_GETGROUPS@
695 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
697 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
699 _GL_CXXALIASWARN (getgroups
);
700 #elif defined GNULIB_POSIXCHECK
702 # if HAVE_RAW_DECL_GETGROUPS
703 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
704 "use gnulib module getgroups for portability");
709 #if @GNULIB_GETHOSTNAME@
710 /* Return the standard host name of the machine.
711 WARNING! The host name may or may not be fully qualified.
713 Put up to LEN bytes of the host name into NAME.
714 Null terminate it if the name is shorter than LEN.
715 If the host name is longer than LEN, set errno = EINVAL and return -1.
716 Return 0 if successful, otherwise set errno and return -1. */
717 # if @UNISTD_H_HAVE_WINSOCK2_H@
718 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
720 # define gethostname rpl_gethostname
722 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
723 _GL_ARG_NONNULL ((1)));
724 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
726 # if !@HAVE_GETHOSTNAME@
727 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
728 _GL_ARG_NONNULL ((1)));
730 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
733 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
735 _GL_CXXALIASWARN (gethostname
);
736 #elif @UNISTD_H_HAVE_WINSOCK2_H@
738 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
739 #elif defined GNULIB_POSIXCHECK
741 # if HAVE_RAW_DECL_GETHOSTNAME
742 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
743 "use gnulib module gethostname for portability");
748 #if @GNULIB_GETLOGIN@
749 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
750 returns NULL with errno set.
752 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
754 Most programs don't need to use this function, because the information is
755 available through environment variables:
756 ${LOGNAME-$USER} on Unix platforms,
757 $USERNAME on native Windows platforms.
759 # if !@HAVE_GETLOGIN@
760 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
762 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
763 _GL_CXXALIASWARN (getlogin
);
764 #elif defined GNULIB_POSIXCHECK
766 # if HAVE_RAW_DECL_GETLOGIN
767 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
768 "use gnulib module getlogin for portability");
773 #if @GNULIB_GETLOGIN_R@
774 /* Copies the user's login name to NAME.
775 The array pointed to by NAME has room for SIZE bytes.
777 Returns 0 if successful. Upon error, an error number is returned, or -1 in
778 the case that the login name cannot be found but no specific error is
779 provided (this case is hopefully rare but is left open by the POSIX spec).
781 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
783 Most programs don't need to use this function, because the information is
784 available through environment variables:
785 ${LOGNAME-$USER} on Unix platforms,
786 $USERNAME on native Windows platforms.
788 # if @REPLACE_GETLOGIN_R@
789 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
790 # define getlogin_r rpl_getlogin_r
792 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
793 _GL_ARG_NONNULL ((1)));
794 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
796 # if !@HAVE_DECL_GETLOGIN_R@
797 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
798 _GL_ARG_NONNULL ((1)));
800 /* Need to cast, because on Solaris 10 systems, the second argument is
802 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
804 _GL_CXXALIASWARN (getlogin_r
);
805 #elif defined GNULIB_POSIXCHECK
807 # if HAVE_RAW_DECL_GETLOGIN_R
808 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
809 "use gnulib module getlogin_r for portability");
814 #if @GNULIB_GETPAGESIZE@
815 # if @REPLACE_GETPAGESIZE@
816 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
817 # define getpagesize rpl_getpagesize
819 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
820 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
822 # if !@HAVE_GETPAGESIZE@
823 # if !defined getpagesize
824 /* This is for POSIX systems. */
825 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
826 # if ! (defined __VMS && __VMS_VER < 70000000)
827 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
830 /* This is for older VMS. */
831 # if !defined _gl_getpagesize && defined __VMS
833 # define _gl_getpagesize() 8192
835 # define _gl_getpagesize() 512
838 /* This is for BeOS. */
839 # if !defined _gl_getpagesize && @HAVE_OS_H@
841 # if defined B_PAGE_SIZE
842 # define _gl_getpagesize() B_PAGE_SIZE
845 /* This is for AmigaOS4.0. */
846 # if !defined _gl_getpagesize && defined __amigaos4__
847 # define _gl_getpagesize() 2048
849 /* This is for older Unix systems. */
850 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
851 # include <sys/param.h>
852 # ifdef EXEC_PAGESIZE
853 # define _gl_getpagesize() EXEC_PAGESIZE
859 # define _gl_getpagesize() (NBPG * CLSIZE)
862 # define _gl_getpagesize() NBPC
867 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
868 # define getpagesize() _gl_getpagesize ()
870 # if !GNULIB_defined_getpagesize_function
871 _GL_UNISTD_INLINE
int
874 return _gl_getpagesize ();
876 # define GNULIB_defined_getpagesize_function 1
881 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
882 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
884 # if @HAVE_DECL_GETPAGESIZE@
885 _GL_CXXALIASWARN (getpagesize
);
887 #elif defined GNULIB_POSIXCHECK
889 # if HAVE_RAW_DECL_GETPAGESIZE
890 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
891 "use gnulib module getpagesize for portability");
896 #if @GNULIB_GETUSERSHELL@
897 /* Return the next valid login shell on the system, or NULL when the end of
898 the list has been reached. */
899 # if !@HAVE_DECL_GETUSERSHELL@
900 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
902 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
903 _GL_CXXALIASWARN (getusershell
);
904 #elif defined GNULIB_POSIXCHECK
906 # if HAVE_RAW_DECL_GETUSERSHELL
907 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
908 "use gnulib module getusershell for portability");
912 #if @GNULIB_GETUSERSHELL@
913 /* Rewind to pointer that is advanced at each getusershell() call. */
914 # if !@HAVE_DECL_GETUSERSHELL@
915 _GL_FUNCDECL_SYS (setusershell
, void, (void));
917 _GL_CXXALIAS_SYS (setusershell
, void, (void));
918 _GL_CXXALIASWARN (setusershell
);
919 #elif defined GNULIB_POSIXCHECK
921 # if HAVE_RAW_DECL_SETUSERSHELL
922 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
923 "use gnulib module getusershell for portability");
927 #if @GNULIB_GETUSERSHELL@
928 /* Free the pointer that is advanced at each getusershell() call and
929 associated resources. */
930 # if !@HAVE_DECL_GETUSERSHELL@
931 _GL_FUNCDECL_SYS (endusershell
, void, (void));
933 _GL_CXXALIAS_SYS (endusershell
, void, (void));
934 _GL_CXXALIASWARN (endusershell
);
935 #elif defined GNULIB_POSIXCHECK
937 # if HAVE_RAW_DECL_ENDUSERSHELL
938 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
939 "use gnulib module getusershell for portability");
944 #if @GNULIB_GROUP_MEMBER@
945 /* Determine whether group id is in calling user's group list. */
946 # if !@HAVE_GROUP_MEMBER@
947 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
949 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
950 _GL_CXXALIASWARN (group_member
);
951 #elif defined GNULIB_POSIXCHECK
953 # if HAVE_RAW_DECL_GROUP_MEMBER
954 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
955 "use gnulib module group-member for portability");
961 # if @REPLACE_ISATTY@
962 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
964 # define isatty rpl_isatty
966 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
967 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
969 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
971 _GL_CXXALIASWARN (isatty
);
972 #elif defined GNULIB_POSIXCHECK
974 # if HAVE_RAW_DECL_ISATTY
975 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
976 "use gnulib module isatty for portability");
982 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
983 to GID (if GID is not -1). Do not follow symbolic links.
984 Return 0 if successful, otherwise -1 and errno set.
985 See the POSIX:2008 specification
986 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
987 # if @REPLACE_LCHOWN@
988 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
990 # define lchown rpl_lchown
992 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
993 _GL_ARG_NONNULL ((1)));
994 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
997 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
998 _GL_ARG_NONNULL ((1)));
1000 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1002 _GL_CXXALIASWARN (lchown
);
1003 #elif defined GNULIB_POSIXCHECK
1005 # if HAVE_RAW_DECL_LCHOWN
1006 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1007 "use gnulib module lchown for portability");
1013 /* Create a new hard link for an existing file.
1014 Return 0 if successful, otherwise -1 and errno set.
1015 See POSIX:2008 specification
1016 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1018 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1019 # define link rpl_link
1021 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1022 _GL_ARG_NONNULL ((1, 2)));
1023 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1026 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1027 _GL_ARG_NONNULL ((1, 2)));
1029 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1031 _GL_CXXALIASWARN (link
);
1032 #elif defined GNULIB_POSIXCHECK
1034 # if HAVE_RAW_DECL_LINK
1035 _GL_WARN_ON_USE (link
, "link is unportable - "
1036 "use gnulib module link for portability");
1042 /* Create a new hard link for an existing file, relative to two
1043 directories. FLAG controls whether symlinks are followed.
1044 Return 0 if successful, otherwise -1 and errno set. */
1045 # if @REPLACE_LINKAT@
1046 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1048 # define linkat rpl_linkat
1050 _GL_FUNCDECL_RPL (linkat
, int,
1051 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1053 _GL_ARG_NONNULL ((2, 4)));
1054 _GL_CXXALIAS_RPL (linkat
, int,
1055 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1059 _GL_FUNCDECL_SYS (linkat
, int,
1060 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1062 _GL_ARG_NONNULL ((2, 4)));
1064 _GL_CXXALIAS_SYS (linkat
, int,
1065 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1068 _GL_CXXALIASWARN (linkat
);
1069 #elif defined GNULIB_POSIXCHECK
1071 # if HAVE_RAW_DECL_LINKAT
1072 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1073 "use gnulib module linkat for portability");
1079 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1080 Return the new offset if successful, otherwise -1 and errno set.
1081 See the POSIX:2008 specification
1082 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1083 # if @REPLACE_LSEEK@
1084 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1085 # define lseek rpl_lseek
1087 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1088 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1090 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1092 _GL_CXXALIASWARN (lseek
);
1093 #elif defined GNULIB_POSIXCHECK
1095 # if HAVE_RAW_DECL_LSEEK
1096 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1097 "systems - use gnulib module lseek for portability");
1103 /* Create a pipe, defaulting to O_BINARY mode.
1104 Store the read-end as fd[0] and the write-end as fd[1].
1105 Return 0 upon success, or -1 with errno set upon failure. */
1107 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1109 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1110 _GL_CXXALIASWARN (pipe
);
1111 #elif defined GNULIB_POSIXCHECK
1113 # if HAVE_RAW_DECL_PIPE
1114 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1115 "use gnulib module pipe-posix for portability");
1121 /* Create a pipe, applying the given flags when opening the read-end of the
1122 pipe and the write-end of the pipe.
1123 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1124 and O_TEXT, O_BINARY (defined in "binary-io.h").
1125 Store the read-end as fd[0] and the write-end as fd[1].
1126 Return 0 upon success, or -1 with errno set upon failure.
1127 See also the Linux man page at
1128 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1130 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1131 # define pipe2 rpl_pipe2
1133 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1134 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1136 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1137 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1139 _GL_CXXALIASWARN (pipe2
);
1140 #elif defined GNULIB_POSIXCHECK
1142 # if HAVE_RAW_DECL_PIPE2
1143 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1144 "use gnulib module pipe2 for portability");
1150 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1151 Return the number of bytes placed into BUF if successful, otherwise
1152 set errno and return -1. 0 indicates EOF.
1153 See the POSIX:2008 specification
1154 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1155 # if @REPLACE_PREAD@
1156 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1158 # define pread rpl_pread
1160 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1161 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1162 _GL_ARG_NONNULL ((2)));
1163 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1164 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1167 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1168 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1169 _GL_ARG_NONNULL ((2)));
1171 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1172 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1174 _GL_CXXALIASWARN (pread
);
1175 #elif defined GNULIB_POSIXCHECK
1177 # if HAVE_RAW_DECL_PREAD
1178 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1179 "use gnulib module pread for portability");
1185 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1186 Return the number of bytes written if successful, otherwise
1187 set errno and return -1. 0 indicates nothing written. See the
1188 POSIX:2008 specification
1189 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1190 # if @REPLACE_PWRITE@
1191 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1193 # define pwrite rpl_pwrite
1195 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1196 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1197 _GL_ARG_NONNULL ((2)));
1198 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1199 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1202 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1203 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1204 _GL_ARG_NONNULL ((2)));
1206 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1207 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1209 _GL_CXXALIASWARN (pwrite
);
1210 #elif defined GNULIB_POSIXCHECK
1212 # if HAVE_RAW_DECL_PWRITE
1213 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1214 "use gnulib module pwrite for portability");
1220 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1221 at BUF. See the POSIX:2008 specification
1222 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1224 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1226 # define read rpl_read
1228 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1229 _GL_ARG_NONNULL ((2)));
1230 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1232 /* Need to cast, because on mingw, the third parameter is
1234 and the return type is 'int'. */
1235 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1237 _GL_CXXALIASWARN (read
);
1241 #if @GNULIB_READLINK@
1242 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1243 bytes of it into BUF. Return the number of bytes placed into BUF if
1244 successful, otherwise -1 and errno set.
1245 See the POSIX:2008 specification
1246 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1247 # if @REPLACE_READLINK@
1248 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1249 # define readlink rpl_readlink
1251 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1252 (const char *file
, char *buf
, size_t bufsize
)
1253 _GL_ARG_NONNULL ((1, 2)));
1254 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1255 (const char *file
, char *buf
, size_t bufsize
));
1257 # if !@HAVE_READLINK@
1258 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1259 (const char *file
, char *buf
, size_t bufsize
)
1260 _GL_ARG_NONNULL ((1, 2)));
1262 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1263 (const char *file
, char *buf
, size_t bufsize
));
1265 _GL_CXXALIASWARN (readlink
);
1266 #elif defined GNULIB_POSIXCHECK
1268 # if HAVE_RAW_DECL_READLINK
1269 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1270 "use gnulib module readlink for portability");
1275 #if @GNULIB_READLINKAT@
1276 # if !@HAVE_READLINKAT@
1277 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1278 (int fd
, char const *file
, char *buf
, size_t len
)
1279 _GL_ARG_NONNULL ((2, 3)));
1281 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1282 (int fd
, char const *file
, char *buf
, size_t len
));
1283 _GL_CXXALIASWARN (readlinkat
);
1284 #elif defined GNULIB_POSIXCHECK
1286 # if HAVE_RAW_DECL_READLINKAT
1287 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1288 "use gnulib module readlinkat for portability");
1294 /* Remove the directory DIR. */
1295 # if @REPLACE_RMDIR@
1296 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1297 # define rmdir rpl_rmdir
1299 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1300 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1302 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1304 _GL_CXXALIASWARN (rmdir
);
1305 #elif defined GNULIB_POSIXCHECK
1307 # if HAVE_RAW_DECL_RMDIR
1308 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1309 "use gnulib module rmdir for portability");
1314 #if @GNULIB_SETHOSTNAME@
1315 /* Set the host name of the machine.
1316 The host name may or may not be fully qualified.
1318 Put LEN bytes of NAME into the host name.
1319 Return 0 if successful, otherwise, set errno and return -1.
1321 Platforms with no ability to set the hostname return -1 and set
1323 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1324 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1325 _GL_ARG_NONNULL ((1)));
1327 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1328 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1329 2011-10, the first parameter is not const. */
1330 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1331 _GL_CXXALIASWARN (sethostname
);
1332 #elif defined GNULIB_POSIXCHECK
1334 # if HAVE_RAW_DECL_SETHOSTNAME
1335 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1336 "use gnulib module sethostname for portability");
1342 /* Pause the execution of the current thread for N seconds.
1343 Returns the number of seconds left to sleep.
1344 See the POSIX:2008 specification
1345 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1346 # if @REPLACE_SLEEP@
1347 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1349 # define sleep rpl_sleep
1351 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1352 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1355 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1357 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1359 _GL_CXXALIASWARN (sleep
);
1360 #elif defined GNULIB_POSIXCHECK
1362 # if HAVE_RAW_DECL_SLEEP
1363 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1364 "use gnulib module sleep for portability");
1369 #if @GNULIB_SYMLINK@
1370 # if @REPLACE_SYMLINK@
1371 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1373 # define symlink rpl_symlink
1375 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1376 _GL_ARG_NONNULL ((1, 2)));
1377 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1379 # if !@HAVE_SYMLINK@
1380 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1381 _GL_ARG_NONNULL ((1, 2)));
1383 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1385 _GL_CXXALIASWARN (symlink
);
1386 #elif defined GNULIB_POSIXCHECK
1388 # if HAVE_RAW_DECL_SYMLINK
1389 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1390 "use gnulib module symlink for portability");
1395 #if @GNULIB_SYMLINKAT@
1396 # if !@HAVE_SYMLINKAT@
1397 _GL_FUNCDECL_SYS (symlinkat
, int,
1398 (char const *contents
, int fd
, char const *file
)
1399 _GL_ARG_NONNULL ((1, 3)));
1401 _GL_CXXALIAS_SYS (symlinkat
, int,
1402 (char const *contents
, int fd
, char const *file
));
1403 _GL_CXXALIASWARN (symlinkat
);
1404 #elif defined GNULIB_POSIXCHECK
1406 # if HAVE_RAW_DECL_SYMLINKAT
1407 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1408 "use gnulib module symlinkat for portability");
1413 #if @GNULIB_TTYNAME_R@
1414 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1415 open on in BUF. Return 0 on success, otherwise an error number. */
1416 # if @REPLACE_TTYNAME_R@
1417 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1419 # define ttyname_r rpl_ttyname_r
1421 _GL_FUNCDECL_RPL (ttyname_r
, int,
1422 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1423 _GL_CXXALIAS_RPL (ttyname_r
, int,
1424 (int fd
, char *buf
, size_t buflen
));
1426 # if !@HAVE_DECL_TTYNAME_R@
1427 _GL_FUNCDECL_SYS (ttyname_r
, int,
1428 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1430 _GL_CXXALIAS_SYS (ttyname_r
, int,
1431 (int fd
, char *buf
, size_t buflen
));
1433 _GL_CXXALIASWARN (ttyname_r
);
1434 #elif defined GNULIB_POSIXCHECK
1436 # if HAVE_RAW_DECL_TTYNAME_R
1437 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1438 "use gnulib module ttyname_r for portability");
1444 # if @REPLACE_UNLINK@
1445 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1447 # define unlink rpl_unlink
1449 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1450 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1452 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1454 _GL_CXXALIASWARN (unlink
);
1455 #elif defined GNULIB_POSIXCHECK
1457 # if HAVE_RAW_DECL_UNLINK
1458 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1459 "use gnulib module unlink for portability");
1464 #if @GNULIB_UNLINKAT@
1465 # if @REPLACE_UNLINKAT@
1466 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1468 # define unlinkat rpl_unlinkat
1470 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1471 _GL_ARG_NONNULL ((2)));
1472 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1474 # if !@HAVE_UNLINKAT@
1475 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1476 _GL_ARG_NONNULL ((2)));
1478 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1480 _GL_CXXALIASWARN (unlinkat
);
1481 #elif defined GNULIB_POSIXCHECK
1483 # if HAVE_RAW_DECL_UNLINKAT
1484 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1485 "use gnulib module openat for portability");
1491 /* Pause the execution of the current thread for N microseconds.
1492 Returns 0 on completion, or -1 on range error.
1493 See the POSIX:2001 specification
1494 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1495 # if @REPLACE_USLEEP@
1496 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1498 # define usleep rpl_usleep
1500 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1501 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1504 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1506 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1508 _GL_CXXALIASWARN (usleep
);
1509 #elif defined GNULIB_POSIXCHECK
1511 # if HAVE_RAW_DECL_USLEEP
1512 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1513 "use gnulib module usleep for portability");
1519 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1520 See the POSIX:2008 specification
1521 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1522 # if @REPLACE_WRITE@
1523 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1525 # define write rpl_write
1527 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1528 _GL_ARG_NONNULL ((2)));
1529 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1531 /* Need to cast, because on mingw, the third parameter is
1533 and the return type is 'int'. */
1534 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1536 _GL_CXXALIASWARN (write
);
1539 _GL_INLINE_HEADER_END
1541 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1542 #endif /* _@GUARD_PREFIX@_UNISTD_H */