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 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/>. */
18 @PRAGMA_SYSTEM_HEADER@
22 /* Special invocation convention:
23 - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
24 but we need to ensure that both the system <unistd.h> and <winsock2.h>
25 are completely included before we replace gethostname. */
26 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
27 && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
28 /* <unistd.h> is being indirectly included for the first time from
29 <winsock2.h>; avoid declaring any overrides. */
31 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
33 # error unexpected; report this to bug-gnulib@gnu.org
35 # define _GL_WINSOCK2_H_WITNESS
37 /* Normal invocation. */
38 #elif !defined _@GUARD_PREFIX@_UNISTD_H
40 /* The include_next requires a split double-inclusion guard. */
42 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
45 /* Get all possible declarations of gethostname(). */
46 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
47 && !defined _GL_INCLUDING_WINSOCK2_H
48 # define _GL_INCLUDING_WINSOCK2_H
49 # include <winsock2.h>
50 # undef _GL_INCLUDING_WINSOCK2_H
53 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
54 #define _@GUARD_PREFIX@_UNISTD_H
56 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
59 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
60 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
61 /* But avoid namespace pollution on glibc systems. */
62 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
63 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
64 && defined __CYGWIN__)) \
65 && ! defined __GLIBC__
69 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
70 /* But avoid namespace pollution on glibc systems. */
71 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
72 && ! defined __GLIBC__
76 /* mingw fails to declare _exit in <unistd.h>. */
77 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
79 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
80 /* But avoid namespace pollution on glibc systems. */
85 /* Native Windows platforms declare chdir, getcwd, rmdir in
86 <io.h> and/or <direct.h>, not in <unistd.h>.
87 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
88 lseek(), read(), unlink(), write() in <io.h>. */
89 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
90 || defined GNULIB_POSIXCHECK) \
91 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
92 # include <io.h> /* mingw32, mingw64 */
93 # include <direct.h> /* mingw64, MSVC 9 */
94 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
95 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
96 || defined GNULIB_POSIXCHECK) \
97 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
101 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
102 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
103 /* But avoid namespace pollution on glibc systems. */
104 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
105 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
106 && !defined __GLIBC__
110 /* MSVC defines off_t in <sys/types.h>.
111 May also define off_t to a 64-bit type on native Windows. */
112 #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
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 @REPLACE_FTRUNCATE@
567 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
569 # define ftruncate rpl_ftruncate
571 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
572 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
574 # if !@HAVE_FTRUNCATE@
575 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
577 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
579 _GL_CXXALIASWARN (ftruncate
);
580 #elif defined GNULIB_POSIXCHECK
582 # if HAVE_RAW_DECL_FTRUNCATE
583 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
584 "use gnulib module ftruncate for portability");
590 /* Get the name of the current working directory, and put it in SIZE bytes
592 Return BUF if successful, or NULL if the directory couldn't be determined
593 or SIZE was too small.
594 See the POSIX:2008 specification
595 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
596 Additionally, the gnulib module 'getcwd' guarantees the following GNU
597 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
598 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
600 # if @REPLACE_GETCWD@
601 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
602 # define getcwd rpl_getcwd
604 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
605 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
607 /* Need to cast, because on mingw, the second parameter is
609 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
611 _GL_CXXALIASWARN (getcwd
);
612 #elif defined GNULIB_POSIXCHECK
614 # if HAVE_RAW_DECL_GETCWD
615 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
616 "use gnulib module getcwd for portability");
621 #if @GNULIB_GETDOMAINNAME@
622 /* Return the NIS domain name of the machine.
623 WARNING! The NIS domain name is unrelated to the fully qualified host name
624 of the machine. It is also unrelated to email addresses.
625 WARNING! The NIS domain name is usually the empty string or "(none)" when
628 Put up to LEN bytes of the NIS domain name into NAME.
629 Null terminate it if the name is shorter than LEN.
630 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
631 Return 0 if successful, otherwise set errno and return -1. */
632 # if @REPLACE_GETDOMAINNAME@
633 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
634 # undef getdomainname
635 # define getdomainname rpl_getdomainname
637 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
638 _GL_ARG_NONNULL ((1)));
639 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
641 # if !@HAVE_DECL_GETDOMAINNAME@
642 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
643 _GL_ARG_NONNULL ((1)));
645 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
647 _GL_CXXALIASWARN (getdomainname
);
648 #elif defined GNULIB_POSIXCHECK
649 # undef getdomainname
650 # if HAVE_RAW_DECL_GETDOMAINNAME
651 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
652 "use gnulib module getdomainname for portability");
657 #if @GNULIB_GETDTABLESIZE@
658 /* Return the maximum number of file descriptors in the current process.
659 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
660 # if !@HAVE_GETDTABLESIZE@
661 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
663 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
664 _GL_CXXALIASWARN (getdtablesize
);
665 #elif defined GNULIB_POSIXCHECK
666 # undef getdtablesize
667 # if HAVE_RAW_DECL_GETDTABLESIZE
668 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
669 "use gnulib module getdtablesize for portability");
674 #if @GNULIB_GETGROUPS@
675 /* Return the supplemental groups that the current process belongs to.
676 It is unspecified whether the effective group id is in the list.
677 If N is 0, return the group count; otherwise, N describes how many
678 entries are available in GROUPS. Return -1 and set errno if N is
679 not 0 and not large enough. Fails with ENOSYS on some systems. */
680 # if @REPLACE_GETGROUPS@
681 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
683 # define getgroups rpl_getgroups
685 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
686 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
688 # if !@HAVE_GETGROUPS@
689 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
691 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
693 _GL_CXXALIASWARN (getgroups
);
694 #elif defined GNULIB_POSIXCHECK
696 # if HAVE_RAW_DECL_GETGROUPS
697 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
698 "use gnulib module getgroups for portability");
703 #if @GNULIB_GETHOSTNAME@
704 /* Return the standard host name of the machine.
705 WARNING! The host name may or may not be fully qualified.
707 Put up to LEN bytes of the host name into NAME.
708 Null terminate it if the name is shorter than LEN.
709 If the host name is longer than LEN, set errno = EINVAL and return -1.
710 Return 0 if successful, otherwise set errno and return -1. */
711 # if @UNISTD_H_HAVE_WINSOCK2_H@
712 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
714 # define gethostname rpl_gethostname
716 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
717 _GL_ARG_NONNULL ((1)));
718 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
720 # if !@HAVE_GETHOSTNAME@
721 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
722 _GL_ARG_NONNULL ((1)));
724 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
727 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
729 _GL_CXXALIASWARN (gethostname
);
730 #elif @UNISTD_H_HAVE_WINSOCK2_H@
732 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
733 #elif defined GNULIB_POSIXCHECK
735 # if HAVE_RAW_DECL_GETHOSTNAME
736 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
737 "use gnulib module gethostname for portability");
742 #if @GNULIB_GETLOGIN@
743 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
744 returns NULL with errno set.
746 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
748 Most programs don't need to use this function, because the information is
749 available through environment variables:
750 ${LOGNAME-$USER} on Unix platforms,
751 $USERNAME on native Windows platforms.
753 # if !@HAVE_GETLOGIN@
754 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
756 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
757 _GL_CXXALIASWARN (getlogin
);
758 #elif defined GNULIB_POSIXCHECK
760 # if HAVE_RAW_DECL_GETLOGIN
761 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
762 "use gnulib module getlogin for portability");
767 #if @GNULIB_GETLOGIN_R@
768 /* Copies the user's login name to NAME.
769 The array pointed to by NAME has room for SIZE bytes.
771 Returns 0 if successful. Upon error, an error number is returned, or -1 in
772 the case that the login name cannot be found but no specific error is
773 provided (this case is hopefully rare but is left open by the POSIX spec).
775 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
777 Most programs don't need to use this function, because the information is
778 available through environment variables:
779 ${LOGNAME-$USER} on Unix platforms,
780 $USERNAME on native Windows platforms.
782 # if @REPLACE_GETLOGIN_R@
783 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
784 # define getlogin_r rpl_getlogin_r
786 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
787 _GL_ARG_NONNULL ((1)));
788 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
790 # if !@HAVE_DECL_GETLOGIN_R@
791 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
792 _GL_ARG_NONNULL ((1)));
794 /* Need to cast, because on Solaris 10 systems, the second argument is
796 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
798 _GL_CXXALIASWARN (getlogin_r
);
799 #elif defined GNULIB_POSIXCHECK
801 # if HAVE_RAW_DECL_GETLOGIN_R
802 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
803 "use gnulib module getlogin_r for portability");
808 #if @GNULIB_GETPAGESIZE@
809 # if @REPLACE_GETPAGESIZE@
810 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
811 # define getpagesize rpl_getpagesize
813 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
814 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
816 # if !@HAVE_GETPAGESIZE@
817 # if !defined getpagesize
818 /* This is for POSIX systems. */
819 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
820 # if ! (defined __VMS && __VMS_VER < 70000000)
821 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
824 /* This is for older VMS. */
825 # if !defined _gl_getpagesize && defined __VMS
827 # define _gl_getpagesize() 8192
829 # define _gl_getpagesize() 512
832 /* This is for BeOS. */
833 # if !defined _gl_getpagesize && @HAVE_OS_H@
835 # if defined B_PAGE_SIZE
836 # define _gl_getpagesize() B_PAGE_SIZE
839 /* This is for AmigaOS4.0. */
840 # if !defined _gl_getpagesize && defined __amigaos4__
841 # define _gl_getpagesize() 2048
843 /* This is for older Unix systems. */
844 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
845 # include <sys/param.h>
846 # ifdef EXEC_PAGESIZE
847 # define _gl_getpagesize() EXEC_PAGESIZE
853 # define _gl_getpagesize() (NBPG * CLSIZE)
856 # define _gl_getpagesize() NBPC
861 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
862 # define getpagesize() _gl_getpagesize ()
864 # if !GNULIB_defined_getpagesize_function
868 return _gl_getpagesize ();
870 # define GNULIB_defined_getpagesize_function 1
875 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
876 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
878 # if @HAVE_DECL_GETPAGESIZE@
879 _GL_CXXALIASWARN (getpagesize
);
881 #elif defined GNULIB_POSIXCHECK
883 # if HAVE_RAW_DECL_GETPAGESIZE
884 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
885 "use gnulib module getpagesize for portability");
890 #if @GNULIB_GETUSERSHELL@
891 /* Return the next valid login shell on the system, or NULL when the end of
892 the list has been reached. */
893 # if !@HAVE_DECL_GETUSERSHELL@
894 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
896 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
897 _GL_CXXALIASWARN (getusershell
);
898 #elif defined GNULIB_POSIXCHECK
900 # if HAVE_RAW_DECL_GETUSERSHELL
901 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
902 "use gnulib module getusershell for portability");
906 #if @GNULIB_GETUSERSHELL@
907 /* Rewind to pointer that is advanced at each getusershell() call. */
908 # if !@HAVE_DECL_GETUSERSHELL@
909 _GL_FUNCDECL_SYS (setusershell
, void, (void));
911 _GL_CXXALIAS_SYS (setusershell
, void, (void));
912 _GL_CXXALIASWARN (setusershell
);
913 #elif defined GNULIB_POSIXCHECK
915 # if HAVE_RAW_DECL_SETUSERSHELL
916 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
917 "use gnulib module getusershell for portability");
921 #if @GNULIB_GETUSERSHELL@
922 /* Free the pointer that is advanced at each getusershell() call and
923 associated resources. */
924 # if !@HAVE_DECL_GETUSERSHELL@
925 _GL_FUNCDECL_SYS (endusershell
, void, (void));
927 _GL_CXXALIAS_SYS (endusershell
, void, (void));
928 _GL_CXXALIASWARN (endusershell
);
929 #elif defined GNULIB_POSIXCHECK
931 # if HAVE_RAW_DECL_ENDUSERSHELL
932 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
933 "use gnulib module getusershell for portability");
938 #if @GNULIB_GROUP_MEMBER@
939 /* Determine whether group id is in calling user's group list. */
940 # if !@HAVE_GROUP_MEMBER@
941 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
943 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
944 _GL_CXXALIASWARN (group_member
);
945 #elif defined GNULIB_POSIXCHECK
947 # if HAVE_RAW_DECL_GROUP_MEMBER
948 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
949 "use gnulib module group-member for portability");
955 # if @REPLACE_ISATTY@
956 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
958 # define isatty rpl_isatty
960 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
961 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
963 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
965 _GL_CXXALIASWARN (isatty
);
966 #elif defined GNULIB_POSIXCHECK
968 # if HAVE_RAW_DECL_ISATTY
969 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
970 "use gnulib module isatty for portability");
976 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
977 to GID (if GID is not -1). Do not follow symbolic links.
978 Return 0 if successful, otherwise -1 and errno set.
979 See the POSIX:2008 specification
980 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
981 # if @REPLACE_LCHOWN@
982 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
984 # define lchown rpl_lchown
986 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
987 _GL_ARG_NONNULL ((1)));
988 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
991 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
992 _GL_ARG_NONNULL ((1)));
994 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
996 _GL_CXXALIASWARN (lchown
);
997 #elif defined GNULIB_POSIXCHECK
999 # if HAVE_RAW_DECL_LCHOWN
1000 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1001 "use gnulib module lchown for portability");
1007 /* Create a new hard link for an existing file.
1008 Return 0 if successful, otherwise -1 and errno set.
1009 See POSIX:2008 specification
1010 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1012 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1013 # define link rpl_link
1015 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1016 _GL_ARG_NONNULL ((1, 2)));
1017 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1020 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1021 _GL_ARG_NONNULL ((1, 2)));
1023 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1025 _GL_CXXALIASWARN (link
);
1026 #elif defined GNULIB_POSIXCHECK
1028 # if HAVE_RAW_DECL_LINK
1029 _GL_WARN_ON_USE (link
, "link is unportable - "
1030 "use gnulib module link for portability");
1036 /* Create a new hard link for an existing file, relative to two
1037 directories. FLAG controls whether symlinks are followed.
1038 Return 0 if successful, otherwise -1 and errno set. */
1039 # if @REPLACE_LINKAT@
1040 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1042 # define linkat rpl_linkat
1044 _GL_FUNCDECL_RPL (linkat
, int,
1045 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1047 _GL_ARG_NONNULL ((2, 4)));
1048 _GL_CXXALIAS_RPL (linkat
, int,
1049 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1053 _GL_FUNCDECL_SYS (linkat
, int,
1054 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1056 _GL_ARG_NONNULL ((2, 4)));
1058 _GL_CXXALIAS_SYS (linkat
, int,
1059 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1062 _GL_CXXALIASWARN (linkat
);
1063 #elif defined GNULIB_POSIXCHECK
1065 # if HAVE_RAW_DECL_LINKAT
1066 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1067 "use gnulib module linkat for portability");
1073 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1074 Return the new offset if successful, otherwise -1 and errno set.
1075 See the POSIX:2008 specification
1076 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1077 # if @REPLACE_LSEEK@
1078 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1079 # define lseek rpl_lseek
1081 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1082 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1084 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1086 _GL_CXXALIASWARN (lseek
);
1087 #elif defined GNULIB_POSIXCHECK
1089 # if HAVE_RAW_DECL_LSEEK
1090 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1091 "systems - use gnulib module lseek for portability");
1097 /* Create a pipe, defaulting to O_BINARY mode.
1098 Store the read-end as fd[0] and the write-end as fd[1].
1099 Return 0 upon success, or -1 with errno set upon failure. */
1101 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1103 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1104 _GL_CXXALIASWARN (pipe
);
1105 #elif defined GNULIB_POSIXCHECK
1107 # if HAVE_RAW_DECL_PIPE
1108 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1109 "use gnulib module pipe-posix for portability");
1115 /* Create a pipe, applying the given flags when opening the read-end of the
1116 pipe and the write-end of the pipe.
1117 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1118 and O_TEXT, O_BINARY (defined in "binary-io.h").
1119 Store the read-end as fd[0] and the write-end as fd[1].
1120 Return 0 upon success, or -1 with errno set upon failure.
1121 See also the Linux man page at
1122 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1124 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1125 # define pipe2 rpl_pipe2
1127 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1128 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1130 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1131 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1133 _GL_CXXALIASWARN (pipe2
);
1134 #elif defined GNULIB_POSIXCHECK
1136 # if HAVE_RAW_DECL_PIPE2
1137 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1138 "use gnulib module pipe2 for portability");
1144 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1145 Return the number of bytes placed into BUF if successful, otherwise
1146 set errno and return -1. 0 indicates EOF.
1147 See the POSIX:2008 specification
1148 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1149 # if @REPLACE_PREAD@
1150 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1152 # define pread rpl_pread
1154 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1155 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1156 _GL_ARG_NONNULL ((2)));
1157 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1158 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1161 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1162 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1163 _GL_ARG_NONNULL ((2)));
1165 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1166 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1168 _GL_CXXALIASWARN (pread
);
1169 #elif defined GNULIB_POSIXCHECK
1171 # if HAVE_RAW_DECL_PREAD
1172 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1173 "use gnulib module pread for portability");
1179 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1180 Return the number of bytes written if successful, otherwise
1181 set errno and return -1. 0 indicates nothing written. See the
1182 POSIX:2008 specification
1183 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1184 # if @REPLACE_PWRITE@
1185 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1187 # define pwrite rpl_pwrite
1189 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1190 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1191 _GL_ARG_NONNULL ((2)));
1192 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1193 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1196 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1197 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1198 _GL_ARG_NONNULL ((2)));
1200 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1201 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1203 _GL_CXXALIASWARN (pwrite
);
1204 #elif defined GNULIB_POSIXCHECK
1206 # if HAVE_RAW_DECL_PWRITE
1207 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1208 "use gnulib module pwrite for portability");
1214 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1215 at BUF. See the POSIX:2008 specification
1216 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1218 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1220 # define read rpl_read
1222 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1223 _GL_ARG_NONNULL ((2)));
1224 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1226 /* Need to cast, because on mingw, the third parameter is
1228 and the return type is 'int'. */
1229 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1231 _GL_CXXALIASWARN (read
);
1235 #if @GNULIB_READLINK@
1236 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1237 bytes of it into BUF. Return the number of bytes placed into BUF if
1238 successful, otherwise -1 and errno set.
1239 See the POSIX:2008 specification
1240 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1241 # if @REPLACE_READLINK@
1242 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1243 # define readlink rpl_readlink
1245 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1246 (const char *file
, char *buf
, size_t bufsize
)
1247 _GL_ARG_NONNULL ((1, 2)));
1248 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1249 (const char *file
, char *buf
, size_t bufsize
));
1251 # if !@HAVE_READLINK@
1252 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1253 (const char *file
, char *buf
, size_t bufsize
)
1254 _GL_ARG_NONNULL ((1, 2)));
1256 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1257 (const char *file
, char *buf
, size_t bufsize
));
1259 _GL_CXXALIASWARN (readlink
);
1260 #elif defined GNULIB_POSIXCHECK
1262 # if HAVE_RAW_DECL_READLINK
1263 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1264 "use gnulib module readlink for portability");
1269 #if @GNULIB_READLINKAT@
1270 # if !@HAVE_READLINKAT@
1271 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1272 (int fd
, char const *file
, char *buf
, size_t len
)
1273 _GL_ARG_NONNULL ((2, 3)));
1275 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1276 (int fd
, char const *file
, char *buf
, size_t len
));
1277 _GL_CXXALIASWARN (readlinkat
);
1278 #elif defined GNULIB_POSIXCHECK
1280 # if HAVE_RAW_DECL_READLINKAT
1281 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1282 "use gnulib module readlinkat for portability");
1288 /* Remove the directory DIR. */
1289 # if @REPLACE_RMDIR@
1290 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1291 # define rmdir rpl_rmdir
1293 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1294 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1296 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1298 _GL_CXXALIASWARN (rmdir
);
1299 #elif defined GNULIB_POSIXCHECK
1301 # if HAVE_RAW_DECL_RMDIR
1302 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1303 "use gnulib module rmdir for portability");
1308 #if @GNULIB_SETHOSTNAME@
1309 /* Set the host name of the machine.
1310 The host name may or may not be fully qualified.
1312 Put LEN bytes of NAME into the host name.
1313 Return 0 if successful, otherwise, set errno and return -1.
1315 Platforms with no ability to set the hostname return -1 and set
1317 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1318 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1319 _GL_ARG_NONNULL ((1)));
1321 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1322 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1323 2011-10, the first parameter is not const. */
1324 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1325 _GL_CXXALIASWARN (sethostname
);
1326 #elif defined GNULIB_POSIXCHECK
1328 # if HAVE_RAW_DECL_SETHOSTNAME
1329 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1330 "use gnulib module sethostname for portability");
1336 /* Pause the execution of the current thread for N seconds.
1337 Returns the number of seconds left to sleep.
1338 See the POSIX:2008 specification
1339 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1340 # if @REPLACE_SLEEP@
1341 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1343 # define sleep rpl_sleep
1345 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1346 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1349 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1351 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1353 _GL_CXXALIASWARN (sleep
);
1354 #elif defined GNULIB_POSIXCHECK
1356 # if HAVE_RAW_DECL_SLEEP
1357 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1358 "use gnulib module sleep for portability");
1363 #if @GNULIB_SYMLINK@
1364 # if @REPLACE_SYMLINK@
1365 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1367 # define symlink rpl_symlink
1369 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1370 _GL_ARG_NONNULL ((1, 2)));
1371 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1373 # if !@HAVE_SYMLINK@
1374 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1375 _GL_ARG_NONNULL ((1, 2)));
1377 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1379 _GL_CXXALIASWARN (symlink
);
1380 #elif defined GNULIB_POSIXCHECK
1382 # if HAVE_RAW_DECL_SYMLINK
1383 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1384 "use gnulib module symlink for portability");
1389 #if @GNULIB_SYMLINKAT@
1390 # if !@HAVE_SYMLINKAT@
1391 _GL_FUNCDECL_SYS (symlinkat
, int,
1392 (char const *contents
, int fd
, char const *file
)
1393 _GL_ARG_NONNULL ((1, 3)));
1395 _GL_CXXALIAS_SYS (symlinkat
, int,
1396 (char const *contents
, int fd
, char const *file
));
1397 _GL_CXXALIASWARN (symlinkat
);
1398 #elif defined GNULIB_POSIXCHECK
1400 # if HAVE_RAW_DECL_SYMLINKAT
1401 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1402 "use gnulib module symlinkat for portability");
1407 #if @GNULIB_TTYNAME_R@
1408 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1409 open on in BUF. Return 0 on success, otherwise an error number. */
1410 # if @REPLACE_TTYNAME_R@
1411 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1413 # define ttyname_r rpl_ttyname_r
1415 _GL_FUNCDECL_RPL (ttyname_r
, int,
1416 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1417 _GL_CXXALIAS_RPL (ttyname_r
, int,
1418 (int fd
, char *buf
, size_t buflen
));
1420 # if !@HAVE_DECL_TTYNAME_R@
1421 _GL_FUNCDECL_SYS (ttyname_r
, int,
1422 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1424 _GL_CXXALIAS_SYS (ttyname_r
, int,
1425 (int fd
, char *buf
, size_t buflen
));
1427 _GL_CXXALIASWARN (ttyname_r
);
1428 #elif defined GNULIB_POSIXCHECK
1430 # if HAVE_RAW_DECL_TTYNAME_R
1431 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1432 "use gnulib module ttyname_r for portability");
1438 # if @REPLACE_UNLINK@
1439 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1441 # define unlink rpl_unlink
1443 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1444 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1446 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1448 _GL_CXXALIASWARN (unlink
);
1449 #elif defined GNULIB_POSIXCHECK
1451 # if HAVE_RAW_DECL_UNLINK
1452 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1453 "use gnulib module unlink for portability");
1458 #if @GNULIB_UNLINKAT@
1459 # if @REPLACE_UNLINKAT@
1460 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1462 # define unlinkat rpl_unlinkat
1464 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1465 _GL_ARG_NONNULL ((2)));
1466 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1468 # if !@HAVE_UNLINKAT@
1469 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1470 _GL_ARG_NONNULL ((2)));
1472 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1474 _GL_CXXALIASWARN (unlinkat
);
1475 #elif defined GNULIB_POSIXCHECK
1477 # if HAVE_RAW_DECL_UNLINKAT
1478 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1479 "use gnulib module openat for portability");
1485 /* Pause the execution of the current thread for N microseconds.
1486 Returns 0 on completion, or -1 on range error.
1487 See the POSIX:2001 specification
1488 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1489 # if @REPLACE_USLEEP@
1490 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1492 # define usleep rpl_usleep
1494 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1495 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1498 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1500 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1502 _GL_CXXALIASWARN (usleep
);
1503 #elif defined GNULIB_POSIXCHECK
1505 # if HAVE_RAW_DECL_USLEEP
1506 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1507 "use gnulib module usleep for portability");
1513 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1514 See the POSIX:2008 specification
1515 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1516 # if @REPLACE_WRITE@
1517 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1519 # define write rpl_write
1521 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1522 _GL_ARG_NONNULL ((2)));
1523 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1525 /* Need to cast, because on mingw, the third parameter is
1527 and the return type is 'int'. */
1528 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1530 _GL_CXXALIASWARN (write
);
1534 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1535 #endif /* _@GUARD_PREFIX@_UNISTD_H */