1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2012 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18 @PRAGMA_SYSTEM_HEADER@
22 /* Special invocation convention:
23 - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
24 but we need to ensure that both the system <unistd.h> and <winsock2.h>
25 are completely included before we replace gethostname. */
26 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
27 && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
28 /* <unistd.h> is being indirectly included for the first time from
29 <winsock2.h>; avoid declaring any overrides. */
31 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
33 # error unexpected; report this to bug-gnulib@gnu.org
35 # define _GL_WINSOCK2_H_WITNESS
37 /* Normal invocation. */
38 #elif !defined _@GUARD_PREFIX@_UNISTD_H
40 /* The include_next requires a split double-inclusion guard. */
42 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
45 /* Get all possible declarations of gethostname(). */
46 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
47 && !defined _GL_INCLUDING_WINSOCK2_H
48 # define _GL_INCLUDING_WINSOCK2_H
49 # include <winsock2.h>
50 # undef _GL_INCLUDING_WINSOCK2_H
53 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
54 #define _@GUARD_PREFIX@_UNISTD_H
56 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
59 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
60 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
61 /* But avoid namespace pollution on glibc systems. */
62 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
63 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
64 && defined __CYGWIN__)) \
65 && ! defined __GLIBC__
69 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
70 /* But avoid namespace pollution on glibc systems. */
71 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
72 && ! defined __GLIBC__
76 /* mingw fails to declare _exit in <unistd.h>. */
77 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
79 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
80 /* But avoid namespace pollution on glibc systems. */
85 /* Native Windows platforms declare chdir, getcwd, rmdir in
86 <io.h> and/or <direct.h>, not in <unistd.h>.
87 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
88 lseek(), read(), unlink(), write() in <io.h>. */
89 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
90 || defined GNULIB_POSIXCHECK) \
91 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
92 # include <io.h> /* mingw32, mingw64 */
93 # include <direct.h> /* mingw64, MSVC 9 */
94 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
95 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
96 || defined GNULIB_POSIXCHECK) \
97 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
101 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
102 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
103 /* But avoid namespace pollution on glibc systems. */
104 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
105 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
106 && !defined __GLIBC__
110 /* MSVC defines off_t in <sys/types.h>. */
113 # include <sys/types.h>
116 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
117 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
118 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
120 # include <sys/types.h>
123 /* Get getopt(), optarg, optind, opterr, optopt.
124 But avoid namespace pollution on glibc systems. */
125 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
129 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
131 /* The definition of _GL_ARG_NONNULL is copied here. */
133 /* The definition of _GL_WARN_ON_USE is copied here. */
136 /* Hide some function declarations from <winsock2.h>. */
138 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
139 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
140 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
142 # define socket socket_used_without_including_sys_socket_h
144 # define connect connect_used_without_including_sys_socket_h
146 # define accept accept_used_without_including_sys_socket_h
148 # define bind bind_used_without_including_sys_socket_h
150 # define getpeername getpeername_used_without_including_sys_socket_h
152 # define getsockname getsockname_used_without_including_sys_socket_h
154 # define getsockopt getsockopt_used_without_including_sys_socket_h
156 # define listen listen_used_without_including_sys_socket_h
158 # define recv recv_used_without_including_sys_socket_h
160 # define send send_used_without_including_sys_socket_h
162 # define recvfrom recvfrom_used_without_including_sys_socket_h
164 # define sendto sendto_used_without_including_sys_socket_h
166 # define setsockopt setsockopt_used_without_including_sys_socket_h
168 # define shutdown shutdown_used_without_including_sys_socket_h
170 _GL_WARN_ON_USE (socket
,
171 "socket() used without including <sys/socket.h>");
172 _GL_WARN_ON_USE (connect
,
173 "connect() used without including <sys/socket.h>");
174 _GL_WARN_ON_USE (accept
,
175 "accept() used without including <sys/socket.h>");
176 _GL_WARN_ON_USE (bind
,
177 "bind() used without including <sys/socket.h>");
178 _GL_WARN_ON_USE (getpeername
,
179 "getpeername() used without including <sys/socket.h>");
180 _GL_WARN_ON_USE (getsockname
,
181 "getsockname() used without including <sys/socket.h>");
182 _GL_WARN_ON_USE (getsockopt
,
183 "getsockopt() used without including <sys/socket.h>");
184 _GL_WARN_ON_USE (listen
,
185 "listen() used without including <sys/socket.h>");
186 _GL_WARN_ON_USE (recv
,
187 "recv() used without including <sys/socket.h>");
188 _GL_WARN_ON_USE (send
,
189 "send() used without including <sys/socket.h>");
190 _GL_WARN_ON_USE (recvfrom
,
191 "recvfrom() used without including <sys/socket.h>");
192 _GL_WARN_ON_USE (sendto
,
193 "sendto() used without including <sys/socket.h>");
194 _GL_WARN_ON_USE (setsockopt
,
195 "setsockopt() used without including <sys/socket.h>");
196 _GL_WARN_ON_USE (shutdown
,
197 "shutdown() used without including <sys/socket.h>");
200 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
201 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
203 # define select select_used_without_including_sys_select_h
205 _GL_WARN_ON_USE (select
,
206 "select() used without including <sys/select.h>");
212 /* OS/2 EMX lacks these macros. */
214 # define STDIN_FILENO 0
216 #ifndef STDOUT_FILENO
217 # define STDOUT_FILENO 1
219 #ifndef STDERR_FILENO
220 # define STDERR_FILENO 2
223 /* Ensure *_OK macros exist. */
232 /* Declare overridden functions. */
235 #if defined GNULIB_POSIXCHECK
236 /* The access() function is a security risk. */
237 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
238 "use the gnulib module faccessat instead");
243 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
244 _GL_CXXALIASWARN (chdir
);
245 #elif defined GNULIB_POSIXCHECK
247 # if HAVE_RAW_DECL_CHDIR
248 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
249 "use gnulib module chdir for portability");
255 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
256 to GID (if GID is not -1). Follow symbolic links.
257 Return 0 if successful, otherwise -1 and errno set.
258 See the POSIX:2008 specification
259 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
261 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
263 # define chown rpl_chown
265 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
266 _GL_ARG_NONNULL ((1)));
267 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
270 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
271 _GL_ARG_NONNULL ((1)));
273 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
275 _GL_CXXALIASWARN (chown
);
276 #elif defined GNULIB_POSIXCHECK
278 # if HAVE_RAW_DECL_CHOWN
279 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
280 "doesn't treat a uid or gid of -1 on some systems - "
281 "use gnulib module chown for portability");
288 /* Automatically included by modules that need a replacement for close. */
289 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
291 # define close rpl_close
293 _GL_FUNCDECL_RPL (close
, int, (int fd
));
294 _GL_CXXALIAS_RPL (close
, int, (int fd
));
296 _GL_CXXALIAS_SYS (close
, int, (int fd
));
298 _GL_CXXALIASWARN (close
);
299 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
301 # define close close_used_without_requesting_gnulib_module_close
302 #elif defined GNULIB_POSIXCHECK
304 /* Assume close is always declared. */
305 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
306 "use gnulib module close for portability");
312 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
315 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
316 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
318 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
320 _GL_CXXALIASWARN (dup
);
321 #elif defined GNULIB_POSIXCHECK
323 # if HAVE_RAW_DECL_DUP
324 _GL_WARN_ON_USE (dup
, "dup is unportable - "
325 "use gnulib module dup for portability");
331 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
332 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
333 Return newfd if successful, otherwise -1 and errno set.
334 See the POSIX:2008 specification
335 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
337 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
338 # define dup2 rpl_dup2
340 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
341 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
344 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
346 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
348 _GL_CXXALIASWARN (dup2
);
349 #elif defined GNULIB_POSIXCHECK
351 # if HAVE_RAW_DECL_DUP2
352 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
353 "use gnulib module dup2 for portability");
359 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
361 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
362 and O_TEXT, O_BINARY (defined in "binary-io.h").
363 Close NEWFD first if it is open.
364 Return newfd if successful, otherwise -1 and errno set.
365 See the Linux man page at
366 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
368 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
369 # define dup3 rpl_dup3
371 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
372 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
374 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
375 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
377 _GL_CXXALIASWARN (dup3
);
378 #elif defined GNULIB_POSIXCHECK
380 # if HAVE_RAW_DECL_DUP3
381 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
382 "use gnulib module dup3 for portability");
388 # if !@HAVE_DECL_ENVIRON@
389 /* Set of environment variables and values. An array of strings of the form
390 "VARIABLE=VALUE", terminated with a NULL. */
391 # if defined __APPLE__ && defined __MACH__
392 # include <crt_externs.h>
393 # define environ (*_NSGetEnviron ())
398 extern char **environ
;
404 #elif defined GNULIB_POSIXCHECK
405 # if HAVE_RAW_DECL_ENVIRON
406 static inline char ***
411 _GL_WARN_ON_USE (rpl_environ
, "environ is unportable - "
412 "use gnulib module environ for portability");
414 # define environ (*rpl_environ ())
419 #if @GNULIB_EUIDACCESS@
420 /* Like access(), except that it uses the effective user id and group id of
421 the current process. */
422 # if !@HAVE_EUIDACCESS@
423 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
424 _GL_ARG_NONNULL ((1)));
426 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
427 _GL_CXXALIASWARN (euidaccess
);
428 # if defined GNULIB_POSIXCHECK
429 /* Like access(), this function is a security risk. */
430 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
431 "use the gnulib module faccessat instead");
433 #elif defined GNULIB_POSIXCHECK
435 # if HAVE_RAW_DECL_EUIDACCESS
436 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
437 "use gnulib module euidaccess for portability");
442 #if @GNULIB_FACCESSAT@
443 # if !@HAVE_FACCESSAT@
444 _GL_FUNCDECL_SYS (faccessat
, int,
445 (int fd
, char const *file
, int mode
, int flag
)
446 _GL_ARG_NONNULL ((2)));
448 _GL_CXXALIAS_SYS (faccessat
, int,
449 (int fd
, char const *file
, int mode
, int flag
));
450 _GL_CXXALIASWARN (faccessat
);
451 #elif defined GNULIB_POSIXCHECK
453 # if HAVE_RAW_DECL_FACCESSAT
454 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
455 "use gnulib module faccessat for portability");
461 /* Change the process' current working directory to the directory on which
462 the given file descriptor is open.
463 Return 0 if successful, otherwise -1 and errno set.
464 See the POSIX:2008 specification
465 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
467 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
469 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
470 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
471 _GL_ARG_NONNULL ((2));
472 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
473 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
474 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
477 # if !@HAVE_DECL_FCHDIR@
478 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
481 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
482 _GL_CXXALIASWARN (fchdir
);
483 #elif defined GNULIB_POSIXCHECK
485 # if HAVE_RAW_DECL_FCHDIR
486 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
487 "use gnulib module fchdir for portability");
492 #if @GNULIB_FCHOWNAT@
493 # if @REPLACE_FCHOWNAT@
494 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
496 # define fchownat rpl_fchownat
498 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
499 uid_t owner
, gid_t group
, int flag
)
500 _GL_ARG_NONNULL ((2)));
501 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
502 uid_t owner
, gid_t group
, int flag
));
504 # if !@HAVE_FCHOWNAT@
505 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
506 uid_t owner
, gid_t group
, int flag
)
507 _GL_ARG_NONNULL ((2)));
509 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
510 uid_t owner
, gid_t group
, int flag
));
512 _GL_CXXALIASWARN (fchownat
);
513 #elif defined GNULIB_POSIXCHECK
515 # if HAVE_RAW_DECL_FCHOWNAT
516 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
517 "use gnulib module openat for portability");
522 #if @GNULIB_FDATASYNC@
523 /* Synchronize changes to a file.
524 Return 0 if successful, otherwise -1 and errno set.
525 See POSIX:2008 specification
526 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
527 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
528 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
530 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
531 _GL_CXXALIASWARN (fdatasync
);
532 #elif defined GNULIB_POSIXCHECK
534 # if HAVE_RAW_DECL_FDATASYNC
535 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
536 "use gnulib module fdatasync for portability");
542 /* Synchronize changes, including metadata, to a file.
543 Return 0 if successful, otherwise -1 and errno set.
544 See POSIX:2008 specification
545 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
547 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
549 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
550 _GL_CXXALIASWARN (fsync
);
551 #elif defined GNULIB_POSIXCHECK
553 # if HAVE_RAW_DECL_FSYNC
554 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
555 "use gnulib module fsync for portability");
560 #if @GNULIB_FTRUNCATE@
561 /* Change the size of the file to which FD is opened to become equal to LENGTH.
562 Return 0 if successful, otherwise -1 and errno set.
563 See the POSIX:2008 specification
564 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
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
));
569 _GL_CXXALIASWARN (ftruncate
);
570 #elif defined GNULIB_POSIXCHECK
572 # if HAVE_RAW_DECL_FTRUNCATE
573 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
574 "use gnulib module ftruncate for portability");
580 /* Get the name of the current working directory, and put it in SIZE bytes
582 Return BUF if successful, or NULL if the directory couldn't be determined
583 or SIZE was too small.
584 See the POSIX:2008 specification
585 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
586 Additionally, the gnulib module 'getcwd' guarantees the following GNU
587 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
588 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
590 # if @REPLACE_GETCWD@
591 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
592 # define getcwd rpl_getcwd
594 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
595 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
597 /* Need to cast, because on mingw, the second parameter is
599 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
601 _GL_CXXALIASWARN (getcwd
);
602 #elif defined GNULIB_POSIXCHECK
604 # if HAVE_RAW_DECL_GETCWD
605 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
606 "use gnulib module getcwd for portability");
611 #if @GNULIB_GETDOMAINNAME@
612 /* Return the NIS domain name of the machine.
613 WARNING! The NIS domain name is unrelated to the fully qualified host name
614 of the machine. It is also unrelated to email addresses.
615 WARNING! The NIS domain name is usually the empty string or "(none)" when
618 Put up to LEN bytes of the NIS domain name into NAME.
619 Null terminate it if the name is shorter than LEN.
620 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
621 Return 0 if successful, otherwise set errno and return -1. */
622 # if @REPLACE_GETDOMAINNAME@
623 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
624 # undef getdomainname
625 # define getdomainname rpl_getdomainname
627 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
628 _GL_ARG_NONNULL ((1)));
629 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
631 # if !@HAVE_DECL_GETDOMAINNAME@
632 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
633 _GL_ARG_NONNULL ((1)));
635 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
637 _GL_CXXALIASWARN (getdomainname
);
638 #elif defined GNULIB_POSIXCHECK
639 # undef getdomainname
640 # if HAVE_RAW_DECL_GETDOMAINNAME
641 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
642 "use gnulib module getdomainname for portability");
647 #if @GNULIB_GETDTABLESIZE@
648 /* Return the maximum number of file descriptors in the current process.
649 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
650 # if !@HAVE_GETDTABLESIZE@
651 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
653 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
654 _GL_CXXALIASWARN (getdtablesize
);
655 #elif defined GNULIB_POSIXCHECK
656 # undef getdtablesize
657 # if HAVE_RAW_DECL_GETDTABLESIZE
658 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
659 "use gnulib module getdtablesize for portability");
664 #if @GNULIB_GETGROUPS@
665 /* Return the supplemental groups that the current process belongs to.
666 It is unspecified whether the effective group id is in the list.
667 If N is 0, return the group count; otherwise, N describes how many
668 entries are available in GROUPS. Return -1 and set errno if N is
669 not 0 and not large enough. Fails with ENOSYS on some systems. */
670 # if @REPLACE_GETGROUPS@
671 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
673 # define getgroups rpl_getgroups
675 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
676 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
678 # if !@HAVE_GETGROUPS@
679 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
681 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
683 _GL_CXXALIASWARN (getgroups
);
684 #elif defined GNULIB_POSIXCHECK
686 # if HAVE_RAW_DECL_GETGROUPS
687 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
688 "use gnulib module getgroups for portability");
693 #if @GNULIB_GETHOSTNAME@
694 /* Return the standard host name of the machine.
695 WARNING! The host name may or may not be fully qualified.
697 Put up to LEN bytes of the host name into NAME.
698 Null terminate it if the name is shorter than LEN.
699 If the host name is longer than LEN, set errno = EINVAL and return -1.
700 Return 0 if successful, otherwise set errno and return -1. */
701 # if @UNISTD_H_HAVE_WINSOCK2_H@
702 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
704 # define gethostname rpl_gethostname
706 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
707 _GL_ARG_NONNULL ((1)));
708 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
710 # if !@HAVE_GETHOSTNAME@
711 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
712 _GL_ARG_NONNULL ((1)));
714 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
717 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
719 _GL_CXXALIASWARN (gethostname
);
720 #elif @UNISTD_H_HAVE_WINSOCK2_H@
722 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
723 #elif defined GNULIB_POSIXCHECK
725 # if HAVE_RAW_DECL_GETHOSTNAME
726 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
727 "use gnulib module gethostname for portability");
732 #if @GNULIB_GETLOGIN@
733 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
734 returns NULL with errno set.
736 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
738 Most programs don't need to use this function, because the information is
739 available through environment variables:
740 ${LOGNAME-$USER} on Unix platforms,
741 $USERNAME on native Windows platforms.
743 # if !@HAVE_GETLOGIN@
744 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
746 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
747 _GL_CXXALIASWARN (getlogin
);
748 #elif defined GNULIB_POSIXCHECK
750 # if HAVE_RAW_DECL_GETLOGIN
751 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
752 "use gnulib module getlogin for portability");
757 #if @GNULIB_GETLOGIN_R@
758 /* Copies the user's login name to NAME.
759 The array pointed to by NAME has room for SIZE bytes.
761 Returns 0 if successful. Upon error, an error number is returned, or -1 in
762 the case that the login name cannot be found but no specific error is
763 provided (this case is hopefully rare but is left open by the POSIX spec).
765 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
767 Most programs don't need to use this function, because the information is
768 available through environment variables:
769 ${LOGNAME-$USER} on Unix platforms,
770 $USERNAME on native Windows platforms.
772 # if @REPLACE_GETLOGIN_R@
773 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
774 # define getlogin_r rpl_getlogin_r
776 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
777 _GL_ARG_NONNULL ((1)));
778 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
780 # if !@HAVE_DECL_GETLOGIN_R@
781 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
782 _GL_ARG_NONNULL ((1)));
784 /* Need to cast, because on Solaris 10 systems, the second argument is
786 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
788 _GL_CXXALIASWARN (getlogin_r
);
789 #elif defined GNULIB_POSIXCHECK
791 # if HAVE_RAW_DECL_GETLOGIN_R
792 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
793 "use gnulib module getlogin_r for portability");
798 #if @GNULIB_GETPAGESIZE@
799 # if @REPLACE_GETPAGESIZE@
800 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
801 # define getpagesize rpl_getpagesize
803 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
804 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
806 # if !@HAVE_GETPAGESIZE@
807 # if !defined getpagesize
808 /* This is for POSIX systems. */
809 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
810 # if ! (defined __VMS && __VMS_VER < 70000000)
811 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
814 /* This is for older VMS. */
815 # if !defined _gl_getpagesize && defined __VMS
817 # define _gl_getpagesize() 8192
819 # define _gl_getpagesize() 512
822 /* This is for BeOS. */
823 # if !defined _gl_getpagesize && @HAVE_OS_H@
825 # if defined B_PAGE_SIZE
826 # define _gl_getpagesize() B_PAGE_SIZE
829 /* This is for AmigaOS4.0. */
830 # if !defined _gl_getpagesize && defined __amigaos4__
831 # define _gl_getpagesize() 2048
833 /* This is for older Unix systems. */
834 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
835 # include <sys/param.h>
836 # ifdef EXEC_PAGESIZE
837 # define _gl_getpagesize() EXEC_PAGESIZE
843 # define _gl_getpagesize() (NBPG * CLSIZE)
846 # define _gl_getpagesize() NBPC
851 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
852 # define getpagesize() _gl_getpagesize ()
854 # if !GNULIB_defined_getpagesize_function
858 return _gl_getpagesize ();
860 # define GNULIB_defined_getpagesize_function 1
865 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
866 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
868 # if @HAVE_DECL_GETPAGESIZE@
869 _GL_CXXALIASWARN (getpagesize
);
871 #elif defined GNULIB_POSIXCHECK
873 # if HAVE_RAW_DECL_GETPAGESIZE
874 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
875 "use gnulib module getpagesize for portability");
880 #if @GNULIB_GETUSERSHELL@
881 /* Return the next valid login shell on the system, or NULL when the end of
882 the list has been reached. */
883 # if !@HAVE_DECL_GETUSERSHELL@
884 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
886 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
887 _GL_CXXALIASWARN (getusershell
);
888 #elif defined GNULIB_POSIXCHECK
890 # if HAVE_RAW_DECL_GETUSERSHELL
891 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
892 "use gnulib module getusershell for portability");
896 #if @GNULIB_GETUSERSHELL@
897 /* Rewind to pointer that is advanced at each getusershell() call. */
898 # if !@HAVE_DECL_GETUSERSHELL@
899 _GL_FUNCDECL_SYS (setusershell
, void, (void));
901 _GL_CXXALIAS_SYS (setusershell
, void, (void));
902 _GL_CXXALIASWARN (setusershell
);
903 #elif defined GNULIB_POSIXCHECK
905 # if HAVE_RAW_DECL_SETUSERSHELL
906 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
907 "use gnulib module getusershell for portability");
911 #if @GNULIB_GETUSERSHELL@
912 /* Free the pointer that is advanced at each getusershell() call and
913 associated resources. */
914 # if !@HAVE_DECL_GETUSERSHELL@
915 _GL_FUNCDECL_SYS (endusershell
, void, (void));
917 _GL_CXXALIAS_SYS (endusershell
, void, (void));
918 _GL_CXXALIASWARN (endusershell
);
919 #elif defined GNULIB_POSIXCHECK
921 # if HAVE_RAW_DECL_ENDUSERSHELL
922 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
923 "use gnulib module getusershell for portability");
928 #if @GNULIB_GROUP_MEMBER@
929 /* Determine whether group id is in calling user's group list. */
930 # if !@HAVE_GROUP_MEMBER@
931 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
933 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
934 _GL_CXXALIASWARN (group_member
);
935 #elif defined GNULIB_POSIXCHECK
937 # if HAVE_RAW_DECL_GROUP_MEMBER
938 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
939 "use gnulib module group-member for portability");
945 # if @REPLACE_ISATTY@
946 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
948 # define isatty rpl_isatty
950 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
951 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
953 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
955 _GL_CXXALIASWARN (isatty
);
956 #elif defined GNULIB_POSIXCHECK
958 # if HAVE_RAW_DECL_ISATTY
959 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
960 "use gnulib module isatty for portability");
966 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
967 to GID (if GID is not -1). Do not follow symbolic links.
968 Return 0 if successful, otherwise -1 and errno set.
969 See the POSIX:2008 specification
970 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
971 # if @REPLACE_LCHOWN@
972 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
974 # define lchown rpl_lchown
976 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
977 _GL_ARG_NONNULL ((1)));
978 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
981 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
982 _GL_ARG_NONNULL ((1)));
984 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
986 _GL_CXXALIASWARN (lchown
);
987 #elif defined GNULIB_POSIXCHECK
989 # if HAVE_RAW_DECL_LCHOWN
990 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
991 "use gnulib module lchown for portability");
997 /* Create a new hard link for an existing file.
998 Return 0 if successful, otherwise -1 and errno set.
999 See POSIX:2008 specification
1000 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1002 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1003 # define link rpl_link
1005 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1006 _GL_ARG_NONNULL ((1, 2)));
1007 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1010 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1011 _GL_ARG_NONNULL ((1, 2)));
1013 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1015 _GL_CXXALIASWARN (link
);
1016 #elif defined GNULIB_POSIXCHECK
1018 # if HAVE_RAW_DECL_LINK
1019 _GL_WARN_ON_USE (link
, "link is unportable - "
1020 "use gnulib module link for portability");
1026 /* Create a new hard link for an existing file, relative to two
1027 directories. FLAG controls whether symlinks are followed.
1028 Return 0 if successful, otherwise -1 and errno set. */
1029 # if @REPLACE_LINKAT@
1030 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1032 # define linkat rpl_linkat
1034 _GL_FUNCDECL_RPL (linkat
, int,
1035 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1037 _GL_ARG_NONNULL ((2, 4)));
1038 _GL_CXXALIAS_RPL (linkat
, int,
1039 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1043 _GL_FUNCDECL_SYS (linkat
, int,
1044 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1046 _GL_ARG_NONNULL ((2, 4)));
1048 _GL_CXXALIAS_SYS (linkat
, int,
1049 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1052 _GL_CXXALIASWARN (linkat
);
1053 #elif defined GNULIB_POSIXCHECK
1055 # if HAVE_RAW_DECL_LINKAT
1056 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1057 "use gnulib module linkat for portability");
1063 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1064 Return the new offset if successful, otherwise -1 and errno set.
1065 See the POSIX:2008 specification
1066 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1067 # if @REPLACE_LSEEK@
1068 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1069 # define lseek rpl_lseek
1071 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1072 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1074 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1076 _GL_CXXALIASWARN (lseek
);
1077 #elif defined GNULIB_POSIXCHECK
1079 # if HAVE_RAW_DECL_LSEEK
1080 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1081 "systems - use gnulib module lseek for portability");
1087 /* Create a pipe, defaulting to O_BINARY mode.
1088 Store the read-end as fd[0] and the write-end as fd[1].
1089 Return 0 upon success, or -1 with errno set upon failure. */
1091 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1093 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1094 _GL_CXXALIASWARN (pipe
);
1095 #elif defined GNULIB_POSIXCHECK
1097 # if HAVE_RAW_DECL_PIPE
1098 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1099 "use gnulib module pipe-posix for portability");
1105 /* Create a pipe, applying the given flags when opening the read-end of the
1106 pipe and the write-end of the pipe.
1107 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1108 and O_TEXT, O_BINARY (defined in "binary-io.h").
1109 Store the read-end as fd[0] and the write-end as fd[1].
1110 Return 0 upon success, or -1 with errno set upon failure.
1111 See also the Linux man page at
1112 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1114 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1115 # define pipe2 rpl_pipe2
1117 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1118 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1120 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1121 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1123 _GL_CXXALIASWARN (pipe2
);
1124 #elif defined GNULIB_POSIXCHECK
1126 # if HAVE_RAW_DECL_PIPE2
1127 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1128 "use gnulib module pipe2 for portability");
1134 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1135 Return the number of bytes placed into BUF if successful, otherwise
1136 set errno and return -1. 0 indicates EOF.
1137 See the POSIX:2008 specification
1138 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1139 # if @REPLACE_PREAD@
1140 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1142 # define pread rpl_pread
1144 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1145 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1146 _GL_ARG_NONNULL ((2)));
1147 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1148 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1151 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1152 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1153 _GL_ARG_NONNULL ((2)));
1155 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1156 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1158 _GL_CXXALIASWARN (pread
);
1159 #elif defined GNULIB_POSIXCHECK
1161 # if HAVE_RAW_DECL_PREAD
1162 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1163 "use gnulib module pread for portability");
1169 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1170 Return the number of bytes written if successful, otherwise
1171 set errno and return -1. 0 indicates nothing written. See the
1172 POSIX:2008 specification
1173 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1174 # if @REPLACE_PWRITE@
1175 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1177 # define pwrite rpl_pwrite
1179 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1180 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1181 _GL_ARG_NONNULL ((2)));
1182 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1183 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1186 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1187 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1188 _GL_ARG_NONNULL ((2)));
1190 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1191 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1193 _GL_CXXALIASWARN (pwrite
);
1194 #elif defined GNULIB_POSIXCHECK
1196 # if HAVE_RAW_DECL_PWRITE
1197 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1198 "use gnulib module pwrite for portability");
1204 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1205 at BUF. See the POSIX:2008 specification
1206 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1208 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1210 # define read rpl_read
1212 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1213 _GL_ARG_NONNULL ((2)));
1214 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1216 /* Need to cast, because on mingw, the third parameter is
1218 and the return type is 'int'. */
1219 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1221 _GL_CXXALIASWARN (read
);
1225 #if @GNULIB_READLINK@
1226 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1227 bytes of it into BUF. Return the number of bytes placed into BUF if
1228 successful, otherwise -1 and errno set.
1229 See the POSIX:2008 specification
1230 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1231 # if @REPLACE_READLINK@
1232 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1233 # define readlink rpl_readlink
1235 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1236 (const char *file
, char *buf
, size_t bufsize
)
1237 _GL_ARG_NONNULL ((1, 2)));
1238 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1239 (const char *file
, char *buf
, size_t bufsize
));
1241 # if !@HAVE_READLINK@
1242 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1243 (const char *file
, char *buf
, size_t bufsize
)
1244 _GL_ARG_NONNULL ((1, 2)));
1246 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1247 (const char *file
, char *buf
, size_t bufsize
));
1249 _GL_CXXALIASWARN (readlink
);
1250 #elif defined GNULIB_POSIXCHECK
1252 # if HAVE_RAW_DECL_READLINK
1253 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1254 "use gnulib module readlink for portability");
1259 #if @GNULIB_READLINKAT@
1260 # if !@HAVE_READLINKAT@
1261 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1262 (int fd
, char const *file
, char *buf
, size_t len
)
1263 _GL_ARG_NONNULL ((2, 3)));
1265 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1266 (int fd
, char const *file
, char *buf
, size_t len
));
1267 _GL_CXXALIASWARN (readlinkat
);
1268 #elif defined GNULIB_POSIXCHECK
1270 # if HAVE_RAW_DECL_READLINKAT
1271 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1272 "use gnulib module readlinkat for portability");
1278 /* Remove the directory DIR. */
1279 # if @REPLACE_RMDIR@
1280 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1281 # define rmdir rpl_rmdir
1283 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1284 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1286 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1288 _GL_CXXALIASWARN (rmdir
);
1289 #elif defined GNULIB_POSIXCHECK
1291 # if HAVE_RAW_DECL_RMDIR
1292 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1293 "use gnulib module rmdir for portability");
1298 #if @GNULIB_SETHOSTNAME@
1299 /* Set the host name of the machine.
1300 The host name may or may not be fully qualified.
1302 Put LEN bytes of NAME into the host name.
1303 Return 0 if successful, otherwise, set errno and return -1.
1305 Platforms with no ability to set the hostname return -1 and set
1307 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1308 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1309 _GL_ARG_NONNULL ((1)));
1311 /* Need to cast, because on Solaris 11 2011-10, MacOS X 10.5, IRIX 6.5
1312 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1313 2011-10, the first parameter is not const. */
1314 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1315 _GL_CXXALIASWARN (sethostname
);
1316 #elif defined GNULIB_POSIXCHECK
1318 # if HAVE_RAW_DECL_SETHOSTNAME
1319 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1320 "use gnulib module sethostname for portability");
1326 /* Pause the execution of the current thread for N seconds.
1327 Returns the number of seconds left to sleep.
1328 See the POSIX:2008 specification
1329 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1330 # if @REPLACE_SLEEP@
1331 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1333 # define sleep rpl_sleep
1335 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1336 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1339 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1341 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1343 _GL_CXXALIASWARN (sleep
);
1344 #elif defined GNULIB_POSIXCHECK
1346 # if HAVE_RAW_DECL_SLEEP
1347 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1348 "use gnulib module sleep for portability");
1353 #if @GNULIB_SYMLINK@
1354 # if @REPLACE_SYMLINK@
1355 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1357 # define symlink rpl_symlink
1359 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1360 _GL_ARG_NONNULL ((1, 2)));
1361 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1363 # if !@HAVE_SYMLINK@
1364 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1365 _GL_ARG_NONNULL ((1, 2)));
1367 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1369 _GL_CXXALIASWARN (symlink
);
1370 #elif defined GNULIB_POSIXCHECK
1372 # if HAVE_RAW_DECL_SYMLINK
1373 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1374 "use gnulib module symlink for portability");
1379 #if @GNULIB_SYMLINKAT@
1380 # if !@HAVE_SYMLINKAT@
1381 _GL_FUNCDECL_SYS (symlinkat
, int,
1382 (char const *contents
, int fd
, char const *file
)
1383 _GL_ARG_NONNULL ((1, 3)));
1385 _GL_CXXALIAS_SYS (symlinkat
, int,
1386 (char const *contents
, int fd
, char const *file
));
1387 _GL_CXXALIASWARN (symlinkat
);
1388 #elif defined GNULIB_POSIXCHECK
1390 # if HAVE_RAW_DECL_SYMLINKAT
1391 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1392 "use gnulib module symlinkat for portability");
1397 #if @GNULIB_TTYNAME_R@
1398 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1399 open on in BUF. Return 0 on success, otherwise an error number. */
1400 # if @REPLACE_TTYNAME_R@
1401 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1403 # define ttyname_r rpl_ttyname_r
1405 _GL_FUNCDECL_RPL (ttyname_r
, int,
1406 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1407 _GL_CXXALIAS_RPL (ttyname_r
, int,
1408 (int fd
, char *buf
, size_t buflen
));
1410 # if !@HAVE_DECL_TTYNAME_R@
1411 _GL_FUNCDECL_SYS (ttyname_r
, int,
1412 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1414 _GL_CXXALIAS_SYS (ttyname_r
, int,
1415 (int fd
, char *buf
, size_t buflen
));
1417 _GL_CXXALIASWARN (ttyname_r
);
1418 #elif defined GNULIB_POSIXCHECK
1420 # if HAVE_RAW_DECL_TTYNAME_R
1421 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1422 "use gnulib module ttyname_r for portability");
1428 # if @REPLACE_UNLINK@
1429 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1431 # define unlink rpl_unlink
1433 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1434 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1436 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1438 _GL_CXXALIASWARN (unlink
);
1439 #elif defined GNULIB_POSIXCHECK
1441 # if HAVE_RAW_DECL_UNLINK
1442 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1443 "use gnulib module unlink for portability");
1448 #if @GNULIB_UNLINKAT@
1449 # if @REPLACE_UNLINKAT@
1450 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1452 # define unlinkat rpl_unlinkat
1454 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1455 _GL_ARG_NONNULL ((2)));
1456 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1458 # if !@HAVE_UNLINKAT@
1459 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1460 _GL_ARG_NONNULL ((2)));
1462 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1464 _GL_CXXALIASWARN (unlinkat
);
1465 #elif defined GNULIB_POSIXCHECK
1467 # if HAVE_RAW_DECL_UNLINKAT
1468 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1469 "use gnulib module openat for portability");
1475 /* Pause the execution of the current thread for N microseconds.
1476 Returns 0 on completion, or -1 on range error.
1477 See the POSIX:2001 specification
1478 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1479 # if @REPLACE_USLEEP@
1480 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1482 # define usleep rpl_usleep
1484 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1485 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1488 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1490 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1492 _GL_CXXALIASWARN (usleep
);
1493 #elif defined GNULIB_POSIXCHECK
1495 # if HAVE_RAW_DECL_USLEEP
1496 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1497 "use gnulib module usleep for portability");
1503 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1504 See the POSIX:2008 specification
1505 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1506 # if @REPLACE_WRITE@
1507 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1509 # define write rpl_write
1511 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1512 _GL_ARG_NONNULL ((2)));
1513 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1515 /* Need to cast, because on mingw, the third parameter is
1517 and the return type is 'int'. */
1518 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1520 _GL_CXXALIASWARN (write
);
1524 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1525 #endif /* _@GUARD_PREFIX@_UNISTD_H */