1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2019 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 2, 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 __CYGWIN__)) \
65 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
66 && defined __CYGWIN__)) \
67 && ! defined __GLIBC__
71 /* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
73 /* But avoid namespace pollution on glibc systems. */
74 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
75 && (defined __CYGWIN__ || defined __ANDROID__) \
76 && ! defined __GLIBC__
80 /* mingw fails to declare _exit in <unistd.h>. */
81 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
83 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
84 /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
86 /* But avoid namespace pollution on glibc systems. */
87 #if !defined __GLIBC__ && !defined __osf__
88 # define __need_system_stdlib_h
90 # undef __need_system_stdlib_h
93 /* Native Windows platforms declare chdir, getcwd, rmdir in
94 <io.h> and/or <direct.h>, not in <unistd.h>.
95 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
96 lseek(), read(), unlink(), write() in <io.h>. */
97 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
98 || defined GNULIB_POSIXCHECK) \
99 && (defined _WIN32 && ! defined __CYGWIN__))
100 # include <io.h> /* mingw32, mingw64 */
101 # include <direct.h> /* mingw64, MSVC 9 */
102 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
103 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
104 || defined GNULIB_POSIXCHECK) \
105 && (defined _WIN32 && ! defined __CYGWIN__)
109 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
110 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
111 /* But avoid namespace pollution on glibc systems. */
112 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
113 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
114 && !defined __GLIBC__
118 /* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>. */
119 /* But avoid namespace pollution on glibc systems. */
120 #if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
121 && !defined __GLIBC__
122 # include <sys/stat.h>
125 /* MSVC defines off_t in <sys/types.h>.
126 May also define off_t to a 64-bit type on native Windows. */
127 #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
129 # include <sys/types.h>
132 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
133 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
134 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
136 # include <sys/types.h>
139 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
141 /* The definition of _GL_ARG_NONNULL is copied here. */
143 /* The definition of _GL_WARN_ON_USE is copied here. */
146 /* Get getopt(), optarg, optind, opterr, optopt. */
147 #if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
148 # include <getopt-cdefs.h>
149 # include <getopt-pfx-core.h>
152 #ifndef _GL_INLINE_HEADER_BEGIN
153 #error "Please include config.h first."
155 _GL_INLINE_HEADER_BEGIN
156 #ifndef _GL_UNISTD_INLINE
157 # define _GL_UNISTD_INLINE _GL_INLINE
160 /* Hide some function declarations from <winsock2.h>. */
162 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
163 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
164 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
166 # define socket socket_used_without_including_sys_socket_h
168 # define connect connect_used_without_including_sys_socket_h
170 # define accept accept_used_without_including_sys_socket_h
172 # define bind bind_used_without_including_sys_socket_h
174 # define getpeername getpeername_used_without_including_sys_socket_h
176 # define getsockname getsockname_used_without_including_sys_socket_h
178 # define getsockopt getsockopt_used_without_including_sys_socket_h
180 # define listen listen_used_without_including_sys_socket_h
182 # define recv recv_used_without_including_sys_socket_h
184 # define send send_used_without_including_sys_socket_h
186 # define recvfrom recvfrom_used_without_including_sys_socket_h
188 # define sendto sendto_used_without_including_sys_socket_h
190 # define setsockopt setsockopt_used_without_including_sys_socket_h
192 # define shutdown shutdown_used_without_including_sys_socket_h
194 _GL_WARN_ON_USE (socket
,
195 "socket() used without including <sys/socket.h>");
196 _GL_WARN_ON_USE (connect
,
197 "connect() used without including <sys/socket.h>");
198 _GL_WARN_ON_USE (accept
,
199 "accept() used without including <sys/socket.h>");
200 _GL_WARN_ON_USE (bind
,
201 "bind() used without including <sys/socket.h>");
202 _GL_WARN_ON_USE (getpeername
,
203 "getpeername() used without including <sys/socket.h>");
204 _GL_WARN_ON_USE (getsockname
,
205 "getsockname() used without including <sys/socket.h>");
206 _GL_WARN_ON_USE (getsockopt
,
207 "getsockopt() used without including <sys/socket.h>");
208 _GL_WARN_ON_USE (listen
,
209 "listen() used without including <sys/socket.h>");
210 _GL_WARN_ON_USE (recv
,
211 "recv() used without including <sys/socket.h>");
212 _GL_WARN_ON_USE (send
,
213 "send() used without including <sys/socket.h>");
214 _GL_WARN_ON_USE (recvfrom
,
215 "recvfrom() used without including <sys/socket.h>");
216 _GL_WARN_ON_USE (sendto
,
217 "sendto() used without including <sys/socket.h>");
218 _GL_WARN_ON_USE (setsockopt
,
219 "setsockopt() used without including <sys/socket.h>");
220 _GL_WARN_ON_USE (shutdown
,
221 "shutdown() used without including <sys/socket.h>");
224 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
225 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
227 # define select select_used_without_including_sys_select_h
229 _GL_WARN_ON_USE (select
,
230 "select() used without including <sys/select.h>");
236 /* OS/2 EMX lacks these macros. */
238 # define STDIN_FILENO 0
240 #ifndef STDOUT_FILENO
241 # define STDOUT_FILENO 1
243 #ifndef STDERR_FILENO
244 # define STDERR_FILENO 2
247 /* Ensure *_OK macros exist. */
256 /* Declare overridden functions. */
259 #if defined GNULIB_POSIXCHECK
260 /* The access() function is a security risk. */
261 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
262 "use the gnulib module faccessat instead");
267 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
268 _GL_CXXALIASWARN (chdir
);
269 #elif defined GNULIB_POSIXCHECK
271 # if HAVE_RAW_DECL_CHDIR
272 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
273 "use gnulib module chdir for portability");
279 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
280 to GID (if GID is not -1). Follow symbolic links.
281 Return 0 if successful, otherwise -1 and errno set.
282 See the POSIX:2008 specification
283 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
285 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
287 # define chown rpl_chown
289 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
290 _GL_ARG_NONNULL ((1)));
291 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
294 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
295 _GL_ARG_NONNULL ((1)));
297 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
299 _GL_CXXALIASWARN (chown
);
300 #elif defined GNULIB_POSIXCHECK
302 # if HAVE_RAW_DECL_CHOWN
303 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
304 "doesn't treat a uid or gid of -1 on some systems - "
305 "use gnulib module chown for portability");
312 /* Automatically included by modules that need a replacement for close. */
313 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
315 # define close rpl_close
317 _GL_FUNCDECL_RPL (close
, int, (int fd
));
318 _GL_CXXALIAS_RPL (close
, int, (int fd
));
320 _GL_CXXALIAS_SYS (close
, int, (int fd
));
322 _GL_CXXALIASWARN (close
);
323 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
325 # define close close_used_without_requesting_gnulib_module_close
326 #elif defined GNULIB_POSIXCHECK
328 /* Assume close is always declared. */
329 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
330 "use gnulib module close for portability");
336 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
339 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
340 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
342 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
344 _GL_CXXALIASWARN (dup
);
345 #elif defined GNULIB_POSIXCHECK
347 # if HAVE_RAW_DECL_DUP
348 _GL_WARN_ON_USE (dup
, "dup is unportable - "
349 "use gnulib module dup for portability");
355 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
356 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
357 Return newfd if successful, otherwise -1 and errno set.
358 See the POSIX:2008 specification
359 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
361 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
362 # define dup2 rpl_dup2
364 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
365 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
368 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
370 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
372 _GL_CXXALIASWARN (dup2
);
373 #elif defined GNULIB_POSIXCHECK
375 # if HAVE_RAW_DECL_DUP2
376 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
377 "use gnulib module dup2 for portability");
383 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
385 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
386 and O_TEXT, O_BINARY (defined in "binary-io.h").
387 Close NEWFD first if it is open.
388 Return newfd if successful, otherwise -1 and errno set.
389 See the Linux man page at
390 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
392 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
393 # define dup3 rpl_dup3
395 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
396 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
398 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
399 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
401 _GL_CXXALIASWARN (dup3
);
402 #elif defined GNULIB_POSIXCHECK
404 # if HAVE_RAW_DECL_DUP3
405 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
406 "use gnulib module dup3 for portability");
412 # if defined __CYGWIN__ && !defined __i386__
413 /* The 'environ' variable is defined in a DLL. Therefore its declaration needs
414 the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
415 This leads to a link error on 64-bit Cygwin when the option
416 -Wl,--disable-auto-import is in use. */
417 _GL_EXTERN_C
__declspec(dllimport
) char **environ
;
419 # if !@HAVE_DECL_ENVIRON@
420 /* Set of environment variables and values. An array of strings of the form
421 "VARIABLE=VALUE", terminated with a NULL. */
422 # if defined __APPLE__ && defined __MACH__
423 # include <TargetConditionals.h>
424 # if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
425 # define _GL_USE_CRT_EXTERNS
428 # ifdef _GL_USE_CRT_EXTERNS
429 # include <crt_externs.h>
430 # define environ (*_NSGetEnviron ())
435 extern char **environ
;
441 #elif defined GNULIB_POSIXCHECK
442 # if HAVE_RAW_DECL_ENVIRON
443 _GL_UNISTD_INLINE
char ***
444 _GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
445 "use gnulib module environ for portability")
451 # define environ (*rpl_environ ())
456 #if @GNULIB_EUIDACCESS@
457 /* Like access(), except that it uses the effective user id and group id of
458 the current process. */
459 # if !@HAVE_EUIDACCESS@
460 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
461 _GL_ARG_NONNULL ((1)));
463 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
464 _GL_CXXALIASWARN (euidaccess
);
465 # if defined GNULIB_POSIXCHECK
466 /* Like access(), this function is a security risk. */
467 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
468 "use the gnulib module faccessat instead");
470 #elif defined GNULIB_POSIXCHECK
472 # if HAVE_RAW_DECL_EUIDACCESS
473 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
474 "use gnulib module euidaccess for portability");
479 #if @GNULIB_FACCESSAT@
480 # if @REPLACE_FACCESSAT@
481 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
483 # define faccessat rpl_faccessat
485 _GL_FUNCDECL_RPL (faccessat
, int,
486 (int fd
, char const *name
, int mode
, int flag
)
487 _GL_ARG_NONNULL ((2)));
488 _GL_CXXALIAS_RPL (faccessat
, int,
489 (int fd
, char const *name
, int mode
, int flag
));
491 # if !@HAVE_FACCESSAT@
492 _GL_FUNCDECL_SYS (faccessat
, int,
493 (int fd
, char const *file
, int mode
, int flag
)
494 _GL_ARG_NONNULL ((2)));
496 _GL_CXXALIAS_SYS (faccessat
, int,
497 (int fd
, char const *file
, int mode
, int flag
));
499 _GL_CXXALIASWARN (faccessat
);
500 #elif defined GNULIB_POSIXCHECK
502 # if HAVE_RAW_DECL_FACCESSAT
503 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
504 "use gnulib module faccessat for portability");
510 /* Change the process' current working directory to the directory on which
511 the given file descriptor is open.
512 Return 0 if successful, otherwise -1 and errno set.
513 See the POSIX:2008 specification
514 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
516 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
518 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
519 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
520 _GL_ARG_NONNULL ((2));
521 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
522 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
523 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
526 # if !@HAVE_DECL_FCHDIR@
527 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
530 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
531 _GL_CXXALIASWARN (fchdir
);
532 #elif defined GNULIB_POSIXCHECK
534 # if HAVE_RAW_DECL_FCHDIR
535 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
536 "use gnulib module fchdir for portability");
541 #if @GNULIB_FCHOWNAT@
542 # if @REPLACE_FCHOWNAT@
543 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
545 # define fchownat rpl_fchownat
547 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
548 uid_t owner
, gid_t group
, int flag
)
549 _GL_ARG_NONNULL ((2)));
550 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
551 uid_t owner
, gid_t group
, int flag
));
553 # if !@HAVE_FCHOWNAT@
554 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
555 uid_t owner
, gid_t group
, int flag
)
556 _GL_ARG_NONNULL ((2)));
558 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
559 uid_t owner
, gid_t group
, int flag
));
561 _GL_CXXALIASWARN (fchownat
);
562 #elif defined GNULIB_POSIXCHECK
564 # if HAVE_RAW_DECL_FCHOWNAT
565 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
566 "use gnulib module openat for portability");
571 #if @GNULIB_FDATASYNC@
572 /* Synchronize changes to a file.
573 Return 0 if successful, otherwise -1 and errno set.
574 See POSIX:2008 specification
575 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
576 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
577 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
579 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
580 _GL_CXXALIASWARN (fdatasync
);
581 #elif defined GNULIB_POSIXCHECK
583 # if HAVE_RAW_DECL_FDATASYNC
584 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
585 "use gnulib module fdatasync for portability");
591 /* Synchronize changes, including metadata, to a file.
592 Return 0 if successful, otherwise -1 and errno set.
593 See POSIX:2008 specification
594 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
596 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
598 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
599 _GL_CXXALIASWARN (fsync
);
600 #elif defined GNULIB_POSIXCHECK
602 # if HAVE_RAW_DECL_FSYNC
603 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
604 "use gnulib module fsync for portability");
609 #if @GNULIB_FTRUNCATE@
610 /* Change the size of the file to which FD is opened to become equal to LENGTH.
611 Return 0 if successful, otherwise -1 and errno set.
612 See the POSIX:2008 specification
613 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
614 # if @REPLACE_FTRUNCATE@
615 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
617 # define ftruncate rpl_ftruncate
619 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
620 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
622 # if !@HAVE_FTRUNCATE@
623 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
625 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
627 _GL_CXXALIASWARN (ftruncate
);
628 #elif defined GNULIB_POSIXCHECK
630 # if HAVE_RAW_DECL_FTRUNCATE
631 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
632 "use gnulib module ftruncate for portability");
638 /* Get the name of the current working directory, and put it in SIZE bytes
640 Return BUF if successful, or NULL if the directory couldn't be determined
641 or SIZE was too small.
642 See the POSIX:2008 specification
643 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
644 Additionally, the gnulib module 'getcwd' guarantees the following GNU
645 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
646 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
648 # if @REPLACE_GETCWD@
649 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
650 # define getcwd rpl_getcwd
652 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
653 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
655 /* Need to cast, because on mingw, the second parameter is
657 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
659 _GL_CXXALIASWARN (getcwd
);
660 #elif defined GNULIB_POSIXCHECK
662 # if HAVE_RAW_DECL_GETCWD
663 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
664 "use gnulib module getcwd for portability");
669 #if @GNULIB_GETDOMAINNAME@
670 /* Return the NIS domain name of the machine.
671 WARNING! The NIS domain name is unrelated to the fully qualified host name
672 of the machine. It is also unrelated to email addresses.
673 WARNING! The NIS domain name is usually the empty string or "(none)" when
676 Put up to LEN bytes of the NIS domain name into NAME.
677 Null terminate it if the name is shorter than LEN.
678 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
679 Return 0 if successful, otherwise set errno and return -1. */
680 # if @REPLACE_GETDOMAINNAME@
681 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
682 # undef getdomainname
683 # define getdomainname rpl_getdomainname
685 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
686 _GL_ARG_NONNULL ((1)));
687 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
689 # if !@HAVE_DECL_GETDOMAINNAME@
690 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
691 _GL_ARG_NONNULL ((1)));
693 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
695 _GL_CXXALIASWARN (getdomainname
);
696 #elif defined GNULIB_POSIXCHECK
697 # undef getdomainname
698 # if HAVE_RAW_DECL_GETDOMAINNAME
699 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
700 "use gnulib module getdomainname for portability");
705 #if @GNULIB_GETDTABLESIZE@
706 /* Return the maximum number of file descriptors in the current process.
707 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
708 # if @REPLACE_GETDTABLESIZE@
709 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
710 # undef getdtablesize
711 # define getdtablesize rpl_getdtablesize
713 _GL_FUNCDECL_RPL (getdtablesize
, int, (void));
714 _GL_CXXALIAS_RPL (getdtablesize
, int, (void));
716 # if !@HAVE_GETDTABLESIZE@
717 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
719 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
721 _GL_CXXALIASWARN (getdtablesize
);
722 #elif defined GNULIB_POSIXCHECK
723 # undef getdtablesize
724 # if HAVE_RAW_DECL_GETDTABLESIZE
725 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
726 "use gnulib module getdtablesize for portability");
731 #if @GNULIB_GETGROUPS@
732 /* Return the supplemental groups that the current process belongs to.
733 It is unspecified whether the effective group id is in the list.
734 If N is 0, return the group count; otherwise, N describes how many
735 entries are available in GROUPS. Return -1 and set errno if N is
736 not 0 and not large enough. Fails with ENOSYS on some systems. */
737 # if @REPLACE_GETGROUPS@
738 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
740 # define getgroups rpl_getgroups
742 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
743 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
745 # if !@HAVE_GETGROUPS@
746 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
748 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
750 _GL_CXXALIASWARN (getgroups
);
751 #elif defined GNULIB_POSIXCHECK
753 # if HAVE_RAW_DECL_GETGROUPS
754 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
755 "use gnulib module getgroups for portability");
760 #if @GNULIB_GETHOSTNAME@
761 /* Return the standard host name of the machine.
762 WARNING! The host name may or may not be fully qualified.
764 Put up to LEN bytes of the host name into NAME.
765 Null terminate it if the name is shorter than LEN.
766 If the host name is longer than LEN, set errno = EINVAL and return -1.
767 Return 0 if successful, otherwise set errno and return -1. */
768 # if @UNISTD_H_HAVE_WINSOCK2_H@
769 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
771 # define gethostname rpl_gethostname
773 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
774 _GL_ARG_NONNULL ((1)));
775 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
777 # if !@HAVE_GETHOSTNAME@
778 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
779 _GL_ARG_NONNULL ((1)));
781 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
784 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
786 _GL_CXXALIASWARN (gethostname
);
787 #elif @UNISTD_H_HAVE_WINSOCK2_H@
789 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
790 #elif defined GNULIB_POSIXCHECK
792 # if HAVE_RAW_DECL_GETHOSTNAME
793 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
794 "use gnulib module gethostname for portability");
799 #if @GNULIB_GETLOGIN@
800 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
801 returns NULL with errno set.
803 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
805 Most programs don't need to use this function, because the information is
806 available through environment variables:
807 ${LOGNAME-$USER} on Unix platforms,
808 $USERNAME on native Windows platforms.
810 # if !@HAVE_DECL_GETLOGIN@
811 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
813 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
814 _GL_CXXALIASWARN (getlogin
);
815 #elif defined GNULIB_POSIXCHECK
817 # if HAVE_RAW_DECL_GETLOGIN
818 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
819 "use gnulib module getlogin for portability");
824 #if @GNULIB_GETLOGIN_R@
825 /* Copies the user's login name to NAME.
826 The array pointed to by NAME has room for SIZE bytes.
828 Returns 0 if successful. Upon error, an error number is returned, or -1 in
829 the case that the login name cannot be found but no specific error is
830 provided (this case is hopefully rare but is left open by the POSIX spec).
832 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
834 Most programs don't need to use this function, because the information is
835 available through environment variables:
836 ${LOGNAME-$USER} on Unix platforms,
837 $USERNAME on native Windows platforms.
839 # if @REPLACE_GETLOGIN_R@
840 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
841 # define getlogin_r rpl_getlogin_r
843 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
844 _GL_ARG_NONNULL ((1)));
845 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
847 # if !@HAVE_DECL_GETLOGIN_R@
848 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
849 _GL_ARG_NONNULL ((1)));
851 /* Need to cast, because on Solaris 10 systems, the second argument is
853 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
855 _GL_CXXALIASWARN (getlogin_r
);
856 #elif defined GNULIB_POSIXCHECK
858 # if HAVE_RAW_DECL_GETLOGIN_R
859 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
860 "use gnulib module getlogin_r for portability");
865 #if @GNULIB_GETPAGESIZE@
866 # if @REPLACE_GETPAGESIZE@
867 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
868 # define getpagesize rpl_getpagesize
870 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
871 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
873 # if !@HAVE_GETPAGESIZE@
874 # if !defined getpagesize
875 /* This is for POSIX systems. */
876 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
877 # if ! (defined __VMS && __VMS_VER < 70000000)
878 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
881 /* This is for older VMS. */
882 # if !defined _gl_getpagesize && defined __VMS
884 # define _gl_getpagesize() 8192
886 # define _gl_getpagesize() 512
889 /* This is for BeOS. */
890 # if !defined _gl_getpagesize && @HAVE_OS_H@
892 # if defined B_PAGE_SIZE
893 # define _gl_getpagesize() B_PAGE_SIZE
896 /* This is for AmigaOS4.0. */
897 # if !defined _gl_getpagesize && defined __amigaos4__
898 # define _gl_getpagesize() 2048
900 /* This is for older Unix systems. */
901 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
902 # include <sys/param.h>
903 # ifdef EXEC_PAGESIZE
904 # define _gl_getpagesize() EXEC_PAGESIZE
910 # define _gl_getpagesize() (NBPG * CLSIZE)
913 # define _gl_getpagesize() NBPC
918 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
919 # define getpagesize() _gl_getpagesize ()
921 # if !GNULIB_defined_getpagesize_function
922 _GL_UNISTD_INLINE
int
925 return _gl_getpagesize ();
927 # define GNULIB_defined_getpagesize_function 1
932 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
933 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
935 # if @HAVE_DECL_GETPAGESIZE@
936 _GL_CXXALIASWARN (getpagesize
);
938 #elif defined GNULIB_POSIXCHECK
940 # if HAVE_RAW_DECL_GETPAGESIZE
941 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
942 "use gnulib module getpagesize for portability");
948 /* Function getpass() from module 'getpass':
949 Read a password from /dev/tty or stdin.
950 Function getpass() from module 'getpass-gnu':
951 Read a password of arbitrary length from /dev/tty or stdin. */
952 # if @REPLACE_GETPASS@
953 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
955 # define getpass rpl_getpass
957 _GL_FUNCDECL_RPL (getpass
, char *, (const char *prompt
)
958 _GL_ARG_NONNULL ((1)));
959 _GL_CXXALIAS_RPL (getpass
, char *, (const char *prompt
));
962 _GL_FUNCDECL_SYS (getpass
, char *, (const char *prompt
)
963 _GL_ARG_NONNULL ((1)));
965 _GL_CXXALIAS_SYS (getpass
, char *, (const char *prompt
));
967 _GL_CXXALIASWARN (getpass
);
968 #elif defined GNULIB_POSIXCHECK
970 # if HAVE_RAW_DECL_GETPASS
971 _GL_WARN_ON_USE (getpass
, "getpass is unportable - "
972 "use gnulib module getpass or getpass-gnu for portability");
977 #if @GNULIB_GETUSERSHELL@
978 /* Return the next valid login shell on the system, or NULL when the end of
979 the list has been reached. */
980 # if !@HAVE_DECL_GETUSERSHELL@
981 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
983 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
984 _GL_CXXALIASWARN (getusershell
);
985 #elif defined GNULIB_POSIXCHECK
987 # if HAVE_RAW_DECL_GETUSERSHELL
988 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
989 "use gnulib module getusershell for portability");
993 #if @GNULIB_GETUSERSHELL@
994 /* Rewind to pointer that is advanced at each getusershell() call. */
995 # if !@HAVE_DECL_GETUSERSHELL@
996 _GL_FUNCDECL_SYS (setusershell
, void, (void));
998 _GL_CXXALIAS_SYS (setusershell
, void, (void));
999 _GL_CXXALIASWARN (setusershell
);
1000 #elif defined GNULIB_POSIXCHECK
1001 # undef setusershell
1002 # if HAVE_RAW_DECL_SETUSERSHELL
1003 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
1004 "use gnulib module getusershell for portability");
1008 #if @GNULIB_GETUSERSHELL@
1009 /* Free the pointer that is advanced at each getusershell() call and
1010 associated resources. */
1011 # if !@HAVE_DECL_GETUSERSHELL@
1012 _GL_FUNCDECL_SYS (endusershell
, void, (void));
1014 _GL_CXXALIAS_SYS (endusershell
, void, (void));
1015 _GL_CXXALIASWARN (endusershell
);
1016 #elif defined GNULIB_POSIXCHECK
1017 # undef endusershell
1018 # if HAVE_RAW_DECL_ENDUSERSHELL
1019 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
1020 "use gnulib module getusershell for portability");
1025 #if @GNULIB_GROUP_MEMBER@
1026 /* Determine whether group id is in calling user's group list. */
1027 # if !@HAVE_GROUP_MEMBER@
1028 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
1030 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
1031 _GL_CXXALIASWARN (group_member
);
1032 #elif defined GNULIB_POSIXCHECK
1033 # undef group_member
1034 # if HAVE_RAW_DECL_GROUP_MEMBER
1035 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
1036 "use gnulib module group-member for portability");
1042 # if @REPLACE_ISATTY@
1043 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1045 # define isatty rpl_isatty
1047 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
1048 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
1050 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
1052 _GL_CXXALIASWARN (isatty
);
1053 #elif defined GNULIB_POSIXCHECK
1055 # if HAVE_RAW_DECL_ISATTY
1056 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
1057 "use gnulib module isatty for portability");
1063 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1064 to GID (if GID is not -1). Do not follow symbolic links.
1065 Return 0 if successful, otherwise -1 and errno set.
1066 See the POSIX:2008 specification
1067 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1068 # if @REPLACE_LCHOWN@
1069 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1071 # define lchown rpl_lchown
1073 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1074 _GL_ARG_NONNULL ((1)));
1075 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1078 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1079 _GL_ARG_NONNULL ((1)));
1081 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1083 _GL_CXXALIASWARN (lchown
);
1084 #elif defined GNULIB_POSIXCHECK
1086 # if HAVE_RAW_DECL_LCHOWN
1087 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1088 "use gnulib module lchown for portability");
1094 /* Create a new hard link for an existing file.
1095 Return 0 if successful, otherwise -1 and errno set.
1096 See POSIX:2008 specification
1097 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1099 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1100 # define link rpl_link
1102 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1103 _GL_ARG_NONNULL ((1, 2)));
1104 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1107 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1108 _GL_ARG_NONNULL ((1, 2)));
1110 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1112 _GL_CXXALIASWARN (link
);
1113 #elif defined GNULIB_POSIXCHECK
1115 # if HAVE_RAW_DECL_LINK
1116 _GL_WARN_ON_USE (link
, "link is unportable - "
1117 "use gnulib module link for portability");
1123 /* Create a new hard link for an existing file, relative to two
1124 directories. FLAG controls whether symlinks are followed.
1125 Return 0 if successful, otherwise -1 and errno set. */
1126 # if @REPLACE_LINKAT@
1127 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1129 # define linkat rpl_linkat
1131 _GL_FUNCDECL_RPL (linkat
, int,
1132 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1134 _GL_ARG_NONNULL ((2, 4)));
1135 _GL_CXXALIAS_RPL (linkat
, int,
1136 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1140 _GL_FUNCDECL_SYS (linkat
, int,
1141 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1143 _GL_ARG_NONNULL ((2, 4)));
1145 _GL_CXXALIAS_SYS (linkat
, int,
1146 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1149 _GL_CXXALIASWARN (linkat
);
1150 #elif defined GNULIB_POSIXCHECK
1152 # if HAVE_RAW_DECL_LINKAT
1153 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1154 "use gnulib module linkat for portability");
1160 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1161 Return the new offset if successful, otherwise -1 and errno set.
1162 See the POSIX:2008 specification
1163 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1164 # if @REPLACE_LSEEK@
1165 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1166 # define lseek rpl_lseek
1168 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1169 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1171 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1173 _GL_CXXALIASWARN (lseek
);
1174 #elif defined GNULIB_POSIXCHECK
1176 # if HAVE_RAW_DECL_LSEEK
1177 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1178 "systems - use gnulib module lseek for portability");
1184 /* Create a pipe, defaulting to O_BINARY mode.
1185 Store the read-end as fd[0] and the write-end as fd[1].
1186 Return 0 upon success, or -1 with errno set upon failure. */
1188 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1190 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1191 _GL_CXXALIASWARN (pipe
);
1192 #elif defined GNULIB_POSIXCHECK
1194 # if HAVE_RAW_DECL_PIPE
1195 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1196 "use gnulib module pipe-posix for portability");
1202 /* Create a pipe, applying the given flags when opening the read-end of the
1203 pipe and the write-end of the pipe.
1204 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1205 and O_TEXT, O_BINARY (defined in "binary-io.h").
1206 Store the read-end as fd[0] and the write-end as fd[1].
1207 Return 0 upon success, or -1 with errno set upon failure.
1208 See also the Linux man page at
1209 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1211 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1212 # define pipe2 rpl_pipe2
1214 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1215 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1217 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1218 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1220 _GL_CXXALIASWARN (pipe2
);
1221 #elif defined GNULIB_POSIXCHECK
1223 # if HAVE_RAW_DECL_PIPE2
1224 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1225 "use gnulib module pipe2 for portability");
1231 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1232 Return the number of bytes placed into BUF if successful, otherwise
1233 set errno and return -1. 0 indicates EOF.
1234 See the POSIX:2008 specification
1235 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1236 # if @REPLACE_PREAD@
1237 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1239 # define pread rpl_pread
1241 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1242 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1243 _GL_ARG_NONNULL ((2)));
1244 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1245 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1248 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1249 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1250 _GL_ARG_NONNULL ((2)));
1252 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1253 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1255 _GL_CXXALIASWARN (pread
);
1256 #elif defined GNULIB_POSIXCHECK
1258 # if HAVE_RAW_DECL_PREAD
1259 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1260 "use gnulib module pread for portability");
1266 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1267 Return the number of bytes written if successful, otherwise
1268 set errno and return -1. 0 indicates nothing written. See the
1269 POSIX:2008 specification
1270 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1271 # if @REPLACE_PWRITE@
1272 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1274 # define pwrite rpl_pwrite
1276 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1277 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1278 _GL_ARG_NONNULL ((2)));
1279 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1280 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1283 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1284 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1285 _GL_ARG_NONNULL ((2)));
1287 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1288 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1290 _GL_CXXALIASWARN (pwrite
);
1291 #elif defined GNULIB_POSIXCHECK
1293 # if HAVE_RAW_DECL_PWRITE
1294 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1295 "use gnulib module pwrite for portability");
1301 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1302 at BUF. See the POSIX:2008 specification
1303 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1305 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1307 # define read rpl_read
1309 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1310 _GL_ARG_NONNULL ((2)));
1311 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1313 /* Need to cast, because on mingw, the third parameter is
1315 and the return type is 'int'. */
1316 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1318 _GL_CXXALIASWARN (read
);
1322 #if @GNULIB_READLINK@
1323 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1324 bytes of it into BUF. Return the number of bytes placed into BUF if
1325 successful, otherwise -1 and errno set.
1326 See the POSIX:2008 specification
1327 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1328 # if @REPLACE_READLINK@
1329 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1330 # define readlink rpl_readlink
1332 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1333 (const char *file
, char *buf
, size_t bufsize
)
1334 _GL_ARG_NONNULL ((1, 2)));
1335 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1336 (const char *file
, char *buf
, size_t bufsize
));
1338 # if !@HAVE_READLINK@
1339 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1340 (const char *file
, char *buf
, size_t bufsize
)
1341 _GL_ARG_NONNULL ((1, 2)));
1343 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1344 (const char *file
, char *buf
, size_t bufsize
));
1346 _GL_CXXALIASWARN (readlink
);
1347 #elif defined GNULIB_POSIXCHECK
1349 # if HAVE_RAW_DECL_READLINK
1350 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1351 "use gnulib module readlink for portability");
1356 #if @GNULIB_READLINKAT@
1357 # if @REPLACE_READLINKAT@
1358 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1359 # define readlinkat rpl_readlinkat
1361 _GL_FUNCDECL_RPL (readlinkat
, ssize_t
,
1362 (int fd
, char const *file
, char *buf
, size_t len
)
1363 _GL_ARG_NONNULL ((2, 3)));
1364 _GL_CXXALIAS_RPL (readlinkat
, ssize_t
,
1365 (int fd
, char const *file
, char *buf
, size_t len
));
1367 # if !@HAVE_READLINKAT@
1368 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1369 (int fd
, char const *file
, char *buf
, size_t len
)
1370 _GL_ARG_NONNULL ((2, 3)));
1372 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1373 (int fd
, char const *file
, char *buf
, size_t len
));
1375 _GL_CXXALIASWARN (readlinkat
);
1376 #elif defined GNULIB_POSIXCHECK
1378 # if HAVE_RAW_DECL_READLINKAT
1379 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1380 "use gnulib module readlinkat for portability");
1386 /* Remove the directory DIR. */
1387 # if @REPLACE_RMDIR@
1388 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1389 # define rmdir rpl_rmdir
1391 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1392 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1394 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1396 _GL_CXXALIASWARN (rmdir
);
1397 #elif defined GNULIB_POSIXCHECK
1399 # if HAVE_RAW_DECL_RMDIR
1400 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1401 "use gnulib module rmdir for portability");
1406 #if @GNULIB_SETHOSTNAME@
1407 /* Set the host name of the machine.
1408 The host name may or may not be fully qualified.
1410 Put LEN bytes of NAME into the host name.
1411 Return 0 if successful, otherwise, set errno and return -1.
1413 Platforms with no ability to set the hostname return -1 and set
1415 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1416 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1417 _GL_ARG_NONNULL ((1)));
1419 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1420 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1421 2011-10, the first parameter is not const. */
1422 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1423 _GL_CXXALIASWARN (sethostname
);
1424 #elif defined GNULIB_POSIXCHECK
1426 # if HAVE_RAW_DECL_SETHOSTNAME
1427 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1428 "use gnulib module sethostname for portability");
1434 /* Pause the execution of the current thread for N seconds.
1435 Returns the number of seconds left to sleep.
1436 See the POSIX:2008 specification
1437 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1438 # if @REPLACE_SLEEP@
1439 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1441 # define sleep rpl_sleep
1443 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1444 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1447 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1449 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1451 _GL_CXXALIASWARN (sleep
);
1452 #elif defined GNULIB_POSIXCHECK
1454 # if HAVE_RAW_DECL_SLEEP
1455 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1456 "use gnulib module sleep for portability");
1461 #if @GNULIB_SYMLINK@
1462 # if @REPLACE_SYMLINK@
1463 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1465 # define symlink rpl_symlink
1467 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1468 _GL_ARG_NONNULL ((1, 2)));
1469 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1471 # if !@HAVE_SYMLINK@
1472 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1473 _GL_ARG_NONNULL ((1, 2)));
1475 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1477 _GL_CXXALIASWARN (symlink
);
1478 #elif defined GNULIB_POSIXCHECK
1480 # if HAVE_RAW_DECL_SYMLINK
1481 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1482 "use gnulib module symlink for portability");
1487 #if @GNULIB_SYMLINKAT@
1488 # if @REPLACE_SYMLINKAT@
1489 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1491 # define symlinkat rpl_symlinkat
1493 _GL_FUNCDECL_RPL (symlinkat
, int,
1494 (char const *contents
, int fd
, char const *file
)
1495 _GL_ARG_NONNULL ((1, 3)));
1496 _GL_CXXALIAS_RPL (symlinkat
, int,
1497 (char const *contents
, int fd
, char const *file
));
1499 # if !@HAVE_SYMLINKAT@
1500 _GL_FUNCDECL_SYS (symlinkat
, int,
1501 (char const *contents
, int fd
, char const *file
)
1502 _GL_ARG_NONNULL ((1, 3)));
1504 _GL_CXXALIAS_SYS (symlinkat
, int,
1505 (char const *contents
, int fd
, char const *file
));
1507 _GL_CXXALIASWARN (symlinkat
);
1508 #elif defined GNULIB_POSIXCHECK
1510 # if HAVE_RAW_DECL_SYMLINKAT
1511 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1512 "use gnulib module symlinkat for portability");
1517 #if @GNULIB_TRUNCATE@
1518 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
1519 Return 0 if successful, otherwise -1 and errno set.
1520 See the POSIX:2008 specification
1521 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
1522 # if @REPLACE_TRUNCATE@
1523 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1525 # define truncate rpl_truncate
1527 _GL_FUNCDECL_RPL (truncate
, int, (const char *filename
, off_t length
)
1528 _GL_ARG_NONNULL ((1)));
1529 _GL_CXXALIAS_RPL (truncate
, int, (const char *filename
, off_t length
));
1531 # if !@HAVE_DECL_TRUNCATE@
1532 _GL_FUNCDECL_SYS (truncate
, int, (const char *filename
, off_t length
)
1533 _GL_ARG_NONNULL ((1)));
1535 _GL_CXXALIAS_SYS (truncate
, int, (const char *filename
, off_t length
));
1537 _GL_CXXALIASWARN (truncate
);
1538 #elif defined GNULIB_POSIXCHECK
1540 # if HAVE_RAW_DECL_TRUNCATE
1541 _GL_WARN_ON_USE (truncate
, "truncate is unportable - "
1542 "use gnulib module truncate for portability");
1547 #if @GNULIB_TTYNAME_R@
1548 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1549 open on in BUF. Return 0 on success, otherwise an error number. */
1550 # if @REPLACE_TTYNAME_R@
1551 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1553 # define ttyname_r rpl_ttyname_r
1555 _GL_FUNCDECL_RPL (ttyname_r
, int,
1556 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1557 _GL_CXXALIAS_RPL (ttyname_r
, int,
1558 (int fd
, char *buf
, size_t buflen
));
1560 # if !@HAVE_DECL_TTYNAME_R@
1561 _GL_FUNCDECL_SYS (ttyname_r
, int,
1562 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1564 _GL_CXXALIAS_SYS (ttyname_r
, int,
1565 (int fd
, char *buf
, size_t buflen
));
1567 _GL_CXXALIASWARN (ttyname_r
);
1568 #elif defined GNULIB_POSIXCHECK
1570 # if HAVE_RAW_DECL_TTYNAME_R
1571 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1572 "use gnulib module ttyname_r for portability");
1578 # if @REPLACE_UNLINK@
1579 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1581 # define unlink rpl_unlink
1583 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1584 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1586 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1588 _GL_CXXALIASWARN (unlink
);
1589 #elif defined GNULIB_POSIXCHECK
1591 # if HAVE_RAW_DECL_UNLINK
1592 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1593 "use gnulib module unlink for portability");
1598 #if @GNULIB_UNLINKAT@
1599 # if @REPLACE_UNLINKAT@
1600 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1602 # define unlinkat rpl_unlinkat
1604 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1605 _GL_ARG_NONNULL ((2)));
1606 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1608 # if !@HAVE_UNLINKAT@
1609 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1610 _GL_ARG_NONNULL ((2)));
1612 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1614 _GL_CXXALIASWARN (unlinkat
);
1615 #elif defined GNULIB_POSIXCHECK
1617 # if HAVE_RAW_DECL_UNLINKAT
1618 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1619 "use gnulib module openat for portability");
1625 /* Pause the execution of the current thread for N microseconds.
1626 Returns 0 on completion, or -1 on range error.
1627 See the POSIX:2001 specification
1628 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1629 # if @REPLACE_USLEEP@
1630 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1632 # define usleep rpl_usleep
1634 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1635 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1638 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1640 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1642 _GL_CXXALIASWARN (usleep
);
1643 #elif defined GNULIB_POSIXCHECK
1645 # if HAVE_RAW_DECL_USLEEP
1646 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1647 "use gnulib module usleep for portability");
1653 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1654 See the POSIX:2008 specification
1655 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1656 # if @REPLACE_WRITE@
1657 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1659 # define write rpl_write
1661 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1662 _GL_ARG_NONNULL ((2)));
1663 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1665 /* Need to cast, because on mingw, the third parameter is
1667 and the return type is 'int'. */
1668 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1670 _GL_CXXALIASWARN (write
);
1673 _GL_INLINE_HEADER_END
1675 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1676 #endif /* _GL_INCLUDING_UNISTD_H */
1677 #endif /* _@GUARD_PREFIX@_UNISTD_H */