1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2013 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18 @PRAGMA_SYSTEM_HEADER@
22 /* Special invocation convention:
23 - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
24 but we need to ensure that both the system <unistd.h> and <winsock2.h>
25 are completely included before we replace gethostname. */
26 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
27 && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
28 /* <unistd.h> is being indirectly included for the first time from
29 <winsock2.h>; avoid declaring any overrides. */
31 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
33 # error unexpected; report this to bug-gnulib@gnu.org
35 # define _GL_WINSOCK2_H_WITNESS
37 /* Normal invocation. */
38 #elif !defined _@GUARD_PREFIX@_UNISTD_H
40 /* The include_next requires a split double-inclusion guard. */
42 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
45 /* Get all possible declarations of gethostname(). */
46 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
47 && !defined _GL_INCLUDING_WINSOCK2_H
48 # define _GL_INCLUDING_WINSOCK2_H
49 # include <winsock2.h>
50 # undef _GL_INCLUDING_WINSOCK2_H
53 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
54 #define _@GUARD_PREFIX@_UNISTD_H
56 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
59 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
60 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
61 /* But avoid namespace pollution on glibc systems. */
62 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
63 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
64 && defined __CYGWIN__)) \
65 && ! defined __GLIBC__
69 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
70 /* But avoid namespace pollution on glibc systems. */
71 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
72 && ! defined __GLIBC__
76 /* mingw fails to declare _exit in <unistd.h>. */
77 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
79 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
80 /* But avoid namespace pollution on glibc systems. */
82 # define __need_system_stdlib_h
84 # undef __need_system_stdlib_h
87 /* Native Windows platforms declare chdir, getcwd, rmdir in
88 <io.h> and/or <direct.h>, not in <unistd.h>.
89 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
90 lseek(), read(), unlink(), write() in <io.h>. */
91 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
92 || defined GNULIB_POSIXCHECK) \
93 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
94 # include <io.h> /* mingw32, mingw64 */
95 # include <direct.h> /* mingw64, MSVC 9 */
96 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
97 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
98 || defined GNULIB_POSIXCHECK) \
99 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
103 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
104 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
105 /* But avoid namespace pollution on glibc systems. */
106 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
107 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
108 && !defined __GLIBC__
112 /* MSVC defines off_t in <sys/types.h>.
113 May also define off_t to a 64-bit type on native Windows. */
114 #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
116 # include <sys/types.h>
119 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
120 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
121 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
123 # include <sys/types.h>
126 /* Get getopt(), optarg, optind, opterr, optopt.
127 But avoid namespace pollution on glibc systems. */
128 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
132 _GL_INLINE_HEADER_BEGIN
133 #ifndef _GL_UNISTD_INLINE
134 # define _GL_UNISTD_INLINE _GL_INLINE
137 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
139 /* The definition of _GL_ARG_NONNULL is copied here. */
141 /* The definition of _GL_WARN_ON_USE is copied here. */
144 /* Hide some function declarations from <winsock2.h>. */
146 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
147 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
148 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
150 # define socket socket_used_without_including_sys_socket_h
152 # define connect connect_used_without_including_sys_socket_h
154 # define accept accept_used_without_including_sys_socket_h
156 # define bind bind_used_without_including_sys_socket_h
158 # define getpeername getpeername_used_without_including_sys_socket_h
160 # define getsockname getsockname_used_without_including_sys_socket_h
162 # define getsockopt getsockopt_used_without_including_sys_socket_h
164 # define listen listen_used_without_including_sys_socket_h
166 # define recv recv_used_without_including_sys_socket_h
168 # define send send_used_without_including_sys_socket_h
170 # define recvfrom recvfrom_used_without_including_sys_socket_h
172 # define sendto sendto_used_without_including_sys_socket_h
174 # define setsockopt setsockopt_used_without_including_sys_socket_h
176 # define shutdown shutdown_used_without_including_sys_socket_h
178 _GL_WARN_ON_USE (socket
,
179 "socket() used without including <sys/socket.h>");
180 _GL_WARN_ON_USE (connect
,
181 "connect() used without including <sys/socket.h>");
182 _GL_WARN_ON_USE (accept
,
183 "accept() used without including <sys/socket.h>");
184 _GL_WARN_ON_USE (bind
,
185 "bind() used without including <sys/socket.h>");
186 _GL_WARN_ON_USE (getpeername
,
187 "getpeername() used without including <sys/socket.h>");
188 _GL_WARN_ON_USE (getsockname
,
189 "getsockname() used without including <sys/socket.h>");
190 _GL_WARN_ON_USE (getsockopt
,
191 "getsockopt() used without including <sys/socket.h>");
192 _GL_WARN_ON_USE (listen
,
193 "listen() used without including <sys/socket.h>");
194 _GL_WARN_ON_USE (recv
,
195 "recv() used without including <sys/socket.h>");
196 _GL_WARN_ON_USE (send
,
197 "send() used without including <sys/socket.h>");
198 _GL_WARN_ON_USE (recvfrom
,
199 "recvfrom() used without including <sys/socket.h>");
200 _GL_WARN_ON_USE (sendto
,
201 "sendto() used without including <sys/socket.h>");
202 _GL_WARN_ON_USE (setsockopt
,
203 "setsockopt() used without including <sys/socket.h>");
204 _GL_WARN_ON_USE (shutdown
,
205 "shutdown() used without including <sys/socket.h>");
208 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
209 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
211 # define select select_used_without_including_sys_select_h
213 _GL_WARN_ON_USE (select
,
214 "select() used without including <sys/select.h>");
220 /* OS/2 EMX lacks these macros. */
222 # define STDIN_FILENO 0
224 #ifndef STDOUT_FILENO
225 # define STDOUT_FILENO 1
227 #ifndef STDERR_FILENO
228 # define STDERR_FILENO 2
231 /* Ensure *_OK macros exist. */
240 /* Declare overridden functions. */
243 #if defined GNULIB_POSIXCHECK
244 /* The access() function is a security risk. */
245 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
246 "use the gnulib module faccessat instead");
251 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
252 _GL_CXXALIASWARN (chdir
);
253 #elif defined GNULIB_POSIXCHECK
255 # if HAVE_RAW_DECL_CHDIR
256 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
257 "use gnulib module chdir for portability");
263 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
264 to GID (if GID is not -1). Follow symbolic links.
265 Return 0 if successful, otherwise -1 and errno set.
266 See the POSIX:2008 specification
267 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
269 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
271 # define chown rpl_chown
273 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
274 _GL_ARG_NONNULL ((1)));
275 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
278 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
279 _GL_ARG_NONNULL ((1)));
281 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
283 _GL_CXXALIASWARN (chown
);
284 #elif defined GNULIB_POSIXCHECK
286 # if HAVE_RAW_DECL_CHOWN
287 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
288 "doesn't treat a uid or gid of -1 on some systems - "
289 "use gnulib module chown for portability");
296 /* Automatically included by modules that need a replacement for close. */
297 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
299 # define close rpl_close
301 _GL_FUNCDECL_RPL (close
, int, (int fd
));
302 _GL_CXXALIAS_RPL (close
, int, (int fd
));
304 _GL_CXXALIAS_SYS (close
, int, (int fd
));
306 _GL_CXXALIASWARN (close
);
307 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
309 # define close close_used_without_requesting_gnulib_module_close
310 #elif defined GNULIB_POSIXCHECK
312 /* Assume close is always declared. */
313 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
314 "use gnulib module close for portability");
320 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
323 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
324 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
326 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
328 _GL_CXXALIASWARN (dup
);
329 #elif defined GNULIB_POSIXCHECK
331 # if HAVE_RAW_DECL_DUP
332 _GL_WARN_ON_USE (dup
, "dup is unportable - "
333 "use gnulib module dup for portability");
339 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
340 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
341 Return newfd if successful, otherwise -1 and errno set.
342 See the POSIX:2008 specification
343 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
345 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
346 # define dup2 rpl_dup2
348 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
349 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
352 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
354 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
356 _GL_CXXALIASWARN (dup2
);
357 #elif defined GNULIB_POSIXCHECK
359 # if HAVE_RAW_DECL_DUP2
360 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
361 "use gnulib module dup2 for portability");
367 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
369 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
370 and O_TEXT, O_BINARY (defined in "binary-io.h").
371 Close NEWFD first if it is open.
372 Return newfd if successful, otherwise -1 and errno set.
373 See the Linux man page at
374 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
376 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
377 # define dup3 rpl_dup3
379 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
380 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
382 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
383 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
385 _GL_CXXALIASWARN (dup3
);
386 #elif defined GNULIB_POSIXCHECK
388 # if HAVE_RAW_DECL_DUP3
389 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
390 "use gnulib module dup3 for portability");
396 # if !@HAVE_DECL_ENVIRON@
397 /* Set of environment variables and values. An array of strings of the form
398 "VARIABLE=VALUE", terminated with a NULL. */
399 # if defined __APPLE__ && defined __MACH__
400 # include <crt_externs.h>
401 # define environ (*_NSGetEnviron ())
406 extern char **environ
;
412 #elif defined GNULIB_POSIXCHECK
413 # if HAVE_RAW_DECL_ENVIRON
414 _GL_UNISTD_INLINE
char ***
419 _GL_WARN_ON_USE (rpl_environ
, "environ is unportable - "
420 "use gnulib module environ for portability");
422 # define environ (*rpl_environ ())
427 #if @GNULIB_EUIDACCESS@
428 /* Like access(), except that it uses the effective user id and group id of
429 the current process. */
430 # if !@HAVE_EUIDACCESS@
431 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
432 _GL_ARG_NONNULL ((1)));
434 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
435 _GL_CXXALIASWARN (euidaccess
);
436 # if defined GNULIB_POSIXCHECK
437 /* Like access(), this function is a security risk. */
438 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
439 "use the gnulib module faccessat instead");
441 #elif defined GNULIB_POSIXCHECK
443 # if HAVE_RAW_DECL_EUIDACCESS
444 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
445 "use gnulib module euidaccess for portability");
450 #if @GNULIB_FACCESSAT@
451 # if !@HAVE_FACCESSAT@
452 _GL_FUNCDECL_SYS (faccessat
, int,
453 (int fd
, char const *file
, int mode
, int flag
)
454 _GL_ARG_NONNULL ((2)));
456 _GL_CXXALIAS_SYS (faccessat
, int,
457 (int fd
, char const *file
, int mode
, int flag
));
458 _GL_CXXALIASWARN (faccessat
);
459 #elif defined GNULIB_POSIXCHECK
461 # if HAVE_RAW_DECL_FACCESSAT
462 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
463 "use gnulib module faccessat for portability");
469 /* Change the process' current working directory to the directory on which
470 the given file descriptor is open.
471 Return 0 if successful, otherwise -1 and errno set.
472 See the POSIX:2008 specification
473 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
475 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
477 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
478 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
479 _GL_ARG_NONNULL ((2));
480 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
481 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
482 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
485 # if !@HAVE_DECL_FCHDIR@
486 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
489 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
490 _GL_CXXALIASWARN (fchdir
);
491 #elif defined GNULIB_POSIXCHECK
493 # if HAVE_RAW_DECL_FCHDIR
494 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
495 "use gnulib module fchdir for portability");
500 #if @GNULIB_FCHOWNAT@
501 # if @REPLACE_FCHOWNAT@
502 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
504 # define fchownat rpl_fchownat
506 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
507 uid_t owner
, gid_t group
, int flag
)
508 _GL_ARG_NONNULL ((2)));
509 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
510 uid_t owner
, gid_t group
, int flag
));
512 # if !@HAVE_FCHOWNAT@
513 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
514 uid_t owner
, gid_t group
, int flag
)
515 _GL_ARG_NONNULL ((2)));
517 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
518 uid_t owner
, gid_t group
, int flag
));
520 _GL_CXXALIASWARN (fchownat
);
521 #elif defined GNULIB_POSIXCHECK
523 # if HAVE_RAW_DECL_FCHOWNAT
524 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
525 "use gnulib module openat for portability");
530 #if @GNULIB_FDATASYNC@
531 /* Synchronize changes to a file.
532 Return 0 if successful, otherwise -1 and errno set.
533 See POSIX:2008 specification
534 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
535 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
536 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
538 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
539 _GL_CXXALIASWARN (fdatasync
);
540 #elif defined GNULIB_POSIXCHECK
542 # if HAVE_RAW_DECL_FDATASYNC
543 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
544 "use gnulib module fdatasync for portability");
550 /* Synchronize changes, including metadata, to a file.
551 Return 0 if successful, otherwise -1 and errno set.
552 See POSIX:2008 specification
553 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
555 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
557 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
558 _GL_CXXALIASWARN (fsync
);
559 #elif defined GNULIB_POSIXCHECK
561 # if HAVE_RAW_DECL_FSYNC
562 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
563 "use gnulib module fsync for portability");
568 #if @GNULIB_FTRUNCATE@
569 /* Change the size of the file to which FD is opened to become equal to LENGTH.
570 Return 0 if successful, otherwise -1 and errno set.
571 See the POSIX:2008 specification
572 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
573 # if @REPLACE_FTRUNCATE@
574 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
576 # define ftruncate rpl_ftruncate
578 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
579 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
581 # if !@HAVE_FTRUNCATE@
582 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
584 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
586 _GL_CXXALIASWARN (ftruncate
);
587 #elif defined GNULIB_POSIXCHECK
589 # if HAVE_RAW_DECL_FTRUNCATE
590 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
591 "use gnulib module ftruncate for portability");
597 /* Get the name of the current working directory, and put it in SIZE bytes
599 Return BUF if successful, or NULL if the directory couldn't be determined
600 or SIZE was too small.
601 See the POSIX:2008 specification
602 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
603 Additionally, the gnulib module 'getcwd' guarantees the following GNU
604 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
605 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
607 # if @REPLACE_GETCWD@
608 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
609 # define getcwd rpl_getcwd
611 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
612 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
614 /* Need to cast, because on mingw, the second parameter is
616 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
618 _GL_CXXALIASWARN (getcwd
);
619 #elif defined GNULIB_POSIXCHECK
621 # if HAVE_RAW_DECL_GETCWD
622 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
623 "use gnulib module getcwd for portability");
628 #if @GNULIB_GETDOMAINNAME@
629 /* Return the NIS domain name of the machine.
630 WARNING! The NIS domain name is unrelated to the fully qualified host name
631 of the machine. It is also unrelated to email addresses.
632 WARNING! The NIS domain name is usually the empty string or "(none)" when
635 Put up to LEN bytes of the NIS domain name into NAME.
636 Null terminate it if the name is shorter than LEN.
637 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
638 Return 0 if successful, otherwise set errno and return -1. */
639 # if @REPLACE_GETDOMAINNAME@
640 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
641 # undef getdomainname
642 # define getdomainname rpl_getdomainname
644 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
645 _GL_ARG_NONNULL ((1)));
646 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
648 # if !@HAVE_DECL_GETDOMAINNAME@
649 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
650 _GL_ARG_NONNULL ((1)));
652 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
654 _GL_CXXALIASWARN (getdomainname
);
655 #elif defined GNULIB_POSIXCHECK
656 # undef getdomainname
657 # if HAVE_RAW_DECL_GETDOMAINNAME
658 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
659 "use gnulib module getdomainname for portability");
664 #if @GNULIB_GETDTABLESIZE@
665 /* Return the maximum number of file descriptors in the current process.
666 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
667 # if !@HAVE_GETDTABLESIZE@
668 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
670 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
671 _GL_CXXALIASWARN (getdtablesize
);
672 #elif defined GNULIB_POSIXCHECK
673 # undef getdtablesize
674 # if HAVE_RAW_DECL_GETDTABLESIZE
675 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
676 "use gnulib module getdtablesize for portability");
681 #if @GNULIB_GETGROUPS@
682 /* Return the supplemental groups that the current process belongs to.
683 It is unspecified whether the effective group id is in the list.
684 If N is 0, return the group count; otherwise, N describes how many
685 entries are available in GROUPS. Return -1 and set errno if N is
686 not 0 and not large enough. Fails with ENOSYS on some systems. */
687 # if @REPLACE_GETGROUPS@
688 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
690 # define getgroups rpl_getgroups
692 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
693 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
695 # if !@HAVE_GETGROUPS@
696 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
698 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
700 _GL_CXXALIASWARN (getgroups
);
701 #elif defined GNULIB_POSIXCHECK
703 # if HAVE_RAW_DECL_GETGROUPS
704 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
705 "use gnulib module getgroups for portability");
710 #if @GNULIB_GETHOSTNAME@
711 /* Return the standard host name of the machine.
712 WARNING! The host name may or may not be fully qualified.
714 Put up to LEN bytes of the host name into NAME.
715 Null terminate it if the name is shorter than LEN.
716 If the host name is longer than LEN, set errno = EINVAL and return -1.
717 Return 0 if successful, otherwise set errno and return -1. */
718 # if @UNISTD_H_HAVE_WINSOCK2_H@
719 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
721 # define gethostname rpl_gethostname
723 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
724 _GL_ARG_NONNULL ((1)));
725 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
727 # if !@HAVE_GETHOSTNAME@
728 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
729 _GL_ARG_NONNULL ((1)));
731 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
734 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
736 _GL_CXXALIASWARN (gethostname
);
737 #elif @UNISTD_H_HAVE_WINSOCK2_H@
739 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
740 #elif defined GNULIB_POSIXCHECK
742 # if HAVE_RAW_DECL_GETHOSTNAME
743 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
744 "use gnulib module gethostname for portability");
749 #if @GNULIB_GETLOGIN@
750 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
751 returns NULL with errno set.
753 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
755 Most programs don't need to use this function, because the information is
756 available through environment variables:
757 ${LOGNAME-$USER} on Unix platforms,
758 $USERNAME on native Windows platforms.
760 # if !@HAVE_GETLOGIN@
761 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
763 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
764 _GL_CXXALIASWARN (getlogin
);
765 #elif defined GNULIB_POSIXCHECK
767 # if HAVE_RAW_DECL_GETLOGIN
768 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
769 "use gnulib module getlogin for portability");
774 #if @GNULIB_GETLOGIN_R@
775 /* Copies the user's login name to NAME.
776 The array pointed to by NAME has room for SIZE bytes.
778 Returns 0 if successful. Upon error, an error number is returned, or -1 in
779 the case that the login name cannot be found but no specific error is
780 provided (this case is hopefully rare but is left open by the POSIX spec).
782 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
784 Most programs don't need to use this function, because the information is
785 available through environment variables:
786 ${LOGNAME-$USER} on Unix platforms,
787 $USERNAME on native Windows platforms.
789 # if @REPLACE_GETLOGIN_R@
790 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
791 # define getlogin_r rpl_getlogin_r
793 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
794 _GL_ARG_NONNULL ((1)));
795 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
797 # if !@HAVE_DECL_GETLOGIN_R@
798 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
799 _GL_ARG_NONNULL ((1)));
801 /* Need to cast, because on Solaris 10 systems, the second argument is
803 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
805 _GL_CXXALIASWARN (getlogin_r
);
806 #elif defined GNULIB_POSIXCHECK
808 # if HAVE_RAW_DECL_GETLOGIN_R
809 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
810 "use gnulib module getlogin_r for portability");
815 #if @GNULIB_GETPAGESIZE@
816 # if @REPLACE_GETPAGESIZE@
817 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
818 # define getpagesize rpl_getpagesize
820 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
821 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
823 # if !@HAVE_GETPAGESIZE@
824 # if !defined getpagesize
825 /* This is for POSIX systems. */
826 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
827 # if ! (defined __VMS && __VMS_VER < 70000000)
828 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
831 /* This is for older VMS. */
832 # if !defined _gl_getpagesize && defined __VMS
834 # define _gl_getpagesize() 8192
836 # define _gl_getpagesize() 512
839 /* This is for BeOS. */
840 # if !defined _gl_getpagesize && @HAVE_OS_H@
842 # if defined B_PAGE_SIZE
843 # define _gl_getpagesize() B_PAGE_SIZE
846 /* This is for AmigaOS4.0. */
847 # if !defined _gl_getpagesize && defined __amigaos4__
848 # define _gl_getpagesize() 2048
850 /* This is for older Unix systems. */
851 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
852 # include <sys/param.h>
853 # ifdef EXEC_PAGESIZE
854 # define _gl_getpagesize() EXEC_PAGESIZE
860 # define _gl_getpagesize() (NBPG * CLSIZE)
863 # define _gl_getpagesize() NBPC
868 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
869 # define getpagesize() _gl_getpagesize ()
871 # if !GNULIB_defined_getpagesize_function
872 _GL_UNISTD_INLINE
int
875 return _gl_getpagesize ();
877 # define GNULIB_defined_getpagesize_function 1
882 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
883 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
885 # if @HAVE_DECL_GETPAGESIZE@
886 _GL_CXXALIASWARN (getpagesize
);
888 #elif defined GNULIB_POSIXCHECK
890 # if HAVE_RAW_DECL_GETPAGESIZE
891 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
892 "use gnulib module getpagesize for portability");
897 #if @GNULIB_GETUSERSHELL@
898 /* Return the next valid login shell on the system, or NULL when the end of
899 the list has been reached. */
900 # if !@HAVE_DECL_GETUSERSHELL@
901 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
903 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
904 _GL_CXXALIASWARN (getusershell
);
905 #elif defined GNULIB_POSIXCHECK
907 # if HAVE_RAW_DECL_GETUSERSHELL
908 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
909 "use gnulib module getusershell for portability");
913 #if @GNULIB_GETUSERSHELL@
914 /* Rewind to pointer that is advanced at each getusershell() call. */
915 # if !@HAVE_DECL_GETUSERSHELL@
916 _GL_FUNCDECL_SYS (setusershell
, void, (void));
918 _GL_CXXALIAS_SYS (setusershell
, void, (void));
919 _GL_CXXALIASWARN (setusershell
);
920 #elif defined GNULIB_POSIXCHECK
922 # if HAVE_RAW_DECL_SETUSERSHELL
923 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
924 "use gnulib module getusershell for portability");
928 #if @GNULIB_GETUSERSHELL@
929 /* Free the pointer that is advanced at each getusershell() call and
930 associated resources. */
931 # if !@HAVE_DECL_GETUSERSHELL@
932 _GL_FUNCDECL_SYS (endusershell
, void, (void));
934 _GL_CXXALIAS_SYS (endusershell
, void, (void));
935 _GL_CXXALIASWARN (endusershell
);
936 #elif defined GNULIB_POSIXCHECK
938 # if HAVE_RAW_DECL_ENDUSERSHELL
939 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
940 "use gnulib module getusershell for portability");
945 #if @GNULIB_GROUP_MEMBER@
946 /* Determine whether group id is in calling user's group list. */
947 # if !@HAVE_GROUP_MEMBER@
948 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
950 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
951 _GL_CXXALIASWARN (group_member
);
952 #elif defined GNULIB_POSIXCHECK
954 # if HAVE_RAW_DECL_GROUP_MEMBER
955 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
956 "use gnulib module group-member for portability");
962 # if @REPLACE_ISATTY@
963 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
965 # define isatty rpl_isatty
967 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
968 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
970 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
972 _GL_CXXALIASWARN (isatty
);
973 #elif defined GNULIB_POSIXCHECK
975 # if HAVE_RAW_DECL_ISATTY
976 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
977 "use gnulib module isatty for portability");
983 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
984 to GID (if GID is not -1). Do not follow symbolic links.
985 Return 0 if successful, otherwise -1 and errno set.
986 See the POSIX:2008 specification
987 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
988 # if @REPLACE_LCHOWN@
989 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
991 # define lchown rpl_lchown
993 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
994 _GL_ARG_NONNULL ((1)));
995 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
998 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
999 _GL_ARG_NONNULL ((1)));
1001 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1003 _GL_CXXALIASWARN (lchown
);
1004 #elif defined GNULIB_POSIXCHECK
1006 # if HAVE_RAW_DECL_LCHOWN
1007 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1008 "use gnulib module lchown for portability");
1014 /* Create a new hard link for an existing file.
1015 Return 0 if successful, otherwise -1 and errno set.
1016 See POSIX:2008 specification
1017 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1019 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1020 # define link rpl_link
1022 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1023 _GL_ARG_NONNULL ((1, 2)));
1024 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1027 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1028 _GL_ARG_NONNULL ((1, 2)));
1030 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1032 _GL_CXXALIASWARN (link
);
1033 #elif defined GNULIB_POSIXCHECK
1035 # if HAVE_RAW_DECL_LINK
1036 _GL_WARN_ON_USE (link
, "link is unportable - "
1037 "use gnulib module link for portability");
1043 /* Create a new hard link for an existing file, relative to two
1044 directories. FLAG controls whether symlinks are followed.
1045 Return 0 if successful, otherwise -1 and errno set. */
1046 # if @REPLACE_LINKAT@
1047 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1049 # define linkat rpl_linkat
1051 _GL_FUNCDECL_RPL (linkat
, int,
1052 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1054 _GL_ARG_NONNULL ((2, 4)));
1055 _GL_CXXALIAS_RPL (linkat
, int,
1056 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1060 _GL_FUNCDECL_SYS (linkat
, int,
1061 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1063 _GL_ARG_NONNULL ((2, 4)));
1065 _GL_CXXALIAS_SYS (linkat
, int,
1066 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1069 _GL_CXXALIASWARN (linkat
);
1070 #elif defined GNULIB_POSIXCHECK
1072 # if HAVE_RAW_DECL_LINKAT
1073 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1074 "use gnulib module linkat for portability");
1080 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1081 Return the new offset if successful, otherwise -1 and errno set.
1082 See the POSIX:2008 specification
1083 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1084 # if @REPLACE_LSEEK@
1085 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1086 # define lseek rpl_lseek
1088 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1089 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1091 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1093 _GL_CXXALIASWARN (lseek
);
1094 #elif defined GNULIB_POSIXCHECK
1096 # if HAVE_RAW_DECL_LSEEK
1097 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1098 "systems - use gnulib module lseek for portability");
1104 /* Create a pipe, defaulting to O_BINARY mode.
1105 Store the read-end as fd[0] and the write-end as fd[1].
1106 Return 0 upon success, or -1 with errno set upon failure. */
1108 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1110 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1111 _GL_CXXALIASWARN (pipe
);
1112 #elif defined GNULIB_POSIXCHECK
1114 # if HAVE_RAW_DECL_PIPE
1115 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1116 "use gnulib module pipe-posix for portability");
1122 /* Create a pipe, applying the given flags when opening the read-end of the
1123 pipe and the write-end of the pipe.
1124 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1125 and O_TEXT, O_BINARY (defined in "binary-io.h").
1126 Store the read-end as fd[0] and the write-end as fd[1].
1127 Return 0 upon success, or -1 with errno set upon failure.
1128 See also the Linux man page at
1129 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1131 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1132 # define pipe2 rpl_pipe2
1134 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1135 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1137 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1138 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1140 _GL_CXXALIASWARN (pipe2
);
1141 #elif defined GNULIB_POSIXCHECK
1143 # if HAVE_RAW_DECL_PIPE2
1144 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1145 "use gnulib module pipe2 for portability");
1151 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1152 Return the number of bytes placed into BUF if successful, otherwise
1153 set errno and return -1. 0 indicates EOF.
1154 See the POSIX:2008 specification
1155 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1156 # if @REPLACE_PREAD@
1157 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1159 # define pread rpl_pread
1161 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1162 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1163 _GL_ARG_NONNULL ((2)));
1164 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1165 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1168 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1169 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1170 _GL_ARG_NONNULL ((2)));
1172 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1173 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1175 _GL_CXXALIASWARN (pread
);
1176 #elif defined GNULIB_POSIXCHECK
1178 # if HAVE_RAW_DECL_PREAD
1179 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1180 "use gnulib module pread for portability");
1186 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1187 Return the number of bytes written if successful, otherwise
1188 set errno and return -1. 0 indicates nothing written. See the
1189 POSIX:2008 specification
1190 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1191 # if @REPLACE_PWRITE@
1192 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1194 # define pwrite rpl_pwrite
1196 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1197 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1198 _GL_ARG_NONNULL ((2)));
1199 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1200 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1203 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1204 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1205 _GL_ARG_NONNULL ((2)));
1207 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1208 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1210 _GL_CXXALIASWARN (pwrite
);
1211 #elif defined GNULIB_POSIXCHECK
1213 # if HAVE_RAW_DECL_PWRITE
1214 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1215 "use gnulib module pwrite for portability");
1221 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1222 at BUF. See the POSIX:2008 specification
1223 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1225 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1227 # define read rpl_read
1229 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1230 _GL_ARG_NONNULL ((2)));
1231 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1233 /* Need to cast, because on mingw, the third parameter is
1235 and the return type is 'int'. */
1236 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1238 _GL_CXXALIASWARN (read
);
1242 #if @GNULIB_READLINK@
1243 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1244 bytes of it into BUF. Return the number of bytes placed into BUF if
1245 successful, otherwise -1 and errno set.
1246 See the POSIX:2008 specification
1247 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1248 # if @REPLACE_READLINK@
1249 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1250 # define readlink rpl_readlink
1252 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1253 (const char *file
, char *buf
, size_t bufsize
)
1254 _GL_ARG_NONNULL ((1, 2)));
1255 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1256 (const char *file
, char *buf
, size_t bufsize
));
1258 # if !@HAVE_READLINK@
1259 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1260 (const char *file
, char *buf
, size_t bufsize
)
1261 _GL_ARG_NONNULL ((1, 2)));
1263 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1264 (const char *file
, char *buf
, size_t bufsize
));
1266 _GL_CXXALIASWARN (readlink
);
1267 #elif defined GNULIB_POSIXCHECK
1269 # if HAVE_RAW_DECL_READLINK
1270 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1271 "use gnulib module readlink for portability");
1276 #if @GNULIB_READLINKAT@
1277 # if !@HAVE_READLINKAT@
1278 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1279 (int fd
, char const *file
, char *buf
, size_t len
)
1280 _GL_ARG_NONNULL ((2, 3)));
1282 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1283 (int fd
, char const *file
, char *buf
, size_t len
));
1284 _GL_CXXALIASWARN (readlinkat
);
1285 #elif defined GNULIB_POSIXCHECK
1287 # if HAVE_RAW_DECL_READLINKAT
1288 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1289 "use gnulib module readlinkat for portability");
1295 /* Remove the directory DIR. */
1296 # if @REPLACE_RMDIR@
1297 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1298 # define rmdir rpl_rmdir
1300 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1301 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1303 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1305 _GL_CXXALIASWARN (rmdir
);
1306 #elif defined GNULIB_POSIXCHECK
1308 # if HAVE_RAW_DECL_RMDIR
1309 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1310 "use gnulib module rmdir for portability");
1315 #if @GNULIB_SETHOSTNAME@
1316 /* Set the host name of the machine.
1317 The host name may or may not be fully qualified.
1319 Put LEN bytes of NAME into the host name.
1320 Return 0 if successful, otherwise, set errno and return -1.
1322 Platforms with no ability to set the hostname return -1 and set
1324 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1325 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1326 _GL_ARG_NONNULL ((1)));
1328 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1329 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1330 2011-10, the first parameter is not const. */
1331 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1332 _GL_CXXALIASWARN (sethostname
);
1333 #elif defined GNULIB_POSIXCHECK
1335 # if HAVE_RAW_DECL_SETHOSTNAME
1336 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1337 "use gnulib module sethostname for portability");
1343 /* Pause the execution of the current thread for N seconds.
1344 Returns the number of seconds left to sleep.
1345 See the POSIX:2008 specification
1346 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1347 # if @REPLACE_SLEEP@
1348 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1350 # define sleep rpl_sleep
1352 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1353 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1356 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1358 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1360 _GL_CXXALIASWARN (sleep
);
1361 #elif defined GNULIB_POSIXCHECK
1363 # if HAVE_RAW_DECL_SLEEP
1364 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1365 "use gnulib module sleep for portability");
1370 #if @GNULIB_SYMLINK@
1371 # if @REPLACE_SYMLINK@
1372 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1374 # define symlink rpl_symlink
1376 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1377 _GL_ARG_NONNULL ((1, 2)));
1378 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1380 # if !@HAVE_SYMLINK@
1381 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1382 _GL_ARG_NONNULL ((1, 2)));
1384 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1386 _GL_CXXALIASWARN (symlink
);
1387 #elif defined GNULIB_POSIXCHECK
1389 # if HAVE_RAW_DECL_SYMLINK
1390 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1391 "use gnulib module symlink for portability");
1396 #if @GNULIB_SYMLINKAT@
1397 # if !@HAVE_SYMLINKAT@
1398 _GL_FUNCDECL_SYS (symlinkat
, int,
1399 (char const *contents
, int fd
, char const *file
)
1400 _GL_ARG_NONNULL ((1, 3)));
1402 _GL_CXXALIAS_SYS (symlinkat
, int,
1403 (char const *contents
, int fd
, char const *file
));
1404 _GL_CXXALIASWARN (symlinkat
);
1405 #elif defined GNULIB_POSIXCHECK
1407 # if HAVE_RAW_DECL_SYMLINKAT
1408 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1409 "use gnulib module symlinkat for portability");
1414 #if @GNULIB_TTYNAME_R@
1415 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1416 open on in BUF. Return 0 on success, otherwise an error number. */
1417 # if @REPLACE_TTYNAME_R@
1418 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1420 # define ttyname_r rpl_ttyname_r
1422 _GL_FUNCDECL_RPL (ttyname_r
, int,
1423 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1424 _GL_CXXALIAS_RPL (ttyname_r
, int,
1425 (int fd
, char *buf
, size_t buflen
));
1427 # if !@HAVE_DECL_TTYNAME_R@
1428 _GL_FUNCDECL_SYS (ttyname_r
, int,
1429 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1431 _GL_CXXALIAS_SYS (ttyname_r
, int,
1432 (int fd
, char *buf
, size_t buflen
));
1434 _GL_CXXALIASWARN (ttyname_r
);
1435 #elif defined GNULIB_POSIXCHECK
1437 # if HAVE_RAW_DECL_TTYNAME_R
1438 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1439 "use gnulib module ttyname_r for portability");
1445 # if @REPLACE_UNLINK@
1446 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1448 # define unlink rpl_unlink
1450 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1451 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1453 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1455 _GL_CXXALIASWARN (unlink
);
1456 #elif defined GNULIB_POSIXCHECK
1458 # if HAVE_RAW_DECL_UNLINK
1459 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1460 "use gnulib module unlink for portability");
1465 #if @GNULIB_UNLINKAT@
1466 # if @REPLACE_UNLINKAT@
1467 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1469 # define unlinkat rpl_unlinkat
1471 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1472 _GL_ARG_NONNULL ((2)));
1473 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1475 # if !@HAVE_UNLINKAT@
1476 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1477 _GL_ARG_NONNULL ((2)));
1479 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1481 _GL_CXXALIASWARN (unlinkat
);
1482 #elif defined GNULIB_POSIXCHECK
1484 # if HAVE_RAW_DECL_UNLINKAT
1485 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1486 "use gnulib module openat for portability");
1492 /* Pause the execution of the current thread for N microseconds.
1493 Returns 0 on completion, or -1 on range error.
1494 See the POSIX:2001 specification
1495 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1496 # if @REPLACE_USLEEP@
1497 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1499 # define usleep rpl_usleep
1501 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1502 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1505 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1507 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1509 _GL_CXXALIASWARN (usleep
);
1510 #elif defined GNULIB_POSIXCHECK
1512 # if HAVE_RAW_DECL_USLEEP
1513 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1514 "use gnulib module usleep for portability");
1520 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1521 See the POSIX:2008 specification
1522 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1523 # if @REPLACE_WRITE@
1524 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1526 # define write rpl_write
1528 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1529 _GL_ARG_NONNULL ((2)));
1530 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1532 /* Need to cast, because on mingw, the third parameter is
1534 and the return type is 'int'. */
1535 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1537 _GL_CXXALIASWARN (write
);
1540 _GL_INLINE_HEADER_END
1542 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1543 #endif /* _@GUARD_PREFIX@_UNISTD_H */