1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2017 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 #ifdef _GL_INCLUDING_UNISTD_H
25 /* Special invocation convention:
26 - On Mac OS X 10.3.9 we have a sequence of nested includes
27 <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>
28 In this situation, the functions are not yet declared, therefore we cannot
29 provide the C++ aliases. */
31 #@INCLUDE_NEXT@ @NEXT_UNISTD_H@
34 /* Normal invocation convention. */
36 /* The include_next requires a split double-inclusion guard. */
38 # define _GL_INCLUDING_UNISTD_H
39 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
40 # undef _GL_INCLUDING_UNISTD_H
43 /* Get all possible declarations of gethostname(). */
44 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
45 && !defined _GL_INCLUDING_WINSOCK2_H
46 # define _GL_INCLUDING_WINSOCK2_H
47 # include <winsock2.h>
48 # undef _GL_INCLUDING_WINSOCK2_H
51 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
52 #define _@GUARD_PREFIX@_UNISTD_H
54 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
57 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
58 /* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>. We must include
59 it before we #define unlink rpl_unlink. */
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_UNLINK@ || defined GNULIB_POSIXCHECK) \
64 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) \
65 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
66 && defined __CYGWIN__)) \
67 && ! defined __GLIBC__
71 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
72 /* But avoid namespace pollution on glibc systems. */
73 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
74 && ! defined __GLIBC__
78 /* mingw fails to declare _exit in <unistd.h>. */
79 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
81 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
82 /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
84 /* But avoid namespace pollution on glibc systems. */
85 #if !defined __GLIBC__ && !defined __osf__
86 # define __need_system_stdlib_h
88 # undef __need_system_stdlib_h
91 /* Native Windows platforms declare chdir, getcwd, rmdir in
92 <io.h> and/or <direct.h>, not in <unistd.h>.
93 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
94 lseek(), read(), unlink(), write() in <io.h>. */
95 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
96 || defined GNULIB_POSIXCHECK) \
97 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
98 # include <io.h> /* mingw32, mingw64 */
99 # include <direct.h> /* mingw64, MSVC 9 */
100 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
101 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
102 || defined GNULIB_POSIXCHECK) \
103 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
107 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
108 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
109 /* But avoid namespace pollution on glibc systems. */
110 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
111 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
112 && !defined __GLIBC__
116 /* MSVC defines off_t in <sys/types.h>.
117 May also define off_t to a 64-bit type on native Windows. */
118 #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
120 # include <sys/types.h>
123 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
124 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
125 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
127 # include <sys/types.h>
130 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
132 /* The definition of _GL_ARG_NONNULL is copied here. */
134 /* The definition of _GL_WARN_ON_USE is copied here. */
137 /* Get getopt(), optarg, optind, opterr, optopt.
138 But avoid namespace pollution on glibc systems. */
139 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
140 # include <getopt-cdefs.h>
141 # include <getopt-pfx-core.h>
144 #ifndef _GL_INLINE_HEADER_BEGIN
145 #error "Please include config.h first."
147 _GL_INLINE_HEADER_BEGIN
148 #ifndef _GL_UNISTD_INLINE
149 # define _GL_UNISTD_INLINE _GL_INLINE
152 /* Hide some function declarations from <winsock2.h>. */
154 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
155 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
156 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
158 # define socket socket_used_without_including_sys_socket_h
160 # define connect connect_used_without_including_sys_socket_h
162 # define accept accept_used_without_including_sys_socket_h
164 # define bind bind_used_without_including_sys_socket_h
166 # define getpeername getpeername_used_without_including_sys_socket_h
168 # define getsockname getsockname_used_without_including_sys_socket_h
170 # define getsockopt getsockopt_used_without_including_sys_socket_h
172 # define listen listen_used_without_including_sys_socket_h
174 # define recv recv_used_without_including_sys_socket_h
176 # define send send_used_without_including_sys_socket_h
178 # define recvfrom recvfrom_used_without_including_sys_socket_h
180 # define sendto sendto_used_without_including_sys_socket_h
182 # define setsockopt setsockopt_used_without_including_sys_socket_h
184 # define shutdown shutdown_used_without_including_sys_socket_h
186 _GL_WARN_ON_USE (socket
,
187 "socket() used without including <sys/socket.h>");
188 _GL_WARN_ON_USE (connect
,
189 "connect() used without including <sys/socket.h>");
190 _GL_WARN_ON_USE (accept
,
191 "accept() used without including <sys/socket.h>");
192 _GL_WARN_ON_USE (bind
,
193 "bind() used without including <sys/socket.h>");
194 _GL_WARN_ON_USE (getpeername
,
195 "getpeername() used without including <sys/socket.h>");
196 _GL_WARN_ON_USE (getsockname
,
197 "getsockname() used without including <sys/socket.h>");
198 _GL_WARN_ON_USE (getsockopt
,
199 "getsockopt() used without including <sys/socket.h>");
200 _GL_WARN_ON_USE (listen
,
201 "listen() used without including <sys/socket.h>");
202 _GL_WARN_ON_USE (recv
,
203 "recv() used without including <sys/socket.h>");
204 _GL_WARN_ON_USE (send
,
205 "send() used without including <sys/socket.h>");
206 _GL_WARN_ON_USE (recvfrom
,
207 "recvfrom() used without including <sys/socket.h>");
208 _GL_WARN_ON_USE (sendto
,
209 "sendto() used without including <sys/socket.h>");
210 _GL_WARN_ON_USE (setsockopt
,
211 "setsockopt() used without including <sys/socket.h>");
212 _GL_WARN_ON_USE (shutdown
,
213 "shutdown() used without including <sys/socket.h>");
216 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
217 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
219 # define select select_used_without_including_sys_select_h
221 _GL_WARN_ON_USE (select
,
222 "select() used without including <sys/select.h>");
228 /* OS/2 EMX lacks these macros. */
230 # define STDIN_FILENO 0
232 #ifndef STDOUT_FILENO
233 # define STDOUT_FILENO 1
235 #ifndef STDERR_FILENO
236 # define STDERR_FILENO 2
239 /* Ensure *_OK macros exist. */
248 /* Declare overridden functions. */
251 #if defined GNULIB_POSIXCHECK
252 /* The access() function is a security risk. */
253 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
254 "use the gnulib module faccessat instead");
259 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
260 _GL_CXXALIASWARN (chdir
);
261 #elif defined GNULIB_POSIXCHECK
263 # if HAVE_RAW_DECL_CHDIR
264 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
265 "use gnulib module chdir for portability");
271 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
272 to GID (if GID is not -1). Follow symbolic links.
273 Return 0 if successful, otherwise -1 and errno set.
274 See the POSIX:2008 specification
275 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
277 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
279 # define chown rpl_chown
281 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
282 _GL_ARG_NONNULL ((1)));
283 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
286 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
287 _GL_ARG_NONNULL ((1)));
289 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
291 _GL_CXXALIASWARN (chown
);
292 #elif defined GNULIB_POSIXCHECK
294 # if HAVE_RAW_DECL_CHOWN
295 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
296 "doesn't treat a uid or gid of -1 on some systems - "
297 "use gnulib module chown for portability");
304 /* Automatically included by modules that need a replacement for close. */
305 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
307 # define close rpl_close
309 _GL_FUNCDECL_RPL (close
, int, (int fd
));
310 _GL_CXXALIAS_RPL (close
, int, (int fd
));
312 _GL_CXXALIAS_SYS (close
, int, (int fd
));
314 _GL_CXXALIASWARN (close
);
315 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
317 # define close close_used_without_requesting_gnulib_module_close
318 #elif defined GNULIB_POSIXCHECK
320 /* Assume close is always declared. */
321 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
322 "use gnulib module close for portability");
328 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
331 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
332 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
334 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
336 _GL_CXXALIASWARN (dup
);
337 #elif defined GNULIB_POSIXCHECK
339 # if HAVE_RAW_DECL_DUP
340 _GL_WARN_ON_USE (dup
, "dup is unportable - "
341 "use gnulib module dup for portability");
347 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
348 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
349 Return newfd if successful, otherwise -1 and errno set.
350 See the POSIX:2008 specification
351 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
353 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
354 # define dup2 rpl_dup2
356 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
357 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
360 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
362 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
364 _GL_CXXALIASWARN (dup2
);
365 #elif defined GNULIB_POSIXCHECK
367 # if HAVE_RAW_DECL_DUP2
368 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
369 "use gnulib module dup2 for portability");
375 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
377 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
378 and O_TEXT, O_BINARY (defined in "binary-io.h").
379 Close NEWFD first if it is open.
380 Return newfd if successful, otherwise -1 and errno set.
381 See the Linux man page at
382 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
384 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
385 # define dup3 rpl_dup3
387 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
388 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
390 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
391 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
393 _GL_CXXALIASWARN (dup3
);
394 #elif defined GNULIB_POSIXCHECK
396 # if HAVE_RAW_DECL_DUP3
397 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
398 "use gnulib module dup3 for portability");
404 # if !@HAVE_DECL_ENVIRON@
405 /* Set of environment variables and values. An array of strings of the form
406 "VARIABLE=VALUE", terminated with a NULL. */
407 # if defined __APPLE__ && defined __MACH__
408 # include <TargetConditionals.h>
409 # if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
410 # define _GL_USE_CRT_EXTERNS
413 # ifdef _GL_USE_CRT_EXTERNS
414 # include <crt_externs.h>
415 # define environ (*_NSGetEnviron ())
420 extern char **environ
;
426 #elif defined GNULIB_POSIXCHECK
427 # if HAVE_RAW_DECL_ENVIRON
428 _GL_UNISTD_INLINE
char ***
433 _GL_WARN_ON_USE (rpl_environ
, "environ is unportable - "
434 "use gnulib module environ for portability");
436 # define environ (*rpl_environ ())
441 #if @GNULIB_EUIDACCESS@
442 /* Like access(), except that it uses the effective user id and group id of
443 the current process. */
444 # if !@HAVE_EUIDACCESS@
445 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
446 _GL_ARG_NONNULL ((1)));
448 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
449 _GL_CXXALIASWARN (euidaccess
);
450 # if defined GNULIB_POSIXCHECK
451 /* Like access(), this function is a security risk. */
452 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
453 "use the gnulib module faccessat instead");
455 #elif defined GNULIB_POSIXCHECK
457 # if HAVE_RAW_DECL_EUIDACCESS
458 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
459 "use gnulib module euidaccess for portability");
464 #if @GNULIB_FACCESSAT@
465 # if !@HAVE_FACCESSAT@
466 _GL_FUNCDECL_SYS (faccessat
, int,
467 (int fd
, char const *file
, int mode
, int flag
)
468 _GL_ARG_NONNULL ((2)));
470 _GL_CXXALIAS_SYS (faccessat
, int,
471 (int fd
, char const *file
, int mode
, int flag
));
472 _GL_CXXALIASWARN (faccessat
);
473 #elif defined GNULIB_POSIXCHECK
475 # if HAVE_RAW_DECL_FACCESSAT
476 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
477 "use gnulib module faccessat for portability");
483 /* Change the process' current working directory to the directory on which
484 the given file descriptor is open.
485 Return 0 if successful, otherwise -1 and errno set.
486 See the POSIX:2008 specification
487 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
489 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
491 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
492 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
493 _GL_ARG_NONNULL ((2));
494 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
495 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
496 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
499 # if !@HAVE_DECL_FCHDIR@
500 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
503 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
504 _GL_CXXALIASWARN (fchdir
);
505 #elif defined GNULIB_POSIXCHECK
507 # if HAVE_RAW_DECL_FCHDIR
508 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
509 "use gnulib module fchdir for portability");
514 #if @GNULIB_FCHOWNAT@
515 # if @REPLACE_FCHOWNAT@
516 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
518 # define fchownat rpl_fchownat
520 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
521 uid_t owner
, gid_t group
, int flag
)
522 _GL_ARG_NONNULL ((2)));
523 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
524 uid_t owner
, gid_t group
, int flag
));
526 # if !@HAVE_FCHOWNAT@
527 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
528 uid_t owner
, gid_t group
, int flag
)
529 _GL_ARG_NONNULL ((2)));
531 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
532 uid_t owner
, gid_t group
, int flag
));
534 _GL_CXXALIASWARN (fchownat
);
535 #elif defined GNULIB_POSIXCHECK
537 # if HAVE_RAW_DECL_FCHOWNAT
538 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
539 "use gnulib module openat for portability");
544 #if @GNULIB_FDATASYNC@
545 /* Synchronize changes to a file.
546 Return 0 if successful, otherwise -1 and errno set.
547 See POSIX:2008 specification
548 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
549 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
550 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
552 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
553 _GL_CXXALIASWARN (fdatasync
);
554 #elif defined GNULIB_POSIXCHECK
556 # if HAVE_RAW_DECL_FDATASYNC
557 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
558 "use gnulib module fdatasync for portability");
564 /* Synchronize changes, including metadata, to a file.
565 Return 0 if successful, otherwise -1 and errno set.
566 See POSIX:2008 specification
567 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
569 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
571 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
572 _GL_CXXALIASWARN (fsync
);
573 #elif defined GNULIB_POSIXCHECK
575 # if HAVE_RAW_DECL_FSYNC
576 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
577 "use gnulib module fsync for portability");
582 #if @GNULIB_FTRUNCATE@
583 /* Change the size of the file to which FD is opened to become equal to LENGTH.
584 Return 0 if successful, otherwise -1 and errno set.
585 See the POSIX:2008 specification
586 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
587 # if @REPLACE_FTRUNCATE@
588 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
590 # define ftruncate rpl_ftruncate
592 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
593 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
595 # if !@HAVE_FTRUNCATE@
596 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
598 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
600 _GL_CXXALIASWARN (ftruncate
);
601 #elif defined GNULIB_POSIXCHECK
603 # if HAVE_RAW_DECL_FTRUNCATE
604 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
605 "use gnulib module ftruncate for portability");
611 /* Get the name of the current working directory, and put it in SIZE bytes
613 Return BUF if successful, or NULL if the directory couldn't be determined
614 or SIZE was too small.
615 See the POSIX:2008 specification
616 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
617 Additionally, the gnulib module 'getcwd' guarantees the following GNU
618 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
619 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
621 # if @REPLACE_GETCWD@
622 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
623 # define getcwd rpl_getcwd
625 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
626 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
628 /* Need to cast, because on mingw, the second parameter is
630 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
632 _GL_CXXALIASWARN (getcwd
);
633 #elif defined GNULIB_POSIXCHECK
635 # if HAVE_RAW_DECL_GETCWD
636 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
637 "use gnulib module getcwd for portability");
642 #if @GNULIB_GETDOMAINNAME@
643 /* Return the NIS domain name of the machine.
644 WARNING! The NIS domain name is unrelated to the fully qualified host name
645 of the machine. It is also unrelated to email addresses.
646 WARNING! The NIS domain name is usually the empty string or "(none)" when
649 Put up to LEN bytes of the NIS domain name into NAME.
650 Null terminate it if the name is shorter than LEN.
651 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
652 Return 0 if successful, otherwise set errno and return -1. */
653 # if @REPLACE_GETDOMAINNAME@
654 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
655 # undef getdomainname
656 # define getdomainname rpl_getdomainname
658 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
659 _GL_ARG_NONNULL ((1)));
660 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
662 # if !@HAVE_DECL_GETDOMAINNAME@
663 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
664 _GL_ARG_NONNULL ((1)));
666 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
668 _GL_CXXALIASWARN (getdomainname
);
669 #elif defined GNULIB_POSIXCHECK
670 # undef getdomainname
671 # if HAVE_RAW_DECL_GETDOMAINNAME
672 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
673 "use gnulib module getdomainname for portability");
678 #if @GNULIB_GETDTABLESIZE@
679 /* Return the maximum number of file descriptors in the current process.
680 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
681 # if @REPLACE_GETDTABLESIZE@
682 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
683 # undef getdtablesize
684 # define getdtablesize rpl_getdtablesize
686 _GL_FUNCDECL_RPL (getdtablesize
, int, (void));
687 _GL_CXXALIAS_RPL (getdtablesize
, int, (void));
689 # if !@HAVE_GETDTABLESIZE@
690 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
692 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
694 _GL_CXXALIASWARN (getdtablesize
);
695 #elif defined GNULIB_POSIXCHECK
696 # undef getdtablesize
697 # if HAVE_RAW_DECL_GETDTABLESIZE
698 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
699 "use gnulib module getdtablesize for portability");
704 #if @GNULIB_GETGROUPS@
705 /* Return the supplemental groups that the current process belongs to.
706 It is unspecified whether the effective group id is in the list.
707 If N is 0, return the group count; otherwise, N describes how many
708 entries are available in GROUPS. Return -1 and set errno if N is
709 not 0 and not large enough. Fails with ENOSYS on some systems. */
710 # if @REPLACE_GETGROUPS@
711 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
713 # define getgroups rpl_getgroups
715 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
716 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
718 # if !@HAVE_GETGROUPS@
719 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
721 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
723 _GL_CXXALIASWARN (getgroups
);
724 #elif defined GNULIB_POSIXCHECK
726 # if HAVE_RAW_DECL_GETGROUPS
727 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
728 "use gnulib module getgroups for portability");
733 #if @GNULIB_GETHOSTNAME@
734 /* Return the standard host name of the machine.
735 WARNING! The host name may or may not be fully qualified.
737 Put up to LEN bytes of the host name into NAME.
738 Null terminate it if the name is shorter than LEN.
739 If the host name is longer than LEN, set errno = EINVAL and return -1.
740 Return 0 if successful, otherwise set errno and return -1. */
741 # if @UNISTD_H_HAVE_WINSOCK2_H@
742 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
744 # define gethostname rpl_gethostname
746 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
747 _GL_ARG_NONNULL ((1)));
748 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
750 # if !@HAVE_GETHOSTNAME@
751 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
752 _GL_ARG_NONNULL ((1)));
754 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
757 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
759 _GL_CXXALIASWARN (gethostname
);
760 #elif @UNISTD_H_HAVE_WINSOCK2_H@
762 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
763 #elif defined GNULIB_POSIXCHECK
765 # if HAVE_RAW_DECL_GETHOSTNAME
766 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
767 "use gnulib module gethostname for portability");
772 #if @GNULIB_GETLOGIN@
773 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
774 returns NULL with errno set.
776 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
778 Most programs don't need to use this function, because the information is
779 available through environment variables:
780 ${LOGNAME-$USER} on Unix platforms,
781 $USERNAME on native Windows platforms.
783 # if !@HAVE_DECL_GETLOGIN@
784 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
786 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
787 _GL_CXXALIASWARN (getlogin
);
788 #elif defined GNULIB_POSIXCHECK
790 # if HAVE_RAW_DECL_GETLOGIN
791 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
792 "use gnulib module getlogin for portability");
797 #if @GNULIB_GETLOGIN_R@
798 /* Copies the user's login name to NAME.
799 The array pointed to by NAME has room for SIZE bytes.
801 Returns 0 if successful. Upon error, an error number is returned, or -1 in
802 the case that the login name cannot be found but no specific error is
803 provided (this case is hopefully rare but is left open by the POSIX spec).
805 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
807 Most programs don't need to use this function, because the information is
808 available through environment variables:
809 ${LOGNAME-$USER} on Unix platforms,
810 $USERNAME on native Windows platforms.
812 # if @REPLACE_GETLOGIN_R@
813 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
814 # define getlogin_r rpl_getlogin_r
816 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
817 _GL_ARG_NONNULL ((1)));
818 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
820 # if !@HAVE_DECL_GETLOGIN_R@
821 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
822 _GL_ARG_NONNULL ((1)));
824 /* Need to cast, because on Solaris 10 systems, the second argument is
826 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
828 _GL_CXXALIASWARN (getlogin_r
);
829 #elif defined GNULIB_POSIXCHECK
831 # if HAVE_RAW_DECL_GETLOGIN_R
832 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
833 "use gnulib module getlogin_r for portability");
838 #if @GNULIB_GETPAGESIZE@
839 # if @REPLACE_GETPAGESIZE@
840 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
841 # define getpagesize rpl_getpagesize
843 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
844 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
846 # if !@HAVE_GETPAGESIZE@
847 # if !defined getpagesize
848 /* This is for POSIX systems. */
849 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
850 # if ! (defined __VMS && __VMS_VER < 70000000)
851 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
854 /* This is for older VMS. */
855 # if !defined _gl_getpagesize && defined __VMS
857 # define _gl_getpagesize() 8192
859 # define _gl_getpagesize() 512
862 /* This is for BeOS. */
863 # if !defined _gl_getpagesize && @HAVE_OS_H@
865 # if defined B_PAGE_SIZE
866 # define _gl_getpagesize() B_PAGE_SIZE
869 /* This is for AmigaOS4.0. */
870 # if !defined _gl_getpagesize && defined __amigaos4__
871 # define _gl_getpagesize() 2048
873 /* This is for older Unix systems. */
874 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
875 # include <sys/param.h>
876 # ifdef EXEC_PAGESIZE
877 # define _gl_getpagesize() EXEC_PAGESIZE
883 # define _gl_getpagesize() (NBPG * CLSIZE)
886 # define _gl_getpagesize() NBPC
891 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
892 # define getpagesize() _gl_getpagesize ()
894 # if !GNULIB_defined_getpagesize_function
895 _GL_UNISTD_INLINE
int
898 return _gl_getpagesize ();
900 # define GNULIB_defined_getpagesize_function 1
905 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
906 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
908 # if @HAVE_DECL_GETPAGESIZE@
909 _GL_CXXALIASWARN (getpagesize
);
911 #elif defined GNULIB_POSIXCHECK
913 # if HAVE_RAW_DECL_GETPAGESIZE
914 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
915 "use gnulib module getpagesize for portability");
920 #if @GNULIB_GETUSERSHELL@
921 /* Return the next valid login shell on the system, or NULL when the end of
922 the list has been reached. */
923 # if !@HAVE_DECL_GETUSERSHELL@
924 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
926 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
927 _GL_CXXALIASWARN (getusershell
);
928 #elif defined GNULIB_POSIXCHECK
930 # if HAVE_RAW_DECL_GETUSERSHELL
931 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
932 "use gnulib module getusershell for portability");
936 #if @GNULIB_GETUSERSHELL@
937 /* Rewind to pointer that is advanced at each getusershell() call. */
938 # if !@HAVE_DECL_GETUSERSHELL@
939 _GL_FUNCDECL_SYS (setusershell
, void, (void));
941 _GL_CXXALIAS_SYS (setusershell
, void, (void));
942 _GL_CXXALIASWARN (setusershell
);
943 #elif defined GNULIB_POSIXCHECK
945 # if HAVE_RAW_DECL_SETUSERSHELL
946 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
947 "use gnulib module getusershell for portability");
951 #if @GNULIB_GETUSERSHELL@
952 /* Free the pointer that is advanced at each getusershell() call and
953 associated resources. */
954 # if !@HAVE_DECL_GETUSERSHELL@
955 _GL_FUNCDECL_SYS (endusershell
, void, (void));
957 _GL_CXXALIAS_SYS (endusershell
, void, (void));
958 _GL_CXXALIASWARN (endusershell
);
959 #elif defined GNULIB_POSIXCHECK
961 # if HAVE_RAW_DECL_ENDUSERSHELL
962 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
963 "use gnulib module getusershell for portability");
968 #if @GNULIB_GROUP_MEMBER@
969 /* Determine whether group id is in calling user's group list. */
970 # if !@HAVE_GROUP_MEMBER@
971 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
973 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
974 _GL_CXXALIASWARN (group_member
);
975 #elif defined GNULIB_POSIXCHECK
977 # if HAVE_RAW_DECL_GROUP_MEMBER
978 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
979 "use gnulib module group-member for portability");
985 # if @REPLACE_ISATTY@
986 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
988 # define isatty rpl_isatty
990 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
991 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
993 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
995 _GL_CXXALIASWARN (isatty
);
996 #elif defined GNULIB_POSIXCHECK
998 # if HAVE_RAW_DECL_ISATTY
999 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
1000 "use gnulib module isatty for portability");
1006 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1007 to GID (if GID is not -1). Do not follow symbolic links.
1008 Return 0 if successful, otherwise -1 and errno set.
1009 See the POSIX:2008 specification
1010 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1011 # if @REPLACE_LCHOWN@
1012 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1014 # define lchown rpl_lchown
1016 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1017 _GL_ARG_NONNULL ((1)));
1018 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1021 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1022 _GL_ARG_NONNULL ((1)));
1024 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1026 _GL_CXXALIASWARN (lchown
);
1027 #elif defined GNULIB_POSIXCHECK
1029 # if HAVE_RAW_DECL_LCHOWN
1030 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1031 "use gnulib module lchown for portability");
1037 /* Create a new hard link for an existing file.
1038 Return 0 if successful, otherwise -1 and errno set.
1039 See POSIX:2008 specification
1040 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1042 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1043 # define link rpl_link
1045 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1046 _GL_ARG_NONNULL ((1, 2)));
1047 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1050 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1051 _GL_ARG_NONNULL ((1, 2)));
1053 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1055 _GL_CXXALIASWARN (link
);
1056 #elif defined GNULIB_POSIXCHECK
1058 # if HAVE_RAW_DECL_LINK
1059 _GL_WARN_ON_USE (link
, "link is unportable - "
1060 "use gnulib module link for portability");
1066 /* Create a new hard link for an existing file, relative to two
1067 directories. FLAG controls whether symlinks are followed.
1068 Return 0 if successful, otherwise -1 and errno set. */
1069 # if @REPLACE_LINKAT@
1070 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1072 # define linkat rpl_linkat
1074 _GL_FUNCDECL_RPL (linkat
, int,
1075 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1077 _GL_ARG_NONNULL ((2, 4)));
1078 _GL_CXXALIAS_RPL (linkat
, int,
1079 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1083 _GL_FUNCDECL_SYS (linkat
, int,
1084 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1086 _GL_ARG_NONNULL ((2, 4)));
1088 _GL_CXXALIAS_SYS (linkat
, int,
1089 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1092 _GL_CXXALIASWARN (linkat
);
1093 #elif defined GNULIB_POSIXCHECK
1095 # if HAVE_RAW_DECL_LINKAT
1096 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1097 "use gnulib module linkat for portability");
1103 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1104 Return the new offset if successful, otherwise -1 and errno set.
1105 See the POSIX:2008 specification
1106 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1107 # if @REPLACE_LSEEK@
1108 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1109 # define lseek rpl_lseek
1111 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1112 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1114 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1116 _GL_CXXALIASWARN (lseek
);
1117 #elif defined GNULIB_POSIXCHECK
1119 # if HAVE_RAW_DECL_LSEEK
1120 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1121 "systems - use gnulib module lseek for portability");
1127 /* Create a pipe, defaulting to O_BINARY mode.
1128 Store the read-end as fd[0] and the write-end as fd[1].
1129 Return 0 upon success, or -1 with errno set upon failure. */
1131 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1133 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1134 _GL_CXXALIASWARN (pipe
);
1135 #elif defined GNULIB_POSIXCHECK
1137 # if HAVE_RAW_DECL_PIPE
1138 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1139 "use gnulib module pipe-posix for portability");
1145 /* Create a pipe, applying the given flags when opening the read-end of the
1146 pipe and the write-end of the pipe.
1147 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1148 and O_TEXT, O_BINARY (defined in "binary-io.h").
1149 Store the read-end as fd[0] and the write-end as fd[1].
1150 Return 0 upon success, or -1 with errno set upon failure.
1151 See also the Linux man page at
1152 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1154 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1155 # define pipe2 rpl_pipe2
1157 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1158 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1160 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1161 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1163 _GL_CXXALIASWARN (pipe2
);
1164 #elif defined GNULIB_POSIXCHECK
1166 # if HAVE_RAW_DECL_PIPE2
1167 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1168 "use gnulib module pipe2 for portability");
1174 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1175 Return the number of bytes placed into BUF if successful, otherwise
1176 set errno and return -1. 0 indicates EOF.
1177 See the POSIX:2008 specification
1178 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1179 # if @REPLACE_PREAD@
1180 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1182 # define pread rpl_pread
1184 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1185 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1186 _GL_ARG_NONNULL ((2)));
1187 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1188 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1191 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1192 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1193 _GL_ARG_NONNULL ((2)));
1195 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1196 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1198 _GL_CXXALIASWARN (pread
);
1199 #elif defined GNULIB_POSIXCHECK
1201 # if HAVE_RAW_DECL_PREAD
1202 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1203 "use gnulib module pread for portability");
1209 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1210 Return the number of bytes written if successful, otherwise
1211 set errno and return -1. 0 indicates nothing written. See the
1212 POSIX:2008 specification
1213 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1214 # if @REPLACE_PWRITE@
1215 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1217 # define pwrite rpl_pwrite
1219 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1220 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1221 _GL_ARG_NONNULL ((2)));
1222 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1223 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1226 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1227 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1228 _GL_ARG_NONNULL ((2)));
1230 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1231 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1233 _GL_CXXALIASWARN (pwrite
);
1234 #elif defined GNULIB_POSIXCHECK
1236 # if HAVE_RAW_DECL_PWRITE
1237 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1238 "use gnulib module pwrite for portability");
1244 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1245 at BUF. See the POSIX:2008 specification
1246 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1248 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1250 # define read rpl_read
1252 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1253 _GL_ARG_NONNULL ((2)));
1254 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1256 /* Need to cast, because on mingw, the third parameter is
1258 and the return type is 'int'. */
1259 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1261 _GL_CXXALIASWARN (read
);
1265 #if @GNULIB_READLINK@
1266 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1267 bytes of it into BUF. Return the number of bytes placed into BUF if
1268 successful, otherwise -1 and errno set.
1269 See the POSIX:2008 specification
1270 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1271 # if @REPLACE_READLINK@
1272 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1273 # define readlink rpl_readlink
1275 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1276 (const char *file
, char *buf
, size_t bufsize
)
1277 _GL_ARG_NONNULL ((1, 2)));
1278 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1279 (const char *file
, char *buf
, size_t bufsize
));
1281 # if !@HAVE_READLINK@
1282 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1283 (const char *file
, char *buf
, size_t bufsize
)
1284 _GL_ARG_NONNULL ((1, 2)));
1286 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1287 (const char *file
, char *buf
, size_t bufsize
));
1289 _GL_CXXALIASWARN (readlink
);
1290 #elif defined GNULIB_POSIXCHECK
1292 # if HAVE_RAW_DECL_READLINK
1293 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1294 "use gnulib module readlink for portability");
1299 #if @GNULIB_READLINKAT@
1300 # if @REPLACE_READLINKAT@
1301 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1302 # define readlinkat rpl_readlinkat
1304 _GL_FUNCDECL_RPL (readlinkat
, ssize_t
,
1305 (int fd
, char const *file
, char *buf
, size_t len
)
1306 _GL_ARG_NONNULL ((2, 3)));
1307 _GL_CXXALIAS_RPL (readlinkat
, ssize_t
,
1308 (int fd
, char const *file
, char *buf
, size_t len
));
1310 # if !@HAVE_READLINKAT@
1311 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1312 (int fd
, char const *file
, char *buf
, size_t len
)
1313 _GL_ARG_NONNULL ((2, 3)));
1315 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1316 (int fd
, char const *file
, char *buf
, size_t len
));
1318 _GL_CXXALIASWARN (readlinkat
);
1319 #elif defined GNULIB_POSIXCHECK
1321 # if HAVE_RAW_DECL_READLINKAT
1322 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1323 "use gnulib module readlinkat for portability");
1329 /* Remove the directory DIR. */
1330 # if @REPLACE_RMDIR@
1331 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1332 # define rmdir rpl_rmdir
1334 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1335 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1337 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1339 _GL_CXXALIASWARN (rmdir
);
1340 #elif defined GNULIB_POSIXCHECK
1342 # if HAVE_RAW_DECL_RMDIR
1343 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1344 "use gnulib module rmdir for portability");
1349 #if @GNULIB_SETHOSTNAME@
1350 /* Set the host name of the machine.
1351 The host name may or may not be fully qualified.
1353 Put LEN bytes of NAME into the host name.
1354 Return 0 if successful, otherwise, set errno and return -1.
1356 Platforms with no ability to set the hostname return -1 and set
1358 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1359 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1360 _GL_ARG_NONNULL ((1)));
1362 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1363 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1364 2011-10, the first parameter is not const. */
1365 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1366 _GL_CXXALIASWARN (sethostname
);
1367 #elif defined GNULIB_POSIXCHECK
1369 # if HAVE_RAW_DECL_SETHOSTNAME
1370 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1371 "use gnulib module sethostname for portability");
1377 /* Pause the execution of the current thread for N seconds.
1378 Returns the number of seconds left to sleep.
1379 See the POSIX:2008 specification
1380 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1381 # if @REPLACE_SLEEP@
1382 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1384 # define sleep rpl_sleep
1386 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1387 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1390 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1392 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1394 _GL_CXXALIASWARN (sleep
);
1395 #elif defined GNULIB_POSIXCHECK
1397 # if HAVE_RAW_DECL_SLEEP
1398 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1399 "use gnulib module sleep for portability");
1404 #if @GNULIB_SYMLINK@
1405 # if @REPLACE_SYMLINK@
1406 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1408 # define symlink rpl_symlink
1410 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1411 _GL_ARG_NONNULL ((1, 2)));
1412 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1414 # if !@HAVE_SYMLINK@
1415 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1416 _GL_ARG_NONNULL ((1, 2)));
1418 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1420 _GL_CXXALIASWARN (symlink
);
1421 #elif defined GNULIB_POSIXCHECK
1423 # if HAVE_RAW_DECL_SYMLINK
1424 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1425 "use gnulib module symlink for portability");
1430 #if @GNULIB_SYMLINKAT@
1431 # if @REPLACE_SYMLINKAT@
1432 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1434 # define symlinkat rpl_symlinkat
1436 _GL_FUNCDECL_RPL (symlinkat
, int,
1437 (char const *contents
, int fd
, char const *file
)
1438 _GL_ARG_NONNULL ((1, 3)));
1439 _GL_CXXALIAS_RPL (symlinkat
, int,
1440 (char const *contents
, int fd
, char const *file
));
1442 # if !@HAVE_SYMLINKAT@
1443 _GL_FUNCDECL_SYS (symlinkat
, int,
1444 (char const *contents
, int fd
, char const *file
)
1445 _GL_ARG_NONNULL ((1, 3)));
1447 _GL_CXXALIAS_SYS (symlinkat
, int,
1448 (char const *contents
, int fd
, char const *file
));
1450 _GL_CXXALIASWARN (symlinkat
);
1451 #elif defined GNULIB_POSIXCHECK
1453 # if HAVE_RAW_DECL_SYMLINKAT
1454 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1455 "use gnulib module symlinkat for portability");
1460 #if @GNULIB_TRUNCATE@
1461 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
1462 Return 0 if successful, otherwise -1 and errno set.
1463 See the POSIX:2008 specification
1464 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
1465 # if @REPLACE_TRUNCATE@
1466 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1468 # define truncate rpl_truncate
1470 _GL_FUNCDECL_RPL (truncate
, int, (const char *filename
, off_t length
)
1471 _GL_ARG_NONNULL ((1)));
1472 _GL_CXXALIAS_RPL (truncate
, int, (const char *filename
, off_t length
));
1474 # if !@HAVE_TRUNCATE@
1475 _GL_FUNCDECL_SYS (truncate
, int, (const char *filename
, off_t length
)
1476 _GL_ARG_NONNULL ((1)));
1478 _GL_CXXALIAS_SYS (truncate
, int, (const char *filename
, off_t length
));
1480 _GL_CXXALIASWARN (truncate
);
1481 #elif defined GNULIB_POSIXCHECK
1483 # if HAVE_RAW_DECL_TRUNCATE
1484 _GL_WARN_ON_USE (truncate
, "truncate is unportable - "
1485 "use gnulib module truncate for portability");
1490 #if @GNULIB_TTYNAME_R@
1491 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1492 open on in BUF. Return 0 on success, otherwise an error number. */
1493 # if @REPLACE_TTYNAME_R@
1494 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1496 # define ttyname_r rpl_ttyname_r
1498 _GL_FUNCDECL_RPL (ttyname_r
, int,
1499 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1500 _GL_CXXALIAS_RPL (ttyname_r
, int,
1501 (int fd
, char *buf
, size_t buflen
));
1503 # if !@HAVE_DECL_TTYNAME_R@
1504 _GL_FUNCDECL_SYS (ttyname_r
, int,
1505 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1507 _GL_CXXALIAS_SYS (ttyname_r
, int,
1508 (int fd
, char *buf
, size_t buflen
));
1510 _GL_CXXALIASWARN (ttyname_r
);
1511 #elif defined GNULIB_POSIXCHECK
1513 # if HAVE_RAW_DECL_TTYNAME_R
1514 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1515 "use gnulib module ttyname_r for portability");
1521 # if @REPLACE_UNLINK@
1522 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1524 # define unlink rpl_unlink
1526 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1527 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1529 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1531 _GL_CXXALIASWARN (unlink
);
1532 #elif defined GNULIB_POSIXCHECK
1534 # if HAVE_RAW_DECL_UNLINK
1535 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1536 "use gnulib module unlink for portability");
1541 #if @GNULIB_UNLINKAT@
1542 # if @REPLACE_UNLINKAT@
1543 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1545 # define unlinkat rpl_unlinkat
1547 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1548 _GL_ARG_NONNULL ((2)));
1549 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1551 # if !@HAVE_UNLINKAT@
1552 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1553 _GL_ARG_NONNULL ((2)));
1555 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1557 _GL_CXXALIASWARN (unlinkat
);
1558 #elif defined GNULIB_POSIXCHECK
1560 # if HAVE_RAW_DECL_UNLINKAT
1561 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1562 "use gnulib module openat for portability");
1568 /* Pause the execution of the current thread for N microseconds.
1569 Returns 0 on completion, or -1 on range error.
1570 See the POSIX:2001 specification
1571 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1572 # if @REPLACE_USLEEP@
1573 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1575 # define usleep rpl_usleep
1577 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1578 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1581 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1583 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1585 _GL_CXXALIASWARN (usleep
);
1586 #elif defined GNULIB_POSIXCHECK
1588 # if HAVE_RAW_DECL_USLEEP
1589 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1590 "use gnulib module usleep for portability");
1596 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1597 See the POSIX:2008 specification
1598 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1599 # if @REPLACE_WRITE@
1600 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1602 # define write rpl_write
1604 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1605 _GL_ARG_NONNULL ((2)));
1606 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1608 /* Need to cast, because on mingw, the third parameter is
1610 and the return type is 'int'. */
1611 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1613 _GL_CXXALIASWARN (write
);
1616 _GL_INLINE_HEADER_END
1618 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1619 #endif /* _GL_INCLUDING_UNISTD_H */
1620 #endif /* _@GUARD_PREFIX@_UNISTD_H */