1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2018 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 <https://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 #if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
139 # include <getopt-cdefs.h>
140 # include <getopt-pfx-core.h>
143 #ifndef _GL_INLINE_HEADER_BEGIN
144 #error "Please include config.h first."
146 _GL_INLINE_HEADER_BEGIN
147 #ifndef _GL_UNISTD_INLINE
148 # define _GL_UNISTD_INLINE _GL_INLINE
151 /* Hide some function declarations from <winsock2.h>. */
153 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
154 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
155 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
157 # define socket socket_used_without_including_sys_socket_h
159 # define connect connect_used_without_including_sys_socket_h
161 # define accept accept_used_without_including_sys_socket_h
163 # define bind bind_used_without_including_sys_socket_h
165 # define getpeername getpeername_used_without_including_sys_socket_h
167 # define getsockname getsockname_used_without_including_sys_socket_h
169 # define getsockopt getsockopt_used_without_including_sys_socket_h
171 # define listen listen_used_without_including_sys_socket_h
173 # define recv recv_used_without_including_sys_socket_h
175 # define send send_used_without_including_sys_socket_h
177 # define recvfrom recvfrom_used_without_including_sys_socket_h
179 # define sendto sendto_used_without_including_sys_socket_h
181 # define setsockopt setsockopt_used_without_including_sys_socket_h
183 # define shutdown shutdown_used_without_including_sys_socket_h
185 _GL_WARN_ON_USE (socket
,
186 "socket() used without including <sys/socket.h>");
187 _GL_WARN_ON_USE (connect
,
188 "connect() used without including <sys/socket.h>");
189 _GL_WARN_ON_USE (accept
,
190 "accept() used without including <sys/socket.h>");
191 _GL_WARN_ON_USE (bind
,
192 "bind() used without including <sys/socket.h>");
193 _GL_WARN_ON_USE (getpeername
,
194 "getpeername() used without including <sys/socket.h>");
195 _GL_WARN_ON_USE (getsockname
,
196 "getsockname() used without including <sys/socket.h>");
197 _GL_WARN_ON_USE (getsockopt
,
198 "getsockopt() used without including <sys/socket.h>");
199 _GL_WARN_ON_USE (listen
,
200 "listen() used without including <sys/socket.h>");
201 _GL_WARN_ON_USE (recv
,
202 "recv() used without including <sys/socket.h>");
203 _GL_WARN_ON_USE (send
,
204 "send() used without including <sys/socket.h>");
205 _GL_WARN_ON_USE (recvfrom
,
206 "recvfrom() used without including <sys/socket.h>");
207 _GL_WARN_ON_USE (sendto
,
208 "sendto() used without including <sys/socket.h>");
209 _GL_WARN_ON_USE (setsockopt
,
210 "setsockopt() used without including <sys/socket.h>");
211 _GL_WARN_ON_USE (shutdown
,
212 "shutdown() used without including <sys/socket.h>");
215 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
216 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
218 # define select select_used_without_including_sys_select_h
220 _GL_WARN_ON_USE (select
,
221 "select() used without including <sys/select.h>");
227 /* OS/2 EMX lacks these macros. */
229 # define STDIN_FILENO 0
231 #ifndef STDOUT_FILENO
232 # define STDOUT_FILENO 1
234 #ifndef STDERR_FILENO
235 # define STDERR_FILENO 2
238 /* Ensure *_OK macros exist. */
247 /* Declare overridden functions. */
250 #if defined GNULIB_POSIXCHECK
251 /* The access() function is a security risk. */
252 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
253 "use the gnulib module faccessat instead");
258 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
259 _GL_CXXALIASWARN (chdir
);
260 #elif defined GNULIB_POSIXCHECK
262 # if HAVE_RAW_DECL_CHDIR
263 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
264 "use gnulib module chdir for portability");
270 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
271 to GID (if GID is not -1). Follow symbolic links.
272 Return 0 if successful, otherwise -1 and errno set.
273 See the POSIX:2008 specification
274 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
276 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
278 # define chown rpl_chown
280 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
281 _GL_ARG_NONNULL ((1)));
282 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
285 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
286 _GL_ARG_NONNULL ((1)));
288 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
290 _GL_CXXALIASWARN (chown
);
291 #elif defined GNULIB_POSIXCHECK
293 # if HAVE_RAW_DECL_CHOWN
294 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
295 "doesn't treat a uid or gid of -1 on some systems - "
296 "use gnulib module chown for portability");
303 /* Automatically included by modules that need a replacement for close. */
304 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
306 # define close rpl_close
308 _GL_FUNCDECL_RPL (close
, int, (int fd
));
309 _GL_CXXALIAS_RPL (close
, int, (int fd
));
311 _GL_CXXALIAS_SYS (close
, int, (int fd
));
313 _GL_CXXALIASWARN (close
);
314 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
316 # define close close_used_without_requesting_gnulib_module_close
317 #elif defined GNULIB_POSIXCHECK
319 /* Assume close is always declared. */
320 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
321 "use gnulib module close for portability");
327 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
330 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
331 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
333 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
335 _GL_CXXALIASWARN (dup
);
336 #elif defined GNULIB_POSIXCHECK
338 # if HAVE_RAW_DECL_DUP
339 _GL_WARN_ON_USE (dup
, "dup is unportable - "
340 "use gnulib module dup for portability");
346 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
347 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
348 Return newfd if successful, otherwise -1 and errno set.
349 See the POSIX:2008 specification
350 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
352 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
353 # define dup2 rpl_dup2
355 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
356 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
359 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
361 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
363 _GL_CXXALIASWARN (dup2
);
364 #elif defined GNULIB_POSIXCHECK
366 # if HAVE_RAW_DECL_DUP2
367 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
368 "use gnulib module dup2 for portability");
374 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
376 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
377 and O_TEXT, O_BINARY (defined in "binary-io.h").
378 Close NEWFD first if it is open.
379 Return newfd if successful, otherwise -1 and errno set.
380 See the Linux man page at
381 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
383 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
384 # define dup3 rpl_dup3
386 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
387 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
389 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
390 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
392 _GL_CXXALIASWARN (dup3
);
393 #elif defined GNULIB_POSIXCHECK
395 # if HAVE_RAW_DECL_DUP3
396 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
397 "use gnulib module dup3 for portability");
403 # if defined __CYGWIN__ && !defined __i386__
404 /* The 'environ' variable is defined in a DLL. Therefore its declaration needs
405 the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
406 This leads to a link error on 64-bit Cygwin when the option
407 -Wl,--disable-auto-import is in use. */
408 _GL_EXTERN_C
__declspec(dllimport
) char **environ
;
410 # if !@HAVE_DECL_ENVIRON@
411 /* Set of environment variables and values. An array of strings of the form
412 "VARIABLE=VALUE", terminated with a NULL. */
413 # if defined __APPLE__ && defined __MACH__
414 # include <TargetConditionals.h>
415 # if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
416 # define _GL_USE_CRT_EXTERNS
419 # ifdef _GL_USE_CRT_EXTERNS
420 # include <crt_externs.h>
421 # define environ (*_NSGetEnviron ())
426 extern char **environ
;
432 #elif defined GNULIB_POSIXCHECK
433 # if HAVE_RAW_DECL_ENVIRON
434 _GL_UNISTD_INLINE
char ***
439 _GL_WARN_ON_USE (rpl_environ
, "environ is unportable - "
440 "use gnulib module environ for portability");
442 # define environ (*rpl_environ ())
447 #if @GNULIB_EUIDACCESS@
448 /* Like access(), except that it uses the effective user id and group id of
449 the current process. */
450 # if !@HAVE_EUIDACCESS@
451 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
452 _GL_ARG_NONNULL ((1)));
454 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
455 _GL_CXXALIASWARN (euidaccess
);
456 # if defined GNULIB_POSIXCHECK
457 /* Like access(), this function is a security risk. */
458 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
459 "use the gnulib module faccessat instead");
461 #elif defined GNULIB_POSIXCHECK
463 # if HAVE_RAW_DECL_EUIDACCESS
464 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
465 "use gnulib module euidaccess for portability");
470 #if @GNULIB_FACCESSAT@
471 # if @REPLACE_FACCESSAT@
472 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
474 # define faccessat rpl_faccessat
476 _GL_FUNCDECL_RPL (faccessat
, int,
477 (int fd
, char const *name
, int mode
, int flag
)
478 _GL_ARG_NONNULL ((2)));
479 _GL_CXXALIAS_RPL (faccessat
, int,
480 (int fd
, char const *name
, int mode
, int flag
));
482 # if !@HAVE_FACCESSAT@
483 _GL_FUNCDECL_SYS (faccessat
, int,
484 (int fd
, char const *file
, int mode
, int flag
)
485 _GL_ARG_NONNULL ((2)));
487 _GL_CXXALIAS_SYS (faccessat
, int,
488 (int fd
, char const *file
, int mode
, int flag
));
490 _GL_CXXALIASWARN (faccessat
);
491 #elif defined GNULIB_POSIXCHECK
493 # if HAVE_RAW_DECL_FACCESSAT
494 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
495 "use gnulib module faccessat for portability");
501 /* Change the process' current working directory to the directory on which
502 the given file descriptor is open.
503 Return 0 if successful, otherwise -1 and errno set.
504 See the POSIX:2008 specification
505 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
507 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
509 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
510 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
511 _GL_ARG_NONNULL ((2));
512 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
513 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
514 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
517 # if !@HAVE_DECL_FCHDIR@
518 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
521 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
522 _GL_CXXALIASWARN (fchdir
);
523 #elif defined GNULIB_POSIXCHECK
525 # if HAVE_RAW_DECL_FCHDIR
526 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
527 "use gnulib module fchdir for portability");
532 #if @GNULIB_FCHOWNAT@
533 # if @REPLACE_FCHOWNAT@
534 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
536 # define fchownat rpl_fchownat
538 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
539 uid_t owner
, gid_t group
, int flag
)
540 _GL_ARG_NONNULL ((2)));
541 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
542 uid_t owner
, gid_t group
, int flag
));
544 # if !@HAVE_FCHOWNAT@
545 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
546 uid_t owner
, gid_t group
, int flag
)
547 _GL_ARG_NONNULL ((2)));
549 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
550 uid_t owner
, gid_t group
, int flag
));
552 _GL_CXXALIASWARN (fchownat
);
553 #elif defined GNULIB_POSIXCHECK
555 # if HAVE_RAW_DECL_FCHOWNAT
556 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
557 "use gnulib module openat for portability");
562 #if @GNULIB_FDATASYNC@
563 /* Synchronize changes to a file.
564 Return 0 if successful, otherwise -1 and errno set.
565 See POSIX:2008 specification
566 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
567 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
568 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
570 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
571 _GL_CXXALIASWARN (fdatasync
);
572 #elif defined GNULIB_POSIXCHECK
574 # if HAVE_RAW_DECL_FDATASYNC
575 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
576 "use gnulib module fdatasync for portability");
582 /* Synchronize changes, including metadata, to a file.
583 Return 0 if successful, otherwise -1 and errno set.
584 See POSIX:2008 specification
585 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
587 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
589 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
590 _GL_CXXALIASWARN (fsync
);
591 #elif defined GNULIB_POSIXCHECK
593 # if HAVE_RAW_DECL_FSYNC
594 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
595 "use gnulib module fsync for portability");
600 #if @GNULIB_FTRUNCATE@
601 /* Change the size of the file to which FD is opened to become equal to LENGTH.
602 Return 0 if successful, otherwise -1 and errno set.
603 See the POSIX:2008 specification
604 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
605 # if @REPLACE_FTRUNCATE@
606 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
608 # define ftruncate rpl_ftruncate
610 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
611 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
613 # if !@HAVE_FTRUNCATE@
614 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
616 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
618 _GL_CXXALIASWARN (ftruncate
);
619 #elif defined GNULIB_POSIXCHECK
621 # if HAVE_RAW_DECL_FTRUNCATE
622 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
623 "use gnulib module ftruncate for portability");
629 /* Get the name of the current working directory, and put it in SIZE bytes
631 Return BUF if successful, or NULL if the directory couldn't be determined
632 or SIZE was too small.
633 See the POSIX:2008 specification
634 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
635 Additionally, the gnulib module 'getcwd' guarantees the following GNU
636 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
637 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
639 # if @REPLACE_GETCWD@
640 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
641 # define getcwd rpl_getcwd
643 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
644 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
646 /* Need to cast, because on mingw, the second parameter is
648 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
650 _GL_CXXALIASWARN (getcwd
);
651 #elif defined GNULIB_POSIXCHECK
653 # if HAVE_RAW_DECL_GETCWD
654 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
655 "use gnulib module getcwd for portability");
660 #if @GNULIB_GETDOMAINNAME@
661 /* Return the NIS domain name of the machine.
662 WARNING! The NIS domain name is unrelated to the fully qualified host name
663 of the machine. It is also unrelated to email addresses.
664 WARNING! The NIS domain name is usually the empty string or "(none)" when
667 Put up to LEN bytes of the NIS domain name into NAME.
668 Null terminate it if the name is shorter than LEN.
669 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
670 Return 0 if successful, otherwise set errno and return -1. */
671 # if @REPLACE_GETDOMAINNAME@
672 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
673 # undef getdomainname
674 # define getdomainname rpl_getdomainname
676 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
677 _GL_ARG_NONNULL ((1)));
678 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
680 # if !@HAVE_DECL_GETDOMAINNAME@
681 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
682 _GL_ARG_NONNULL ((1)));
684 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
686 _GL_CXXALIASWARN (getdomainname
);
687 #elif defined GNULIB_POSIXCHECK
688 # undef getdomainname
689 # if HAVE_RAW_DECL_GETDOMAINNAME
690 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
691 "use gnulib module getdomainname for portability");
696 #if @GNULIB_GETDTABLESIZE@
697 /* Return the maximum number of file descriptors in the current process.
698 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
699 # if @REPLACE_GETDTABLESIZE@
700 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
701 # undef getdtablesize
702 # define getdtablesize rpl_getdtablesize
704 _GL_FUNCDECL_RPL (getdtablesize
, int, (void));
705 _GL_CXXALIAS_RPL (getdtablesize
, int, (void));
707 # if !@HAVE_GETDTABLESIZE@
708 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
710 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
712 _GL_CXXALIASWARN (getdtablesize
);
713 #elif defined GNULIB_POSIXCHECK
714 # undef getdtablesize
715 # if HAVE_RAW_DECL_GETDTABLESIZE
716 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
717 "use gnulib module getdtablesize for portability");
722 #if @GNULIB_GETGROUPS@
723 /* Return the supplemental groups that the current process belongs to.
724 It is unspecified whether the effective group id is in the list.
725 If N is 0, return the group count; otherwise, N describes how many
726 entries are available in GROUPS. Return -1 and set errno if N is
727 not 0 and not large enough. Fails with ENOSYS on some systems. */
728 # if @REPLACE_GETGROUPS@
729 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
731 # define getgroups rpl_getgroups
733 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
734 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
736 # if !@HAVE_GETGROUPS@
737 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
739 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
741 _GL_CXXALIASWARN (getgroups
);
742 #elif defined GNULIB_POSIXCHECK
744 # if HAVE_RAW_DECL_GETGROUPS
745 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
746 "use gnulib module getgroups for portability");
751 #if @GNULIB_GETHOSTNAME@
752 /* Return the standard host name of the machine.
753 WARNING! The host name may or may not be fully qualified.
755 Put up to LEN bytes of the host name into NAME.
756 Null terminate it if the name is shorter than LEN.
757 If the host name is longer than LEN, set errno = EINVAL and return -1.
758 Return 0 if successful, otherwise set errno and return -1. */
759 # if @UNISTD_H_HAVE_WINSOCK2_H@
760 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
762 # define gethostname rpl_gethostname
764 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
765 _GL_ARG_NONNULL ((1)));
766 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
768 # if !@HAVE_GETHOSTNAME@
769 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
770 _GL_ARG_NONNULL ((1)));
772 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
775 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
777 _GL_CXXALIASWARN (gethostname
);
778 #elif @UNISTD_H_HAVE_WINSOCK2_H@
780 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
781 #elif defined GNULIB_POSIXCHECK
783 # if HAVE_RAW_DECL_GETHOSTNAME
784 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
785 "use gnulib module gethostname for portability");
790 #if @GNULIB_GETLOGIN@
791 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
792 returns NULL with errno set.
794 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
796 Most programs don't need to use this function, because the information is
797 available through environment variables:
798 ${LOGNAME-$USER} on Unix platforms,
799 $USERNAME on native Windows platforms.
801 # if !@HAVE_DECL_GETLOGIN@
802 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
804 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
805 _GL_CXXALIASWARN (getlogin
);
806 #elif defined GNULIB_POSIXCHECK
808 # if HAVE_RAW_DECL_GETLOGIN
809 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
810 "use gnulib module getlogin for portability");
815 #if @GNULIB_GETLOGIN_R@
816 /* Copies the user's login name to NAME.
817 The array pointed to by NAME has room for SIZE bytes.
819 Returns 0 if successful. Upon error, an error number is returned, or -1 in
820 the case that the login name cannot be found but no specific error is
821 provided (this case is hopefully rare but is left open by the POSIX spec).
823 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
825 Most programs don't need to use this function, because the information is
826 available through environment variables:
827 ${LOGNAME-$USER} on Unix platforms,
828 $USERNAME on native Windows platforms.
830 # if @REPLACE_GETLOGIN_R@
831 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
832 # define getlogin_r rpl_getlogin_r
834 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
835 _GL_ARG_NONNULL ((1)));
836 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
838 # if !@HAVE_DECL_GETLOGIN_R@
839 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
840 _GL_ARG_NONNULL ((1)));
842 /* Need to cast, because on Solaris 10 systems, the second argument is
844 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
846 _GL_CXXALIASWARN (getlogin_r
);
847 #elif defined GNULIB_POSIXCHECK
849 # if HAVE_RAW_DECL_GETLOGIN_R
850 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
851 "use gnulib module getlogin_r for portability");
856 #if @GNULIB_GETPAGESIZE@
857 # if @REPLACE_GETPAGESIZE@
858 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
859 # define getpagesize rpl_getpagesize
861 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
862 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
864 # if !@HAVE_GETPAGESIZE@
865 # if !defined getpagesize
866 /* This is for POSIX systems. */
867 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
868 # if ! (defined __VMS && __VMS_VER < 70000000)
869 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
872 /* This is for older VMS. */
873 # if !defined _gl_getpagesize && defined __VMS
875 # define _gl_getpagesize() 8192
877 # define _gl_getpagesize() 512
880 /* This is for BeOS. */
881 # if !defined _gl_getpagesize && @HAVE_OS_H@
883 # if defined B_PAGE_SIZE
884 # define _gl_getpagesize() B_PAGE_SIZE
887 /* This is for AmigaOS4.0. */
888 # if !defined _gl_getpagesize && defined __amigaos4__
889 # define _gl_getpagesize() 2048
891 /* This is for older Unix systems. */
892 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
893 # include <sys/param.h>
894 # ifdef EXEC_PAGESIZE
895 # define _gl_getpagesize() EXEC_PAGESIZE
901 # define _gl_getpagesize() (NBPG * CLSIZE)
904 # define _gl_getpagesize() NBPC
909 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
910 # define getpagesize() _gl_getpagesize ()
912 # if !GNULIB_defined_getpagesize_function
913 _GL_UNISTD_INLINE
int
916 return _gl_getpagesize ();
918 # define GNULIB_defined_getpagesize_function 1
923 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
924 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
926 # if @HAVE_DECL_GETPAGESIZE@
927 _GL_CXXALIASWARN (getpagesize
);
929 #elif defined GNULIB_POSIXCHECK
931 # if HAVE_RAW_DECL_GETPAGESIZE
932 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
933 "use gnulib module getpagesize for portability");
938 #if @GNULIB_GETUSERSHELL@
939 /* Return the next valid login shell on the system, or NULL when the end of
940 the list has been reached. */
941 # if !@HAVE_DECL_GETUSERSHELL@
942 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
944 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
945 _GL_CXXALIASWARN (getusershell
);
946 #elif defined GNULIB_POSIXCHECK
948 # if HAVE_RAW_DECL_GETUSERSHELL
949 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
950 "use gnulib module getusershell for portability");
954 #if @GNULIB_GETUSERSHELL@
955 /* Rewind to pointer that is advanced at each getusershell() call. */
956 # if !@HAVE_DECL_GETUSERSHELL@
957 _GL_FUNCDECL_SYS (setusershell
, void, (void));
959 _GL_CXXALIAS_SYS (setusershell
, void, (void));
960 _GL_CXXALIASWARN (setusershell
);
961 #elif defined GNULIB_POSIXCHECK
963 # if HAVE_RAW_DECL_SETUSERSHELL
964 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
965 "use gnulib module getusershell for portability");
969 #if @GNULIB_GETUSERSHELL@
970 /* Free the pointer that is advanced at each getusershell() call and
971 associated resources. */
972 # if !@HAVE_DECL_GETUSERSHELL@
973 _GL_FUNCDECL_SYS (endusershell
, void, (void));
975 _GL_CXXALIAS_SYS (endusershell
, void, (void));
976 _GL_CXXALIASWARN (endusershell
);
977 #elif defined GNULIB_POSIXCHECK
979 # if HAVE_RAW_DECL_ENDUSERSHELL
980 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
981 "use gnulib module getusershell for portability");
986 #if @GNULIB_GROUP_MEMBER@
987 /* Determine whether group id is in calling user's group list. */
988 # if !@HAVE_GROUP_MEMBER@
989 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
991 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
992 _GL_CXXALIASWARN (group_member
);
993 #elif defined GNULIB_POSIXCHECK
995 # if HAVE_RAW_DECL_GROUP_MEMBER
996 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
997 "use gnulib module group-member for portability");
1003 # if @REPLACE_ISATTY@
1004 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1006 # define isatty rpl_isatty
1008 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
1009 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
1011 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
1013 _GL_CXXALIASWARN (isatty
);
1014 #elif defined GNULIB_POSIXCHECK
1016 # if HAVE_RAW_DECL_ISATTY
1017 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
1018 "use gnulib module isatty for portability");
1024 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1025 to GID (if GID is not -1). Do not follow symbolic links.
1026 Return 0 if successful, otherwise -1 and errno set.
1027 See the POSIX:2008 specification
1028 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1029 # if @REPLACE_LCHOWN@
1030 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1032 # define lchown rpl_lchown
1034 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1035 _GL_ARG_NONNULL ((1)));
1036 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1039 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1040 _GL_ARG_NONNULL ((1)));
1042 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1044 _GL_CXXALIASWARN (lchown
);
1045 #elif defined GNULIB_POSIXCHECK
1047 # if HAVE_RAW_DECL_LCHOWN
1048 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1049 "use gnulib module lchown for portability");
1055 /* Create a new hard link for an existing file.
1056 Return 0 if successful, otherwise -1 and errno set.
1057 See POSIX:2008 specification
1058 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1060 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1061 # define link rpl_link
1063 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1064 _GL_ARG_NONNULL ((1, 2)));
1065 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1068 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1069 _GL_ARG_NONNULL ((1, 2)));
1071 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1073 _GL_CXXALIASWARN (link
);
1074 #elif defined GNULIB_POSIXCHECK
1076 # if HAVE_RAW_DECL_LINK
1077 _GL_WARN_ON_USE (link
, "link is unportable - "
1078 "use gnulib module link for portability");
1084 /* Create a new hard link for an existing file, relative to two
1085 directories. FLAG controls whether symlinks are followed.
1086 Return 0 if successful, otherwise -1 and errno set. */
1087 # if @REPLACE_LINKAT@
1088 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1090 # define linkat rpl_linkat
1092 _GL_FUNCDECL_RPL (linkat
, int,
1093 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1095 _GL_ARG_NONNULL ((2, 4)));
1096 _GL_CXXALIAS_RPL (linkat
, int,
1097 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1101 _GL_FUNCDECL_SYS (linkat
, int,
1102 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1104 _GL_ARG_NONNULL ((2, 4)));
1106 _GL_CXXALIAS_SYS (linkat
, int,
1107 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1110 _GL_CXXALIASWARN (linkat
);
1111 #elif defined GNULIB_POSIXCHECK
1113 # if HAVE_RAW_DECL_LINKAT
1114 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1115 "use gnulib module linkat for portability");
1121 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1122 Return the new offset if successful, otherwise -1 and errno set.
1123 See the POSIX:2008 specification
1124 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1125 # if @REPLACE_LSEEK@
1126 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1127 # define lseek rpl_lseek
1129 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1130 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1132 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1134 _GL_CXXALIASWARN (lseek
);
1135 #elif defined GNULIB_POSIXCHECK
1137 # if HAVE_RAW_DECL_LSEEK
1138 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1139 "systems - use gnulib module lseek for portability");
1145 /* Create a pipe, defaulting to O_BINARY mode.
1146 Store the read-end as fd[0] and the write-end as fd[1].
1147 Return 0 upon success, or -1 with errno set upon failure. */
1149 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1151 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1152 _GL_CXXALIASWARN (pipe
);
1153 #elif defined GNULIB_POSIXCHECK
1155 # if HAVE_RAW_DECL_PIPE
1156 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1157 "use gnulib module pipe-posix for portability");
1163 /* Create a pipe, applying the given flags when opening the read-end of the
1164 pipe and the write-end of the pipe.
1165 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1166 and O_TEXT, O_BINARY (defined in "binary-io.h").
1167 Store the read-end as fd[0] and the write-end as fd[1].
1168 Return 0 upon success, or -1 with errno set upon failure.
1169 See also the Linux man page at
1170 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1172 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1173 # define pipe2 rpl_pipe2
1175 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1176 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1178 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1179 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1181 _GL_CXXALIASWARN (pipe2
);
1182 #elif defined GNULIB_POSIXCHECK
1184 # if HAVE_RAW_DECL_PIPE2
1185 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1186 "use gnulib module pipe2 for portability");
1192 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1193 Return the number of bytes placed into BUF if successful, otherwise
1194 set errno and return -1. 0 indicates EOF.
1195 See the POSIX:2008 specification
1196 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1197 # if @REPLACE_PREAD@
1198 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1200 # define pread rpl_pread
1202 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1203 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1204 _GL_ARG_NONNULL ((2)));
1205 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1206 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1209 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1210 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1211 _GL_ARG_NONNULL ((2)));
1213 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1214 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1216 _GL_CXXALIASWARN (pread
);
1217 #elif defined GNULIB_POSIXCHECK
1219 # if HAVE_RAW_DECL_PREAD
1220 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1221 "use gnulib module pread for portability");
1227 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1228 Return the number of bytes written if successful, otherwise
1229 set errno and return -1. 0 indicates nothing written. See the
1230 POSIX:2008 specification
1231 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1232 # if @REPLACE_PWRITE@
1233 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1235 # define pwrite rpl_pwrite
1237 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1238 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1239 _GL_ARG_NONNULL ((2)));
1240 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1241 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1244 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1245 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1246 _GL_ARG_NONNULL ((2)));
1248 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1249 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1251 _GL_CXXALIASWARN (pwrite
);
1252 #elif defined GNULIB_POSIXCHECK
1254 # if HAVE_RAW_DECL_PWRITE
1255 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1256 "use gnulib module pwrite for portability");
1262 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1263 at BUF. See the POSIX:2008 specification
1264 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1266 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1268 # define read rpl_read
1270 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1271 _GL_ARG_NONNULL ((2)));
1272 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1274 /* Need to cast, because on mingw, the third parameter is
1276 and the return type is 'int'. */
1277 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1279 _GL_CXXALIASWARN (read
);
1283 #if @GNULIB_READLINK@
1284 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1285 bytes of it into BUF. Return the number of bytes placed into BUF if
1286 successful, otherwise -1 and errno set.
1287 See the POSIX:2008 specification
1288 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1289 # if @REPLACE_READLINK@
1290 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1291 # define readlink rpl_readlink
1293 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1294 (const char *file
, char *buf
, size_t bufsize
)
1295 _GL_ARG_NONNULL ((1, 2)));
1296 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1297 (const char *file
, char *buf
, size_t bufsize
));
1299 # if !@HAVE_READLINK@
1300 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1301 (const char *file
, char *buf
, size_t bufsize
)
1302 _GL_ARG_NONNULL ((1, 2)));
1304 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1305 (const char *file
, char *buf
, size_t bufsize
));
1307 _GL_CXXALIASWARN (readlink
);
1308 #elif defined GNULIB_POSIXCHECK
1310 # if HAVE_RAW_DECL_READLINK
1311 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1312 "use gnulib module readlink for portability");
1317 #if @GNULIB_READLINKAT@
1318 # if @REPLACE_READLINKAT@
1319 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1320 # define readlinkat rpl_readlinkat
1322 _GL_FUNCDECL_RPL (readlinkat
, ssize_t
,
1323 (int fd
, char const *file
, char *buf
, size_t len
)
1324 _GL_ARG_NONNULL ((2, 3)));
1325 _GL_CXXALIAS_RPL (readlinkat
, ssize_t
,
1326 (int fd
, char const *file
, char *buf
, size_t len
));
1328 # if !@HAVE_READLINKAT@
1329 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1330 (int fd
, char const *file
, char *buf
, size_t len
)
1331 _GL_ARG_NONNULL ((2, 3)));
1333 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1334 (int fd
, char const *file
, char *buf
, size_t len
));
1336 _GL_CXXALIASWARN (readlinkat
);
1337 #elif defined GNULIB_POSIXCHECK
1339 # if HAVE_RAW_DECL_READLINKAT
1340 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1341 "use gnulib module readlinkat for portability");
1347 /* Remove the directory DIR. */
1348 # if @REPLACE_RMDIR@
1349 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1350 # define rmdir rpl_rmdir
1352 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1353 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1355 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1357 _GL_CXXALIASWARN (rmdir
);
1358 #elif defined GNULIB_POSIXCHECK
1360 # if HAVE_RAW_DECL_RMDIR
1361 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1362 "use gnulib module rmdir for portability");
1367 #if @GNULIB_SETHOSTNAME@
1368 /* Set the host name of the machine.
1369 The host name may or may not be fully qualified.
1371 Put LEN bytes of NAME into the host name.
1372 Return 0 if successful, otherwise, set errno and return -1.
1374 Platforms with no ability to set the hostname return -1 and set
1376 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1377 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1378 _GL_ARG_NONNULL ((1)));
1380 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1381 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1382 2011-10, the first parameter is not const. */
1383 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1384 _GL_CXXALIASWARN (sethostname
);
1385 #elif defined GNULIB_POSIXCHECK
1387 # if HAVE_RAW_DECL_SETHOSTNAME
1388 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1389 "use gnulib module sethostname for portability");
1395 /* Pause the execution of the current thread for N seconds.
1396 Returns the number of seconds left to sleep.
1397 See the POSIX:2008 specification
1398 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1399 # if @REPLACE_SLEEP@
1400 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1402 # define sleep rpl_sleep
1404 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1405 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1408 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1410 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1412 _GL_CXXALIASWARN (sleep
);
1413 #elif defined GNULIB_POSIXCHECK
1415 # if HAVE_RAW_DECL_SLEEP
1416 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1417 "use gnulib module sleep for portability");
1422 #if @GNULIB_SYMLINK@
1423 # if @REPLACE_SYMLINK@
1424 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1426 # define symlink rpl_symlink
1428 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1429 _GL_ARG_NONNULL ((1, 2)));
1430 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1432 # if !@HAVE_SYMLINK@
1433 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1434 _GL_ARG_NONNULL ((1, 2)));
1436 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1438 _GL_CXXALIASWARN (symlink
);
1439 #elif defined GNULIB_POSIXCHECK
1441 # if HAVE_RAW_DECL_SYMLINK
1442 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1443 "use gnulib module symlink for portability");
1448 #if @GNULIB_SYMLINKAT@
1449 # if @REPLACE_SYMLINKAT@
1450 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1452 # define symlinkat rpl_symlinkat
1454 _GL_FUNCDECL_RPL (symlinkat
, int,
1455 (char const *contents
, int fd
, char const *file
)
1456 _GL_ARG_NONNULL ((1, 3)));
1457 _GL_CXXALIAS_RPL (symlinkat
, int,
1458 (char const *contents
, int fd
, char const *file
));
1460 # if !@HAVE_SYMLINKAT@
1461 _GL_FUNCDECL_SYS (symlinkat
, int,
1462 (char const *contents
, int fd
, char const *file
)
1463 _GL_ARG_NONNULL ((1, 3)));
1465 _GL_CXXALIAS_SYS (symlinkat
, int,
1466 (char const *contents
, int fd
, char const *file
));
1468 _GL_CXXALIASWARN (symlinkat
);
1469 #elif defined GNULIB_POSIXCHECK
1471 # if HAVE_RAW_DECL_SYMLINKAT
1472 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1473 "use gnulib module symlinkat for portability");
1478 #if @GNULIB_TRUNCATE@
1479 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
1480 Return 0 if successful, otherwise -1 and errno set.
1481 See the POSIX:2008 specification
1482 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
1483 # if @REPLACE_TRUNCATE@
1484 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1486 # define truncate rpl_truncate
1488 _GL_FUNCDECL_RPL (truncate
, int, (const char *filename
, off_t length
)
1489 _GL_ARG_NONNULL ((1)));
1490 _GL_CXXALIAS_RPL (truncate
, int, (const char *filename
, off_t length
));
1492 # if !@HAVE_TRUNCATE@
1493 _GL_FUNCDECL_SYS (truncate
, int, (const char *filename
, off_t length
)
1494 _GL_ARG_NONNULL ((1)));
1496 _GL_CXXALIAS_SYS (truncate
, int, (const char *filename
, off_t length
));
1498 _GL_CXXALIASWARN (truncate
);
1499 #elif defined GNULIB_POSIXCHECK
1501 # if HAVE_RAW_DECL_TRUNCATE
1502 _GL_WARN_ON_USE (truncate
, "truncate is unportable - "
1503 "use gnulib module truncate for portability");
1508 #if @GNULIB_TTYNAME_R@
1509 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1510 open on in BUF. Return 0 on success, otherwise an error number. */
1511 # if @REPLACE_TTYNAME_R@
1512 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1514 # define ttyname_r rpl_ttyname_r
1516 _GL_FUNCDECL_RPL (ttyname_r
, int,
1517 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1518 _GL_CXXALIAS_RPL (ttyname_r
, int,
1519 (int fd
, char *buf
, size_t buflen
));
1521 # if !@HAVE_DECL_TTYNAME_R@
1522 _GL_FUNCDECL_SYS (ttyname_r
, int,
1523 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1525 _GL_CXXALIAS_SYS (ttyname_r
, int,
1526 (int fd
, char *buf
, size_t buflen
));
1528 _GL_CXXALIASWARN (ttyname_r
);
1529 #elif defined GNULIB_POSIXCHECK
1531 # if HAVE_RAW_DECL_TTYNAME_R
1532 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1533 "use gnulib module ttyname_r for portability");
1539 # if @REPLACE_UNLINK@
1540 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1542 # define unlink rpl_unlink
1544 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1545 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1547 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1549 _GL_CXXALIASWARN (unlink
);
1550 #elif defined GNULIB_POSIXCHECK
1552 # if HAVE_RAW_DECL_UNLINK
1553 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1554 "use gnulib module unlink for portability");
1559 #if @GNULIB_UNLINKAT@
1560 # if @REPLACE_UNLINKAT@
1561 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1563 # define unlinkat rpl_unlinkat
1565 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1566 _GL_ARG_NONNULL ((2)));
1567 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1569 # if !@HAVE_UNLINKAT@
1570 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1571 _GL_ARG_NONNULL ((2)));
1573 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1575 _GL_CXXALIASWARN (unlinkat
);
1576 #elif defined GNULIB_POSIXCHECK
1578 # if HAVE_RAW_DECL_UNLINKAT
1579 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1580 "use gnulib module openat for portability");
1586 /* Pause the execution of the current thread for N microseconds.
1587 Returns 0 on completion, or -1 on range error.
1588 See the POSIX:2001 specification
1589 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1590 # if @REPLACE_USLEEP@
1591 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1593 # define usleep rpl_usleep
1595 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1596 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1599 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1601 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1603 _GL_CXXALIASWARN (usleep
);
1604 #elif defined GNULIB_POSIXCHECK
1606 # if HAVE_RAW_DECL_USLEEP
1607 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1608 "use gnulib module usleep for portability");
1614 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1615 See the POSIX:2008 specification
1616 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1617 # if @REPLACE_WRITE@
1618 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1620 # define write rpl_write
1622 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1623 _GL_ARG_NONNULL ((2)));
1624 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1626 /* Need to cast, because on mingw, the third parameter is
1628 and the return type is 'int'. */
1629 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1631 _GL_CXXALIASWARN (write
);
1634 _GL_INLINE_HEADER_END
1636 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1637 #endif /* _GL_INCLUDING_UNISTD_H */
1638 #endif /* _@GUARD_PREFIX@_UNISTD_H */