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
116 _GL_INLINE_HEADER_BEGIN
117 #ifndef _GL_UNISTD_INLINE
118 # define _GL_UNISTD_INLINE _GL_INLINE
121 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
123 /* The definition of _GL_ARG_NONNULL is copied here. */
125 /* The definition of _GL_WARN_ON_USE is copied here. */
128 /* Hide some function declarations from <winsock2.h>. */
130 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
131 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
132 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
134 # define socket socket_used_without_including_sys_socket_h
136 # define connect connect_used_without_including_sys_socket_h
138 # define accept accept_used_without_including_sys_socket_h
140 # define bind bind_used_without_including_sys_socket_h
142 # define getpeername getpeername_used_without_including_sys_socket_h
144 # define getsockname getsockname_used_without_including_sys_socket_h
146 # define getsockopt getsockopt_used_without_including_sys_socket_h
148 # define listen listen_used_without_including_sys_socket_h
150 # define recv recv_used_without_including_sys_socket_h
152 # define send send_used_without_including_sys_socket_h
154 # define recvfrom recvfrom_used_without_including_sys_socket_h
156 # define sendto sendto_used_without_including_sys_socket_h
158 # define setsockopt setsockopt_used_without_including_sys_socket_h
160 # define shutdown shutdown_used_without_including_sys_socket_h
162 _GL_WARN_ON_USE (socket
,
163 "socket() used without including <sys/socket.h>");
164 _GL_WARN_ON_USE (connect
,
165 "connect() used without including <sys/socket.h>");
166 _GL_WARN_ON_USE (accept
,
167 "accept() used without including <sys/socket.h>");
168 _GL_WARN_ON_USE (bind
,
169 "bind() used without including <sys/socket.h>");
170 _GL_WARN_ON_USE (getpeername
,
171 "getpeername() used without including <sys/socket.h>");
172 _GL_WARN_ON_USE (getsockname
,
173 "getsockname() used without including <sys/socket.h>");
174 _GL_WARN_ON_USE (getsockopt
,
175 "getsockopt() used without including <sys/socket.h>");
176 _GL_WARN_ON_USE (listen
,
177 "listen() used without including <sys/socket.h>");
178 _GL_WARN_ON_USE (recv
,
179 "recv() used without including <sys/socket.h>");
180 _GL_WARN_ON_USE (send
,
181 "send() used without including <sys/socket.h>");
182 _GL_WARN_ON_USE (recvfrom
,
183 "recvfrom() used without including <sys/socket.h>");
184 _GL_WARN_ON_USE (sendto
,
185 "sendto() used without including <sys/socket.h>");
186 _GL_WARN_ON_USE (setsockopt
,
187 "setsockopt() used without including <sys/socket.h>");
188 _GL_WARN_ON_USE (shutdown
,
189 "shutdown() used without including <sys/socket.h>");
192 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
193 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
195 # define select select_used_without_including_sys_select_h
197 _GL_WARN_ON_USE (select
,
198 "select() used without including <sys/select.h>");
204 /* OS/2 EMX lacks these macros. */
206 # define STDIN_FILENO 0
208 #ifndef STDOUT_FILENO
209 # define STDOUT_FILENO 1
211 #ifndef STDERR_FILENO
212 # define STDERR_FILENO 2
215 /* Ensure *_OK macros exist. */
224 /* Declare overridden functions. */
227 #if defined GNULIB_POSIXCHECK
228 /* The access() function is a security risk. */
229 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
230 "use the gnulib module faccessat instead");
235 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
236 _GL_CXXALIASWARN (chdir
);
237 #elif defined GNULIB_POSIXCHECK
239 # if HAVE_RAW_DECL_CHDIR
240 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
241 "use gnulib module chdir for portability");
247 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
248 to GID (if GID is not -1). Follow symbolic links.
249 Return 0 if successful, otherwise -1 and errno set.
250 See the POSIX:2008 specification
251 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
253 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
255 # define chown rpl_chown
257 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
258 _GL_ARG_NONNULL ((1)));
259 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
262 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
263 _GL_ARG_NONNULL ((1)));
265 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
267 _GL_CXXALIASWARN (chown
);
268 #elif defined GNULIB_POSIXCHECK
270 # if HAVE_RAW_DECL_CHOWN
271 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
272 "doesn't treat a uid or gid of -1 on some systems - "
273 "use gnulib module chown for portability");
280 /* Automatically included by modules that need a replacement for close. */
281 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
283 # define close rpl_close
285 _GL_FUNCDECL_RPL (close
, int, (int fd
));
286 _GL_CXXALIAS_RPL (close
, int, (int fd
));
288 _GL_CXXALIAS_SYS (close
, int, (int fd
));
290 _GL_CXXALIASWARN (close
);
291 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
293 # define close close_used_without_requesting_gnulib_module_close
294 #elif defined GNULIB_POSIXCHECK
296 /* Assume close is always declared. */
297 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
298 "use gnulib module close for portability");
304 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
307 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
308 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
310 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
312 _GL_CXXALIASWARN (dup
);
313 #elif defined GNULIB_POSIXCHECK
315 # if HAVE_RAW_DECL_DUP
316 _GL_WARN_ON_USE (dup
, "dup is unportable - "
317 "use gnulib module dup for portability");
323 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
324 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
325 Return newfd if successful, otherwise -1 and errno set.
326 See the POSIX:2008 specification
327 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
329 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
330 # define dup2 rpl_dup2
332 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
333 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
336 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
338 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
340 _GL_CXXALIASWARN (dup2
);
341 #elif defined GNULIB_POSIXCHECK
343 # if HAVE_RAW_DECL_DUP2
344 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
345 "use gnulib module dup2 for portability");
351 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
353 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
354 and O_TEXT, O_BINARY (defined in "binary-io.h").
355 Close NEWFD first if it is open.
356 Return newfd if successful, otherwise -1 and errno set.
357 See the Linux man page at
358 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
360 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
361 # define dup3 rpl_dup3
363 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
364 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
366 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
367 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
369 _GL_CXXALIASWARN (dup3
);
370 #elif defined GNULIB_POSIXCHECK
372 # if HAVE_RAW_DECL_DUP3
373 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
374 "use gnulib module dup3 for portability");
380 # if !@HAVE_DECL_ENVIRON@
381 /* Set of environment variables and values. An array of strings of the form
382 "VARIABLE=VALUE", terminated with a NULL. */
383 # if defined __APPLE__ && defined __MACH__
384 # include <crt_externs.h>
385 # define environ (*_NSGetEnviron ())
390 extern char **environ
;
396 #elif defined GNULIB_POSIXCHECK
397 # if HAVE_RAW_DECL_ENVIRON
398 _GL_UNISTD_INLINE
char ***
403 _GL_WARN_ON_USE (rpl_environ
, "environ is unportable - "
404 "use gnulib module environ for portability");
406 # define environ (*rpl_environ ())
411 #if @GNULIB_EUIDACCESS@
412 /* Like access(), except that it uses the effective user id and group id of
413 the current process. */
414 # if !@HAVE_EUIDACCESS@
415 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
416 _GL_ARG_NONNULL ((1)));
418 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
419 _GL_CXXALIASWARN (euidaccess
);
420 # if defined GNULIB_POSIXCHECK
421 /* Like access(), this function is a security risk. */
422 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
423 "use the gnulib module faccessat instead");
425 #elif defined GNULIB_POSIXCHECK
427 # if HAVE_RAW_DECL_EUIDACCESS
428 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
429 "use gnulib module euidaccess for portability");
434 #if @GNULIB_FACCESSAT@
435 # if !@HAVE_FACCESSAT@
436 _GL_FUNCDECL_SYS (faccessat
, int,
437 (int fd
, char const *file
, int mode
, int flag
)
438 _GL_ARG_NONNULL ((2)));
440 _GL_CXXALIAS_SYS (faccessat
, int,
441 (int fd
, char const *file
, int mode
, int flag
));
442 _GL_CXXALIASWARN (faccessat
);
443 #elif defined GNULIB_POSIXCHECK
445 # if HAVE_RAW_DECL_FACCESSAT
446 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
447 "use gnulib module faccessat for portability");
453 /* Change the process' current working directory to the directory on which
454 the given file descriptor is open.
455 Return 0 if successful, otherwise -1 and errno set.
456 See the POSIX:2008 specification
457 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
459 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
461 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
462 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
463 _GL_ARG_NONNULL ((2));
464 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
465 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
466 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
469 # if !@HAVE_DECL_FCHDIR@
470 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
473 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
474 _GL_CXXALIASWARN (fchdir
);
475 #elif defined GNULIB_POSIXCHECK
477 # if HAVE_RAW_DECL_FCHDIR
478 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
479 "use gnulib module fchdir for portability");
484 #if @GNULIB_FCHOWNAT@
485 # if @REPLACE_FCHOWNAT@
486 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
488 # define fchownat rpl_fchownat
490 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
491 uid_t owner
, gid_t group
, int flag
)
492 _GL_ARG_NONNULL ((2)));
493 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
494 uid_t owner
, gid_t group
, int flag
));
496 # if !@HAVE_FCHOWNAT@
497 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
498 uid_t owner
, gid_t group
, int flag
)
499 _GL_ARG_NONNULL ((2)));
501 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
502 uid_t owner
, gid_t group
, int flag
));
504 _GL_CXXALIASWARN (fchownat
);
505 #elif defined GNULIB_POSIXCHECK
507 # if HAVE_RAW_DECL_FCHOWNAT
508 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
509 "use gnulib module openat for portability");
514 #if @GNULIB_FDATASYNC@
515 /* Synchronize changes to a file.
516 Return 0 if successful, otherwise -1 and errno set.
517 See POSIX:2008 specification
518 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
519 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
520 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
522 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
523 _GL_CXXALIASWARN (fdatasync
);
524 #elif defined GNULIB_POSIXCHECK
526 # if HAVE_RAW_DECL_FDATASYNC
527 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
528 "use gnulib module fdatasync for portability");
534 /* Synchronize changes, including metadata, to a file.
535 Return 0 if successful, otherwise -1 and errno set.
536 See POSIX:2008 specification
537 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
539 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
541 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
542 _GL_CXXALIASWARN (fsync
);
543 #elif defined GNULIB_POSIXCHECK
545 # if HAVE_RAW_DECL_FSYNC
546 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
547 "use gnulib module fsync for portability");
552 #if @GNULIB_FTRUNCATE@
553 /* Change the size of the file to which FD is opened to become equal to LENGTH.
554 Return 0 if successful, otherwise -1 and errno set.
555 See the POSIX:2008 specification
556 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
557 # if @REPLACE_FTRUNCATE@
558 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
560 # define ftruncate rpl_ftruncate
562 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
563 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
565 # if !@HAVE_FTRUNCATE@
566 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
568 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
570 _GL_CXXALIASWARN (ftruncate
);
571 #elif defined GNULIB_POSIXCHECK
573 # if HAVE_RAW_DECL_FTRUNCATE
574 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
575 "use gnulib module ftruncate for portability");
581 /* Get the name of the current working directory, and put it in SIZE bytes
583 Return BUF if successful, or NULL if the directory couldn't be determined
584 or SIZE was too small.
585 See the POSIX:2008 specification
586 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
587 Additionally, the gnulib module 'getcwd' guarantees the following GNU
588 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
589 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
591 # if @REPLACE_GETCWD@
592 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
593 # define getcwd rpl_getcwd
595 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
596 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
598 /* Need to cast, because on mingw, the second parameter is
600 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
602 _GL_CXXALIASWARN (getcwd
);
603 #elif defined GNULIB_POSIXCHECK
605 # if HAVE_RAW_DECL_GETCWD
606 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
607 "use gnulib module getcwd for portability");
612 #if @GNULIB_GETDOMAINNAME@
613 /* Return the NIS domain name of the machine.
614 WARNING! The NIS domain name is unrelated to the fully qualified host name
615 of the machine. It is also unrelated to email addresses.
616 WARNING! The NIS domain name is usually the empty string or "(none)" when
619 Put up to LEN bytes of the NIS domain name into NAME.
620 Null terminate it if the name is shorter than LEN.
621 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
622 Return 0 if successful, otherwise set errno and return -1. */
623 # if @REPLACE_GETDOMAINNAME@
624 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
625 # undef getdomainname
626 # define getdomainname rpl_getdomainname
628 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
629 _GL_ARG_NONNULL ((1)));
630 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
632 # if !@HAVE_DECL_GETDOMAINNAME@
633 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
634 _GL_ARG_NONNULL ((1)));
636 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
638 _GL_CXXALIASWARN (getdomainname
);
639 #elif defined GNULIB_POSIXCHECK
640 # undef getdomainname
641 # if HAVE_RAW_DECL_GETDOMAINNAME
642 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
643 "use gnulib module getdomainname for portability");
648 #if @GNULIB_GETDTABLESIZE@
649 /* Return the maximum number of file descriptors in the current process.
650 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
651 # if !@HAVE_GETDTABLESIZE@
652 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
654 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
655 _GL_CXXALIASWARN (getdtablesize
);
656 #elif defined GNULIB_POSIXCHECK
657 # undef getdtablesize
658 # if HAVE_RAW_DECL_GETDTABLESIZE
659 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
660 "use gnulib module getdtablesize for portability");
665 #if @GNULIB_GETGROUPS@
666 /* Return the supplemental groups that the current process belongs to.
667 It is unspecified whether the effective group id is in the list.
668 If N is 0, return the group count; otherwise, N describes how many
669 entries are available in GROUPS. Return -1 and set errno if N is
670 not 0 and not large enough. Fails with ENOSYS on some systems. */
671 # if @REPLACE_GETGROUPS@
672 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
674 # define getgroups rpl_getgroups
676 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
677 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
679 # if !@HAVE_GETGROUPS@
680 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
682 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
684 _GL_CXXALIASWARN (getgroups
);
685 #elif defined GNULIB_POSIXCHECK
687 # if HAVE_RAW_DECL_GETGROUPS
688 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
689 "use gnulib module getgroups for portability");
694 #if @GNULIB_GETHOSTNAME@
695 /* Return the standard host name of the machine.
696 WARNING! The host name may or may not be fully qualified.
698 Put up to LEN bytes of the host name into NAME.
699 Null terminate it if the name is shorter than LEN.
700 If the host name is longer than LEN, set errno = EINVAL and return -1.
701 Return 0 if successful, otherwise set errno and return -1. */
702 # if @UNISTD_H_HAVE_WINSOCK2_H@
703 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
705 # define gethostname rpl_gethostname
707 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
708 _GL_ARG_NONNULL ((1)));
709 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
711 # if !@HAVE_GETHOSTNAME@
712 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
713 _GL_ARG_NONNULL ((1)));
715 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
718 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
720 _GL_CXXALIASWARN (gethostname
);
721 #elif @UNISTD_H_HAVE_WINSOCK2_H@
723 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
724 #elif defined GNULIB_POSIXCHECK
726 # if HAVE_RAW_DECL_GETHOSTNAME
727 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
728 "use gnulib module gethostname for portability");
733 #if @GNULIB_GETLOGIN@
734 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
735 returns NULL with errno set.
737 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
739 Most programs don't need to use this function, because the information is
740 available through environment variables:
741 ${LOGNAME-$USER} on Unix platforms,
742 $USERNAME on native Windows platforms.
744 # if !@HAVE_GETLOGIN@
745 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
747 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
748 _GL_CXXALIASWARN (getlogin
);
749 #elif defined GNULIB_POSIXCHECK
751 # if HAVE_RAW_DECL_GETLOGIN
752 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
753 "use gnulib module getlogin for portability");
758 #if @GNULIB_GETLOGIN_R@
759 /* Copies the user's login name to NAME.
760 The array pointed to by NAME has room for SIZE bytes.
762 Returns 0 if successful. Upon error, an error number is returned, or -1 in
763 the case that the login name cannot be found but no specific error is
764 provided (this case is hopefully rare but is left open by the POSIX spec).
766 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
768 Most programs don't need to use this function, because the information is
769 available through environment variables:
770 ${LOGNAME-$USER} on Unix platforms,
771 $USERNAME on native Windows platforms.
773 # if @REPLACE_GETLOGIN_R@
774 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
775 # define getlogin_r rpl_getlogin_r
777 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
778 _GL_ARG_NONNULL ((1)));
779 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
781 # if !@HAVE_DECL_GETLOGIN_R@
782 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
783 _GL_ARG_NONNULL ((1)));
785 /* Need to cast, because on Solaris 10 systems, the second argument is
787 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
789 _GL_CXXALIASWARN (getlogin_r
);
790 #elif defined GNULIB_POSIXCHECK
792 # if HAVE_RAW_DECL_GETLOGIN_R
793 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
794 "use gnulib module getlogin_r for portability");
799 #if @GNULIB_GETPAGESIZE@
800 # if @REPLACE_GETPAGESIZE@
801 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
802 # define getpagesize rpl_getpagesize
804 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
805 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
807 # if !@HAVE_GETPAGESIZE@
808 # if !defined getpagesize
809 /* This is for POSIX systems. */
810 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
811 # if ! (defined __VMS && __VMS_VER < 70000000)
812 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
815 /* This is for older VMS. */
816 # if !defined _gl_getpagesize && defined __VMS
818 # define _gl_getpagesize() 8192
820 # define _gl_getpagesize() 512
823 /* This is for BeOS. */
824 # if !defined _gl_getpagesize && @HAVE_OS_H@
826 # if defined B_PAGE_SIZE
827 # define _gl_getpagesize() B_PAGE_SIZE
830 /* This is for AmigaOS4.0. */
831 # if !defined _gl_getpagesize && defined __amigaos4__
832 # define _gl_getpagesize() 2048
834 /* This is for older Unix systems. */
835 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
836 # include <sys/param.h>
837 # ifdef EXEC_PAGESIZE
838 # define _gl_getpagesize() EXEC_PAGESIZE
844 # define _gl_getpagesize() (NBPG * CLSIZE)
847 # define _gl_getpagesize() NBPC
852 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
853 # define getpagesize() _gl_getpagesize ()
855 # if !GNULIB_defined_getpagesize_function
856 _GL_UNISTD_INLINE
int
859 return _gl_getpagesize ();
861 # define GNULIB_defined_getpagesize_function 1
866 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
867 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
869 # if @HAVE_DECL_GETPAGESIZE@
870 _GL_CXXALIASWARN (getpagesize
);
872 #elif defined GNULIB_POSIXCHECK
874 # if HAVE_RAW_DECL_GETPAGESIZE
875 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
876 "use gnulib module getpagesize for portability");
881 #if @GNULIB_GETUSERSHELL@
882 /* Return the next valid login shell on the system, or NULL when the end of
883 the list has been reached. */
884 # if !@HAVE_DECL_GETUSERSHELL@
885 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
887 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
888 _GL_CXXALIASWARN (getusershell
);
889 #elif defined GNULIB_POSIXCHECK
891 # if HAVE_RAW_DECL_GETUSERSHELL
892 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
893 "use gnulib module getusershell for portability");
897 #if @GNULIB_GETUSERSHELL@
898 /* Rewind to pointer that is advanced at each getusershell() call. */
899 # if !@HAVE_DECL_GETUSERSHELL@
900 _GL_FUNCDECL_SYS (setusershell
, void, (void));
902 _GL_CXXALIAS_SYS (setusershell
, void, (void));
903 _GL_CXXALIASWARN (setusershell
);
904 #elif defined GNULIB_POSIXCHECK
906 # if HAVE_RAW_DECL_SETUSERSHELL
907 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
908 "use gnulib module getusershell for portability");
912 #if @GNULIB_GETUSERSHELL@
913 /* Free the pointer that is advanced at each getusershell() call and
914 associated resources. */
915 # if !@HAVE_DECL_GETUSERSHELL@
916 _GL_FUNCDECL_SYS (endusershell
, void, (void));
918 _GL_CXXALIAS_SYS (endusershell
, void, (void));
919 _GL_CXXALIASWARN (endusershell
);
920 #elif defined GNULIB_POSIXCHECK
922 # if HAVE_RAW_DECL_ENDUSERSHELL
923 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
924 "use gnulib module getusershell for portability");
929 #if @GNULIB_GROUP_MEMBER@
930 /* Determine whether group id is in calling user's group list. */
931 # if !@HAVE_GROUP_MEMBER@
932 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
934 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
935 _GL_CXXALIASWARN (group_member
);
936 #elif defined GNULIB_POSIXCHECK
938 # if HAVE_RAW_DECL_GROUP_MEMBER
939 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
940 "use gnulib module group-member for portability");
946 # if @REPLACE_ISATTY@
947 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
949 # define isatty rpl_isatty
951 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
952 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
954 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
956 _GL_CXXALIASWARN (isatty
);
957 #elif defined GNULIB_POSIXCHECK
959 # if HAVE_RAW_DECL_ISATTY
960 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
961 "use gnulib module isatty for portability");
967 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
968 to GID (if GID is not -1). Do not follow symbolic links.
969 Return 0 if successful, otherwise -1 and errno set.
970 See the POSIX:2008 specification
971 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
972 # if @REPLACE_LCHOWN@
973 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
975 # define lchown rpl_lchown
977 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
978 _GL_ARG_NONNULL ((1)));
979 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
982 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
983 _GL_ARG_NONNULL ((1)));
985 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
987 _GL_CXXALIASWARN (lchown
);
988 #elif defined GNULIB_POSIXCHECK
990 # if HAVE_RAW_DECL_LCHOWN
991 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
992 "use gnulib module lchown for portability");
998 /* Create a new hard link for an existing file.
999 Return 0 if successful, otherwise -1 and errno set.
1000 See POSIX:2008 specification
1001 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1003 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1004 # define link rpl_link
1006 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1007 _GL_ARG_NONNULL ((1, 2)));
1008 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1011 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1012 _GL_ARG_NONNULL ((1, 2)));
1014 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1016 _GL_CXXALIASWARN (link
);
1017 #elif defined GNULIB_POSIXCHECK
1019 # if HAVE_RAW_DECL_LINK
1020 _GL_WARN_ON_USE (link
, "link is unportable - "
1021 "use gnulib module link for portability");
1027 /* Create a new hard link for an existing file, relative to two
1028 directories. FLAG controls whether symlinks are followed.
1029 Return 0 if successful, otherwise -1 and errno set. */
1030 # if @REPLACE_LINKAT@
1031 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1033 # define linkat rpl_linkat
1035 _GL_FUNCDECL_RPL (linkat
, int,
1036 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1038 _GL_ARG_NONNULL ((2, 4)));
1039 _GL_CXXALIAS_RPL (linkat
, int,
1040 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1044 _GL_FUNCDECL_SYS (linkat
, int,
1045 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1047 _GL_ARG_NONNULL ((2, 4)));
1049 _GL_CXXALIAS_SYS (linkat
, int,
1050 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1053 _GL_CXXALIASWARN (linkat
);
1054 #elif defined GNULIB_POSIXCHECK
1056 # if HAVE_RAW_DECL_LINKAT
1057 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1058 "use gnulib module linkat for portability");
1064 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1065 Return the new offset if successful, otherwise -1 and errno set.
1066 See the POSIX:2008 specification
1067 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1068 # if @REPLACE_LSEEK@
1069 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1070 # define lseek rpl_lseek
1072 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1073 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1075 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1077 _GL_CXXALIASWARN (lseek
);
1078 #elif defined GNULIB_POSIXCHECK
1080 # if HAVE_RAW_DECL_LSEEK
1081 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1082 "systems - use gnulib module lseek for portability");
1088 /* Create a pipe, defaulting to O_BINARY mode.
1089 Store the read-end as fd[0] and the write-end as fd[1].
1090 Return 0 upon success, or -1 with errno set upon failure. */
1092 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1094 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1095 _GL_CXXALIASWARN (pipe
);
1096 #elif defined GNULIB_POSIXCHECK
1098 # if HAVE_RAW_DECL_PIPE
1099 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1100 "use gnulib module pipe-posix for portability");
1106 /* Create a pipe, applying the given flags when opening the read-end of the
1107 pipe and the write-end of the pipe.
1108 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1109 and O_TEXT, O_BINARY (defined in "binary-io.h").
1110 Store the read-end as fd[0] and the write-end as fd[1].
1111 Return 0 upon success, or -1 with errno set upon failure.
1112 See also the Linux man page at
1113 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1115 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1116 # define pipe2 rpl_pipe2
1118 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1119 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1121 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1122 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1124 _GL_CXXALIASWARN (pipe2
);
1125 #elif defined GNULIB_POSIXCHECK
1127 # if HAVE_RAW_DECL_PIPE2
1128 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1129 "use gnulib module pipe2 for portability");
1135 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1136 Return the number of bytes placed into BUF if successful, otherwise
1137 set errno and return -1. 0 indicates EOF.
1138 See the POSIX:2008 specification
1139 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1140 # if @REPLACE_PREAD@
1141 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1143 # define pread rpl_pread
1145 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1146 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1147 _GL_ARG_NONNULL ((2)));
1148 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1149 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1152 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1153 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1154 _GL_ARG_NONNULL ((2)));
1156 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1157 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1159 _GL_CXXALIASWARN (pread
);
1160 #elif defined GNULIB_POSIXCHECK
1162 # if HAVE_RAW_DECL_PREAD
1163 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1164 "use gnulib module pread for portability");
1170 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1171 Return the number of bytes written if successful, otherwise
1172 set errno and return -1. 0 indicates nothing written. See the
1173 POSIX:2008 specification
1174 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1175 # if @REPLACE_PWRITE@
1176 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1178 # define pwrite rpl_pwrite
1180 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1181 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1182 _GL_ARG_NONNULL ((2)));
1183 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1184 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1187 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1188 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1189 _GL_ARG_NONNULL ((2)));
1191 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1192 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1194 _GL_CXXALIASWARN (pwrite
);
1195 #elif defined GNULIB_POSIXCHECK
1197 # if HAVE_RAW_DECL_PWRITE
1198 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1199 "use gnulib module pwrite for portability");
1205 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1206 at BUF. See the POSIX:2008 specification
1207 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1209 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1211 # define read rpl_read
1213 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1214 _GL_ARG_NONNULL ((2)));
1215 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1217 /* Need to cast, because on mingw, the third parameter is
1219 and the return type is 'int'. */
1220 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1222 _GL_CXXALIASWARN (read
);
1226 #if @GNULIB_READLINK@
1227 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1228 bytes of it into BUF. Return the number of bytes placed into BUF if
1229 successful, otherwise -1 and errno set.
1230 See the POSIX:2008 specification
1231 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1232 # if @REPLACE_READLINK@
1233 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1234 # define readlink rpl_readlink
1236 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1237 (const char *file
, char *buf
, size_t bufsize
)
1238 _GL_ARG_NONNULL ((1, 2)));
1239 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1240 (const char *file
, char *buf
, size_t bufsize
));
1242 # if !@HAVE_READLINK@
1243 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1244 (const char *file
, char *buf
, size_t bufsize
)
1245 _GL_ARG_NONNULL ((1, 2)));
1247 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1248 (const char *file
, char *buf
, size_t bufsize
));
1250 _GL_CXXALIASWARN (readlink
);
1251 #elif defined GNULIB_POSIXCHECK
1253 # if HAVE_RAW_DECL_READLINK
1254 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1255 "use gnulib module readlink for portability");
1260 #if @GNULIB_READLINKAT@
1261 # if !@HAVE_READLINKAT@
1262 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1263 (int fd
, char const *file
, char *buf
, size_t len
)
1264 _GL_ARG_NONNULL ((2, 3)));
1266 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1267 (int fd
, char const *file
, char *buf
, size_t len
));
1268 _GL_CXXALIASWARN (readlinkat
);
1269 #elif defined GNULIB_POSIXCHECK
1271 # if HAVE_RAW_DECL_READLINKAT
1272 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1273 "use gnulib module readlinkat for portability");
1279 /* Remove the directory DIR. */
1280 # if @REPLACE_RMDIR@
1281 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1282 # define rmdir rpl_rmdir
1284 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1285 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1287 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1289 _GL_CXXALIASWARN (rmdir
);
1290 #elif defined GNULIB_POSIXCHECK
1292 # if HAVE_RAW_DECL_RMDIR
1293 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1294 "use gnulib module rmdir for portability");
1299 #if @GNULIB_SETHOSTNAME@
1300 /* Set the host name of the machine.
1301 The host name may or may not be fully qualified.
1303 Put LEN bytes of NAME into the host name.
1304 Return 0 if successful, otherwise, set errno and return -1.
1306 Platforms with no ability to set the hostname return -1 and set
1308 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1309 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1310 _GL_ARG_NONNULL ((1)));
1312 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1313 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1314 2011-10, the first parameter is not const. */
1315 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1316 _GL_CXXALIASWARN (sethostname
);
1317 #elif defined GNULIB_POSIXCHECK
1319 # if HAVE_RAW_DECL_SETHOSTNAME
1320 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1321 "use gnulib module sethostname for portability");
1327 /* Pause the execution of the current thread for N seconds.
1328 Returns the number of seconds left to sleep.
1329 See the POSIX:2008 specification
1330 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1331 # if @REPLACE_SLEEP@
1332 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1334 # define sleep rpl_sleep
1336 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1337 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1340 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1342 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1344 _GL_CXXALIASWARN (sleep
);
1345 #elif defined GNULIB_POSIXCHECK
1347 # if HAVE_RAW_DECL_SLEEP
1348 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1349 "use gnulib module sleep for portability");
1354 #if @GNULIB_SYMLINK@
1355 # if @REPLACE_SYMLINK@
1356 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1358 # define symlink rpl_symlink
1360 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1361 _GL_ARG_NONNULL ((1, 2)));
1362 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1364 # if !@HAVE_SYMLINK@
1365 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1366 _GL_ARG_NONNULL ((1, 2)));
1368 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1370 _GL_CXXALIASWARN (symlink
);
1371 #elif defined GNULIB_POSIXCHECK
1373 # if HAVE_RAW_DECL_SYMLINK
1374 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1375 "use gnulib module symlink for portability");
1380 #if @GNULIB_SYMLINKAT@
1381 # if !@HAVE_SYMLINKAT@
1382 _GL_FUNCDECL_SYS (symlinkat
, int,
1383 (char const *contents
, int fd
, char const *file
)
1384 _GL_ARG_NONNULL ((1, 3)));
1386 _GL_CXXALIAS_SYS (symlinkat
, int,
1387 (char const *contents
, int fd
, char const *file
));
1388 _GL_CXXALIASWARN (symlinkat
);
1389 #elif defined GNULIB_POSIXCHECK
1391 # if HAVE_RAW_DECL_SYMLINKAT
1392 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1393 "use gnulib module symlinkat for portability");
1398 #if @GNULIB_TTYNAME_R@
1399 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1400 open on in BUF. Return 0 on success, otherwise an error number. */
1401 # if @REPLACE_TTYNAME_R@
1402 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1404 # define ttyname_r rpl_ttyname_r
1406 _GL_FUNCDECL_RPL (ttyname_r
, int,
1407 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1408 _GL_CXXALIAS_RPL (ttyname_r
, int,
1409 (int fd
, char *buf
, size_t buflen
));
1411 # if !@HAVE_DECL_TTYNAME_R@
1412 _GL_FUNCDECL_SYS (ttyname_r
, int,
1413 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1415 _GL_CXXALIAS_SYS (ttyname_r
, int,
1416 (int fd
, char *buf
, size_t buflen
));
1418 _GL_CXXALIASWARN (ttyname_r
);
1419 #elif defined GNULIB_POSIXCHECK
1421 # if HAVE_RAW_DECL_TTYNAME_R
1422 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1423 "use gnulib module ttyname_r for portability");
1429 # if @REPLACE_UNLINK@
1430 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1432 # define unlink rpl_unlink
1434 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1435 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1437 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1439 _GL_CXXALIASWARN (unlink
);
1440 #elif defined GNULIB_POSIXCHECK
1442 # if HAVE_RAW_DECL_UNLINK
1443 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1444 "use gnulib module unlink for portability");
1449 #if @GNULIB_UNLINKAT@
1450 # if @REPLACE_UNLINKAT@
1451 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1453 # define unlinkat rpl_unlinkat
1455 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1456 _GL_ARG_NONNULL ((2)));
1457 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1459 # if !@HAVE_UNLINKAT@
1460 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1461 _GL_ARG_NONNULL ((2)));
1463 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1465 _GL_CXXALIASWARN (unlinkat
);
1466 #elif defined GNULIB_POSIXCHECK
1468 # if HAVE_RAW_DECL_UNLINKAT
1469 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1470 "use gnulib module openat for portability");
1476 /* Pause the execution of the current thread for N microseconds.
1477 Returns 0 on completion, or -1 on range error.
1478 See the POSIX:2001 specification
1479 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1480 # if @REPLACE_USLEEP@
1481 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1483 # define usleep rpl_usleep
1485 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1486 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1489 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1491 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1493 _GL_CXXALIASWARN (usleep
);
1494 #elif defined GNULIB_POSIXCHECK
1496 # if HAVE_RAW_DECL_USLEEP
1497 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1498 "use gnulib module usleep for portability");
1504 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1505 See the POSIX:2008 specification
1506 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1507 # if @REPLACE_WRITE@
1508 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1510 # define write rpl_write
1512 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1513 _GL_ARG_NONNULL ((2)));
1514 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1516 /* Need to cast, because on mingw, the third parameter is
1518 and the return type is 'int'. */
1519 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1521 _GL_CXXALIASWARN (write
);
1524 _GL_INLINE_HEADER_END
1526 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1527 #endif /* _@GUARD_PREFIX@_UNISTD_H */