1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2013 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 #ifndef _@GUARD_PREFIX@_UNISTD_H
20 @PRAGMA_SYSTEM_HEADER@
24 /* The include_next requires a split double-inclusion guard. */
26 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
29 /* Get all possible declarations of gethostname(). */
30 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
31 && !defined _GL_INCLUDING_WINSOCK2_H
32 # define _GL_INCLUDING_WINSOCK2_H
33 # include <winsock2.h>
34 # undef _GL_INCLUDING_WINSOCK2_H
37 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
38 #define _@GUARD_PREFIX@_UNISTD_H
40 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
43 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
44 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
45 /* But avoid namespace pollution on glibc systems. */
46 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
47 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
48 && defined __CYGWIN__)) \
49 && ! defined __GLIBC__
53 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
54 /* But avoid namespace pollution on glibc systems. */
55 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
56 && ! defined __GLIBC__
60 /* mingw fails to declare _exit in <unistd.h>. */
61 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
63 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
64 /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
66 /* But avoid namespace pollution on glibc systems. */
67 #if !defined __GLIBC__ && !defined __osf__
68 # define __need_system_stdlib_h
70 # undef __need_system_stdlib_h
73 /* Native Windows platforms declare chdir, getcwd, rmdir in
74 <io.h> and/or <direct.h>, not in <unistd.h>.
75 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
76 lseek(), read(), unlink(), write() in <io.h>. */
77 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
78 || defined GNULIB_POSIXCHECK) \
79 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
80 # include <io.h> /* mingw32, mingw64 */
81 # include <direct.h> /* mingw64, MSVC 9 */
82 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
83 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
84 || defined GNULIB_POSIXCHECK) \
85 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
89 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
90 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
91 /* But avoid namespace pollution on glibc systems. */
92 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
93 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
98 /* MSVC defines off_t in <sys/types.h>.
99 May also define off_t to a 64-bit type on native Windows. */
100 #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
102 # include <sys/types.h>
105 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
106 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
107 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
109 # include <sys/types.h>
112 /* Get getopt(), optarg, optind, opterr, optopt.
113 But avoid namespace pollution on glibc systems. */
114 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
115 # define __need_getopt
119 _GL_INLINE_HEADER_BEGIN
120 #ifndef _GL_UNISTD_INLINE
121 # define _GL_UNISTD_INLINE _GL_INLINE
124 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
126 /* The definition of _GL_ARG_NONNULL is copied here. */
128 /* The definition of _GL_WARN_ON_USE is copied here. */
131 /* Hide some function declarations from <winsock2.h>. */
133 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
134 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
135 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
137 # define socket socket_used_without_including_sys_socket_h
139 # define connect connect_used_without_including_sys_socket_h
141 # define accept accept_used_without_including_sys_socket_h
143 # define bind bind_used_without_including_sys_socket_h
145 # define getpeername getpeername_used_without_including_sys_socket_h
147 # define getsockname getsockname_used_without_including_sys_socket_h
149 # define getsockopt getsockopt_used_without_including_sys_socket_h
151 # define listen listen_used_without_including_sys_socket_h
153 # define recv recv_used_without_including_sys_socket_h
155 # define send send_used_without_including_sys_socket_h
157 # define recvfrom recvfrom_used_without_including_sys_socket_h
159 # define sendto sendto_used_without_including_sys_socket_h
161 # define setsockopt setsockopt_used_without_including_sys_socket_h
163 # define shutdown shutdown_used_without_including_sys_socket_h
165 _GL_WARN_ON_USE (socket
,
166 "socket() used without including <sys/socket.h>");
167 _GL_WARN_ON_USE (connect
,
168 "connect() used without including <sys/socket.h>");
169 _GL_WARN_ON_USE (accept
,
170 "accept() used without including <sys/socket.h>");
171 _GL_WARN_ON_USE (bind
,
172 "bind() used without including <sys/socket.h>");
173 _GL_WARN_ON_USE (getpeername
,
174 "getpeername() used without including <sys/socket.h>");
175 _GL_WARN_ON_USE (getsockname
,
176 "getsockname() used without including <sys/socket.h>");
177 _GL_WARN_ON_USE (getsockopt
,
178 "getsockopt() used without including <sys/socket.h>");
179 _GL_WARN_ON_USE (listen
,
180 "listen() used without including <sys/socket.h>");
181 _GL_WARN_ON_USE (recv
,
182 "recv() used without including <sys/socket.h>");
183 _GL_WARN_ON_USE (send
,
184 "send() used without including <sys/socket.h>");
185 _GL_WARN_ON_USE (recvfrom
,
186 "recvfrom() used without including <sys/socket.h>");
187 _GL_WARN_ON_USE (sendto
,
188 "sendto() used without including <sys/socket.h>");
189 _GL_WARN_ON_USE (setsockopt
,
190 "setsockopt() used without including <sys/socket.h>");
191 _GL_WARN_ON_USE (shutdown
,
192 "shutdown() used without including <sys/socket.h>");
195 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
196 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
198 # define select select_used_without_including_sys_select_h
200 _GL_WARN_ON_USE (select
,
201 "select() used without including <sys/select.h>");
207 /* OS/2 EMX lacks these macros. */
209 # define STDIN_FILENO 0
211 #ifndef STDOUT_FILENO
212 # define STDOUT_FILENO 1
214 #ifndef STDERR_FILENO
215 # define STDERR_FILENO 2
218 /* Ensure *_OK macros exist. */
227 /* Declare overridden functions. */
230 #if defined GNULIB_POSIXCHECK
231 /* The access() function is a security risk. */
232 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
233 "use the gnulib module faccessat instead");
238 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
239 _GL_CXXALIASWARN (chdir
);
240 #elif defined GNULIB_POSIXCHECK
242 # if HAVE_RAW_DECL_CHDIR
243 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
244 "use gnulib module chdir for portability");
250 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
251 to GID (if GID is not -1). Follow symbolic links.
252 Return 0 if successful, otherwise -1 and errno set.
253 See the POSIX:2008 specification
254 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
256 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
258 # define chown rpl_chown
260 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
261 _GL_ARG_NONNULL ((1)));
262 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
265 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
266 _GL_ARG_NONNULL ((1)));
268 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
270 _GL_CXXALIASWARN (chown
);
271 #elif defined GNULIB_POSIXCHECK
273 # if HAVE_RAW_DECL_CHOWN
274 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
275 "doesn't treat a uid or gid of -1 on some systems - "
276 "use gnulib module chown for portability");
283 /* Automatically included by modules that need a replacement for close. */
284 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
286 # define close rpl_close
288 _GL_FUNCDECL_RPL (close
, int, (int fd
));
289 _GL_CXXALIAS_RPL (close
, int, (int fd
));
291 _GL_CXXALIAS_SYS (close
, int, (int fd
));
293 _GL_CXXALIASWARN (close
);
294 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
296 # define close close_used_without_requesting_gnulib_module_close
297 #elif defined GNULIB_POSIXCHECK
299 /* Assume close is always declared. */
300 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
301 "use gnulib module close for portability");
307 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
310 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
311 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
313 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
315 _GL_CXXALIASWARN (dup
);
316 #elif defined GNULIB_POSIXCHECK
318 # if HAVE_RAW_DECL_DUP
319 _GL_WARN_ON_USE (dup
, "dup is unportable - "
320 "use gnulib module dup for portability");
326 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
327 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
328 Return newfd if successful, otherwise -1 and errno set.
329 See the POSIX:2008 specification
330 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
332 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
333 # define dup2 rpl_dup2
335 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
336 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
339 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
341 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
343 _GL_CXXALIASWARN (dup2
);
344 #elif defined GNULIB_POSIXCHECK
346 # if HAVE_RAW_DECL_DUP2
347 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
348 "use gnulib module dup2 for portability");
354 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
356 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
357 and O_TEXT, O_BINARY (defined in "binary-io.h").
358 Close NEWFD first if it is open.
359 Return newfd if successful, otherwise -1 and errno set.
360 See the Linux man page at
361 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
363 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
364 # define dup3 rpl_dup3
366 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
367 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
369 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
370 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
372 _GL_CXXALIASWARN (dup3
);
373 #elif defined GNULIB_POSIXCHECK
375 # if HAVE_RAW_DECL_DUP3
376 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
377 "use gnulib module dup3 for portability");
383 # if !@HAVE_DECL_ENVIRON@
384 /* Set of environment variables and values. An array of strings of the form
385 "VARIABLE=VALUE", terminated with a NULL. */
386 # if defined __APPLE__ && defined __MACH__
387 # include <crt_externs.h>
388 # define environ (*_NSGetEnviron ())
393 extern char **environ
;
399 #elif defined GNULIB_POSIXCHECK
400 # if HAVE_RAW_DECL_ENVIRON
401 _GL_UNISTD_INLINE
char ***
406 _GL_WARN_ON_USE (rpl_environ
, "environ is unportable - "
407 "use gnulib module environ for portability");
409 # define environ (*rpl_environ ())
414 #if @GNULIB_EUIDACCESS@
415 /* Like access(), except that it uses the effective user id and group id of
416 the current process. */
417 # if !@HAVE_EUIDACCESS@
418 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
419 _GL_ARG_NONNULL ((1)));
421 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
422 _GL_CXXALIASWARN (euidaccess
);
423 # if defined GNULIB_POSIXCHECK
424 /* Like access(), this function is a security risk. */
425 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
426 "use the gnulib module faccessat instead");
428 #elif defined GNULIB_POSIXCHECK
430 # if HAVE_RAW_DECL_EUIDACCESS
431 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
432 "use gnulib module euidaccess for portability");
437 #if @GNULIB_FACCESSAT@
438 # if !@HAVE_FACCESSAT@
439 _GL_FUNCDECL_SYS (faccessat
, int,
440 (int fd
, char const *file
, int mode
, int flag
)
441 _GL_ARG_NONNULL ((2)));
443 _GL_CXXALIAS_SYS (faccessat
, int,
444 (int fd
, char const *file
, int mode
, int flag
));
445 _GL_CXXALIASWARN (faccessat
);
446 #elif defined GNULIB_POSIXCHECK
448 # if HAVE_RAW_DECL_FACCESSAT
449 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
450 "use gnulib module faccessat for portability");
456 /* Change the process' current working directory to the directory on which
457 the given file descriptor is open.
458 Return 0 if successful, otherwise -1 and errno set.
459 See the POSIX:2008 specification
460 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
462 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
464 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
465 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
466 _GL_ARG_NONNULL ((2));
467 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
468 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
469 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
472 # if !@HAVE_DECL_FCHDIR@
473 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
476 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
477 _GL_CXXALIASWARN (fchdir
);
478 #elif defined GNULIB_POSIXCHECK
480 # if HAVE_RAW_DECL_FCHDIR
481 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
482 "use gnulib module fchdir for portability");
487 #if @GNULIB_FCHOWNAT@
488 # if @REPLACE_FCHOWNAT@
489 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
491 # define fchownat rpl_fchownat
493 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
494 uid_t owner
, gid_t group
, int flag
)
495 _GL_ARG_NONNULL ((2)));
496 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
497 uid_t owner
, gid_t group
, int flag
));
499 # if !@HAVE_FCHOWNAT@
500 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
501 uid_t owner
, gid_t group
, int flag
)
502 _GL_ARG_NONNULL ((2)));
504 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
505 uid_t owner
, gid_t group
, int flag
));
507 _GL_CXXALIASWARN (fchownat
);
508 #elif defined GNULIB_POSIXCHECK
510 # if HAVE_RAW_DECL_FCHOWNAT
511 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
512 "use gnulib module openat for portability");
517 #if @GNULIB_FDATASYNC@
518 /* Synchronize changes to a file.
519 Return 0 if successful, otherwise -1 and errno set.
520 See POSIX:2008 specification
521 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
522 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
523 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
525 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
526 _GL_CXXALIASWARN (fdatasync
);
527 #elif defined GNULIB_POSIXCHECK
529 # if HAVE_RAW_DECL_FDATASYNC
530 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
531 "use gnulib module fdatasync for portability");
537 /* Synchronize changes, including metadata, to a file.
538 Return 0 if successful, otherwise -1 and errno set.
539 See POSIX:2008 specification
540 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
542 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
544 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
545 _GL_CXXALIASWARN (fsync
);
546 #elif defined GNULIB_POSIXCHECK
548 # if HAVE_RAW_DECL_FSYNC
549 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
550 "use gnulib module fsync for portability");
555 #if @GNULIB_FTRUNCATE@
556 /* Change the size of the file to which FD is opened to become equal to LENGTH.
557 Return 0 if successful, otherwise -1 and errno set.
558 See the POSIX:2008 specification
559 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
560 # if @REPLACE_FTRUNCATE@
561 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
563 # define ftruncate rpl_ftruncate
565 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
566 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
568 # if !@HAVE_FTRUNCATE@
569 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
571 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
573 _GL_CXXALIASWARN (ftruncate
);
574 #elif defined GNULIB_POSIXCHECK
576 # if HAVE_RAW_DECL_FTRUNCATE
577 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
578 "use gnulib module ftruncate for portability");
584 /* Get the name of the current working directory, and put it in SIZE bytes
586 Return BUF if successful, or NULL if the directory couldn't be determined
587 or SIZE was too small.
588 See the POSIX:2008 specification
589 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
590 Additionally, the gnulib module 'getcwd' guarantees the following GNU
591 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
592 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
594 # if @REPLACE_GETCWD@
595 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
596 # define getcwd rpl_getcwd
598 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
599 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
601 /* Need to cast, because on mingw, the second parameter is
603 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
605 _GL_CXXALIASWARN (getcwd
);
606 #elif defined GNULIB_POSIXCHECK
608 # if HAVE_RAW_DECL_GETCWD
609 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
610 "use gnulib module getcwd for portability");
615 #if @GNULIB_GETDOMAINNAME@
616 /* Return the NIS domain name of the machine.
617 WARNING! The NIS domain name is unrelated to the fully qualified host name
618 of the machine. It is also unrelated to email addresses.
619 WARNING! The NIS domain name is usually the empty string or "(none)" when
622 Put up to LEN bytes of the NIS domain name into NAME.
623 Null terminate it if the name is shorter than LEN.
624 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
625 Return 0 if successful, otherwise set errno and return -1. */
626 # if @REPLACE_GETDOMAINNAME@
627 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
628 # undef getdomainname
629 # define getdomainname rpl_getdomainname
631 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
632 _GL_ARG_NONNULL ((1)));
633 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
635 # if !@HAVE_DECL_GETDOMAINNAME@
636 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
637 _GL_ARG_NONNULL ((1)));
639 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
641 _GL_CXXALIASWARN (getdomainname
);
642 #elif defined GNULIB_POSIXCHECK
643 # undef getdomainname
644 # if HAVE_RAW_DECL_GETDOMAINNAME
645 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
646 "use gnulib module getdomainname for portability");
651 #if @GNULIB_GETDTABLESIZE@
652 /* Return the maximum number of file descriptors in the current process.
653 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
654 # if !@HAVE_GETDTABLESIZE@
655 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
657 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
658 _GL_CXXALIASWARN (getdtablesize
);
659 #elif defined GNULIB_POSIXCHECK
660 # undef getdtablesize
661 # if HAVE_RAW_DECL_GETDTABLESIZE
662 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
663 "use gnulib module getdtablesize for portability");
668 #if @GNULIB_GETGROUPS@
669 /* Return the supplemental groups that the current process belongs to.
670 It is unspecified whether the effective group id is in the list.
671 If N is 0, return the group count; otherwise, N describes how many
672 entries are available in GROUPS. Return -1 and set errno if N is
673 not 0 and not large enough. Fails with ENOSYS on some systems. */
674 # if @REPLACE_GETGROUPS@
675 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
677 # define getgroups rpl_getgroups
679 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
680 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
682 # if !@HAVE_GETGROUPS@
683 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
685 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
687 _GL_CXXALIASWARN (getgroups
);
688 #elif defined GNULIB_POSIXCHECK
690 # if HAVE_RAW_DECL_GETGROUPS
691 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
692 "use gnulib module getgroups for portability");
697 #if @GNULIB_GETHOSTNAME@
698 /* Return the standard host name of the machine.
699 WARNING! The host name may or may not be fully qualified.
701 Put up to LEN bytes of the host name into NAME.
702 Null terminate it if the name is shorter than LEN.
703 If the host name is longer than LEN, set errno = EINVAL and return -1.
704 Return 0 if successful, otherwise set errno and return -1. */
705 # if @UNISTD_H_HAVE_WINSOCK2_H@
706 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
708 # define gethostname rpl_gethostname
710 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
711 _GL_ARG_NONNULL ((1)));
712 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
714 # if !@HAVE_GETHOSTNAME@
715 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
716 _GL_ARG_NONNULL ((1)));
718 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
721 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
723 _GL_CXXALIASWARN (gethostname
);
724 #elif @UNISTD_H_HAVE_WINSOCK2_H@
726 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
727 #elif defined GNULIB_POSIXCHECK
729 # if HAVE_RAW_DECL_GETHOSTNAME
730 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
731 "use gnulib module gethostname for portability");
736 #if @GNULIB_GETLOGIN@
737 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
738 returns NULL with errno set.
740 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
742 Most programs don't need to use this function, because the information is
743 available through environment variables:
744 ${LOGNAME-$USER} on Unix platforms,
745 $USERNAME on native Windows platforms.
747 # if !@HAVE_GETLOGIN@
748 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
750 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
751 _GL_CXXALIASWARN (getlogin
);
752 #elif defined GNULIB_POSIXCHECK
754 # if HAVE_RAW_DECL_GETLOGIN
755 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
756 "use gnulib module getlogin for portability");
761 #if @GNULIB_GETLOGIN_R@
762 /* Copies the user's login name to NAME.
763 The array pointed to by NAME has room for SIZE bytes.
765 Returns 0 if successful. Upon error, an error number is returned, or -1 in
766 the case that the login name cannot be found but no specific error is
767 provided (this case is hopefully rare but is left open by the POSIX spec).
769 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
771 Most programs don't need to use this function, because the information is
772 available through environment variables:
773 ${LOGNAME-$USER} on Unix platforms,
774 $USERNAME on native Windows platforms.
776 # if @REPLACE_GETLOGIN_R@
777 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
778 # define getlogin_r rpl_getlogin_r
780 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
781 _GL_ARG_NONNULL ((1)));
782 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
784 # if !@HAVE_DECL_GETLOGIN_R@
785 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
786 _GL_ARG_NONNULL ((1)));
788 /* Need to cast, because on Solaris 10 systems, the second argument is
790 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
792 _GL_CXXALIASWARN (getlogin_r
);
793 #elif defined GNULIB_POSIXCHECK
795 # if HAVE_RAW_DECL_GETLOGIN_R
796 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
797 "use gnulib module getlogin_r for portability");
802 #if @GNULIB_GETPAGESIZE@
803 # if @REPLACE_GETPAGESIZE@
804 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
805 # define getpagesize rpl_getpagesize
807 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
808 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
810 # if !@HAVE_GETPAGESIZE@
811 # if !defined getpagesize
812 /* This is for POSIX systems. */
813 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
814 # if ! (defined __VMS && __VMS_VER < 70000000)
815 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
818 /* This is for older VMS. */
819 # if !defined _gl_getpagesize && defined __VMS
821 # define _gl_getpagesize() 8192
823 # define _gl_getpagesize() 512
826 /* This is for BeOS. */
827 # if !defined _gl_getpagesize && @HAVE_OS_H@
829 # if defined B_PAGE_SIZE
830 # define _gl_getpagesize() B_PAGE_SIZE
833 /* This is for AmigaOS4.0. */
834 # if !defined _gl_getpagesize && defined __amigaos4__
835 # define _gl_getpagesize() 2048
837 /* This is for older Unix systems. */
838 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
839 # include <sys/param.h>
840 # ifdef EXEC_PAGESIZE
841 # define _gl_getpagesize() EXEC_PAGESIZE
847 # define _gl_getpagesize() (NBPG * CLSIZE)
850 # define _gl_getpagesize() NBPC
855 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
856 # define getpagesize() _gl_getpagesize ()
858 # if !GNULIB_defined_getpagesize_function
859 _GL_UNISTD_INLINE
int
862 return _gl_getpagesize ();
864 # define GNULIB_defined_getpagesize_function 1
869 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
870 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
872 # if @HAVE_DECL_GETPAGESIZE@
873 _GL_CXXALIASWARN (getpagesize
);
875 #elif defined GNULIB_POSIXCHECK
877 # if HAVE_RAW_DECL_GETPAGESIZE
878 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
879 "use gnulib module getpagesize for portability");
884 #if @GNULIB_GETUSERSHELL@
885 /* Return the next valid login shell on the system, or NULL when the end of
886 the list has been reached. */
887 # if !@HAVE_DECL_GETUSERSHELL@
888 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
890 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
891 _GL_CXXALIASWARN (getusershell
);
892 #elif defined GNULIB_POSIXCHECK
894 # if HAVE_RAW_DECL_GETUSERSHELL
895 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
896 "use gnulib module getusershell for portability");
900 #if @GNULIB_GETUSERSHELL@
901 /* Rewind to pointer that is advanced at each getusershell() call. */
902 # if !@HAVE_DECL_GETUSERSHELL@
903 _GL_FUNCDECL_SYS (setusershell
, void, (void));
905 _GL_CXXALIAS_SYS (setusershell
, void, (void));
906 _GL_CXXALIASWARN (setusershell
);
907 #elif defined GNULIB_POSIXCHECK
909 # if HAVE_RAW_DECL_SETUSERSHELL
910 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
911 "use gnulib module getusershell for portability");
915 #if @GNULIB_GETUSERSHELL@
916 /* Free the pointer that is advanced at each getusershell() call and
917 associated resources. */
918 # if !@HAVE_DECL_GETUSERSHELL@
919 _GL_FUNCDECL_SYS (endusershell
, void, (void));
921 _GL_CXXALIAS_SYS (endusershell
, void, (void));
922 _GL_CXXALIASWARN (endusershell
);
923 #elif defined GNULIB_POSIXCHECK
925 # if HAVE_RAW_DECL_ENDUSERSHELL
926 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
927 "use gnulib module getusershell for portability");
932 #if @GNULIB_GROUP_MEMBER@
933 /* Determine whether group id is in calling user's group list. */
934 # if !@HAVE_GROUP_MEMBER@
935 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
937 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
938 _GL_CXXALIASWARN (group_member
);
939 #elif defined GNULIB_POSIXCHECK
941 # if HAVE_RAW_DECL_GROUP_MEMBER
942 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
943 "use gnulib module group-member for portability");
949 # if @REPLACE_ISATTY@
950 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
952 # define isatty rpl_isatty
954 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
955 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
957 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
959 _GL_CXXALIASWARN (isatty
);
960 #elif defined GNULIB_POSIXCHECK
962 # if HAVE_RAW_DECL_ISATTY
963 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
964 "use gnulib module isatty for portability");
970 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
971 to GID (if GID is not -1). Do not follow symbolic links.
972 Return 0 if successful, otherwise -1 and errno set.
973 See the POSIX:2008 specification
974 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
975 # if @REPLACE_LCHOWN@
976 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
978 # define lchown rpl_lchown
980 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
981 _GL_ARG_NONNULL ((1)));
982 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
985 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
986 _GL_ARG_NONNULL ((1)));
988 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
990 _GL_CXXALIASWARN (lchown
);
991 #elif defined GNULIB_POSIXCHECK
993 # if HAVE_RAW_DECL_LCHOWN
994 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
995 "use gnulib module lchown for portability");
1001 /* Create a new hard link for an existing file.
1002 Return 0 if successful, otherwise -1 and errno set.
1003 See POSIX:2008 specification
1004 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1006 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1007 # define link rpl_link
1009 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1010 _GL_ARG_NONNULL ((1, 2)));
1011 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1014 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1015 _GL_ARG_NONNULL ((1, 2)));
1017 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1019 _GL_CXXALIASWARN (link
);
1020 #elif defined GNULIB_POSIXCHECK
1022 # if HAVE_RAW_DECL_LINK
1023 _GL_WARN_ON_USE (link
, "link is unportable - "
1024 "use gnulib module link for portability");
1030 /* Create a new hard link for an existing file, relative to two
1031 directories. FLAG controls whether symlinks are followed.
1032 Return 0 if successful, otherwise -1 and errno set. */
1033 # if @REPLACE_LINKAT@
1034 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1036 # define linkat rpl_linkat
1038 _GL_FUNCDECL_RPL (linkat
, int,
1039 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1041 _GL_ARG_NONNULL ((2, 4)));
1042 _GL_CXXALIAS_RPL (linkat
, int,
1043 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1047 _GL_FUNCDECL_SYS (linkat
, int,
1048 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1050 _GL_ARG_NONNULL ((2, 4)));
1052 _GL_CXXALIAS_SYS (linkat
, int,
1053 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1056 _GL_CXXALIASWARN (linkat
);
1057 #elif defined GNULIB_POSIXCHECK
1059 # if HAVE_RAW_DECL_LINKAT
1060 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1061 "use gnulib module linkat for portability");
1067 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1068 Return the new offset if successful, otherwise -1 and errno set.
1069 See the POSIX:2008 specification
1070 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1071 # if @REPLACE_LSEEK@
1072 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1073 # define lseek rpl_lseek
1075 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1076 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1078 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1080 _GL_CXXALIASWARN (lseek
);
1081 #elif defined GNULIB_POSIXCHECK
1083 # if HAVE_RAW_DECL_LSEEK
1084 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1085 "systems - use gnulib module lseek for portability");
1091 /* Create a pipe, defaulting to O_BINARY mode.
1092 Store the read-end as fd[0] and the write-end as fd[1].
1093 Return 0 upon success, or -1 with errno set upon failure. */
1095 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1097 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1098 _GL_CXXALIASWARN (pipe
);
1099 #elif defined GNULIB_POSIXCHECK
1101 # if HAVE_RAW_DECL_PIPE
1102 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1103 "use gnulib module pipe-posix for portability");
1109 /* Create a pipe, applying the given flags when opening the read-end of the
1110 pipe and the write-end of the pipe.
1111 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1112 and O_TEXT, O_BINARY (defined in "binary-io.h").
1113 Store the read-end as fd[0] and the write-end as fd[1].
1114 Return 0 upon success, or -1 with errno set upon failure.
1115 See also the Linux man page at
1116 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1118 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1119 # define pipe2 rpl_pipe2
1121 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1122 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1124 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1125 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1127 _GL_CXXALIASWARN (pipe2
);
1128 #elif defined GNULIB_POSIXCHECK
1130 # if HAVE_RAW_DECL_PIPE2
1131 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1132 "use gnulib module pipe2 for portability");
1138 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1139 Return the number of bytes placed into BUF if successful, otherwise
1140 set errno and return -1. 0 indicates EOF.
1141 See the POSIX:2008 specification
1142 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1143 # if @REPLACE_PREAD@
1144 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1146 # define pread rpl_pread
1148 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1149 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1150 _GL_ARG_NONNULL ((2)));
1151 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1152 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1155 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1156 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1157 _GL_ARG_NONNULL ((2)));
1159 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1160 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1162 _GL_CXXALIASWARN (pread
);
1163 #elif defined GNULIB_POSIXCHECK
1165 # if HAVE_RAW_DECL_PREAD
1166 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1167 "use gnulib module pread for portability");
1173 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1174 Return the number of bytes written if successful, otherwise
1175 set errno and return -1. 0 indicates nothing written. See the
1176 POSIX:2008 specification
1177 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1178 # if @REPLACE_PWRITE@
1179 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1181 # define pwrite rpl_pwrite
1183 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1184 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1185 _GL_ARG_NONNULL ((2)));
1186 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1187 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1190 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1191 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1192 _GL_ARG_NONNULL ((2)));
1194 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1195 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1197 _GL_CXXALIASWARN (pwrite
);
1198 #elif defined GNULIB_POSIXCHECK
1200 # if HAVE_RAW_DECL_PWRITE
1201 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1202 "use gnulib module pwrite for portability");
1208 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1209 at BUF. See the POSIX:2008 specification
1210 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1212 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1214 # define read rpl_read
1216 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1217 _GL_ARG_NONNULL ((2)));
1218 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1220 /* Need to cast, because on mingw, the third parameter is
1222 and the return type is 'int'. */
1223 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1225 _GL_CXXALIASWARN (read
);
1229 #if @GNULIB_READLINK@
1230 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1231 bytes of it into BUF. Return the number of bytes placed into BUF if
1232 successful, otherwise -1 and errno set.
1233 See the POSIX:2008 specification
1234 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1235 # if @REPLACE_READLINK@
1236 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1237 # define readlink rpl_readlink
1239 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1240 (const char *file
, char *buf
, size_t bufsize
)
1241 _GL_ARG_NONNULL ((1, 2)));
1242 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1243 (const char *file
, char *buf
, size_t bufsize
));
1245 # if !@HAVE_READLINK@
1246 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1247 (const char *file
, char *buf
, size_t bufsize
)
1248 _GL_ARG_NONNULL ((1, 2)));
1250 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1251 (const char *file
, char *buf
, size_t bufsize
));
1253 _GL_CXXALIASWARN (readlink
);
1254 #elif defined GNULIB_POSIXCHECK
1256 # if HAVE_RAW_DECL_READLINK
1257 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1258 "use gnulib module readlink for portability");
1263 #if @GNULIB_READLINKAT@
1264 # if !@HAVE_READLINKAT@
1265 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1266 (int fd
, char const *file
, char *buf
, size_t len
)
1267 _GL_ARG_NONNULL ((2, 3)));
1269 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1270 (int fd
, char const *file
, char *buf
, size_t len
));
1271 _GL_CXXALIASWARN (readlinkat
);
1272 #elif defined GNULIB_POSIXCHECK
1274 # if HAVE_RAW_DECL_READLINKAT
1275 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1276 "use gnulib module readlinkat for portability");
1282 /* Remove the directory DIR. */
1283 # if @REPLACE_RMDIR@
1284 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1285 # define rmdir rpl_rmdir
1287 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1288 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1290 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1292 _GL_CXXALIASWARN (rmdir
);
1293 #elif defined GNULIB_POSIXCHECK
1295 # if HAVE_RAW_DECL_RMDIR
1296 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1297 "use gnulib module rmdir for portability");
1302 #if @GNULIB_SETHOSTNAME@
1303 /* Set the host name of the machine.
1304 The host name may or may not be fully qualified.
1306 Put LEN bytes of NAME into the host name.
1307 Return 0 if successful, otherwise, set errno and return -1.
1309 Platforms with no ability to set the hostname return -1 and set
1311 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1312 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1313 _GL_ARG_NONNULL ((1)));
1315 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1316 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1317 2011-10, the first parameter is not const. */
1318 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1319 _GL_CXXALIASWARN (sethostname
);
1320 #elif defined GNULIB_POSIXCHECK
1322 # if HAVE_RAW_DECL_SETHOSTNAME
1323 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1324 "use gnulib module sethostname for portability");
1330 /* Pause the execution of the current thread for N seconds.
1331 Returns the number of seconds left to sleep.
1332 See the POSIX:2008 specification
1333 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1334 # if @REPLACE_SLEEP@
1335 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1337 # define sleep rpl_sleep
1339 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1340 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1343 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1345 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1347 _GL_CXXALIASWARN (sleep
);
1348 #elif defined GNULIB_POSIXCHECK
1350 # if HAVE_RAW_DECL_SLEEP
1351 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1352 "use gnulib module sleep for portability");
1357 #if @GNULIB_SYMLINK@
1358 # if @REPLACE_SYMLINK@
1359 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1361 # define symlink rpl_symlink
1363 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1364 _GL_ARG_NONNULL ((1, 2)));
1365 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1367 # if !@HAVE_SYMLINK@
1368 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1369 _GL_ARG_NONNULL ((1, 2)));
1371 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1373 _GL_CXXALIASWARN (symlink
);
1374 #elif defined GNULIB_POSIXCHECK
1376 # if HAVE_RAW_DECL_SYMLINK
1377 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1378 "use gnulib module symlink for portability");
1383 #if @GNULIB_SYMLINKAT@
1384 # if !@HAVE_SYMLINKAT@
1385 _GL_FUNCDECL_SYS (symlinkat
, int,
1386 (char const *contents
, int fd
, char const *file
)
1387 _GL_ARG_NONNULL ((1, 3)));
1389 _GL_CXXALIAS_SYS (symlinkat
, int,
1390 (char const *contents
, int fd
, char const *file
));
1391 _GL_CXXALIASWARN (symlinkat
);
1392 #elif defined GNULIB_POSIXCHECK
1394 # if HAVE_RAW_DECL_SYMLINKAT
1395 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1396 "use gnulib module symlinkat for portability");
1401 #if @GNULIB_TTYNAME_R@
1402 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1403 open on in BUF. Return 0 on success, otherwise an error number. */
1404 # if @REPLACE_TTYNAME_R@
1405 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1407 # define ttyname_r rpl_ttyname_r
1409 _GL_FUNCDECL_RPL (ttyname_r
, int,
1410 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1411 _GL_CXXALIAS_RPL (ttyname_r
, int,
1412 (int fd
, char *buf
, size_t buflen
));
1414 # if !@HAVE_DECL_TTYNAME_R@
1415 _GL_FUNCDECL_SYS (ttyname_r
, int,
1416 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1418 _GL_CXXALIAS_SYS (ttyname_r
, int,
1419 (int fd
, char *buf
, size_t buflen
));
1421 _GL_CXXALIASWARN (ttyname_r
);
1422 #elif defined GNULIB_POSIXCHECK
1424 # if HAVE_RAW_DECL_TTYNAME_R
1425 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1426 "use gnulib module ttyname_r for portability");
1432 # if @REPLACE_UNLINK@
1433 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1435 # define unlink rpl_unlink
1437 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1438 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1440 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1442 _GL_CXXALIASWARN (unlink
);
1443 #elif defined GNULIB_POSIXCHECK
1445 # if HAVE_RAW_DECL_UNLINK
1446 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1447 "use gnulib module unlink for portability");
1452 #if @GNULIB_UNLINKAT@
1453 # if @REPLACE_UNLINKAT@
1454 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1456 # define unlinkat rpl_unlinkat
1458 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1459 _GL_ARG_NONNULL ((2)));
1460 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1462 # if !@HAVE_UNLINKAT@
1463 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1464 _GL_ARG_NONNULL ((2)));
1466 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1468 _GL_CXXALIASWARN (unlinkat
);
1469 #elif defined GNULIB_POSIXCHECK
1471 # if HAVE_RAW_DECL_UNLINKAT
1472 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1473 "use gnulib module openat for portability");
1479 /* Pause the execution of the current thread for N microseconds.
1480 Returns 0 on completion, or -1 on range error.
1481 See the POSIX:2001 specification
1482 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1483 # if @REPLACE_USLEEP@
1484 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1486 # define usleep rpl_usleep
1488 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1489 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1492 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1494 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1496 _GL_CXXALIASWARN (usleep
);
1497 #elif defined GNULIB_POSIXCHECK
1499 # if HAVE_RAW_DECL_USLEEP
1500 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1501 "use gnulib module usleep for portability");
1507 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1508 See the POSIX:2008 specification
1509 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1510 # if @REPLACE_WRITE@
1511 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1513 # define write rpl_write
1515 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1516 _GL_ARG_NONNULL ((2)));
1517 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1519 /* Need to cast, because on mingw, the third parameter is
1521 and the return type is 'int'. */
1522 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1524 _GL_CXXALIASWARN (write
);
1527 _GL_INLINE_HEADER_END
1529 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1530 #endif /* _@GUARD_PREFIX@_UNISTD_H */