1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2012 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 Lesser General Public License as published by
6 the Free Software Foundation; either version 2, 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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 @PRAGMA_SYSTEM_HEADER@
23 /* Special invocation convention:
24 - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
25 but we need to ensure that both the system <unistd.h> and <winsock2.h>
26 are completely included before we replace gethostname. */
27 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
28 && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
29 /* <unistd.h> is being indirectly included for the first time from
30 <winsock2.h>; avoid declaring any overrides. */
32 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
34 # error unexpected; report this to bug-gnulib@gnu.org
36 # define _GL_WINSOCK2_H_WITNESS
38 /* Normal invocation. */
39 #elif !defined _@GUARD_PREFIX@_UNISTD_H
41 /* The include_next requires a split double-inclusion guard. */
43 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
46 /* Get all possible declarations of gethostname(). */
47 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
48 && !defined _GL_INCLUDING_WINSOCK2_H
49 # define _GL_INCLUDING_WINSOCK2_H
50 # include <winsock2.h>
51 # undef _GL_INCLUDING_WINSOCK2_H
54 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
55 #define _@GUARD_PREFIX@_UNISTD_H
57 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
60 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
61 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
62 /* But avoid namespace pollution on glibc systems. */
63 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
64 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
65 && defined __CYGWIN__)) \
66 && ! defined __GLIBC__
70 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
71 /* But avoid namespace pollution on glibc systems. */
72 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
73 && ! defined __GLIBC__
77 /* mingw fails to declare _exit in <unistd.h>. */
78 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
80 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
81 /* But avoid namespace pollution on glibc systems. */
86 /* Native Windows platforms declare chdir, getcwd, rmdir in
87 <io.h> and/or <direct.h>, not in <unistd.h>.
88 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
89 lseek(), read(), unlink(), write() in <io.h>. */
90 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
91 || defined GNULIB_POSIXCHECK) \
92 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
93 # include <io.h> /* mingw32, mingw64 */
94 # include <direct.h> /* mingw64, MSVC 9 */
95 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
96 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
97 || defined GNULIB_POSIXCHECK) \
98 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
102 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
103 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
104 /* But avoid namespace pollution on glibc systems. */
105 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
106 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
107 && !defined __GLIBC__
111 /* MSVC defines off_t in <sys/types.h>. */
114 # include <sys/types.h>
117 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
118 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
119 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
121 # include <sys/types.h>
124 /* Get getopt(), optarg, optind, opterr, optopt.
125 But avoid namespace pollution on glibc systems. */
126 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
130 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
132 /* The definition of _GL_ARG_NONNULL is copied here. */
134 /* The definition of _GL_WARN_ON_USE is copied here. */
137 /* Hide some function declarations from <winsock2.h>. */
139 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
140 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
141 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
143 # define socket socket_used_without_including_sys_socket_h
145 # define connect connect_used_without_including_sys_socket_h
147 # define accept accept_used_without_including_sys_socket_h
149 # define bind bind_used_without_including_sys_socket_h
151 # define getpeername getpeername_used_without_including_sys_socket_h
153 # define getsockname getsockname_used_without_including_sys_socket_h
155 # define getsockopt getsockopt_used_without_including_sys_socket_h
157 # define listen listen_used_without_including_sys_socket_h
159 # define recv recv_used_without_including_sys_socket_h
161 # define send send_used_without_including_sys_socket_h
163 # define recvfrom recvfrom_used_without_including_sys_socket_h
165 # define sendto sendto_used_without_including_sys_socket_h
167 # define setsockopt setsockopt_used_without_including_sys_socket_h
169 # define shutdown shutdown_used_without_including_sys_socket_h
171 _GL_WARN_ON_USE (socket
,
172 "socket() used without including <sys/socket.h>");
173 _GL_WARN_ON_USE (connect
,
174 "connect() used without including <sys/socket.h>");
175 _GL_WARN_ON_USE (accept
,
176 "accept() used without including <sys/socket.h>");
177 _GL_WARN_ON_USE (bind
,
178 "bind() used without including <sys/socket.h>");
179 _GL_WARN_ON_USE (getpeername
,
180 "getpeername() used without including <sys/socket.h>");
181 _GL_WARN_ON_USE (getsockname
,
182 "getsockname() used without including <sys/socket.h>");
183 _GL_WARN_ON_USE (getsockopt
,
184 "getsockopt() used without including <sys/socket.h>");
185 _GL_WARN_ON_USE (listen
,
186 "listen() used without including <sys/socket.h>");
187 _GL_WARN_ON_USE (recv
,
188 "recv() used without including <sys/socket.h>");
189 _GL_WARN_ON_USE (send
,
190 "send() used without including <sys/socket.h>");
191 _GL_WARN_ON_USE (recvfrom
,
192 "recvfrom() used without including <sys/socket.h>");
193 _GL_WARN_ON_USE (sendto
,
194 "sendto() used without including <sys/socket.h>");
195 _GL_WARN_ON_USE (setsockopt
,
196 "setsockopt() used without including <sys/socket.h>");
197 _GL_WARN_ON_USE (shutdown
,
198 "shutdown() used without including <sys/socket.h>");
201 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
202 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
204 # define select select_used_without_including_sys_select_h
206 _GL_WARN_ON_USE (select
,
207 "select() used without including <sys/select.h>");
213 /* OS/2 EMX lacks these macros. */
215 # define STDIN_FILENO 0
217 #ifndef STDOUT_FILENO
218 # define STDOUT_FILENO 1
220 #ifndef STDERR_FILENO
221 # define STDERR_FILENO 2
224 /* Ensure *_OK macros exist. */
233 /* Declare overridden functions. */
236 #if defined GNULIB_POSIXCHECK
237 /* The access() function is a security risk. */
238 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
239 "use the gnulib module faccessat instead");
244 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
245 _GL_CXXALIASWARN (chdir
);
246 #elif defined GNULIB_POSIXCHECK
248 # if HAVE_RAW_DECL_CHDIR
249 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
250 "use gnulib module chdir for portability");
256 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
257 to GID (if GID is not -1). Follow symbolic links.
258 Return 0 if successful, otherwise -1 and errno set.
259 See the POSIX:2008 specification
260 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
262 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
264 # define chown rpl_chown
266 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
267 _GL_ARG_NONNULL ((1)));
268 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
271 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
272 _GL_ARG_NONNULL ((1)));
274 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
276 _GL_CXXALIASWARN (chown
);
277 #elif defined GNULIB_POSIXCHECK
279 # if HAVE_RAW_DECL_CHOWN
280 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
281 "doesn't treat a uid or gid of -1 on some systems - "
282 "use gnulib module chown for portability");
289 /* Automatically included by modules that need a replacement for close. */
290 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
292 # define close rpl_close
294 _GL_FUNCDECL_RPL (close
, int, (int fd
));
295 _GL_CXXALIAS_RPL (close
, int, (int fd
));
297 _GL_CXXALIAS_SYS (close
, int, (int fd
));
299 _GL_CXXALIASWARN (close
);
300 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
302 # define close close_used_without_requesting_gnulib_module_close
303 #elif defined GNULIB_POSIXCHECK
305 /* Assume close is always declared. */
306 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
307 "use gnulib module close for portability");
313 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
316 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
317 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
319 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
321 _GL_CXXALIASWARN (dup
);
322 #elif defined GNULIB_POSIXCHECK
324 # if HAVE_RAW_DECL_DUP
325 _GL_WARN_ON_USE (dup
, "dup is unportable - "
326 "use gnulib module dup for portability");
332 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
333 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
334 Return newfd if successful, otherwise -1 and errno set.
335 See the POSIX:2008 specification
336 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
338 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
339 # define dup2 rpl_dup2
341 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
342 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
345 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
347 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
349 _GL_CXXALIASWARN (dup2
);
350 #elif defined GNULIB_POSIXCHECK
352 # if HAVE_RAW_DECL_DUP2
353 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
354 "use gnulib module dup2 for portability");
360 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
362 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
363 and O_TEXT, O_BINARY (defined in "binary-io.h").
364 Close NEWFD first if it is open.
365 Return newfd if successful, otherwise -1 and errno set.
366 See the Linux man page at
367 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
369 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
370 # define dup3 rpl_dup3
372 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
373 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
375 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
376 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
378 _GL_CXXALIASWARN (dup3
);
379 #elif defined GNULIB_POSIXCHECK
381 # if HAVE_RAW_DECL_DUP3
382 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
383 "use gnulib module dup3 for portability");
389 # if !@HAVE_DECL_ENVIRON@
390 /* Set of environment variables and values. An array of strings of the form
391 "VARIABLE=VALUE", terminated with a NULL. */
392 # if defined __APPLE__ && defined __MACH__
393 # include <crt_externs.h>
394 # define environ (*_NSGetEnviron ())
399 extern char **environ
;
405 #elif defined GNULIB_POSIXCHECK
406 # if HAVE_RAW_DECL_ENVIRON
407 static inline char ***
412 _GL_WARN_ON_USE (rpl_environ
, "environ is unportable - "
413 "use gnulib module environ for portability");
415 # define environ (*rpl_environ ())
420 #if @GNULIB_EUIDACCESS@
421 /* Like access(), except that it uses the effective user id and group id of
422 the current process. */
423 # if !@HAVE_EUIDACCESS@
424 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
425 _GL_ARG_NONNULL ((1)));
427 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
428 _GL_CXXALIASWARN (euidaccess
);
429 # if defined GNULIB_POSIXCHECK
430 /* Like access(), this function is a security risk. */
431 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
432 "use the gnulib module faccessat instead");
434 #elif defined GNULIB_POSIXCHECK
436 # if HAVE_RAW_DECL_EUIDACCESS
437 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
438 "use gnulib module euidaccess for portability");
443 #if @GNULIB_FACCESSAT@
444 # if !@HAVE_FACCESSAT@
445 _GL_FUNCDECL_SYS (faccessat
, int,
446 (int fd
, char const *file
, int mode
, int flag
)
447 _GL_ARG_NONNULL ((2)));
449 _GL_CXXALIAS_SYS (faccessat
, int,
450 (int fd
, char const *file
, int mode
, int flag
));
451 _GL_CXXALIASWARN (faccessat
);
452 #elif defined GNULIB_POSIXCHECK
454 # if HAVE_RAW_DECL_FACCESSAT
455 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
456 "use gnulib module faccessat for portability");
462 /* Change the process' current working directory to the directory on which
463 the given file descriptor is open.
464 Return 0 if successful, otherwise -1 and errno set.
465 See the POSIX:2008 specification
466 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
468 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
470 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
471 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
472 _GL_ARG_NONNULL ((2));
473 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
474 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
475 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
478 # if !@HAVE_DECL_FCHDIR@
479 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
482 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
483 _GL_CXXALIASWARN (fchdir
);
484 #elif defined GNULIB_POSIXCHECK
486 # if HAVE_RAW_DECL_FCHDIR
487 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
488 "use gnulib module fchdir for portability");
493 #if @GNULIB_FCHOWNAT@
494 # if @REPLACE_FCHOWNAT@
495 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
497 # define fchownat rpl_fchownat
499 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
500 uid_t owner
, gid_t group
, int flag
)
501 _GL_ARG_NONNULL ((2)));
502 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
503 uid_t owner
, gid_t group
, int flag
));
505 # if !@HAVE_FCHOWNAT@
506 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
507 uid_t owner
, gid_t group
, int flag
)
508 _GL_ARG_NONNULL ((2)));
510 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
511 uid_t owner
, gid_t group
, int flag
));
513 _GL_CXXALIASWARN (fchownat
);
514 #elif defined GNULIB_POSIXCHECK
516 # if HAVE_RAW_DECL_FCHOWNAT
517 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
518 "use gnulib module openat for portability");
523 #if @GNULIB_FDATASYNC@
524 /* Synchronize changes to a file.
525 Return 0 if successful, otherwise -1 and errno set.
526 See POSIX:2008 specification
527 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
528 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
529 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
531 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
532 _GL_CXXALIASWARN (fdatasync
);
533 #elif defined GNULIB_POSIXCHECK
535 # if HAVE_RAW_DECL_FDATASYNC
536 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
537 "use gnulib module fdatasync for portability");
543 /* Synchronize changes, including metadata, to a file.
544 Return 0 if successful, otherwise -1 and errno set.
545 See POSIX:2008 specification
546 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
548 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
550 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
551 _GL_CXXALIASWARN (fsync
);
552 #elif defined GNULIB_POSIXCHECK
554 # if HAVE_RAW_DECL_FSYNC
555 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
556 "use gnulib module fsync for portability");
561 #if @GNULIB_FTRUNCATE@
562 /* Change the size of the file to which FD is opened to become equal to LENGTH.
563 Return 0 if successful, otherwise -1 and errno set.
564 See the POSIX:2008 specification
565 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
566 # if !@HAVE_FTRUNCATE@
567 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
569 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
570 _GL_CXXALIASWARN (ftruncate
);
571 #elif defined GNULIB_POSIXCHECK
573 # if HAVE_RAW_DECL_FTRUNCATE
574 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
575 "use gnulib module ftruncate for portability");
581 /* Get the name of the current working directory, and put it in SIZE bytes
583 Return BUF if successful, or NULL if the directory couldn't be determined
584 or SIZE was too small.
585 See the POSIX:2008 specification
586 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
587 Additionally, the gnulib module 'getcwd' guarantees the following GNU
588 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
589 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
591 # if @REPLACE_GETCWD@
592 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
593 # define getcwd rpl_getcwd
595 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
596 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
598 /* Need to cast, because on mingw, the second parameter is
600 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
602 _GL_CXXALIASWARN (getcwd
);
603 #elif defined GNULIB_POSIXCHECK
605 # if HAVE_RAW_DECL_GETCWD
606 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
607 "use gnulib module getcwd for portability");
612 #if @GNULIB_GETDOMAINNAME@
613 /* Return the NIS domain name of the machine.
614 WARNING! The NIS domain name is unrelated to the fully qualified host name
615 of the machine. It is also unrelated to email addresses.
616 WARNING! The NIS domain name is usually the empty string or "(none)" when
619 Put up to LEN bytes of the NIS domain name into NAME.
620 Null terminate it if the name is shorter than LEN.
621 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
622 Return 0 if successful, otherwise set errno and return -1. */
623 # if @REPLACE_GETDOMAINNAME@
624 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
625 # undef getdomainname
626 # define getdomainname rpl_getdomainname
628 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
629 _GL_ARG_NONNULL ((1)));
630 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
632 # if !@HAVE_DECL_GETDOMAINNAME@
633 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
634 _GL_ARG_NONNULL ((1)));
636 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
638 _GL_CXXALIASWARN (getdomainname
);
639 #elif defined GNULIB_POSIXCHECK
640 # undef getdomainname
641 # if HAVE_RAW_DECL_GETDOMAINNAME
642 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
643 "use gnulib module getdomainname for portability");
648 #if @GNULIB_GETDTABLESIZE@
649 /* Return the maximum number of file descriptors in the current process.
650 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
651 # if !@HAVE_GETDTABLESIZE@
652 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
654 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
655 _GL_CXXALIASWARN (getdtablesize
);
656 #elif defined GNULIB_POSIXCHECK
657 # undef getdtablesize
658 # if HAVE_RAW_DECL_GETDTABLESIZE
659 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
660 "use gnulib module getdtablesize for portability");
665 #if @GNULIB_GETGROUPS@
666 /* Return the supplemental groups that the current process belongs to.
667 It is unspecified whether the effective group id is in the list.
668 If N is 0, return the group count; otherwise, N describes how many
669 entries are available in GROUPS. Return -1 and set errno if N is
670 not 0 and not large enough. Fails with ENOSYS on some systems. */
671 # if @REPLACE_GETGROUPS@
672 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
674 # define getgroups rpl_getgroups
676 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
677 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
679 # if !@HAVE_GETGROUPS@
680 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
682 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
684 _GL_CXXALIASWARN (getgroups
);
685 #elif defined GNULIB_POSIXCHECK
687 # if HAVE_RAW_DECL_GETGROUPS
688 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
689 "use gnulib module getgroups for portability");
694 #if @GNULIB_GETHOSTNAME@
695 /* Return the standard host name of the machine.
696 WARNING! The host name may or may not be fully qualified.
698 Put up to LEN bytes of the host name into NAME.
699 Null terminate it if the name is shorter than LEN.
700 If the host name is longer than LEN, set errno = EINVAL and return -1.
701 Return 0 if successful, otherwise set errno and return -1. */
702 # if @UNISTD_H_HAVE_WINSOCK2_H@
703 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
705 # define gethostname rpl_gethostname
707 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
708 _GL_ARG_NONNULL ((1)));
709 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
711 # if !@HAVE_GETHOSTNAME@
712 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
713 _GL_ARG_NONNULL ((1)));
715 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
718 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
720 _GL_CXXALIASWARN (gethostname
);
721 #elif @UNISTD_H_HAVE_WINSOCK2_H@
723 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
724 #elif defined GNULIB_POSIXCHECK
726 # if HAVE_RAW_DECL_GETHOSTNAME
727 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
728 "use gnulib module gethostname for portability");
733 #if @GNULIB_GETLOGIN@
734 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
735 returns NULL with errno set.
737 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
739 Most programs don't need to use this function, because the information is
740 available through environment variables:
741 ${LOGNAME-$USER} on Unix platforms,
742 $USERNAME on native Windows platforms.
744 # if !@HAVE_GETLOGIN@
745 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
747 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
748 _GL_CXXALIASWARN (getlogin
);
749 #elif defined GNULIB_POSIXCHECK
751 # if HAVE_RAW_DECL_GETLOGIN
752 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
753 "use gnulib module getlogin for portability");
758 #if @GNULIB_GETLOGIN_R@
759 /* Copies the user's login name to NAME.
760 The array pointed to by NAME has room for SIZE bytes.
762 Returns 0 if successful. Upon error, an error number is returned, or -1 in
763 the case that the login name cannot be found but no specific error is
764 provided (this case is hopefully rare but is left open by the POSIX spec).
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 @REPLACE_GETLOGIN_R@
774 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
775 # define getlogin_r rpl_getlogin_r
777 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
778 _GL_ARG_NONNULL ((1)));
779 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
781 # if !@HAVE_DECL_GETLOGIN_R@
782 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
783 _GL_ARG_NONNULL ((1)));
785 /* Need to cast, because on Solaris 10 systems, the second argument is
787 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
789 _GL_CXXALIASWARN (getlogin_r
);
790 #elif defined GNULIB_POSIXCHECK
792 # if HAVE_RAW_DECL_GETLOGIN_R
793 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
794 "use gnulib module getlogin_r for portability");
799 #if @GNULIB_GETPAGESIZE@
800 # if @REPLACE_GETPAGESIZE@
801 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
802 # define getpagesize rpl_getpagesize
804 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
805 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
807 # if !@HAVE_GETPAGESIZE@
808 # if !defined getpagesize
809 /* This is for POSIX systems. */
810 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
811 # if ! (defined __VMS && __VMS_VER < 70000000)
812 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
815 /* This is for older VMS. */
816 # if !defined _gl_getpagesize && defined __VMS
818 # define _gl_getpagesize() 8192
820 # define _gl_getpagesize() 512
823 /* This is for BeOS. */
824 # if !defined _gl_getpagesize && @HAVE_OS_H@
826 # if defined B_PAGE_SIZE
827 # define _gl_getpagesize() B_PAGE_SIZE
830 /* This is for AmigaOS4.0. */
831 # if !defined _gl_getpagesize && defined __amigaos4__
832 # define _gl_getpagesize() 2048
834 /* This is for older Unix systems. */
835 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
836 # include <sys/param.h>
837 # ifdef EXEC_PAGESIZE
838 # define _gl_getpagesize() EXEC_PAGESIZE
844 # define _gl_getpagesize() (NBPG * CLSIZE)
847 # define _gl_getpagesize() NBPC
852 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
853 # define getpagesize() _gl_getpagesize ()
855 # if !GNULIB_defined_getpagesize_function
859 return _gl_getpagesize ();
861 # define GNULIB_defined_getpagesize_function 1
866 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
867 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
869 # if @HAVE_DECL_GETPAGESIZE@
870 _GL_CXXALIASWARN (getpagesize
);
872 #elif defined GNULIB_POSIXCHECK
874 # if HAVE_RAW_DECL_GETPAGESIZE
875 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
876 "use gnulib module getpagesize for portability");
881 #if @GNULIB_GETUSERSHELL@
882 /* Return the next valid login shell on the system, or NULL when the end of
883 the list has been reached. */
884 # if !@HAVE_DECL_GETUSERSHELL@
885 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
887 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
888 _GL_CXXALIASWARN (getusershell
);
889 #elif defined GNULIB_POSIXCHECK
891 # if HAVE_RAW_DECL_GETUSERSHELL
892 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
893 "use gnulib module getusershell for portability");
897 #if @GNULIB_GETUSERSHELL@
898 /* Rewind to pointer that is advanced at each getusershell() call. */
899 # if !@HAVE_DECL_GETUSERSHELL@
900 _GL_FUNCDECL_SYS (setusershell
, void, (void));
902 _GL_CXXALIAS_SYS (setusershell
, void, (void));
903 _GL_CXXALIASWARN (setusershell
);
904 #elif defined GNULIB_POSIXCHECK
906 # if HAVE_RAW_DECL_SETUSERSHELL
907 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
908 "use gnulib module getusershell for portability");
912 #if @GNULIB_GETUSERSHELL@
913 /* Free the pointer that is advanced at each getusershell() call and
914 associated resources. */
915 # if !@HAVE_DECL_GETUSERSHELL@
916 _GL_FUNCDECL_SYS (endusershell
, void, (void));
918 _GL_CXXALIAS_SYS (endusershell
, void, (void));
919 _GL_CXXALIASWARN (endusershell
);
920 #elif defined GNULIB_POSIXCHECK
922 # if HAVE_RAW_DECL_ENDUSERSHELL
923 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
924 "use gnulib module getusershell for portability");
929 #if @GNULIB_GROUP_MEMBER@
930 /* Determine whether group id is in calling user's group list. */
931 # if !@HAVE_GROUP_MEMBER@
932 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
934 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
935 _GL_CXXALIASWARN (group_member
);
936 #elif defined GNULIB_POSIXCHECK
938 # if HAVE_RAW_DECL_GROUP_MEMBER
939 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
940 "use gnulib module group-member for portability");
946 # if @REPLACE_ISATTY@
947 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
949 # define isatty rpl_isatty
951 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
952 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
954 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
956 _GL_CXXALIASWARN (isatty
);
957 #elif defined GNULIB_POSIXCHECK
959 # if HAVE_RAW_DECL_ISATTY
960 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
961 "use gnulib module isatty for portability");
967 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
968 to GID (if GID is not -1). Do not follow symbolic links.
969 Return 0 if successful, otherwise -1 and errno set.
970 See the POSIX:2008 specification
971 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
972 # if @REPLACE_LCHOWN@
973 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
975 # define lchown rpl_lchown
977 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
978 _GL_ARG_NONNULL ((1)));
979 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
982 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
983 _GL_ARG_NONNULL ((1)));
985 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
987 _GL_CXXALIASWARN (lchown
);
988 #elif defined GNULIB_POSIXCHECK
990 # if HAVE_RAW_DECL_LCHOWN
991 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
992 "use gnulib module lchown for portability");
998 /* Create a new hard link for an existing file.
999 Return 0 if successful, otherwise -1 and errno set.
1000 See POSIX:2008 specification
1001 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1003 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1004 # define link rpl_link
1006 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1007 _GL_ARG_NONNULL ((1, 2)));
1008 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1011 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1012 _GL_ARG_NONNULL ((1, 2)));
1014 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1016 _GL_CXXALIASWARN (link
);
1017 #elif defined GNULIB_POSIXCHECK
1019 # if HAVE_RAW_DECL_LINK
1020 _GL_WARN_ON_USE (link
, "link is unportable - "
1021 "use gnulib module link for portability");
1027 /* Create a new hard link for an existing file, relative to two
1028 directories. FLAG controls whether symlinks are followed.
1029 Return 0 if successful, otherwise -1 and errno set. */
1030 # if @REPLACE_LINKAT@
1031 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1033 # define linkat rpl_linkat
1035 _GL_FUNCDECL_RPL (linkat
, int,
1036 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1038 _GL_ARG_NONNULL ((2, 4)));
1039 _GL_CXXALIAS_RPL (linkat
, int,
1040 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1044 _GL_FUNCDECL_SYS (linkat
, int,
1045 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1047 _GL_ARG_NONNULL ((2, 4)));
1049 _GL_CXXALIAS_SYS (linkat
, int,
1050 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1053 _GL_CXXALIASWARN (linkat
);
1054 #elif defined GNULIB_POSIXCHECK
1056 # if HAVE_RAW_DECL_LINKAT
1057 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1058 "use gnulib module linkat for portability");
1064 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1065 Return the new offset if successful, otherwise -1 and errno set.
1066 See the POSIX:2008 specification
1067 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1068 # if @REPLACE_LSEEK@
1069 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1070 # define lseek rpl_lseek
1072 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1073 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1075 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1077 _GL_CXXALIASWARN (lseek
);
1078 #elif defined GNULIB_POSIXCHECK
1080 # if HAVE_RAW_DECL_LSEEK
1081 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1082 "systems - use gnulib module lseek for portability");
1088 /* Create a pipe, defaulting to O_BINARY mode.
1089 Store the read-end as fd[0] and the write-end as fd[1].
1090 Return 0 upon success, or -1 with errno set upon failure. */
1092 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1094 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1095 _GL_CXXALIASWARN (pipe
);
1096 #elif defined GNULIB_POSIXCHECK
1098 # if HAVE_RAW_DECL_PIPE
1099 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1100 "use gnulib module pipe-posix for portability");
1106 /* Create a pipe, applying the given flags when opening the read-end of the
1107 pipe and the write-end of the pipe.
1108 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1109 and O_TEXT, O_BINARY (defined in "binary-io.h").
1110 Store the read-end as fd[0] and the write-end as fd[1].
1111 Return 0 upon success, or -1 with errno set upon failure.
1112 See also the Linux man page at
1113 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1115 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1116 # define pipe2 rpl_pipe2
1118 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1119 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1121 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1122 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1124 _GL_CXXALIASWARN (pipe2
);
1125 #elif defined GNULIB_POSIXCHECK
1127 # if HAVE_RAW_DECL_PIPE2
1128 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1129 "use gnulib module pipe2 for portability");
1135 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1136 Return the number of bytes placed into BUF if successful, otherwise
1137 set errno and return -1. 0 indicates EOF.
1138 See the POSIX:2008 specification
1139 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1140 # if @REPLACE_PREAD@
1141 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1143 # define pread rpl_pread
1145 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1146 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1147 _GL_ARG_NONNULL ((2)));
1148 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1149 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1152 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1153 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1154 _GL_ARG_NONNULL ((2)));
1156 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1157 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1159 _GL_CXXALIASWARN (pread
);
1160 #elif defined GNULIB_POSIXCHECK
1162 # if HAVE_RAW_DECL_PREAD
1163 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1164 "use gnulib module pread for portability");
1170 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1171 Return the number of bytes written if successful, otherwise
1172 set errno and return -1. 0 indicates nothing written. See the
1173 POSIX:2008 specification
1174 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1175 # if @REPLACE_PWRITE@
1176 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1178 # define pwrite rpl_pwrite
1180 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1181 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1182 _GL_ARG_NONNULL ((2)));
1183 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1184 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1187 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1188 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1189 _GL_ARG_NONNULL ((2)));
1191 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1192 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1194 _GL_CXXALIASWARN (pwrite
);
1195 #elif defined GNULIB_POSIXCHECK
1197 # if HAVE_RAW_DECL_PWRITE
1198 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1199 "use gnulib module pwrite for portability");
1205 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1206 at BUF. See the POSIX:2008 specification
1207 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1209 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1211 # define read rpl_read
1213 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1214 _GL_ARG_NONNULL ((2)));
1215 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1217 /* Need to cast, because on mingw, the third parameter is
1219 and the return type is 'int'. */
1220 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1222 _GL_CXXALIASWARN (read
);
1226 #if @GNULIB_READLINK@
1227 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1228 bytes of it into BUF. Return the number of bytes placed into BUF if
1229 successful, otherwise -1 and errno set.
1230 See the POSIX:2008 specification
1231 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1232 # if @REPLACE_READLINK@
1233 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1234 # define readlink rpl_readlink
1236 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1237 (const char *file
, char *buf
, size_t bufsize
)
1238 _GL_ARG_NONNULL ((1, 2)));
1239 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1240 (const char *file
, char *buf
, size_t bufsize
));
1242 # if !@HAVE_READLINK@
1243 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1244 (const char *file
, char *buf
, size_t bufsize
)
1245 _GL_ARG_NONNULL ((1, 2)));
1247 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1248 (const char *file
, char *buf
, size_t bufsize
));
1250 _GL_CXXALIASWARN (readlink
);
1251 #elif defined GNULIB_POSIXCHECK
1253 # if HAVE_RAW_DECL_READLINK
1254 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1255 "use gnulib module readlink for portability");
1260 #if @GNULIB_READLINKAT@
1261 # if !@HAVE_READLINKAT@
1262 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1263 (int fd
, char const *file
, char *buf
, size_t len
)
1264 _GL_ARG_NONNULL ((2, 3)));
1266 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1267 (int fd
, char const *file
, char *buf
, size_t len
));
1268 _GL_CXXALIASWARN (readlinkat
);
1269 #elif defined GNULIB_POSIXCHECK
1271 # if HAVE_RAW_DECL_READLINKAT
1272 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1273 "use gnulib module readlinkat for portability");
1279 /* Remove the directory DIR. */
1280 # if @REPLACE_RMDIR@
1281 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1282 # define rmdir rpl_rmdir
1284 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1285 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1287 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1289 _GL_CXXALIASWARN (rmdir
);
1290 #elif defined GNULIB_POSIXCHECK
1292 # if HAVE_RAW_DECL_RMDIR
1293 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1294 "use gnulib module rmdir for portability");
1299 #if @GNULIB_SETHOSTNAME@
1300 /* Set the host name of the machine.
1301 The host name may or may not be fully qualified.
1303 Put LEN bytes of NAME into the host name.
1304 Return 0 if successful, otherwise, set errno and return -1.
1306 Platforms with no ability to set the hostname return -1 and set
1308 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1309 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1310 _GL_ARG_NONNULL ((1)));
1312 /* Need to cast, because on Solaris 11 2011-10, MacOS X 10.5, IRIX 6.5
1313 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1314 2011-10, the first parameter is not const. */
1315 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1316 _GL_CXXALIASWARN (sethostname
);
1317 #elif defined GNULIB_POSIXCHECK
1319 # if HAVE_RAW_DECL_SETHOSTNAME
1320 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1321 "use gnulib module sethostname for portability");
1327 /* Pause the execution of the current thread for N seconds.
1328 Returns the number of seconds left to sleep.
1329 See the POSIX:2008 specification
1330 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1331 # if @REPLACE_SLEEP@
1332 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1334 # define sleep rpl_sleep
1336 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1337 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1340 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1342 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1344 _GL_CXXALIASWARN (sleep
);
1345 #elif defined GNULIB_POSIXCHECK
1347 # if HAVE_RAW_DECL_SLEEP
1348 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1349 "use gnulib module sleep for portability");
1354 #if @GNULIB_SYMLINK@
1355 # if @REPLACE_SYMLINK@
1356 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1358 # define symlink rpl_symlink
1360 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1361 _GL_ARG_NONNULL ((1, 2)));
1362 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1364 # if !@HAVE_SYMLINK@
1365 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1366 _GL_ARG_NONNULL ((1, 2)));
1368 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1370 _GL_CXXALIASWARN (symlink
);
1371 #elif defined GNULIB_POSIXCHECK
1373 # if HAVE_RAW_DECL_SYMLINK
1374 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1375 "use gnulib module symlink for portability");
1380 #if @GNULIB_SYMLINKAT@
1381 # if !@HAVE_SYMLINKAT@
1382 _GL_FUNCDECL_SYS (symlinkat
, int,
1383 (char const *contents
, int fd
, char const *file
)
1384 _GL_ARG_NONNULL ((1, 3)));
1386 _GL_CXXALIAS_SYS (symlinkat
, int,
1387 (char const *contents
, int fd
, char const *file
));
1388 _GL_CXXALIASWARN (symlinkat
);
1389 #elif defined GNULIB_POSIXCHECK
1391 # if HAVE_RAW_DECL_SYMLINKAT
1392 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1393 "use gnulib module symlinkat for portability");
1398 #if @GNULIB_TTYNAME_R@
1399 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1400 open on in BUF. Return 0 on success, otherwise an error number. */
1401 # if @REPLACE_TTYNAME_R@
1402 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1404 # define ttyname_r rpl_ttyname_r
1406 _GL_FUNCDECL_RPL (ttyname_r
, int,
1407 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1408 _GL_CXXALIAS_RPL (ttyname_r
, int,
1409 (int fd
, char *buf
, size_t buflen
));
1411 # if !@HAVE_DECL_TTYNAME_R@
1412 _GL_FUNCDECL_SYS (ttyname_r
, int,
1413 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1415 _GL_CXXALIAS_SYS (ttyname_r
, int,
1416 (int fd
, char *buf
, size_t buflen
));
1418 _GL_CXXALIASWARN (ttyname_r
);
1419 #elif defined GNULIB_POSIXCHECK
1421 # if HAVE_RAW_DECL_TTYNAME_R
1422 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1423 "use gnulib module ttyname_r for portability");
1429 # if @REPLACE_UNLINK@
1430 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1432 # define unlink rpl_unlink
1434 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1435 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1437 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1439 _GL_CXXALIASWARN (unlink
);
1440 #elif defined GNULIB_POSIXCHECK
1442 # if HAVE_RAW_DECL_UNLINK
1443 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1444 "use gnulib module unlink for portability");
1449 #if @GNULIB_UNLINKAT@
1450 # if @REPLACE_UNLINKAT@
1451 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1453 # define unlinkat rpl_unlinkat
1455 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1456 _GL_ARG_NONNULL ((2)));
1457 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1459 # if !@HAVE_UNLINKAT@
1460 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1461 _GL_ARG_NONNULL ((2)));
1463 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1465 _GL_CXXALIASWARN (unlinkat
);
1466 #elif defined GNULIB_POSIXCHECK
1468 # if HAVE_RAW_DECL_UNLINKAT
1469 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1470 "use gnulib module openat for portability");
1476 /* Pause the execution of the current thread for N microseconds.
1477 Returns 0 on completion, or -1 on range error.
1478 See the POSIX:2001 specification
1479 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1480 # if @REPLACE_USLEEP@
1481 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1483 # define usleep rpl_usleep
1485 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1486 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1489 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1491 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1493 _GL_CXXALIASWARN (usleep
);
1494 #elif defined GNULIB_POSIXCHECK
1496 # if HAVE_RAW_DECL_USLEEP
1497 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1498 "use gnulib module usleep for portability");
1504 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1505 See the POSIX:2008 specification
1506 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1507 # if @REPLACE_WRITE@
1508 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1510 # define write rpl_write
1512 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1513 _GL_ARG_NONNULL ((2)));
1514 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1516 /* Need to cast, because on mingw, the third parameter is
1518 and the return type is 'int'. */
1519 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1521 _GL_CXXALIASWARN (write
);
1525 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1526 #endif /* _@GUARD_PREFIX@_UNISTD_H */