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. */
85 /* Native Windows platforms declare chdir, getcwd, rmdir in
86 <io.h> and/or <direct.h>, not in <unistd.h>.
87 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
88 lseek(), read(), unlink(), write() in <io.h>. */
89 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
90 || defined GNULIB_POSIXCHECK) \
91 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
92 # include <io.h> /* mingw32, mingw64 */
93 # include <direct.h> /* mingw64, MSVC 9 */
94 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
95 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
96 || defined GNULIB_POSIXCHECK) \
97 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
101 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
102 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
103 /* But avoid namespace pollution on glibc systems. */
104 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
105 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
106 && !defined __GLIBC__
110 /* MSVC defines off_t in <sys/types.h>.
111 May also define off_t to a 64-bit type on native Windows. */
112 #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
114 # include <sys/types.h>
117 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
118 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
119 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
121 # include <sys/types.h>
124 /* Get getopt(), optarg, optind, opterr, optopt.
125 But avoid namespace pollution on glibc systems. */
126 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
130 _GL_INLINE_HEADER_BEGIN
131 #ifndef _GL_UNISTD_INLINE
132 # define _GL_UNISTD_INLINE _GL_INLINE
135 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
137 /* The definition of _GL_ARG_NONNULL is copied here. */
139 /* The definition of _GL_WARN_ON_USE is copied here. */
142 /* Hide some function declarations from <winsock2.h>. */
144 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
145 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
146 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
148 # define socket socket_used_without_including_sys_socket_h
150 # define connect connect_used_without_including_sys_socket_h
152 # define accept accept_used_without_including_sys_socket_h
154 # define bind bind_used_without_including_sys_socket_h
156 # define getpeername getpeername_used_without_including_sys_socket_h
158 # define getsockname getsockname_used_without_including_sys_socket_h
160 # define getsockopt getsockopt_used_without_including_sys_socket_h
162 # define listen listen_used_without_including_sys_socket_h
164 # define recv recv_used_without_including_sys_socket_h
166 # define send send_used_without_including_sys_socket_h
168 # define recvfrom recvfrom_used_without_including_sys_socket_h
170 # define sendto sendto_used_without_including_sys_socket_h
172 # define setsockopt setsockopt_used_without_including_sys_socket_h
174 # define shutdown shutdown_used_without_including_sys_socket_h
176 _GL_WARN_ON_USE (socket
,
177 "socket() used without including <sys/socket.h>");
178 _GL_WARN_ON_USE (connect
,
179 "connect() used without including <sys/socket.h>");
180 _GL_WARN_ON_USE (accept
,
181 "accept() used without including <sys/socket.h>");
182 _GL_WARN_ON_USE (bind
,
183 "bind() used without including <sys/socket.h>");
184 _GL_WARN_ON_USE (getpeername
,
185 "getpeername() used without including <sys/socket.h>");
186 _GL_WARN_ON_USE (getsockname
,
187 "getsockname() used without including <sys/socket.h>");
188 _GL_WARN_ON_USE (getsockopt
,
189 "getsockopt() used without including <sys/socket.h>");
190 _GL_WARN_ON_USE (listen
,
191 "listen() used without including <sys/socket.h>");
192 _GL_WARN_ON_USE (recv
,
193 "recv() used without including <sys/socket.h>");
194 _GL_WARN_ON_USE (send
,
195 "send() used without including <sys/socket.h>");
196 _GL_WARN_ON_USE (recvfrom
,
197 "recvfrom() used without including <sys/socket.h>");
198 _GL_WARN_ON_USE (sendto
,
199 "sendto() used without including <sys/socket.h>");
200 _GL_WARN_ON_USE (setsockopt
,
201 "setsockopt() used without including <sys/socket.h>");
202 _GL_WARN_ON_USE (shutdown
,
203 "shutdown() used without including <sys/socket.h>");
206 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
207 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
209 # define select select_used_without_including_sys_select_h
211 _GL_WARN_ON_USE (select
,
212 "select() used without including <sys/select.h>");
218 /* OS/2 EMX lacks these macros. */
220 # define STDIN_FILENO 0
222 #ifndef STDOUT_FILENO
223 # define STDOUT_FILENO 1
225 #ifndef STDERR_FILENO
226 # define STDERR_FILENO 2
229 /* Ensure *_OK macros exist. */
238 /* Declare overridden functions. */
241 #if defined GNULIB_POSIXCHECK
242 /* The access() function is a security risk. */
243 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
244 "use the gnulib module faccessat instead");
249 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
250 _GL_CXXALIASWARN (chdir
);
251 #elif defined GNULIB_POSIXCHECK
253 # if HAVE_RAW_DECL_CHDIR
254 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
255 "use gnulib module chdir for portability");
261 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
262 to GID (if GID is not -1). Follow symbolic links.
263 Return 0 if successful, otherwise -1 and errno set.
264 See the POSIX:2008 specification
265 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
267 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
269 # define chown rpl_chown
271 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
272 _GL_ARG_NONNULL ((1)));
273 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
276 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
277 _GL_ARG_NONNULL ((1)));
279 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
281 _GL_CXXALIASWARN (chown
);
282 #elif defined GNULIB_POSIXCHECK
284 # if HAVE_RAW_DECL_CHOWN
285 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
286 "doesn't treat a uid or gid of -1 on some systems - "
287 "use gnulib module chown for portability");
294 /* Automatically included by modules that need a replacement for close. */
295 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
297 # define close rpl_close
299 _GL_FUNCDECL_RPL (close
, int, (int fd
));
300 _GL_CXXALIAS_RPL (close
, int, (int fd
));
302 _GL_CXXALIAS_SYS (close
, int, (int fd
));
304 _GL_CXXALIASWARN (close
);
305 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
307 # define close close_used_without_requesting_gnulib_module_close
308 #elif defined GNULIB_POSIXCHECK
310 /* Assume close is always declared. */
311 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
312 "use gnulib module close for portability");
318 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
321 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
322 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
324 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
326 _GL_CXXALIASWARN (dup
);
327 #elif defined GNULIB_POSIXCHECK
329 # if HAVE_RAW_DECL_DUP
330 _GL_WARN_ON_USE (dup
, "dup is unportable - "
331 "use gnulib module dup for portability");
337 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
338 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
339 Return newfd if successful, otherwise -1 and errno set.
340 See the POSIX:2008 specification
341 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
343 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
344 # define dup2 rpl_dup2
346 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
347 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
350 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
352 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
354 _GL_CXXALIASWARN (dup2
);
355 #elif defined GNULIB_POSIXCHECK
357 # if HAVE_RAW_DECL_DUP2
358 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
359 "use gnulib module dup2 for portability");
365 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
367 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
368 and O_TEXT, O_BINARY (defined in "binary-io.h").
369 Close NEWFD first if it is open.
370 Return newfd if successful, otherwise -1 and errno set.
371 See the Linux man page at
372 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
374 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
375 # define dup3 rpl_dup3
377 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
378 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
380 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
381 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
383 _GL_CXXALIASWARN (dup3
);
384 #elif defined GNULIB_POSIXCHECK
386 # if HAVE_RAW_DECL_DUP3
387 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
388 "use gnulib module dup3 for portability");
394 # if !@HAVE_DECL_ENVIRON@
395 /* Set of environment variables and values. An array of strings of the form
396 "VARIABLE=VALUE", terminated with a NULL. */
397 # if defined __APPLE__ && defined __MACH__
398 # include <crt_externs.h>
399 # define environ (*_NSGetEnviron ())
404 extern char **environ
;
410 #elif defined GNULIB_POSIXCHECK
411 # if HAVE_RAW_DECL_ENVIRON
412 _GL_UNISTD_INLINE
char ***
417 _GL_WARN_ON_USE (rpl_environ
, "environ is unportable - "
418 "use gnulib module environ for portability");
420 # define environ (*rpl_environ ())
425 #if @GNULIB_EUIDACCESS@
426 /* Like access(), except that it uses the effective user id and group id of
427 the current process. */
428 # if !@HAVE_EUIDACCESS@
429 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
430 _GL_ARG_NONNULL ((1)));
432 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
433 _GL_CXXALIASWARN (euidaccess
);
434 # if defined GNULIB_POSIXCHECK
435 /* Like access(), this function is a security risk. */
436 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
437 "use the gnulib module faccessat instead");
439 #elif defined GNULIB_POSIXCHECK
441 # if HAVE_RAW_DECL_EUIDACCESS
442 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
443 "use gnulib module euidaccess for portability");
448 #if @GNULIB_FACCESSAT@
449 # if !@HAVE_FACCESSAT@
450 _GL_FUNCDECL_SYS (faccessat
, int,
451 (int fd
, char const *file
, int mode
, int flag
)
452 _GL_ARG_NONNULL ((2)));
454 _GL_CXXALIAS_SYS (faccessat
, int,
455 (int fd
, char const *file
, int mode
, int flag
));
456 _GL_CXXALIASWARN (faccessat
);
457 #elif defined GNULIB_POSIXCHECK
459 # if HAVE_RAW_DECL_FACCESSAT
460 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
461 "use gnulib module faccessat for portability");
467 /* Change the process' current working directory to the directory on which
468 the given file descriptor is open.
469 Return 0 if successful, otherwise -1 and errno set.
470 See the POSIX:2008 specification
471 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
473 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
475 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
476 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
477 _GL_ARG_NONNULL ((2));
478 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
479 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
480 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
483 # if !@HAVE_DECL_FCHDIR@
484 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
487 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
488 _GL_CXXALIASWARN (fchdir
);
489 #elif defined GNULIB_POSIXCHECK
491 # if HAVE_RAW_DECL_FCHDIR
492 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
493 "use gnulib module fchdir for portability");
498 #if @GNULIB_FCHOWNAT@
499 # if @REPLACE_FCHOWNAT@
500 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
502 # define fchownat rpl_fchownat
504 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
505 uid_t owner
, gid_t group
, int flag
)
506 _GL_ARG_NONNULL ((2)));
507 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
508 uid_t owner
, gid_t group
, int flag
));
510 # if !@HAVE_FCHOWNAT@
511 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
512 uid_t owner
, gid_t group
, int flag
)
513 _GL_ARG_NONNULL ((2)));
515 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
516 uid_t owner
, gid_t group
, int flag
));
518 _GL_CXXALIASWARN (fchownat
);
519 #elif defined GNULIB_POSIXCHECK
521 # if HAVE_RAW_DECL_FCHOWNAT
522 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
523 "use gnulib module openat for portability");
528 #if @GNULIB_FDATASYNC@
529 /* Synchronize changes to a file.
530 Return 0 if successful, otherwise -1 and errno set.
531 See POSIX:2008 specification
532 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
533 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
534 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
536 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
537 _GL_CXXALIASWARN (fdatasync
);
538 #elif defined GNULIB_POSIXCHECK
540 # if HAVE_RAW_DECL_FDATASYNC
541 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
542 "use gnulib module fdatasync for portability");
548 /* Synchronize changes, including metadata, to a file.
549 Return 0 if successful, otherwise -1 and errno set.
550 See POSIX:2008 specification
551 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
553 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
555 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
556 _GL_CXXALIASWARN (fsync
);
557 #elif defined GNULIB_POSIXCHECK
559 # if HAVE_RAW_DECL_FSYNC
560 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
561 "use gnulib module fsync for portability");
566 #if @GNULIB_FTRUNCATE@
567 /* Change the size of the file to which FD is opened to become equal to LENGTH.
568 Return 0 if successful, otherwise -1 and errno set.
569 See the POSIX:2008 specification
570 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
571 # if @REPLACE_FTRUNCATE@
572 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
574 # define ftruncate rpl_ftruncate
576 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
577 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
579 # if !@HAVE_FTRUNCATE@
580 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
582 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
584 _GL_CXXALIASWARN (ftruncate
);
585 #elif defined GNULIB_POSIXCHECK
587 # if HAVE_RAW_DECL_FTRUNCATE
588 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
589 "use gnulib module ftruncate for portability");
595 /* Get the name of the current working directory, and put it in SIZE bytes
597 Return BUF if successful, or NULL if the directory couldn't be determined
598 or SIZE was too small.
599 See the POSIX:2008 specification
600 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
601 Additionally, the gnulib module 'getcwd' guarantees the following GNU
602 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
603 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
605 # if @REPLACE_GETCWD@
606 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
607 # define getcwd rpl_getcwd
609 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
610 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
612 /* Need to cast, because on mingw, the second parameter is
614 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
616 _GL_CXXALIASWARN (getcwd
);
617 #elif defined GNULIB_POSIXCHECK
619 # if HAVE_RAW_DECL_GETCWD
620 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
621 "use gnulib module getcwd for portability");
626 #if @GNULIB_GETDOMAINNAME@
627 /* Return the NIS domain name of the machine.
628 WARNING! The NIS domain name is unrelated to the fully qualified host name
629 of the machine. It is also unrelated to email addresses.
630 WARNING! The NIS domain name is usually the empty string or "(none)" when
633 Put up to LEN bytes of the NIS domain name into NAME.
634 Null terminate it if the name is shorter than LEN.
635 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
636 Return 0 if successful, otherwise set errno and return -1. */
637 # if @REPLACE_GETDOMAINNAME@
638 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
639 # undef getdomainname
640 # define getdomainname rpl_getdomainname
642 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
643 _GL_ARG_NONNULL ((1)));
644 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
646 # if !@HAVE_DECL_GETDOMAINNAME@
647 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
648 _GL_ARG_NONNULL ((1)));
650 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
652 _GL_CXXALIASWARN (getdomainname
);
653 #elif defined GNULIB_POSIXCHECK
654 # undef getdomainname
655 # if HAVE_RAW_DECL_GETDOMAINNAME
656 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
657 "use gnulib module getdomainname for portability");
662 #if @GNULIB_GETDTABLESIZE@
663 /* Return the maximum number of file descriptors in the current process.
664 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
665 # if !@HAVE_GETDTABLESIZE@
666 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
668 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
669 _GL_CXXALIASWARN (getdtablesize
);
670 #elif defined GNULIB_POSIXCHECK
671 # undef getdtablesize
672 # if HAVE_RAW_DECL_GETDTABLESIZE
673 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
674 "use gnulib module getdtablesize for portability");
679 #if @GNULIB_GETGROUPS@
680 /* Return the supplemental groups that the current process belongs to.
681 It is unspecified whether the effective group id is in the list.
682 If N is 0, return the group count; otherwise, N describes how many
683 entries are available in GROUPS. Return -1 and set errno if N is
684 not 0 and not large enough. Fails with ENOSYS on some systems. */
685 # if @REPLACE_GETGROUPS@
686 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
688 # define getgroups rpl_getgroups
690 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
691 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
693 # if !@HAVE_GETGROUPS@
694 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
696 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
698 _GL_CXXALIASWARN (getgroups
);
699 #elif defined GNULIB_POSIXCHECK
701 # if HAVE_RAW_DECL_GETGROUPS
702 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
703 "use gnulib module getgroups for portability");
708 #if @GNULIB_GETHOSTNAME@
709 /* Return the standard host name of the machine.
710 WARNING! The host name may or may not be fully qualified.
712 Put up to LEN bytes of the host name into NAME.
713 Null terminate it if the name is shorter than LEN.
714 If the host name is longer than LEN, set errno = EINVAL and return -1.
715 Return 0 if successful, otherwise set errno and return -1. */
716 # if @UNISTD_H_HAVE_WINSOCK2_H@
717 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
719 # define gethostname rpl_gethostname
721 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
722 _GL_ARG_NONNULL ((1)));
723 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
725 # if !@HAVE_GETHOSTNAME@
726 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
727 _GL_ARG_NONNULL ((1)));
729 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
732 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
734 _GL_CXXALIASWARN (gethostname
);
735 #elif @UNISTD_H_HAVE_WINSOCK2_H@
737 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
738 #elif defined GNULIB_POSIXCHECK
740 # if HAVE_RAW_DECL_GETHOSTNAME
741 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
742 "use gnulib module gethostname for portability");
747 #if @GNULIB_GETLOGIN@
748 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
749 returns NULL with errno set.
751 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
753 Most programs don't need to use this function, because the information is
754 available through environment variables:
755 ${LOGNAME-$USER} on Unix platforms,
756 $USERNAME on native Windows platforms.
758 # if !@HAVE_GETLOGIN@
759 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
761 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
762 _GL_CXXALIASWARN (getlogin
);
763 #elif defined GNULIB_POSIXCHECK
765 # if HAVE_RAW_DECL_GETLOGIN
766 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
767 "use gnulib module getlogin for portability");
772 #if @GNULIB_GETLOGIN_R@
773 /* Copies the user's login name to NAME.
774 The array pointed to by NAME has room for SIZE bytes.
776 Returns 0 if successful. Upon error, an error number is returned, or -1 in
777 the case that the login name cannot be found but no specific error is
778 provided (this case is hopefully rare but is left open by the POSIX spec).
780 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
782 Most programs don't need to use this function, because the information is
783 available through environment variables:
784 ${LOGNAME-$USER} on Unix platforms,
785 $USERNAME on native Windows platforms.
787 # if @REPLACE_GETLOGIN_R@
788 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
789 # define getlogin_r rpl_getlogin_r
791 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
792 _GL_ARG_NONNULL ((1)));
793 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
795 # if !@HAVE_DECL_GETLOGIN_R@
796 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
797 _GL_ARG_NONNULL ((1)));
799 /* Need to cast, because on Solaris 10 systems, the second argument is
801 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
803 _GL_CXXALIASWARN (getlogin_r
);
804 #elif defined GNULIB_POSIXCHECK
806 # if HAVE_RAW_DECL_GETLOGIN_R
807 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
808 "use gnulib module getlogin_r for portability");
813 #if @GNULIB_GETPAGESIZE@
814 # if @REPLACE_GETPAGESIZE@
815 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
816 # define getpagesize rpl_getpagesize
818 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
819 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
821 # if !@HAVE_GETPAGESIZE@
822 # if !defined getpagesize
823 /* This is for POSIX systems. */
824 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
825 # if ! (defined __VMS && __VMS_VER < 70000000)
826 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
829 /* This is for older VMS. */
830 # if !defined _gl_getpagesize && defined __VMS
832 # define _gl_getpagesize() 8192
834 # define _gl_getpagesize() 512
837 /* This is for BeOS. */
838 # if !defined _gl_getpagesize && @HAVE_OS_H@
840 # if defined B_PAGE_SIZE
841 # define _gl_getpagesize() B_PAGE_SIZE
844 /* This is for AmigaOS4.0. */
845 # if !defined _gl_getpagesize && defined __amigaos4__
846 # define _gl_getpagesize() 2048
848 /* This is for older Unix systems. */
849 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
850 # include <sys/param.h>
851 # ifdef EXEC_PAGESIZE
852 # define _gl_getpagesize() EXEC_PAGESIZE
858 # define _gl_getpagesize() (NBPG * CLSIZE)
861 # define _gl_getpagesize() NBPC
866 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
867 # define getpagesize() _gl_getpagesize ()
869 # if !GNULIB_defined_getpagesize_function
870 _GL_UNISTD_INLINE
int
873 return _gl_getpagesize ();
875 # define GNULIB_defined_getpagesize_function 1
880 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
881 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
883 # if @HAVE_DECL_GETPAGESIZE@
884 _GL_CXXALIASWARN (getpagesize
);
886 #elif defined GNULIB_POSIXCHECK
888 # if HAVE_RAW_DECL_GETPAGESIZE
889 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
890 "use gnulib module getpagesize for portability");
895 #if @GNULIB_GETUSERSHELL@
896 /* Return the next valid login shell on the system, or NULL when the end of
897 the list has been reached. */
898 # if !@HAVE_DECL_GETUSERSHELL@
899 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
901 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
902 _GL_CXXALIASWARN (getusershell
);
903 #elif defined GNULIB_POSIXCHECK
905 # if HAVE_RAW_DECL_GETUSERSHELL
906 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
907 "use gnulib module getusershell for portability");
911 #if @GNULIB_GETUSERSHELL@
912 /* Rewind to pointer that is advanced at each getusershell() call. */
913 # if !@HAVE_DECL_GETUSERSHELL@
914 _GL_FUNCDECL_SYS (setusershell
, void, (void));
916 _GL_CXXALIAS_SYS (setusershell
, void, (void));
917 _GL_CXXALIASWARN (setusershell
);
918 #elif defined GNULIB_POSIXCHECK
920 # if HAVE_RAW_DECL_SETUSERSHELL
921 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
922 "use gnulib module getusershell for portability");
926 #if @GNULIB_GETUSERSHELL@
927 /* Free the pointer that is advanced at each getusershell() call and
928 associated resources. */
929 # if !@HAVE_DECL_GETUSERSHELL@
930 _GL_FUNCDECL_SYS (endusershell
, void, (void));
932 _GL_CXXALIAS_SYS (endusershell
, void, (void));
933 _GL_CXXALIASWARN (endusershell
);
934 #elif defined GNULIB_POSIXCHECK
936 # if HAVE_RAW_DECL_ENDUSERSHELL
937 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
938 "use gnulib module getusershell for portability");
943 #if @GNULIB_GROUP_MEMBER@
944 /* Determine whether group id is in calling user's group list. */
945 # if !@HAVE_GROUP_MEMBER@
946 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
948 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
949 _GL_CXXALIASWARN (group_member
);
950 #elif defined GNULIB_POSIXCHECK
952 # if HAVE_RAW_DECL_GROUP_MEMBER
953 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
954 "use gnulib module group-member for portability");
960 # if @REPLACE_ISATTY@
961 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
963 # define isatty rpl_isatty
965 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
966 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
968 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
970 _GL_CXXALIASWARN (isatty
);
971 #elif defined GNULIB_POSIXCHECK
973 # if HAVE_RAW_DECL_ISATTY
974 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
975 "use gnulib module isatty for portability");
981 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
982 to GID (if GID is not -1). Do not follow symbolic links.
983 Return 0 if successful, otherwise -1 and errno set.
984 See the POSIX:2008 specification
985 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
986 # if @REPLACE_LCHOWN@
987 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
989 # define lchown rpl_lchown
991 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
992 _GL_ARG_NONNULL ((1)));
993 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
996 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
997 _GL_ARG_NONNULL ((1)));
999 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1001 _GL_CXXALIASWARN (lchown
);
1002 #elif defined GNULIB_POSIXCHECK
1004 # if HAVE_RAW_DECL_LCHOWN
1005 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1006 "use gnulib module lchown for portability");
1012 /* Create a new hard link for an existing file.
1013 Return 0 if successful, otherwise -1 and errno set.
1014 See POSIX:2008 specification
1015 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1017 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1018 # define link rpl_link
1020 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1021 _GL_ARG_NONNULL ((1, 2)));
1022 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1025 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1026 _GL_ARG_NONNULL ((1, 2)));
1028 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1030 _GL_CXXALIASWARN (link
);
1031 #elif defined GNULIB_POSIXCHECK
1033 # if HAVE_RAW_DECL_LINK
1034 _GL_WARN_ON_USE (link
, "link is unportable - "
1035 "use gnulib module link for portability");
1041 /* Create a new hard link for an existing file, relative to two
1042 directories. FLAG controls whether symlinks are followed.
1043 Return 0 if successful, otherwise -1 and errno set. */
1044 # if @REPLACE_LINKAT@
1045 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1047 # define linkat rpl_linkat
1049 _GL_FUNCDECL_RPL (linkat
, int,
1050 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1052 _GL_ARG_NONNULL ((2, 4)));
1053 _GL_CXXALIAS_RPL (linkat
, int,
1054 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1058 _GL_FUNCDECL_SYS (linkat
, int,
1059 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1061 _GL_ARG_NONNULL ((2, 4)));
1063 _GL_CXXALIAS_SYS (linkat
, int,
1064 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1067 _GL_CXXALIASWARN (linkat
);
1068 #elif defined GNULIB_POSIXCHECK
1070 # if HAVE_RAW_DECL_LINKAT
1071 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1072 "use gnulib module linkat for portability");
1078 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1079 Return the new offset if successful, otherwise -1 and errno set.
1080 See the POSIX:2008 specification
1081 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1082 # if @REPLACE_LSEEK@
1083 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1084 # define lseek rpl_lseek
1086 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1087 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1089 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1091 _GL_CXXALIASWARN (lseek
);
1092 #elif defined GNULIB_POSIXCHECK
1094 # if HAVE_RAW_DECL_LSEEK
1095 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1096 "systems - use gnulib module lseek for portability");
1102 /* Create a pipe, defaulting to O_BINARY mode.
1103 Store the read-end as fd[0] and the write-end as fd[1].
1104 Return 0 upon success, or -1 with errno set upon failure. */
1106 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1108 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1109 _GL_CXXALIASWARN (pipe
);
1110 #elif defined GNULIB_POSIXCHECK
1112 # if HAVE_RAW_DECL_PIPE
1113 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1114 "use gnulib module pipe-posix for portability");
1120 /* Create a pipe, applying the given flags when opening the read-end of the
1121 pipe and the write-end of the pipe.
1122 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1123 and O_TEXT, O_BINARY (defined in "binary-io.h").
1124 Store the read-end as fd[0] and the write-end as fd[1].
1125 Return 0 upon success, or -1 with errno set upon failure.
1126 See also the Linux man page at
1127 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1129 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1130 # define pipe2 rpl_pipe2
1132 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1133 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1135 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1136 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1138 _GL_CXXALIASWARN (pipe2
);
1139 #elif defined GNULIB_POSIXCHECK
1141 # if HAVE_RAW_DECL_PIPE2
1142 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1143 "use gnulib module pipe2 for portability");
1149 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1150 Return the number of bytes placed into BUF if successful, otherwise
1151 set errno and return -1. 0 indicates EOF.
1152 See the POSIX:2008 specification
1153 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1154 # if @REPLACE_PREAD@
1155 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1157 # define pread rpl_pread
1159 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1160 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1161 _GL_ARG_NONNULL ((2)));
1162 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1163 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1166 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1167 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1168 _GL_ARG_NONNULL ((2)));
1170 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1171 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1173 _GL_CXXALIASWARN (pread
);
1174 #elif defined GNULIB_POSIXCHECK
1176 # if HAVE_RAW_DECL_PREAD
1177 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1178 "use gnulib module pread for portability");
1184 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1185 Return the number of bytes written if successful, otherwise
1186 set errno and return -1. 0 indicates nothing written. See the
1187 POSIX:2008 specification
1188 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1189 # if @REPLACE_PWRITE@
1190 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1192 # define pwrite rpl_pwrite
1194 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1195 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1196 _GL_ARG_NONNULL ((2)));
1197 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1198 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1201 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1202 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1203 _GL_ARG_NONNULL ((2)));
1205 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1206 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1208 _GL_CXXALIASWARN (pwrite
);
1209 #elif defined GNULIB_POSIXCHECK
1211 # if HAVE_RAW_DECL_PWRITE
1212 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1213 "use gnulib module pwrite for portability");
1219 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1220 at BUF. See the POSIX:2008 specification
1221 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1223 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1225 # define read rpl_read
1227 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1228 _GL_ARG_NONNULL ((2)));
1229 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1231 /* Need to cast, because on mingw, the third parameter is
1233 and the return type is 'int'. */
1234 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1236 _GL_CXXALIASWARN (read
);
1240 #if @GNULIB_READLINK@
1241 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1242 bytes of it into BUF. Return the number of bytes placed into BUF if
1243 successful, otherwise -1 and errno set.
1244 See the POSIX:2008 specification
1245 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1246 # if @REPLACE_READLINK@
1247 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1248 # define readlink rpl_readlink
1250 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1251 (const char *file
, char *buf
, size_t bufsize
)
1252 _GL_ARG_NONNULL ((1, 2)));
1253 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1254 (const char *file
, char *buf
, size_t bufsize
));
1256 # if !@HAVE_READLINK@
1257 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1258 (const char *file
, char *buf
, size_t bufsize
)
1259 _GL_ARG_NONNULL ((1, 2)));
1261 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1262 (const char *file
, char *buf
, size_t bufsize
));
1264 _GL_CXXALIASWARN (readlink
);
1265 #elif defined GNULIB_POSIXCHECK
1267 # if HAVE_RAW_DECL_READLINK
1268 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1269 "use gnulib module readlink for portability");
1274 #if @GNULIB_READLINKAT@
1275 # if !@HAVE_READLINKAT@
1276 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1277 (int fd
, char const *file
, char *buf
, size_t len
)
1278 _GL_ARG_NONNULL ((2, 3)));
1280 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1281 (int fd
, char const *file
, char *buf
, size_t len
));
1282 _GL_CXXALIASWARN (readlinkat
);
1283 #elif defined GNULIB_POSIXCHECK
1285 # if HAVE_RAW_DECL_READLINKAT
1286 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1287 "use gnulib module readlinkat for portability");
1293 /* Remove the directory DIR. */
1294 # if @REPLACE_RMDIR@
1295 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1296 # define rmdir rpl_rmdir
1298 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1299 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1301 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1303 _GL_CXXALIASWARN (rmdir
);
1304 #elif defined GNULIB_POSIXCHECK
1306 # if HAVE_RAW_DECL_RMDIR
1307 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1308 "use gnulib module rmdir for portability");
1313 #if @GNULIB_SETHOSTNAME@
1314 /* Set the host name of the machine.
1315 The host name may or may not be fully qualified.
1317 Put LEN bytes of NAME into the host name.
1318 Return 0 if successful, otherwise, set errno and return -1.
1320 Platforms with no ability to set the hostname return -1 and set
1322 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1323 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1324 _GL_ARG_NONNULL ((1)));
1326 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1327 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1328 2011-10, the first parameter is not const. */
1329 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1330 _GL_CXXALIASWARN (sethostname
);
1331 #elif defined GNULIB_POSIXCHECK
1333 # if HAVE_RAW_DECL_SETHOSTNAME
1334 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1335 "use gnulib module sethostname for portability");
1341 /* Pause the execution of the current thread for N seconds.
1342 Returns the number of seconds left to sleep.
1343 See the POSIX:2008 specification
1344 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1345 # if @REPLACE_SLEEP@
1346 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1348 # define sleep rpl_sleep
1350 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1351 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1354 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1356 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1358 _GL_CXXALIASWARN (sleep
);
1359 #elif defined GNULIB_POSIXCHECK
1361 # if HAVE_RAW_DECL_SLEEP
1362 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1363 "use gnulib module sleep for portability");
1368 #if @GNULIB_SYMLINK@
1369 # if @REPLACE_SYMLINK@
1370 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1372 # define symlink rpl_symlink
1374 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1375 _GL_ARG_NONNULL ((1, 2)));
1376 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1378 # if !@HAVE_SYMLINK@
1379 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1380 _GL_ARG_NONNULL ((1, 2)));
1382 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1384 _GL_CXXALIASWARN (symlink
);
1385 #elif defined GNULIB_POSIXCHECK
1387 # if HAVE_RAW_DECL_SYMLINK
1388 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1389 "use gnulib module symlink for portability");
1394 #if @GNULIB_SYMLINKAT@
1395 # if !@HAVE_SYMLINKAT@
1396 _GL_FUNCDECL_SYS (symlinkat
, int,
1397 (char const *contents
, int fd
, char const *file
)
1398 _GL_ARG_NONNULL ((1, 3)));
1400 _GL_CXXALIAS_SYS (symlinkat
, int,
1401 (char const *contents
, int fd
, char const *file
));
1402 _GL_CXXALIASWARN (symlinkat
);
1403 #elif defined GNULIB_POSIXCHECK
1405 # if HAVE_RAW_DECL_SYMLINKAT
1406 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1407 "use gnulib module symlinkat for portability");
1412 #if @GNULIB_TTYNAME_R@
1413 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1414 open on in BUF. Return 0 on success, otherwise an error number. */
1415 # if @REPLACE_TTYNAME_R@
1416 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1418 # define ttyname_r rpl_ttyname_r
1420 _GL_FUNCDECL_RPL (ttyname_r
, int,
1421 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1422 _GL_CXXALIAS_RPL (ttyname_r
, int,
1423 (int fd
, char *buf
, size_t buflen
));
1425 # if !@HAVE_DECL_TTYNAME_R@
1426 _GL_FUNCDECL_SYS (ttyname_r
, int,
1427 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1429 _GL_CXXALIAS_SYS (ttyname_r
, int,
1430 (int fd
, char *buf
, size_t buflen
));
1432 _GL_CXXALIASWARN (ttyname_r
);
1433 #elif defined GNULIB_POSIXCHECK
1435 # if HAVE_RAW_DECL_TTYNAME_R
1436 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1437 "use gnulib module ttyname_r for portability");
1443 # if @REPLACE_UNLINK@
1444 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1446 # define unlink rpl_unlink
1448 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1449 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1451 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1453 _GL_CXXALIASWARN (unlink
);
1454 #elif defined GNULIB_POSIXCHECK
1456 # if HAVE_RAW_DECL_UNLINK
1457 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1458 "use gnulib module unlink for portability");
1463 #if @GNULIB_UNLINKAT@
1464 # if @REPLACE_UNLINKAT@
1465 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1467 # define unlinkat rpl_unlinkat
1469 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1470 _GL_ARG_NONNULL ((2)));
1471 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1473 # if !@HAVE_UNLINKAT@
1474 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1475 _GL_ARG_NONNULL ((2)));
1477 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1479 _GL_CXXALIASWARN (unlinkat
);
1480 #elif defined GNULIB_POSIXCHECK
1482 # if HAVE_RAW_DECL_UNLINKAT
1483 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1484 "use gnulib module openat for portability");
1490 /* Pause the execution of the current thread for N microseconds.
1491 Returns 0 on completion, or -1 on range error.
1492 See the POSIX:2001 specification
1493 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1494 # if @REPLACE_USLEEP@
1495 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1497 # define usleep rpl_usleep
1499 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1500 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1503 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1505 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1507 _GL_CXXALIASWARN (usleep
);
1508 #elif defined GNULIB_POSIXCHECK
1510 # if HAVE_RAW_DECL_USLEEP
1511 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1512 "use gnulib module usleep for portability");
1518 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1519 See the POSIX:2008 specification
1520 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1521 # if @REPLACE_WRITE@
1522 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1524 # define write rpl_write
1526 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1527 _GL_ARG_NONNULL ((2)));
1528 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1530 /* Need to cast, because on mingw, the third parameter is
1532 and the return type is 'int'. */
1533 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1535 _GL_CXXALIASWARN (write
);
1538 _GL_INLINE_HEADER_END
1540 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1541 #endif /* _@GUARD_PREFIX@_UNISTD_H */