1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2011 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, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 @PRAGMA_SYSTEM_HEADER@
23 /* Special invocation convention:
24 - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
25 but we need to ensure that both the system <unistd.h> and <winsock2.h>
26 are completely included before we replace gethostname. */
27 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
28 && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
29 /* <unistd.h> is being indirectly included for the first time from
30 <winsock2.h>; avoid declaring any overrides. */
32 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
34 # error unexpected; report this to bug-gnulib@gnu.org
36 # define _GL_WINSOCK2_H_WITNESS
38 /* Normal invocation. */
39 #elif !defined _@GUARD_PREFIX@_UNISTD_H
41 /* The include_next requires a split double-inclusion guard. */
43 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
46 /* Get all possible declarations of gethostname(). */
47 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
48 && !defined _GL_INCLUDING_WINSOCK2_H
49 # define _GL_INCLUDING_WINSOCK2_H
50 # include <winsock2.h>
51 # undef _GL_INCLUDING_WINSOCK2_H
54 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
55 #define _@GUARD_PREFIX@_UNISTD_H
57 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
60 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
61 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
62 /* But avoid namespace pollution on glibc systems. */
63 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
64 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
65 && defined __CYGWIN__)) \
66 && ! defined __GLIBC__
70 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
71 /* But avoid namespace pollution on glibc systems. */
72 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
73 && ! defined __GLIBC__
77 /* mingw fails to declare _exit in <unistd.h>. */
78 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
79 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
80 /* But avoid namespace pollution on glibc systems. */
85 /* mingw declares getcwd in <io.h>, not in <unistd.h>. */
86 #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
87 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
91 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
92 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
93 /* But avoid namespace pollution on glibc systems. */
94 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
95 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
100 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
101 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
102 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
104 # include <sys/types.h>
107 /* Get getopt(), optarg, optind, opterr, optopt.
108 But avoid namespace pollution on glibc systems. */
109 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
113 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
115 /* The definition of _GL_ARG_NONNULL is copied here. */
117 /* The definition of _GL_WARN_ON_USE is copied here. */
120 /* Hide some function declarations from <winsock2.h>. */
122 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
123 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
124 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
126 # define socket socket_used_without_including_sys_socket_h
128 # define connect connect_used_without_including_sys_socket_h
130 # define accept accept_used_without_including_sys_socket_h
132 # define bind bind_used_without_including_sys_socket_h
134 # define getpeername getpeername_used_without_including_sys_socket_h
136 # define getsockname getsockname_used_without_including_sys_socket_h
138 # define getsockopt getsockopt_used_without_including_sys_socket_h
140 # define listen listen_used_without_including_sys_socket_h
142 # define recv recv_used_without_including_sys_socket_h
144 # define send send_used_without_including_sys_socket_h
146 # define recvfrom recvfrom_used_without_including_sys_socket_h
148 # define sendto sendto_used_without_including_sys_socket_h
150 # define setsockopt setsockopt_used_without_including_sys_socket_h
152 # define shutdown shutdown_used_without_including_sys_socket_h
154 _GL_WARN_ON_USE (socket
,
155 "socket() used without including <sys/socket.h>");
156 _GL_WARN_ON_USE (connect
,
157 "connect() used without including <sys/socket.h>");
158 _GL_WARN_ON_USE (accept
,
159 "accept() used without including <sys/socket.h>");
160 _GL_WARN_ON_USE (bind
,
161 "bind() used without including <sys/socket.h>");
162 _GL_WARN_ON_USE (getpeername
,
163 "getpeername() used without including <sys/socket.h>");
164 _GL_WARN_ON_USE (getsockname
,
165 "getsockname() used without including <sys/socket.h>");
166 _GL_WARN_ON_USE (getsockopt
,
167 "getsockopt() used without including <sys/socket.h>");
168 _GL_WARN_ON_USE (listen
,
169 "listen() used without including <sys/socket.h>");
170 _GL_WARN_ON_USE (recv
,
171 "recv() used without including <sys/socket.h>");
172 _GL_WARN_ON_USE (send
,
173 "send() used without including <sys/socket.h>");
174 _GL_WARN_ON_USE (recvfrom
,
175 "recvfrom() used without including <sys/socket.h>");
176 _GL_WARN_ON_USE (sendto
,
177 "sendto() used without including <sys/socket.h>");
178 _GL_WARN_ON_USE (setsockopt
,
179 "setsockopt() used without including <sys/socket.h>");
180 _GL_WARN_ON_USE (shutdown
,
181 "shutdown() used without including <sys/socket.h>");
184 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
185 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
187 # define select select_used_without_including_sys_select_h
189 _GL_WARN_ON_USE (select
,
190 "select() used without including <sys/select.h>");
196 /* OS/2 EMX lacks these macros. */
198 # define STDIN_FILENO 0
200 #ifndef STDOUT_FILENO
201 # define STDOUT_FILENO 1
203 #ifndef STDERR_FILENO
204 # define STDERR_FILENO 2
207 /* Ensure *_OK macros exist. */
216 /* Declare overridden functions. */
219 #if defined GNULIB_POSIXCHECK
220 /* The access() function is a security risk. */
221 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
222 "use the gnulib module faccessat instead");
227 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
228 to GID (if GID is not -1). Follow symbolic links.
229 Return 0 if successful, otherwise -1 and errno set.
230 See the POSIX:2001 specification
231 <http://www.opengroup.org/susv3xsh/chown.html>. */
233 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
235 # define chown rpl_chown
237 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
238 _GL_ARG_NONNULL ((1)));
239 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
242 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
243 _GL_ARG_NONNULL ((1)));
245 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
247 _GL_CXXALIASWARN (chown
);
248 #elif defined GNULIB_POSIXCHECK
250 # if HAVE_RAW_DECL_CHOWN
251 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
252 "doesn't treat a uid or gid of -1 on some systems - "
253 "use gnulib module chown for portability");
260 /* Automatically included by modules that need a replacement for close. */
261 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
263 # define close rpl_close
265 _GL_FUNCDECL_RPL (close
, int, (int fd
));
266 _GL_CXXALIAS_RPL (close
, int, (int fd
));
268 _GL_CXXALIAS_SYS (close
, int, (int fd
));
270 _GL_CXXALIASWARN (close
);
271 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
273 # define close close_used_without_requesting_gnulib_module_close
274 #elif defined GNULIB_POSIXCHECK
276 /* Assume close is always declared. */
277 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
278 "use gnulib module close for portability");
283 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
286 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
287 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
289 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
291 _GL_CXXALIASWARN (dup
);
295 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
296 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
297 Return newfd if successful, otherwise -1 and errno set.
298 See the POSIX:2001 specification
299 <http://www.opengroup.org/susv3xsh/dup2.html>. */
301 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
302 # define dup2 rpl_dup2
304 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
305 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
308 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
310 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
312 _GL_CXXALIASWARN (dup2
);
313 #elif defined GNULIB_POSIXCHECK
315 # if HAVE_RAW_DECL_DUP2
316 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
317 "use gnulib module dup2 for portability");
323 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
325 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
326 and O_TEXT, O_BINARY (defined in "binary-io.h").
327 Close NEWFD first if it is open.
328 Return newfd if successful, otherwise -1 and errno set.
329 See the Linux man page at
330 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
332 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
333 # define dup3 rpl_dup3
335 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
336 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
338 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
339 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
341 _GL_CXXALIASWARN (dup3
);
342 #elif defined GNULIB_POSIXCHECK
344 # if HAVE_RAW_DECL_DUP3
345 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
346 "use gnulib module dup3 for portability");
352 # if !@HAVE_DECL_ENVIRON@
353 /* Set of environment variables and values. An array of strings of the form
354 "VARIABLE=VALUE", terminated with a NULL. */
355 # if defined __APPLE__ && defined __MACH__
356 # include <crt_externs.h>
357 # define environ (*_NSGetEnviron ())
362 extern char **environ
;
368 #elif defined GNULIB_POSIXCHECK
369 # if HAVE_RAW_DECL_ENVIRON
370 static inline char ***
375 _GL_WARN_ON_USE (rpl_environ
, "environ is unportable - "
376 "use gnulib module environ for portability");
378 # define environ (*rpl_environ ())
383 #if @GNULIB_EUIDACCESS@
384 /* Like access(), except that it uses the effective user id and group id of
385 the current process. */
386 # if !@HAVE_EUIDACCESS@
387 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
388 _GL_ARG_NONNULL ((1)));
390 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
391 _GL_CXXALIASWARN (euidaccess
);
392 # if defined GNULIB_POSIXCHECK
393 /* Like access(), this function is a security risk. */
394 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
395 "use the gnulib module faccessat instead");
397 #elif defined GNULIB_POSIXCHECK
399 # if HAVE_RAW_DECL_EUIDACCESS
400 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
401 "use gnulib module euidaccess for portability");
406 #if @GNULIB_FACCESSAT@
407 # if !@HAVE_FACCESSAT@
408 _GL_FUNCDECL_SYS (faccessat
, int,
409 (int fd
, char const *file
, int mode
, int flag
)
410 _GL_ARG_NONNULL ((2)));
412 _GL_CXXALIAS_SYS (faccessat
, int,
413 (int fd
, char const *file
, int mode
, int flag
));
414 _GL_CXXALIASWARN (faccessat
);
415 #elif defined GNULIB_POSIXCHECK
417 # if HAVE_RAW_DECL_FACCESSAT
418 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
419 "use gnulib module faccessat for portability");
425 /* Change the process' current working directory to the directory on which
426 the given file descriptor is open.
427 Return 0 if successful, otherwise -1 and errno set.
428 See the POSIX:2001 specification
429 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
431 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
433 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
434 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
435 _GL_ARG_NONNULL ((2));
436 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
437 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
438 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
441 # if !@HAVE_DECL_FCHDIR@
442 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
445 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
446 _GL_CXXALIASWARN (fchdir
);
447 #elif defined GNULIB_POSIXCHECK
449 # if HAVE_RAW_DECL_FCHDIR
450 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
451 "use gnulib module fchdir for portability");
456 #if @GNULIB_FCHOWNAT@
457 # if @REPLACE_FCHOWNAT@
458 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
460 # define fchownat rpl_fchownat
462 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
463 uid_t owner
, gid_t group
, int flag
)
464 _GL_ARG_NONNULL ((2)));
465 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
466 uid_t owner
, gid_t group
, int flag
));
468 # if !@HAVE_FCHOWNAT@
469 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
470 uid_t owner
, gid_t group
, int flag
)
471 _GL_ARG_NONNULL ((2)));
473 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
474 uid_t owner
, gid_t group
, int flag
));
476 _GL_CXXALIASWARN (fchownat
);
477 #elif defined GNULIB_POSIXCHECK
479 # if HAVE_RAW_DECL_FCHOWNAT
480 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
481 "use gnulib module openat for portability");
487 /* Synchronize changes to a file.
488 Return 0 if successful, otherwise -1 and errno set.
489 See POSIX:2001 specification
490 <http://www.opengroup.org/susv3xsh/fsync.html>. */
492 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
494 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
495 _GL_CXXALIASWARN (fsync
);
496 #elif defined GNULIB_POSIXCHECK
498 # if HAVE_RAW_DECL_FSYNC
499 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
500 "use gnulib module fsync for portability");
505 #if @GNULIB_FTRUNCATE@
506 /* Change the size of the file to which FD is opened to become equal to LENGTH.
507 Return 0 if successful, otherwise -1 and errno set.
508 See the POSIX:2001 specification
509 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
510 # if !@HAVE_FTRUNCATE@
511 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
513 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
514 _GL_CXXALIASWARN (ftruncate
);
515 #elif defined GNULIB_POSIXCHECK
517 # if HAVE_RAW_DECL_FTRUNCATE
518 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
519 "use gnulib module ftruncate for portability");
525 /* Get the name of the current working directory, and put it in SIZE bytes
527 Return BUF if successful, or NULL if the directory couldn't be determined
528 or SIZE was too small.
529 See the POSIX:2001 specification
530 <http://www.opengroup.org/susv3xsh/getcwd.html>.
531 Additionally, the gnulib module 'getcwd' guarantees the following GNU
532 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
533 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
535 # if @REPLACE_GETCWD@
536 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
537 # define getcwd rpl_getcwd
539 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
540 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
542 /* Need to cast, because on mingw, the second parameter is
544 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
546 _GL_CXXALIASWARN (getcwd
);
547 #elif defined GNULIB_POSIXCHECK
549 # if HAVE_RAW_DECL_GETCWD
550 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
551 "use gnulib module getcwd for portability");
556 #if @GNULIB_GETDOMAINNAME@
557 /* Return the NIS domain name of the machine.
558 WARNING! The NIS domain name is unrelated to the fully qualified host name
559 of the machine. It is also unrelated to email addresses.
560 WARNING! The NIS domain name is usually the empty string or "(none)" when
563 Put up to LEN bytes of the NIS domain name into NAME.
564 Null terminate it if the name is shorter than LEN.
565 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
566 Return 0 if successful, otherwise set errno and return -1. */
567 # if @REPLACE_GETDOMAINNAME@
568 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
569 # undef getdomainname
570 # define getdomainname rpl_getdomainname
572 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
573 _GL_ARG_NONNULL ((1)));
574 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
576 # if !@HAVE_DECL_GETDOMAINNAME@
577 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
578 _GL_ARG_NONNULL ((1)));
580 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
582 _GL_CXXALIASWARN (getdomainname
);
583 #elif defined GNULIB_POSIXCHECK
584 # undef getdomainname
585 # if HAVE_RAW_DECL_GETDOMAINNAME
586 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
587 "use gnulib module getdomainname for portability");
592 #if @GNULIB_GETDTABLESIZE@
593 /* Return the maximum number of file descriptors in the current process.
594 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
595 # if !@HAVE_GETDTABLESIZE@
596 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
598 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
599 _GL_CXXALIASWARN (getdtablesize
);
600 #elif defined GNULIB_POSIXCHECK
601 # undef getdtablesize
602 # if HAVE_RAW_DECL_GETDTABLESIZE
603 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
604 "use gnulib module getdtablesize for portability");
609 #if @GNULIB_GETGROUPS@
610 /* Return the supplemental groups that the current process belongs to.
611 It is unspecified whether the effective group id is in the list.
612 If N is 0, return the group count; otherwise, N describes how many
613 entries are available in GROUPS. Return -1 and set errno if N is
614 not 0 and not large enough. Fails with ENOSYS on some systems. */
615 # if @REPLACE_GETGROUPS@
616 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
618 # define getgroups rpl_getgroups
620 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
621 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
623 # if !@HAVE_GETGROUPS@
624 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
626 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
628 _GL_CXXALIASWARN (getgroups
);
629 #elif defined GNULIB_POSIXCHECK
631 # if HAVE_RAW_DECL_GETGROUPS
632 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
633 "use gnulib module getgroups for portability");
638 #if @GNULIB_GETHOSTNAME@
639 /* Return the standard host name of the machine.
640 WARNING! The host name may or may not be fully qualified.
642 Put up to LEN bytes of the host name into NAME.
643 Null terminate it if the name is shorter than LEN.
644 If the host name is longer than LEN, set errno = EINVAL and return -1.
645 Return 0 if successful, otherwise set errno and return -1. */
646 # if @UNISTD_H_HAVE_WINSOCK2_H@
647 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
649 # define gethostname rpl_gethostname
651 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
652 _GL_ARG_NONNULL ((1)));
653 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
655 # if !@HAVE_GETHOSTNAME@
656 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
657 _GL_ARG_NONNULL ((1)));
659 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
662 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
664 _GL_CXXALIASWARN (gethostname
);
665 #elif @UNISTD_H_HAVE_WINSOCK2_H@
667 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
668 #elif defined GNULIB_POSIXCHECK
670 # if HAVE_RAW_DECL_GETHOSTNAME
671 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
672 "use gnulib module gethostname for portability");
677 #if @GNULIB_GETLOGIN@
678 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
679 returns NULL with errno set.
681 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
683 Most programs don't need to use this function, because the information is
684 available through environment variables:
685 ${LOGNAME-$USER} on Unix platforms,
686 $USERNAME on native Windows platforms.
688 # if !@HAVE_GETLOGIN@
689 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
691 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
692 _GL_CXXALIASWARN (getlogin
);
693 #elif defined GNULIB_POSIXCHECK
695 # if HAVE_RAW_DECL_GETLOGIN
696 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
697 "use gnulib module getlogin for portability");
702 #if @GNULIB_GETLOGIN_R@
703 /* Copies the user's login name to NAME.
704 The array pointed to by NAME has room for SIZE bytes.
706 Returns 0 if successful. Upon error, an error number is returned, or -1 in
707 the case that the login name cannot be found but no specific error is
708 provided (this case is hopefully rare but is left open by the POSIX spec).
710 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
712 Most programs don't need to use this function, because the information is
713 available through environment variables:
714 ${LOGNAME-$USER} on Unix platforms,
715 $USERNAME on native Windows platforms.
717 # if @REPLACE_GETLOGIN_R@
718 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
719 # define getlogin_r rpl_getlogin_r
721 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
722 _GL_ARG_NONNULL ((1)));
723 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
725 # if !@HAVE_DECL_GETLOGIN_R@
726 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
727 _GL_ARG_NONNULL ((1)));
729 /* Need to cast, because on Solaris 10 systems, the second argument is
731 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
733 _GL_CXXALIASWARN (getlogin_r
);
734 #elif defined GNULIB_POSIXCHECK
736 # if HAVE_RAW_DECL_GETLOGIN_R
737 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
738 "use gnulib module getlogin_r for portability");
743 #if @GNULIB_GETPAGESIZE@
744 # if @REPLACE_GETPAGESIZE@
745 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
746 # define getpagesize rpl_getpagesize
748 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
749 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
751 # if !@HAVE_GETPAGESIZE@
752 # if !defined getpagesize
753 /* This is for POSIX systems. */
754 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
755 # if ! (defined __VMS && __VMS_VER < 70000000)
756 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
759 /* This is for older VMS. */
760 # if !defined _gl_getpagesize && defined __VMS
762 # define _gl_getpagesize() 8192
764 # define _gl_getpagesize() 512
767 /* This is for BeOS. */
768 # if !defined _gl_getpagesize && @HAVE_OS_H@
770 # if defined B_PAGE_SIZE
771 # define _gl_getpagesize() B_PAGE_SIZE
774 /* This is for AmigaOS4.0. */
775 # if !defined _gl_getpagesize && defined __amigaos4__
776 # define _gl_getpagesize() 2048
778 /* This is for older Unix systems. */
779 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
780 # include <sys/param.h>
781 # ifdef EXEC_PAGESIZE
782 # define _gl_getpagesize() EXEC_PAGESIZE
788 # define _gl_getpagesize() (NBPG * CLSIZE)
791 # define _gl_getpagesize() NBPC
796 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
797 # define getpagesize() _gl_getpagesize ()
799 # if !GNULIB_defined_getpagesize_function
803 return _gl_getpagesize ();
805 # define GNULIB_defined_getpagesize_function 1
810 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
811 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
813 # if @HAVE_DECL_GETPAGESIZE@
814 _GL_CXXALIASWARN (getpagesize
);
816 #elif defined GNULIB_POSIXCHECK
818 # if HAVE_RAW_DECL_GETPAGESIZE
819 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
820 "use gnulib module getpagesize for portability");
825 #if @GNULIB_GETUSERSHELL@
826 /* Return the next valid login shell on the system, or NULL when the end of
827 the list has been reached. */
828 # if !@HAVE_DECL_GETUSERSHELL@
829 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
831 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
832 _GL_CXXALIASWARN (getusershell
);
833 #elif defined GNULIB_POSIXCHECK
835 # if HAVE_RAW_DECL_GETUSERSHELL
836 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
837 "use gnulib module getusershell for portability");
841 #if @GNULIB_GETUSERSHELL@
842 /* Rewind to pointer that is advanced at each getusershell() call. */
843 # if !@HAVE_DECL_GETUSERSHELL@
844 _GL_FUNCDECL_SYS (setusershell
, void, (void));
846 _GL_CXXALIAS_SYS (setusershell
, void, (void));
847 _GL_CXXALIASWARN (setusershell
);
848 #elif defined GNULIB_POSIXCHECK
850 # if HAVE_RAW_DECL_SETUSERSHELL
851 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
852 "use gnulib module getusershell for portability");
856 #if @GNULIB_GETUSERSHELL@
857 /* Free the pointer that is advanced at each getusershell() call and
858 associated resources. */
859 # if !@HAVE_DECL_GETUSERSHELL@
860 _GL_FUNCDECL_SYS (endusershell
, void, (void));
862 _GL_CXXALIAS_SYS (endusershell
, void, (void));
863 _GL_CXXALIASWARN (endusershell
);
864 #elif defined GNULIB_POSIXCHECK
866 # if HAVE_RAW_DECL_ENDUSERSHELL
867 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
868 "use gnulib module getusershell for portability");
873 #if @GNULIB_GROUP_MEMBER@
874 /* Determine whether group id is in calling user's group list. */
875 # if !@HAVE_GROUP_MEMBER@
876 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
878 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
879 _GL_CXXALIASWARN (group_member
);
880 #elif defined GNULIB_POSIXCHECK
882 # if HAVE_RAW_DECL_GROUP_MEMBER
883 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
884 "use gnulib module group-member for portability");
890 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
891 to GID (if GID is not -1). Do not follow symbolic links.
892 Return 0 if successful, otherwise -1 and errno set.
893 See the POSIX:2001 specification
894 <http://www.opengroup.org/susv3xsh/lchown.html>. */
895 # if @REPLACE_LCHOWN@
896 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
898 # define lchown rpl_lchown
900 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
901 _GL_ARG_NONNULL ((1)));
902 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
905 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
906 _GL_ARG_NONNULL ((1)));
908 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
910 _GL_CXXALIASWARN (lchown
);
911 #elif defined GNULIB_POSIXCHECK
913 # if HAVE_RAW_DECL_LCHOWN
914 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
915 "use gnulib module lchown for portability");
921 /* Create a new hard link for an existing file.
922 Return 0 if successful, otherwise -1 and errno set.
923 See POSIX:2001 specification
924 <http://www.opengroup.org/susv3xsh/link.html>. */
926 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
927 # define link rpl_link
929 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
930 _GL_ARG_NONNULL ((1, 2)));
931 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
934 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
935 _GL_ARG_NONNULL ((1, 2)));
937 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
939 _GL_CXXALIASWARN (link
);
940 #elif defined GNULIB_POSIXCHECK
942 # if HAVE_RAW_DECL_LINK
943 _GL_WARN_ON_USE (link
, "link is unportable - "
944 "use gnulib module link for portability");
950 /* Create a new hard link for an existing file, relative to two
951 directories. FLAG controls whether symlinks are followed.
952 Return 0 if successful, otherwise -1 and errno set. */
953 # if @REPLACE_LINKAT@
954 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
956 # define linkat rpl_linkat
958 _GL_FUNCDECL_RPL (linkat
, int,
959 (int fd1
, const char *path1
, int fd2
, const char *path2
,
961 _GL_ARG_NONNULL ((2, 4)));
962 _GL_CXXALIAS_RPL (linkat
, int,
963 (int fd1
, const char *path1
, int fd2
, const char *path2
,
967 _GL_FUNCDECL_SYS (linkat
, int,
968 (int fd1
, const char *path1
, int fd2
, const char *path2
,
970 _GL_ARG_NONNULL ((2, 4)));
972 _GL_CXXALIAS_SYS (linkat
, int,
973 (int fd1
, const char *path1
, int fd2
, const char *path2
,
976 _GL_CXXALIASWARN (linkat
);
977 #elif defined GNULIB_POSIXCHECK
979 # if HAVE_RAW_DECL_LINKAT
980 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
981 "use gnulib module linkat for portability");
987 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
988 Return the new offset if successful, otherwise -1 and errno set.
989 See the POSIX:2001 specification
990 <http://www.opengroup.org/susv3xsh/lseek.html>. */
992 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
993 # define lseek rpl_lseek
995 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
996 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
998 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1000 _GL_CXXALIASWARN (lseek
);
1001 #elif defined GNULIB_POSIXCHECK
1003 # if HAVE_RAW_DECL_LSEEK
1004 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1005 "systems - use gnulib module lseek for portability");
1011 /* Create a pipe, defaulting to O_BINARY mode.
1012 Store the read-end as fd[0] and the write-end as fd[1].
1013 Return 0 upon success, or -1 with errno set upon failure. */
1015 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1017 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1018 _GL_CXXALIASWARN (pipe
);
1019 #elif defined GNULIB_POSIXCHECK
1021 # if HAVE_RAW_DECL_PIPE
1022 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1023 "use gnulib module pipe-posix for portability");
1029 /* Create a pipe, applying the given flags when opening the read-end of the
1030 pipe and the write-end of the pipe.
1031 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1032 and O_TEXT, O_BINARY (defined in "binary-io.h").
1033 Store the read-end as fd[0] and the write-end as fd[1].
1034 Return 0 upon success, or -1 with errno set upon failure.
1035 See also the Linux man page at
1036 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1038 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1039 # define pipe2 rpl_pipe2
1041 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1042 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1044 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1045 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1047 _GL_CXXALIASWARN (pipe2
);
1048 #elif defined GNULIB_POSIXCHECK
1050 # if HAVE_RAW_DECL_PIPE2
1051 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1052 "use gnulib module pipe2 for portability");
1058 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1059 Return the number of bytes placed into BUF if successful, otherwise
1060 set errno and return -1. 0 indicates EOF. See the POSIX:2001
1061 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
1062 # if @REPLACE_PREAD@
1063 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1065 # define pread rpl_pread
1067 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1068 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1069 _GL_ARG_NONNULL ((2)));
1070 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1071 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1074 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1075 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1076 _GL_ARG_NONNULL ((2)));
1078 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1079 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1081 _GL_CXXALIASWARN (pread
);
1082 #elif defined GNULIB_POSIXCHECK
1084 # if HAVE_RAW_DECL_PREAD
1085 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1086 "use gnulib module pread for portability");
1092 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1093 Return the number of bytes written if successful, otherwise
1094 set errno and return -1. 0 indicates nothing written. See the
1095 POSIX:2001 specification
1096 <http://www.opengroup.org/susv3xsh/pwrite.html>. */
1097 # if @REPLACE_PWRITE@
1098 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1100 # define pwrite rpl_pwrite
1102 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1103 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1104 _GL_ARG_NONNULL ((2)));
1105 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1106 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1109 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1110 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1111 _GL_ARG_NONNULL ((2)));
1113 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1114 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1116 _GL_CXXALIASWARN (pwrite
);
1117 #elif defined GNULIB_POSIXCHECK
1119 # if HAVE_RAW_DECL_PWRITE
1120 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1121 "use gnulib module pwrite for portability");
1127 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1128 at BUF. See the POSIX:2001 specification
1129 <http://www.opengroup.org/susv3xsh/read.html>. */
1130 # if @REPLACE_READ@ && @GNULIB_UNISTD_H_NONBLOCKING@
1131 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1133 # define read rpl_read
1135 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1136 _GL_ARG_NONNULL ((2)));
1137 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1139 /* Need to cast, because on mingw, the third parameter is
1141 and the return type is 'int'. */
1142 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1144 _GL_CXXALIASWARN (read
);
1148 #if @GNULIB_READLINK@
1149 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1150 bytes of it into BUF. Return the number of bytes placed into BUF if
1151 successful, otherwise -1 and errno set.
1152 See the POSIX:2001 specification
1153 <http://www.opengroup.org/susv3xsh/readlink.html>. */
1154 # if @REPLACE_READLINK@
1155 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1156 # define readlink rpl_readlink
1158 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1159 (const char *file
, char *buf
, size_t bufsize
)
1160 _GL_ARG_NONNULL ((1, 2)));
1161 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1162 (const char *file
, char *buf
, size_t bufsize
));
1164 # if !@HAVE_READLINK@
1165 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1166 (const char *file
, char *buf
, size_t bufsize
)
1167 _GL_ARG_NONNULL ((1, 2)));
1169 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1170 (const char *file
, char *buf
, size_t bufsize
));
1172 _GL_CXXALIASWARN (readlink
);
1173 #elif defined GNULIB_POSIXCHECK
1175 # if HAVE_RAW_DECL_READLINK
1176 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1177 "use gnulib module readlink for portability");
1182 #if @GNULIB_READLINKAT@
1183 # if !@HAVE_READLINKAT@
1184 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1185 (int fd
, char const *file
, char *buf
, size_t len
)
1186 _GL_ARG_NONNULL ((2, 3)));
1188 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1189 (int fd
, char const *file
, char *buf
, size_t len
));
1190 _GL_CXXALIASWARN (readlinkat
);
1191 #elif defined GNULIB_POSIXCHECK
1193 # if HAVE_RAW_DECL_READLINKAT
1194 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1195 "use gnulib module readlinkat for portability");
1201 /* Remove the directory DIR. */
1202 # if @REPLACE_RMDIR@
1203 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1204 # define rmdir rpl_rmdir
1206 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1207 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1209 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1211 _GL_CXXALIASWARN (rmdir
);
1212 #elif defined GNULIB_POSIXCHECK
1214 # if HAVE_RAW_DECL_RMDIR
1215 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1216 "use gnulib module rmdir for portability");
1222 /* Pause the execution of the current thread for N seconds.
1223 Returns the number of seconds left to sleep.
1224 See the POSIX:2001 specification
1225 <http://www.opengroup.org/susv3xsh/sleep.html>. */
1226 # if @REPLACE_SLEEP@
1227 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1229 # define sleep rpl_sleep
1231 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1232 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1235 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1237 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1239 _GL_CXXALIASWARN (sleep
);
1240 #elif defined GNULIB_POSIXCHECK
1242 # if HAVE_RAW_DECL_SLEEP
1243 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1244 "use gnulib module sleep for portability");
1249 #if @GNULIB_SYMLINK@
1250 # if @REPLACE_SYMLINK@
1251 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1253 # define symlink rpl_symlink
1255 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1256 _GL_ARG_NONNULL ((1, 2)));
1257 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1259 # if !@HAVE_SYMLINK@
1260 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1261 _GL_ARG_NONNULL ((1, 2)));
1263 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1265 _GL_CXXALIASWARN (symlink
);
1266 #elif defined GNULIB_POSIXCHECK
1268 # if HAVE_RAW_DECL_SYMLINK
1269 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1270 "use gnulib module symlink for portability");
1275 #if @GNULIB_SYMLINKAT@
1276 # if !@HAVE_SYMLINKAT@
1277 _GL_FUNCDECL_SYS (symlinkat
, int,
1278 (char const *contents
, int fd
, char const *file
)
1279 _GL_ARG_NONNULL ((1, 3)));
1281 _GL_CXXALIAS_SYS (symlinkat
, int,
1282 (char const *contents
, int fd
, char const *file
));
1283 _GL_CXXALIASWARN (symlinkat
);
1284 #elif defined GNULIB_POSIXCHECK
1286 # if HAVE_RAW_DECL_SYMLINKAT
1287 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1288 "use gnulib module symlinkat for portability");
1293 #if @GNULIB_TTYNAME_R@
1294 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1295 open on in BUF. Return 0 on success, otherwise an error number. */
1296 # if @REPLACE_TTYNAME_R@
1297 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1299 # define ttyname_r rpl_ttyname_r
1301 _GL_FUNCDECL_RPL (ttyname_r
, int,
1302 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1303 _GL_CXXALIAS_RPL (ttyname_r
, int,
1304 (int fd
, char *buf
, size_t buflen
));
1306 # if !@HAVE_DECL_TTYNAME_R@
1307 _GL_FUNCDECL_SYS (ttyname_r
, int,
1308 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
1310 _GL_CXXALIAS_SYS (ttyname_r
, int,
1311 (int fd
, char *buf
, size_t buflen
));
1313 _GL_CXXALIASWARN (ttyname_r
);
1314 #elif defined GNULIB_POSIXCHECK
1316 # if HAVE_RAW_DECL_TTYNAME_R
1317 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
1318 "use gnulib module ttyname_r for portability");
1324 # if @REPLACE_UNLINK@
1325 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1327 # define unlink rpl_unlink
1329 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
1330 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
1332 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
1334 _GL_CXXALIASWARN (unlink
);
1335 #elif defined GNULIB_POSIXCHECK
1337 # if HAVE_RAW_DECL_UNLINK
1338 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
1339 "use gnulib module unlink for portability");
1344 #if @GNULIB_UNLINKAT@
1345 # if @REPLACE_UNLINKAT@
1346 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1348 # define unlinkat rpl_unlinkat
1350 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
1351 _GL_ARG_NONNULL ((2)));
1352 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
1354 # if !@HAVE_UNLINKAT@
1355 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
1356 _GL_ARG_NONNULL ((2)));
1358 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
1360 _GL_CXXALIASWARN (unlinkat
);
1361 #elif defined GNULIB_POSIXCHECK
1363 # if HAVE_RAW_DECL_UNLINKAT
1364 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
1365 "use gnulib module openat for portability");
1371 /* Pause the execution of the current thread for N microseconds.
1372 Returns 0 on completion, or -1 on range error.
1373 See the POSIX:2001 specification
1374 <http://www.opengroup.org/susv3xsh/sleep.html>. */
1375 # if @REPLACE_USLEEP@
1376 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1378 # define usleep rpl_usleep
1380 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
1381 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
1384 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
1386 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
1388 _GL_CXXALIASWARN (usleep
);
1389 #elif defined GNULIB_POSIXCHECK
1391 # if HAVE_RAW_DECL_USLEEP
1392 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
1393 "use gnulib module usleep for portability");
1399 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1400 See the POSIX:2001 specification
1401 <http://www.opengroup.org/susv3xsh/write.html>. */
1402 # if @REPLACE_WRITE@ && (@GNULIB_UNISTD_H_NONBLOCKING@ || @GNULIB_UNISTD_H_SIGPIPE@)
1403 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1405 # define write rpl_write
1407 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
1408 _GL_ARG_NONNULL ((2)));
1409 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1411 /* Need to cast, because on mingw, the third parameter is
1413 and the return type is 'int'. */
1414 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
1416 _GL_CXXALIASWARN (write
);
1420 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1421 #endif /* _@GUARD_PREFIX@_UNISTD_H */