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 /* But avoid namespace pollution on glibc systems. */
66 # define __need_system_stdlib_h
68 # undef __need_system_stdlib_h
71 /* Native Windows platforms declare chdir, getcwd, rmdir in
72 <io.h> and/or <direct.h>, not in <unistd.h>.
73 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
74 lseek(), read(), unlink(), write() in <io.h>. */
75 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
76 || defined GNULIB_POSIXCHECK) \
77 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
78 # include <io.h> /* mingw32, mingw64 */
79 # include <direct.h> /* mingw64, MSVC 9 */
80 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
81 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
82 || defined GNULIB_POSIXCHECK) \
83 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
87 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
88 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
89 /* But avoid namespace pollution on glibc systems. */
90 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
91 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
96 /* MSVC defines off_t in <sys/types.h>.
97 May also define off_t to a 64-bit type on native Windows. */
98 #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
100 # include <sys/types.h>
103 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
104 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
105 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
107 # include <sys/types.h>
110 /* Get getopt(), optarg, optind, opterr, optopt.
111 But avoid namespace pollution on glibc systems. */
112 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
113 # define __need_getopt
117 _GL_INLINE_HEADER_BEGIN
118 #ifndef _GL_UNISTD_INLINE
119 # define _GL_UNISTD_INLINE _GL_INLINE
122 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
124 /* The definition of _GL_ARG_NONNULL is copied here. */
126 /* The definition of _GL_WARN_ON_USE is copied here. */
129 /* Hide some function declarations from <winsock2.h>. */
131 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
132 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
133 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
135 # define socket socket_used_without_including_sys_socket_h
137 # define connect connect_used_without_including_sys_socket_h
139 # define accept accept_used_without_including_sys_socket_h
141 # define bind bind_used_without_including_sys_socket_h
143 # define getpeername getpeername_used_without_including_sys_socket_h
145 # define getsockname getsockname_used_without_including_sys_socket_h
147 # define getsockopt getsockopt_used_without_including_sys_socket_h
149 # define listen listen_used_without_including_sys_socket_h
151 # define recv recv_used_without_including_sys_socket_h
153 # define send send_used_without_including_sys_socket_h
155 # define recvfrom recvfrom_used_without_including_sys_socket_h
157 # define sendto sendto_used_without_including_sys_socket_h
159 # define setsockopt setsockopt_used_without_including_sys_socket_h
161 # define shutdown shutdown_used_without_including_sys_socket_h
163 _GL_WARN_ON_USE (socket
,
164 "socket() used without including <sys/socket.h>");
165 _GL_WARN_ON_USE (connect
,
166 "connect() used without including <sys/socket.h>");
167 _GL_WARN_ON_USE (accept
,
168 "accept() used without including <sys/socket.h>");
169 _GL_WARN_ON_USE (bind
,
170 "bind() used without including <sys/socket.h>");
171 _GL_WARN_ON_USE (getpeername
,
172 "getpeername() used without including <sys/socket.h>");
173 _GL_WARN_ON_USE (getsockname
,
174 "getsockname() used without including <sys/socket.h>");
175 _GL_WARN_ON_USE (getsockopt
,
176 "getsockopt() used without including <sys/socket.h>");
177 _GL_WARN_ON_USE (listen
,
178 "listen() used without including <sys/socket.h>");
179 _GL_WARN_ON_USE (recv
,
180 "recv() used without including <sys/socket.h>");
181 _GL_WARN_ON_USE (send
,
182 "send() used without including <sys/socket.h>");
183 _GL_WARN_ON_USE (recvfrom
,
184 "recvfrom() used without including <sys/socket.h>");
185 _GL_WARN_ON_USE (sendto
,
186 "sendto() used without including <sys/socket.h>");
187 _GL_WARN_ON_USE (setsockopt
,
188 "setsockopt() used without including <sys/socket.h>");
189 _GL_WARN_ON_USE (shutdown
,
190 "shutdown() used without including <sys/socket.h>");
193 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
194 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
196 # define select select_used_without_including_sys_select_h
198 _GL_WARN_ON_USE (select
,
199 "select() used without including <sys/select.h>");
205 /* OS/2 EMX lacks these macros. */
207 # define STDIN_FILENO 0
209 #ifndef STDOUT_FILENO
210 # define STDOUT_FILENO 1
212 #ifndef STDERR_FILENO
213 # define STDERR_FILENO 2
216 /* Ensure *_OK macros exist. */
225 /* Declare overridden functions. */
228 #if defined GNULIB_POSIXCHECK
229 /* The access() function is a security risk. */
230 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
231 "use the gnulib module faccessat instead");
236 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
237 _GL_CXXALIASWARN (chdir
);
238 #elif defined GNULIB_POSIXCHECK
240 # if HAVE_RAW_DECL_CHDIR
241 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
242 "use gnulib module chdir for portability");
248 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
249 to GID (if GID is not -1). Follow symbolic links.
250 Return 0 if successful, otherwise -1 and errno set.
251 See the POSIX:2008 specification
252 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
254 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
256 # define chown rpl_chown
258 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
259 _GL_ARG_NONNULL ((1)));
260 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
263 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
264 _GL_ARG_NONNULL ((1)));
266 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
268 _GL_CXXALIASWARN (chown
);
269 #elif defined GNULIB_POSIXCHECK
271 # if HAVE_RAW_DECL_CHOWN
272 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
273 "doesn't treat a uid or gid of -1 on some systems - "
274 "use gnulib module chown for portability");
281 /* Automatically included by modules that need a replacement for close. */
282 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
284 # define close rpl_close
286 _GL_FUNCDECL_RPL (close
, int, (int fd
));
287 _GL_CXXALIAS_RPL (close
, int, (int fd
));
289 _GL_CXXALIAS_SYS (close
, int, (int fd
));
291 _GL_CXXALIASWARN (close
);
292 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
294 # define close close_used_without_requesting_gnulib_module_close
295 #elif defined GNULIB_POSIXCHECK
297 /* Assume close is always declared. */
298 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
299 "use gnulib module close for portability");
305 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
308 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
309 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
311 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
313 _GL_CXXALIASWARN (dup
);
314 #elif defined GNULIB_POSIXCHECK
316 # if HAVE_RAW_DECL_DUP
317 _GL_WARN_ON_USE (dup
, "dup is unportable - "
318 "use gnulib module dup for portability");
324 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
325 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
326 Return newfd if successful, otherwise -1 and errno set.
327 See the POSIX:2008 specification
328 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
330 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
331 # define dup2 rpl_dup2
333 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
334 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
337 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
339 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
341 _GL_CXXALIASWARN (dup2
);
342 #elif defined GNULIB_POSIXCHECK
344 # if HAVE_RAW_DECL_DUP2
345 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
346 "use gnulib module dup2 for portability");
352 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
354 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
355 and O_TEXT, O_BINARY (defined in "binary-io.h").
356 Close NEWFD first if it is open.
357 Return newfd if successful, otherwise -1 and errno set.
358 See the Linux man page at
359 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
361 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
362 # define dup3 rpl_dup3
364 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
365 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
367 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
368 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
370 _GL_CXXALIASWARN (dup3
);
371 #elif defined GNULIB_POSIXCHECK
373 # if HAVE_RAW_DECL_DUP3
374 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
375 "use gnulib module dup3 for portability");
381 # if !@HAVE_DECL_ENVIRON@
382 /* Set of environment variables and values. An array of strings of the form
383 "VARIABLE=VALUE", terminated with a NULL. */
384 # if defined __APPLE__ && defined __MACH__
385 # include <crt_externs.h>
386 # define environ (*_NSGetEnviron ())
391 extern char **environ
;
397 #elif defined GNULIB_POSIXCHECK
398 # if HAVE_RAW_DECL_ENVIRON
399 _GL_UNISTD_INLINE
char ***
404 _GL_WARN_ON_USE (rpl_environ
, "environ is unportable - "
405 "use gnulib module environ for portability");
407 # define environ (*rpl_environ ())
412 #if @GNULIB_EUIDACCESS@
413 /* Like access(), except that it uses the effective user id and group id of
414 the current process. */
415 # if !@HAVE_EUIDACCESS@
416 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
417 _GL_ARG_NONNULL ((1)));
419 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
420 _GL_CXXALIASWARN (euidaccess
);
421 # if defined GNULIB_POSIXCHECK
422 /* Like access(), this function is a security risk. */
423 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
424 "use the gnulib module faccessat instead");
426 #elif defined GNULIB_POSIXCHECK
428 # if HAVE_RAW_DECL_EUIDACCESS
429 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
430 "use gnulib module euidaccess for portability");
435 #if @GNULIB_FACCESSAT@
436 # if !@HAVE_FACCESSAT@
437 _GL_FUNCDECL_SYS (faccessat
, int,
438 (int fd
, char const *file
, int mode
, int flag
)
439 _GL_ARG_NONNULL ((2)));
441 _GL_CXXALIAS_SYS (faccessat
, int,
442 (int fd
, char const *file
, int mode
, int flag
));
443 _GL_CXXALIASWARN (faccessat
);
444 #elif defined GNULIB_POSIXCHECK
446 # if HAVE_RAW_DECL_FACCESSAT
447 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
448 "use gnulib module faccessat for portability");
454 /* Change the process' current working directory to the directory on which
455 the given file descriptor is open.
456 Return 0 if successful, otherwise -1 and errno set.
457 See the POSIX:2008 specification
458 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
460 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
462 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
463 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
464 _GL_ARG_NONNULL ((2));
465 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
466 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
467 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
470 # if !@HAVE_DECL_FCHDIR@
471 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
474 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
475 _GL_CXXALIASWARN (fchdir
);
476 #elif defined GNULIB_POSIXCHECK
478 # if HAVE_RAW_DECL_FCHDIR
479 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
480 "use gnulib module fchdir for portability");
485 #if @GNULIB_FCHOWNAT@
486 # if @REPLACE_FCHOWNAT@
487 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
489 # define fchownat rpl_fchownat
491 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
492 uid_t owner
, gid_t group
, int flag
)
493 _GL_ARG_NONNULL ((2)));
494 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
495 uid_t owner
, gid_t group
, int flag
));
497 # if !@HAVE_FCHOWNAT@
498 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
499 uid_t owner
, gid_t group
, int flag
)
500 _GL_ARG_NONNULL ((2)));
502 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
503 uid_t owner
, gid_t group
, int flag
));
505 _GL_CXXALIASWARN (fchownat
);
506 #elif defined GNULIB_POSIXCHECK
508 # if HAVE_RAW_DECL_FCHOWNAT
509 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
510 "use gnulib module openat for portability");
515 #if @GNULIB_FDATASYNC@
516 /* Synchronize changes to a file.
517 Return 0 if successful, otherwise -1 and errno set.
518 See POSIX:2008 specification
519 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
520 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
521 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
523 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
524 _GL_CXXALIASWARN (fdatasync
);
525 #elif defined GNULIB_POSIXCHECK
527 # if HAVE_RAW_DECL_FDATASYNC
528 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
529 "use gnulib module fdatasync for portability");
535 /* Synchronize changes, including metadata, to a file.
536 Return 0 if successful, otherwise -1 and errno set.
537 See POSIX:2008 specification
538 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
540 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
542 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
543 _GL_CXXALIASWARN (fsync
);
544 #elif defined GNULIB_POSIXCHECK
546 # if HAVE_RAW_DECL_FSYNC
547 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
548 "use gnulib module fsync for portability");
553 #if @GNULIB_FTRUNCATE@
554 /* Change the size of the file to which FD is opened to become equal to LENGTH.
555 Return 0 if successful, otherwise -1 and errno set.
556 See the POSIX:2008 specification
557 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
558 # if @REPLACE_FTRUNCATE@
559 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
561 # define ftruncate rpl_ftruncate
563 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
564 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
566 # if !@HAVE_FTRUNCATE@
567 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
569 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
571 _GL_CXXALIASWARN (ftruncate
);
572 #elif defined GNULIB_POSIXCHECK
574 # if HAVE_RAW_DECL_FTRUNCATE
575 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
576 "use gnulib module ftruncate for portability");
582 /* Get the name of the current working directory, and put it in SIZE bytes
584 Return BUF if successful, or NULL if the directory couldn't be determined
585 or SIZE was too small.
586 See the POSIX:2008 specification
587 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
588 Additionally, the gnulib module 'getcwd' guarantees the following GNU
589 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
590 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
592 # if @REPLACE_GETCWD@
593 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
594 # define getcwd rpl_getcwd
596 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
597 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
599 /* Need to cast, because on mingw, the second parameter is
601 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
603 _GL_CXXALIASWARN (getcwd
);
604 #elif defined GNULIB_POSIXCHECK
606 # if HAVE_RAW_DECL_GETCWD
607 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
608 "use gnulib module getcwd for portability");
613 #if @GNULIB_GETDOMAINNAME@
614 /* Return the NIS domain name of the machine.
615 WARNING! The NIS domain name is unrelated to the fully qualified host name
616 of the machine. It is also unrelated to email addresses.
617 WARNING! The NIS domain name is usually the empty string or "(none)" when
620 Put up to LEN bytes of the NIS domain name into NAME.
621 Null terminate it if the name is shorter than LEN.
622 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
623 Return 0 if successful, otherwise set errno and return -1. */
624 # if @REPLACE_GETDOMAINNAME@
625 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
626 # undef getdomainname
627 # define getdomainname rpl_getdomainname
629 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
630 _GL_ARG_NONNULL ((1)));
631 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
633 # if !@HAVE_DECL_GETDOMAINNAME@
634 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
635 _GL_ARG_NONNULL ((1)));
637 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
639 _GL_CXXALIASWARN (getdomainname
);
640 #elif defined GNULIB_POSIXCHECK
641 # undef getdomainname
642 # if HAVE_RAW_DECL_GETDOMAINNAME
643 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
644 "use gnulib module getdomainname for portability");
649 #if @GNULIB_GETDTABLESIZE@
650 /* Return the maximum number of file descriptors in the current process.
651 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
652 # if !@HAVE_GETDTABLESIZE@
653 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
655 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
656 _GL_CXXALIASWARN (getdtablesize
);
657 #elif defined GNULIB_POSIXCHECK
658 # undef getdtablesize
659 # if HAVE_RAW_DECL_GETDTABLESIZE
660 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
661 "use gnulib module getdtablesize for portability");
666 #if @GNULIB_GETGROUPS@
667 /* Return the supplemental groups that the current process belongs to.
668 It is unspecified whether the effective group id is in the list.
669 If N is 0, return the group count; otherwise, N describes how many
670 entries are available in GROUPS. Return -1 and set errno if N is
671 not 0 and not large enough. Fails with ENOSYS on some systems. */
672 # if @REPLACE_GETGROUPS@
673 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
675 # define getgroups rpl_getgroups
677 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
678 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
680 # if !@HAVE_GETGROUPS@
681 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
683 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
685 _GL_CXXALIASWARN (getgroups
);
686 #elif defined GNULIB_POSIXCHECK
688 # if HAVE_RAW_DECL_GETGROUPS
689 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
690 "use gnulib module getgroups for portability");
695 #if @GNULIB_GETHOSTNAME@
696 /* Return the standard host name of the machine.
697 WARNING! The host name may or may not be fully qualified.
699 Put up to LEN bytes of the host name into NAME.
700 Null terminate it if the name is shorter than LEN.
701 If the host name is longer than LEN, set errno = EINVAL and return -1.
702 Return 0 if successful, otherwise set errno and return -1. */
703 # if @UNISTD_H_HAVE_WINSOCK2_H@
704 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
706 # define gethostname rpl_gethostname
708 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
709 _GL_ARG_NONNULL ((1)));
710 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
712 # if !@HAVE_GETHOSTNAME@
713 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
714 _GL_ARG_NONNULL ((1)));
716 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
719 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
721 _GL_CXXALIASWARN (gethostname
);
722 #elif @UNISTD_H_HAVE_WINSOCK2_H@
724 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
725 #elif defined GNULIB_POSIXCHECK
727 # if HAVE_RAW_DECL_GETHOSTNAME
728 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
729 "use gnulib module gethostname for portability");
734 #if @GNULIB_GETLOGIN@
735 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
736 returns NULL with errno set.
738 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
740 Most programs don't need to use this function, because the information is
741 available through environment variables:
742 ${LOGNAME-$USER} on Unix platforms,
743 $USERNAME on native Windows platforms.
745 # if !@HAVE_GETLOGIN@
746 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
748 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
749 _GL_CXXALIASWARN (getlogin
);
750 #elif defined GNULIB_POSIXCHECK
752 # if HAVE_RAW_DECL_GETLOGIN
753 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
754 "use gnulib module getlogin for portability");
759 #if @GNULIB_GETLOGIN_R@
760 /* Copies the user's login name to NAME.
761 The array pointed to by NAME has room for SIZE bytes.
763 Returns 0 if successful. Upon error, an error number is returned, or -1 in
764 the case that the login name cannot be found but no specific error is
765 provided (this case is hopefully rare but is left open by the POSIX spec).
767 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
769 Most programs don't need to use this function, because the information is
770 available through environment variables:
771 ${LOGNAME-$USER} on Unix platforms,
772 $USERNAME on native Windows platforms.
774 # if @REPLACE_GETLOGIN_R@
775 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
776 # define getlogin_r rpl_getlogin_r
778 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
779 _GL_ARG_NONNULL ((1)));
780 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
782 # if !@HAVE_DECL_GETLOGIN_R@
783 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
784 _GL_ARG_NONNULL ((1)));
786 /* Need to cast, because on Solaris 10 systems, the second argument is
788 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
790 _GL_CXXALIASWARN (getlogin_r
);
791 #elif defined GNULIB_POSIXCHECK
793 # if HAVE_RAW_DECL_GETLOGIN_R
794 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
795 "use gnulib module getlogin_r for portability");
800 #if @GNULIB_GETPAGESIZE@
801 # if @REPLACE_GETPAGESIZE@
802 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
803 # define getpagesize rpl_getpagesize
805 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
806 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
808 # if !@HAVE_GETPAGESIZE@
809 # if !defined getpagesize
810 /* This is for POSIX systems. */
811 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
812 # if ! (defined __VMS && __VMS_VER < 70000000)
813 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
816 /* This is for older VMS. */
817 # if !defined _gl_getpagesize && defined __VMS
819 # define _gl_getpagesize() 8192
821 # define _gl_getpagesize() 512
824 /* This is for BeOS. */
825 # if !defined _gl_getpagesize && @HAVE_OS_H@
827 # if defined B_PAGE_SIZE
828 # define _gl_getpagesize() B_PAGE_SIZE
831 /* This is for AmigaOS4.0. */
832 # if !defined _gl_getpagesize && defined __amigaos4__
833 # define _gl_getpagesize() 2048
835 /* This is for older Unix systems. */
836 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
837 # include <sys/param.h>
838 # ifdef EXEC_PAGESIZE
839 # define _gl_getpagesize() EXEC_PAGESIZE
845 # define _gl_getpagesize() (NBPG * CLSIZE)
848 # define _gl_getpagesize() NBPC
853 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
854 # define getpagesize() _gl_getpagesize ()
856 # if !GNULIB_defined_getpagesize_function
857 _GL_UNISTD_INLINE
int
860 return _gl_getpagesize ();
862 # define GNULIB_defined_getpagesize_function 1
867 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
868 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
870 # if @HAVE_DECL_GETPAGESIZE@
871 _GL_CXXALIASWARN (getpagesize
);
873 #elif defined GNULIB_POSIXCHECK
875 # if HAVE_RAW_DECL_GETPAGESIZE
876 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
877 "use gnulib module getpagesize for portability");
882 #if @GNULIB_GETUSERSHELL@
883 /* Return the next valid login shell on the system, or NULL when the end of
884 the list has been reached. */
885 # if !@HAVE_DECL_GETUSERSHELL@
886 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
888 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
889 _GL_CXXALIASWARN (getusershell
);
890 #elif defined GNULIB_POSIXCHECK
892 # if HAVE_RAW_DECL_GETUSERSHELL
893 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
894 "use gnulib module getusershell for portability");
898 #if @GNULIB_GETUSERSHELL@
899 /* Rewind to pointer that is advanced at each getusershell() call. */
900 # if !@HAVE_DECL_GETUSERSHELL@
901 _GL_FUNCDECL_SYS (setusershell
, void, (void));
903 _GL_CXXALIAS_SYS (setusershell
, void, (void));
904 _GL_CXXALIASWARN (setusershell
);
905 #elif defined GNULIB_POSIXCHECK
907 # if HAVE_RAW_DECL_SETUSERSHELL
908 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
909 "use gnulib module getusershell for portability");
913 #if @GNULIB_GETUSERSHELL@
914 /* Free the pointer that is advanced at each getusershell() call and
915 associated resources. */
916 # if !@HAVE_DECL_GETUSERSHELL@
917 _GL_FUNCDECL_SYS (endusershell
, void, (void));
919 _GL_CXXALIAS_SYS (endusershell
, void, (void));
920 _GL_CXXALIASWARN (endusershell
);
921 #elif defined GNULIB_POSIXCHECK
923 # if HAVE_RAW_DECL_ENDUSERSHELL
924 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
925 "use gnulib module getusershell for portability");
930 #if @GNULIB_GROUP_MEMBER@
931 /* Determine whether group id is in calling user's group list. */
932 # if !@HAVE_GROUP_MEMBER@
933 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
935 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
936 _GL_CXXALIASWARN (group_member
);
937 #elif defined GNULIB_POSIXCHECK
939 # if HAVE_RAW_DECL_GROUP_MEMBER
940 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
941 "use gnulib module group-member for portability");
947 # if @REPLACE_ISATTY@
948 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
950 # define isatty rpl_isatty
952 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
953 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
955 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
957 _GL_CXXALIASWARN (isatty
);
958 #elif defined GNULIB_POSIXCHECK
960 # if HAVE_RAW_DECL_ISATTY
961 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
962 "use gnulib module isatty for portability");
968 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
969 to GID (if GID is not -1). Do not follow symbolic links.
970 Return 0 if successful, otherwise -1 and errno set.
971 See the POSIX:2008 specification
972 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
973 # if @REPLACE_LCHOWN@
974 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
976 # define lchown rpl_lchown
978 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
979 _GL_ARG_NONNULL ((1)));
980 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
983 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
984 _GL_ARG_NONNULL ((1)));
986 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
988 _GL_CXXALIASWARN (lchown
);
989 #elif defined GNULIB_POSIXCHECK
991 # if HAVE_RAW_DECL_LCHOWN
992 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
993 "use gnulib module lchown for portability");
999 /* Create a new hard link for an existing file.
1000 Return 0 if successful, otherwise -1 and errno set.
1001 See POSIX:2008 specification
1002 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1004 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1005 # define link rpl_link
1007 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1008 _GL_ARG_NONNULL ((1, 2)));
1009 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1012 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1013 _GL_ARG_NONNULL ((1, 2)));
1015 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1017 _GL_CXXALIASWARN (link
);
1018 #elif defined GNULIB_POSIXCHECK
1020 # if HAVE_RAW_DECL_LINK
1021 _GL_WARN_ON_USE (link
, "link is unportable - "
1022 "use gnulib module link for portability");
1028 /* Create a new hard link for an existing file, relative to two
1029 directories. FLAG controls whether symlinks are followed.
1030 Return 0 if successful, otherwise -1 and errno set. */
1031 # if @REPLACE_LINKAT@
1032 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1034 # define linkat rpl_linkat
1036 _GL_FUNCDECL_RPL (linkat
, int,
1037 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1039 _GL_ARG_NONNULL ((2, 4)));
1040 _GL_CXXALIAS_RPL (linkat
, int,
1041 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1045 _GL_FUNCDECL_SYS (linkat
, int,
1046 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1048 _GL_ARG_NONNULL ((2, 4)));
1050 _GL_CXXALIAS_SYS (linkat
, int,
1051 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1054 _GL_CXXALIASWARN (linkat
);
1055 #elif defined GNULIB_POSIXCHECK
1057 # if HAVE_RAW_DECL_LINKAT
1058 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1059 "use gnulib module linkat for portability");
1065 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1066 Return the new offset if successful, otherwise -1 and errno set.
1067 See the POSIX:2008 specification
1068 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1069 # if @REPLACE_LSEEK@
1070 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1071 # define lseek rpl_lseek
1073 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1074 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1076 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1078 _GL_CXXALIASWARN (lseek
);
1079 #elif defined GNULIB_POSIXCHECK
1081 # if HAVE_RAW_DECL_LSEEK
1082 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1083 "systems - use gnulib module lseek for portability");
1089 /* Create a pipe, defaulting to O_BINARY mode.
1090 Store the read-end as fd[0] and the write-end as fd[1].
1091 Return 0 upon success, or -1 with errno set upon failure. */
1093 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1095 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1096 _GL_CXXALIASWARN (pipe
);
1097 #elif defined GNULIB_POSIXCHECK
1099 # if HAVE_RAW_DECL_PIPE
1100 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1101 "use gnulib module pipe-posix for portability");
1107 /* Create a pipe, applying the given flags when opening the read-end of the
1108 pipe and the write-end of the pipe.
1109 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1110 and O_TEXT, O_BINARY (defined in "binary-io.h").
1111 Store the read-end as fd[0] and the write-end as fd[1].
1112 Return 0 upon success, or -1 with errno set upon failure.
1113 See also the Linux man page at
1114 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1116 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1117 # define pipe2 rpl_pipe2
1119 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1120 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1122 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1123 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1125 _GL_CXXALIASWARN (pipe2
);
1126 #elif defined GNULIB_POSIXCHECK
1128 # if HAVE_RAW_DECL_PIPE2
1129 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1130 "use gnulib module pipe2 for portability");
1136 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1137 Return the number of bytes placed into BUF if successful, otherwise
1138 set errno and return -1. 0 indicates EOF.
1139 See the POSIX:2008 specification
1140 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1141 # if @REPLACE_PREAD@
1142 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1144 # define pread rpl_pread
1146 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1147 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1148 _GL_ARG_NONNULL ((2)));
1149 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1150 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1153 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1154 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1155 _GL_ARG_NONNULL ((2)));
1157 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1158 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1160 _GL_CXXALIASWARN (pread
);
1161 #elif defined GNULIB_POSIXCHECK
1163 # if HAVE_RAW_DECL_PREAD
1164 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1165 "use gnulib module pread for portability");
1171 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1172 Return the number of bytes written if successful, otherwise
1173 set errno and return -1. 0 indicates nothing written. See the
1174 POSIX:2008 specification
1175 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1176 # if @REPLACE_PWRITE@
1177 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1179 # define pwrite rpl_pwrite
1181 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1182 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1183 _GL_ARG_NONNULL ((2)));
1184 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1185 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1188 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1189 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1190 _GL_ARG_NONNULL ((2)));
1192 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1193 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1195 _GL_CXXALIASWARN (pwrite
);
1196 #elif defined GNULIB_POSIXCHECK
1198 # if HAVE_RAW_DECL_PWRITE
1199 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1200 "use gnulib module pwrite for portability");
1206 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1207 at BUF. See the POSIX:2008 specification
1208 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1210 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1212 # define read rpl_read
1214 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1215 _GL_ARG_NONNULL ((2)));
1216 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1218 /* Need to cast, because on mingw, the third parameter is
1220 and the return type is 'int'. */
1221 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1223 _GL_CXXALIASWARN (read
);
1227 #if @GNULIB_READLINK@
1228 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1229 bytes of it into BUF. Return the number of bytes placed into BUF if
1230 successful, otherwise -1 and errno set.
1231 See the POSIX:2008 specification
1232 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1233 # if @REPLACE_READLINK@
1234 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1235 # define readlink rpl_readlink
1237 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1238 (const char *file
, char *buf
, size_t bufsize
)
1239 _GL_ARG_NONNULL ((1, 2)));
1240 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1241 (const char *file
, char *buf
, size_t bufsize
));
1243 # if !@HAVE_READLINK@
1244 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1245 (const char *file
, char *buf
, size_t bufsize
)
1246 _GL_ARG_NONNULL ((1, 2)));
1248 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1249 (const char *file
, char *buf
, size_t bufsize
));
1251 _GL_CXXALIASWARN (readlink
);
1252 #elif defined GNULIB_POSIXCHECK
1254 # if HAVE_RAW_DECL_READLINK
1255 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1256 "use gnulib module readlink for portability");
1261 #if @GNULIB_READLINKAT@
1262 # if !@HAVE_READLINKAT@
1263 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1264 (int fd
, char const *file
, char *buf
, size_t len
)
1265 _GL_ARG_NONNULL ((2, 3)));
1267 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1268 (int fd
, char const *file
, char *buf
, size_t len
));
1269 _GL_CXXALIASWARN (readlinkat
);
1270 #elif defined GNULIB_POSIXCHECK
1272 # if HAVE_RAW_DECL_READLINKAT
1273 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1274 "use gnulib module readlinkat for portability");
1280 /* Remove the directory DIR. */
1281 # if @REPLACE_RMDIR@
1282 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1283 # define rmdir rpl_rmdir
1285 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1286 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1288 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1290 _GL_CXXALIASWARN (rmdir
);
1291 #elif defined GNULIB_POSIXCHECK
1293 # if HAVE_RAW_DECL_RMDIR
1294 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1295 "use gnulib module rmdir for portability");
1300 #if @GNULIB_SETHOSTNAME@
1301 /* Set the host name of the machine.
1302 The host name may or may not be fully qualified.
1304 Put LEN bytes of NAME into the host name.
1305 Return 0 if successful, otherwise, set errno and return -1.
1307 Platforms with no ability to set the hostname return -1 and set
1309 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1310 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1311 _GL_ARG_NONNULL ((1)));
1313 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1314 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1315 2011-10, the first parameter is not const. */
1316 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1317 _GL_CXXALIASWARN (sethostname
);
1318 #elif defined GNULIB_POSIXCHECK
1320 # if HAVE_RAW_DECL_SETHOSTNAME
1321 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1322 "use gnulib module sethostname for portability");
1328 /* Pause the execution of the current thread for N seconds.
1329 Returns the number of seconds left to sleep.
1330 See the POSIX:2008 specification
1331 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1332 # if @REPLACE_SLEEP@
1333 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1335 # define sleep rpl_sleep
1337 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1338 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1341 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1343 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1345 _GL_CXXALIASWARN (sleep
);
1346 #elif defined GNULIB_POSIXCHECK
1348 # if HAVE_RAW_DECL_SLEEP
1349 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1350 "use gnulib module sleep for portability");
1355 #if @GNULIB_SYMLINK@
1356 # if @REPLACE_SYMLINK@
1357 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1359 # define symlink rpl_symlink
1361 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1362 _GL_ARG_NONNULL ((1, 2)));
1363 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1365 # if !@HAVE_SYMLINK@
1366 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1367 _GL_ARG_NONNULL ((1, 2)));
1369 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1371 _GL_CXXALIASWARN (symlink
);
1372 #elif defined GNULIB_POSIXCHECK
1374 # if HAVE_RAW_DECL_SYMLINK
1375 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1376 "use gnulib module symlink for portability");
1381 #if @GNULIB_SYMLINKAT@
1382 # if !@HAVE_SYMLINKAT@
1383 _GL_FUNCDECL_SYS (symlinkat
, int,
1384 (char const *contents
, int fd
, char const *file
)
1385 _GL_ARG_NONNULL ((1, 3)));
1387 _GL_CXXALIAS_SYS (symlinkat
, int,
1388 (char const *contents
, int fd
, char const *file
));
1389 _GL_CXXALIASWARN (symlinkat
);
1390 #elif defined GNULIB_POSIXCHECK
1392 # if HAVE_RAW_DECL_SYMLINKAT
1393 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1394 "use gnulib module symlinkat for portability");
1399 #if @GNULIB_TTYNAME_R@
1400 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1401 open on in BUF. Return 0 on success, otherwise an error number. */
1402 # if @REPLACE_TTYNAME_R@
1403 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1405 # define ttyname_r rpl_ttyname_r
1407 _GL_FUNCDECL_RPL (ttyname_r
, int,
1408 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1409 _GL_CXXALIAS_RPL (ttyname_r
, int,
1410 (int fd
, char *buf
, size_t buflen
));
1412 # if !@HAVE_DECL_TTYNAME_R@
1413 _GL_FUNCDECL_SYS (ttyname_r
, int,
1414 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1416 _GL_CXXALIAS_SYS (ttyname_r
, int,
1417 (int fd
, char *buf
, size_t buflen
));
1419 _GL_CXXALIASWARN (ttyname_r
);
1420 #elif defined GNULIB_POSIXCHECK
1422 # if HAVE_RAW_DECL_TTYNAME_R
1423 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1424 "use gnulib module ttyname_r for portability");
1430 # if @REPLACE_UNLINK@
1431 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1433 # define unlink rpl_unlink
1435 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1436 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1438 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1440 _GL_CXXALIASWARN (unlink
);
1441 #elif defined GNULIB_POSIXCHECK
1443 # if HAVE_RAW_DECL_UNLINK
1444 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1445 "use gnulib module unlink for portability");
1450 #if @GNULIB_UNLINKAT@
1451 # if @REPLACE_UNLINKAT@
1452 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1454 # define unlinkat rpl_unlinkat
1456 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1457 _GL_ARG_NONNULL ((2)));
1458 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1460 # if !@HAVE_UNLINKAT@
1461 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1462 _GL_ARG_NONNULL ((2)));
1464 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1466 _GL_CXXALIASWARN (unlinkat
);
1467 #elif defined GNULIB_POSIXCHECK
1469 # if HAVE_RAW_DECL_UNLINKAT
1470 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1471 "use gnulib module openat for portability");
1477 /* Pause the execution of the current thread for N microseconds.
1478 Returns 0 on completion, or -1 on range error.
1479 See the POSIX:2001 specification
1480 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1481 # if @REPLACE_USLEEP@
1482 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1484 # define usleep rpl_usleep
1486 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1487 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1490 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1492 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1494 _GL_CXXALIASWARN (usleep
);
1495 #elif defined GNULIB_POSIXCHECK
1497 # if HAVE_RAW_DECL_USLEEP
1498 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1499 "use gnulib module usleep for portability");
1505 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1506 See the POSIX:2008 specification
1507 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1508 # if @REPLACE_WRITE@
1509 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1511 # define write rpl_write
1513 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1514 _GL_ARG_NONNULL ((2)));
1515 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1517 /* Need to cast, because on mingw, the third parameter is
1519 and the return type is 'int'. */
1520 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1522 _GL_CXXALIASWARN (write
);
1525 _GL_INLINE_HEADER_END
1527 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1528 #endif /* _@GUARD_PREFIX@_UNISTD_H */