1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Substitute for and wrapper around <unistd.h>.
4 Copyright (C) 2003-2010 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
23 @PRAGMA_SYSTEM_HEADER@
26 /* The include_next requires a split double-inclusion guard. */
28 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
34 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
37 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
38 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
39 /* But avoid namespace pollution on glibc systems. */
40 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
41 || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \
42 && ! defined __GLIBC__
46 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
47 /* But avoid namespace pollution on glibc systems. */
48 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
52 /* mingw fails to declare _exit in <unistd.h>. */
53 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
54 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
55 /* But avoid namespace pollution on glibc systems. */
60 /* mingw declares getcwd in <io.h>, not in <unistd.h>. */
61 #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
62 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
66 #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
67 || @GNULIB_PREAD@ || defined GNULIB_POSIXCHECK)
69 # include <sys/types.h>
72 /* Get getopt(), optarg, optind, opterr, optopt.
73 But avoid namespace pollution on glibc systems. */
74 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
78 #if @GNULIB_GETHOSTNAME@
79 /* Get all possible declarations of gethostname(). */
80 # if @UNISTD_H_HAVE_WINSOCK2_H@
81 # include <winsock2.h>
82 # if !defined _GL_SYS_SOCKET_H
84 # define socket socket_used_without_including_sys_socket_h
86 # define connect connect_used_without_including_sys_socket_h
88 # define accept accept_used_without_including_sys_socket_h
90 # define bind bind_used_without_including_sys_socket_h
92 # define getpeername getpeername_used_without_including_sys_socket_h
94 # define getsockname getsockname_used_without_including_sys_socket_h
96 # define getsockopt getsockopt_used_without_including_sys_socket_h
98 # define listen listen_used_without_including_sys_socket_h
100 # define recv recv_used_without_including_sys_socket_h
102 # define send send_used_without_including_sys_socket_h
104 # define recvfrom recvfrom_used_without_including_sys_socket_h
106 # define sendto sendto_used_without_including_sys_socket_h
108 # define setsockopt setsockopt_used_without_including_sys_socket_h
110 # define shutdown shutdown_used_without_including_sys_socket_h
112 # if !defined _GL_SYS_SELECT_H
114 # define select select_used_without_including_sys_select_h
119 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
121 /* The definition of _GL_ARG_NONNULL is copied here. */
123 /* The definition of _GL_WARN_ON_USE is copied here. */
126 /* OS/2 EMX lacks these macros. */
128 # define STDIN_FILENO 0
130 #ifndef STDOUT_FILENO
131 # define STDOUT_FILENO 1
133 #ifndef STDERR_FILENO
134 # define STDERR_FILENO 2
137 /* Ensure *_OK macros exist. */
146 /* Declare overridden functions. */
149 #if defined GNULIB_POSIXCHECK
150 /* The access() function is a security risk. */
151 _GL_WARN_ON_USE (access, "the access function is a security risk - "
152 "use the gnulib module faccessat instead");
157 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
158 to GID (if GID is not -1). Follow symbolic links.
159 Return 0 if successful, otherwise -1 and errno set.
160 See the POSIX:2001 specification
161 <http://www.opengroup.org/susv3xsh/chown.html>. */
163 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
165 # define chown rpl_chown
167 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
168 _GL_ARG_NONNULL ((1)));
169 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
172 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
173 _GL_ARG_NONNULL ((1)));
175 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
177 _GL_CXXALIASWARN (chown);
178 #elif defined GNULIB_POSIXCHECK
180 # if HAVE_RAW_DECL_CHOWN
181 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
182 "doesn't treat a uid or gid of -1 on some systems - "
183 "use gnulib module chown for portability");
190 /* Automatically included by modules that need a replacement for close. */
191 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
193 # define close rpl_close
195 _GL_FUNCDECL_RPL (close, int, (int fd));
196 _GL_CXXALIAS_RPL (close, int, (int fd));
198 _GL_CXXALIAS_SYS (close, int, (int fd));
200 _GL_CXXALIASWARN (close);
201 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
203 # define close close_used_without_requesting_gnulib_module_close
204 #elif defined GNULIB_POSIXCHECK
206 /* Assume close is always declared. */
207 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
208 "use gnulib module close for portability");
213 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
216 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
217 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
219 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
221 _GL_CXXALIASWARN (dup);
225 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
226 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
227 Return newfd if successful, otherwise -1 and errno set.
228 See the POSIX:2001 specification
229 <http://www.opengroup.org/susv3xsh/dup2.html>. */
231 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
232 # define dup2 rpl_dup2
234 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
235 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
238 _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
240 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
242 _GL_CXXALIASWARN (dup2);
243 #elif defined GNULIB_POSIXCHECK
245 # if HAVE_RAW_DECL_DUP2
246 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
247 "use gnulib module dup2 for portability");
253 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
255 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
256 and O_TEXT, O_BINARY (defined in "binary-io.h").
257 Close NEWFD first if it is open.
258 Return newfd if successful, otherwise -1 and errno set.
259 See the Linux man page at
260 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
262 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
263 # define dup3 rpl_dup3
265 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
266 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
268 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
269 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
271 _GL_CXXALIASWARN (dup3);
272 #elif defined GNULIB_POSIXCHECK
274 # if HAVE_RAW_DECL_DUP3
275 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
276 "use gnulib module dup3 for portability");
282 # if !@HAVE_DECL_ENVIRON@
283 /* Set of environment variables and values. An array of strings of the form
284 "VARIABLE=VALUE", terminated with a NULL. */
285 # if defined __APPLE__ && defined __MACH__
286 # include <crt_externs.h>
287 # define environ (*_NSGetEnviron ())
292 extern char **environ;
298 #elif defined GNULIB_POSIXCHECK
299 # if HAVE_RAW_DECL_ENVIRON
300 static inline char ***
305 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
306 "use gnulib module environ for portability");
308 # define environ (*rpl_environ ())
313 #if @GNULIB_EUIDACCESS@
314 /* Like access(), except that it uses the effective user id and group id of
315 the current process. */
316 # if !@HAVE_EUIDACCESS@
317 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
318 _GL_ARG_NONNULL ((1)));
320 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
321 _GL_CXXALIASWARN (euidaccess);
322 # if defined GNULIB_POSIXCHECK
323 /* Like access(), this function is a security risk. */
324 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
325 "use the gnulib module faccessat instead");
327 #elif defined GNULIB_POSIXCHECK
329 # if HAVE_RAW_DECL_EUIDACCESS
330 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
331 "use gnulib module euidaccess for portability");
336 #if @GNULIB_FACCESSAT@
337 # if !@HAVE_FACCESSAT@
338 _GL_FUNCDECL_SYS (faccessat, int,
339 (int fd, char const *file, int mode, int flag)
340 _GL_ARG_NONNULL ((2)));
342 _GL_CXXALIAS_SYS (faccessat, int,
343 (int fd, char const *file, int mode, int flag));
344 _GL_CXXALIASWARN (faccessat);
345 #elif defined GNULIB_POSIXCHECK
347 # if HAVE_RAW_DECL_FACCESSAT
348 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
349 "use gnulib module faccessat for portability");
355 /* Change the process' current working directory to the directory on which
356 the given file descriptor is open.
357 Return 0 if successful, otherwise -1 and errno set.
358 See the POSIX:2001 specification
359 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
360 # if @REPLACE_FCHDIR@
361 _GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/));
362 _GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/));
364 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
365 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
366 _GL_ARG_NONNULL ((2));
367 _GL_EXTERN_C void _gl_unregister_fd (int fd);
368 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
369 _GL_EXTERN_C const char *_gl_directory_name (int fd);
372 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
374 _GL_CXXALIASWARN (fchdir);
375 #elif defined GNULIB_POSIXCHECK
377 # if HAVE_RAW_DECL_FCHDIR
378 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
379 "use gnulib module fchdir for portability");
384 #if @GNULIB_FCHOWNAT@
385 # if @REPLACE_FCHOWNAT@
386 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
388 # define fchownat rpl_fchownat
390 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
391 uid_t owner, gid_t group, int flag)
392 _GL_ARG_NONNULL ((2)));
393 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
394 uid_t owner, gid_t group, int flag));
396 # if !@HAVE_FCHOWNAT@
397 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
398 uid_t owner, gid_t group, int flag)
399 _GL_ARG_NONNULL ((2)));
401 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
402 uid_t owner, gid_t group, int flag));
404 _GL_CXXALIASWARN (fchownat);
405 #elif defined GNULIB_POSIXCHECK
407 # if HAVE_RAW_DECL_FCHOWNAT
408 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
409 "use gnulib module openat for portability");
415 /* Synchronize changes to a file.
416 Return 0 if successful, otherwise -1 and errno set.
417 See POSIX:2001 specification
418 <http://www.opengroup.org/susv3xsh/fsync.html>. */
420 _GL_FUNCDECL_SYS (fsync, int, (int fd));
422 _GL_CXXALIAS_SYS (fsync, int, (int fd));
423 _GL_CXXALIASWARN (fsync);
424 #elif defined GNULIB_POSIXCHECK
426 # if HAVE_RAW_DECL_FSYNC
427 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
428 "use gnulib module fsync for portability");
433 #if @GNULIB_FTRUNCATE@
434 /* Change the size of the file to which FD is opened to become equal to LENGTH.
435 Return 0 if successful, otherwise -1 and errno set.
436 See the POSIX:2001 specification
437 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
438 # if !@HAVE_FTRUNCATE@
439 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
441 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
442 _GL_CXXALIASWARN (ftruncate);
443 #elif defined GNULIB_POSIXCHECK
445 # if HAVE_RAW_DECL_FTRUNCATE
446 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
447 "use gnulib module ftruncate for portability");
453 /* Get the name of the current working directory, and put it in SIZE bytes
455 Return BUF if successful, or NULL if the directory couldn't be determined
456 or SIZE was too small.
457 See the POSIX:2001 specification
458 <http://www.opengroup.org/susv3xsh/getcwd.html>.
459 Additionally, the gnulib module 'getcwd' guarantees the following GNU
460 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
461 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
463 # if @REPLACE_GETCWD@
464 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
465 # define getcwd rpl_getcwd
467 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
468 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
470 _GL_CXXALIAS_SYS (getcwd, char *, (char *buf, size_t size));
472 _GL_CXXALIASWARN (getcwd);
473 #elif defined GNULIB_POSIXCHECK
475 # if HAVE_RAW_DECL_GETCWD
476 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
477 "use gnulib module getcwd for portability");
482 #if @GNULIB_GETDOMAINNAME@
483 /* Return the NIS domain name of the machine.
484 WARNING! The NIS domain name is unrelated to the fully qualified host name
485 of the machine. It is also unrelated to email addresses.
486 WARNING! The NIS domain name is usually the empty string or "(none)" when
489 Put up to LEN bytes of the NIS domain name into NAME.
490 Null terminate it if the name is shorter than LEN.
491 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
492 Return 0 if successful, otherwise set errno and return -1. */
493 # if !@HAVE_GETDOMAINNAME@
494 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
495 _GL_ARG_NONNULL ((1)));
497 /* Need to cast, because on MacOS X 10.5 systems, the second parameter is
499 _GL_CXXALIAS_SYS_CAST (getdomainname, int, (char *name, size_t len));
500 _GL_CXXALIASWARN (getdomainname);
501 #elif defined GNULIB_POSIXCHECK
502 # undef getdomainname
503 # if HAVE_RAW_DECL_GETDOMAINNAME
504 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
505 "use gnulib module getdomainname for portability");
510 #if @GNULIB_GETDTABLESIZE@
511 /* Return the maximum number of file descriptors in the current process.
512 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
513 # if !@HAVE_GETDTABLESIZE@
514 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
516 _GL_CXXALIAS_SYS (getdtablesize, int, (void));
517 _GL_CXXALIASWARN (getdtablesize);
518 #elif defined GNULIB_POSIXCHECK
519 # undef getdtablesize
520 # if HAVE_RAW_DECL_GETDTABLESIZE
521 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
522 "use gnulib module getdtablesize for portability");
527 #if @GNULIB_GETGROUPS@
528 /* Return the supplemental groups that the current process belongs to.
529 It is unspecified whether the effective group id is in the list.
530 If N is 0, return the group count; otherwise, N describes how many
531 entries are available in GROUPS. Return -1 and set errno if N is
532 not 0 and not large enough. Fails with ENOSYS on some systems. */
533 # if @REPLACE_GETGROUPS@
534 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
536 # define getgroups rpl_getgroups
538 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
539 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
541 # if !@HAVE_GETGROUPS@
542 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
544 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
546 _GL_CXXALIASWARN (getgroups);
547 #elif defined GNULIB_POSIXCHECK
549 # if HAVE_RAW_DECL_GETGROUPS
550 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
551 "use gnulib module getgroups for portability");
556 #if @GNULIB_GETHOSTNAME@
557 /* Return the standard host name of the machine.
558 WARNING! The host name may or may not be fully qualified.
560 Put up to LEN bytes of the host name into NAME.
561 Null terminate it if the name is shorter than LEN.
562 If the host name is longer than LEN, set errno = EINVAL and return -1.
563 Return 0 if successful, otherwise set errno and return -1. */
564 # if @UNISTD_H_HAVE_WINSOCK2_H@
565 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
567 # define gethostname rpl_gethostname
569 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
570 _GL_ARG_NONNULL ((1)));
571 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
573 # if !@HAVE_GETHOSTNAME@
574 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
575 _GL_ARG_NONNULL ((1)));
577 /* Need to cast, because on Solaris 10 systems, the second parameter is
579 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
581 _GL_CXXALIASWARN (gethostname);
582 #elif @UNISTD_H_HAVE_WINSOCK2_H@
584 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
585 #elif defined GNULIB_POSIXCHECK
587 # if HAVE_RAW_DECL_GETHOSTNAME
588 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
589 "use gnulib module gethostname for portability");
594 #if @GNULIB_GETLOGIN@
595 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
596 returns NULL with errno set.
598 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
600 Most programs don't need to use this function, because the information is
601 available through environment variables:
602 ${LOGNAME-$USER} on Unix platforms,
603 $USERNAME on native Windows platforms.
605 # if !@HAVE_GETLOGIN@
606 _GL_FUNCDECL_SYS (getlogin, char *, (void));
608 _GL_CXXALIAS_SYS (getlogin, char *, (void));
609 _GL_CXXALIASWARN (getlogin);
610 #elif defined GNULIB_POSIXCHECK
612 # if HAVE_RAW_DECL_GETLOGIN
613 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
614 "use gnulib module getlogin for portability");
619 #if @GNULIB_GETLOGIN_R@
620 /* Copies the user's login name to NAME.
621 The array pointed to by NAME has room for SIZE bytes.
623 Returns 0 if successful. Upon error, an error number is returned, or -1 in
624 the case that the login name cannot be found but no specific error is
625 provided (this case is hopefully rare but is left open by the POSIX spec).
627 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
629 Most programs don't need to use this function, because the information is
630 available through environment variables:
631 ${LOGNAME-$USER} on Unix platforms,
632 $USERNAME on native Windows platforms.
634 # if !@HAVE_DECL_GETLOGIN_R@
635 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
636 _GL_ARG_NONNULL ((1)));
638 /* Need to cast, because on Solaris 10 systems, the second argument is
640 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
641 _GL_CXXALIASWARN (getlogin_r);
642 #elif defined GNULIB_POSIXCHECK
644 # if HAVE_RAW_DECL_GETLOGIN_R
645 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
646 "use gnulib module getlogin_r for portability");
651 #if @GNULIB_GETPAGESIZE@
652 # if @REPLACE_GETPAGESIZE@
653 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
654 # define getpagesize rpl_getpagesize
656 _GL_FUNCDECL_RPL (getpagesize, int, (void));
657 _GL_CXXALIAS_RPL (getpagesize, int, (void));
659 # if !@HAVE_GETPAGESIZE@
660 # if !defined getpagesize
661 /* This is for POSIX systems. */
662 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
663 # if ! (defined __VMS && __VMS_VER < 70000000)
664 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
667 /* This is for older VMS. */
668 # if !defined _gl_getpagesize && defined __VMS
670 # define _gl_getpagesize() 8192
672 # define _gl_getpagesize() 512
675 /* This is for BeOS. */
676 # if !defined _gl_getpagesize && @HAVE_OS_H@
678 # if defined B_PAGE_SIZE
679 # define _gl_getpagesize() B_PAGE_SIZE
682 /* This is for AmigaOS4.0. */
683 # if !defined _gl_getpagesize && defined __amigaos4__
684 # define _gl_getpagesize() 2048
686 /* This is for older Unix systems. */
687 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
688 # include <sys/param.h>
689 # ifdef EXEC_PAGESIZE
690 # define _gl_getpagesize() EXEC_PAGESIZE
696 # define _gl_getpagesize() (NBPG * CLSIZE)
699 # define _gl_getpagesize() NBPC
704 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
705 # define getpagesize() _gl_getpagesize ()
710 return _gl_getpagesize ();
715 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
716 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
718 _GL_CXXALIASWARN (getpagesize);
719 #elif defined GNULIB_POSIXCHECK
721 # if HAVE_RAW_DECL_GETPAGESIZE
722 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
723 "use gnulib module getpagesize for portability");
728 #if @GNULIB_GETUSERSHELL@
729 /* Return the next valid login shell on the system, or NULL when the end of
730 the list has been reached. */
731 # if !@HAVE_GETUSERSHELL@
732 _GL_FUNCDECL_SYS (getusershell, char *, (void));
734 _GL_CXXALIAS_SYS (getusershell, char *, (void));
735 _GL_CXXALIASWARN (getusershell);
736 #elif defined GNULIB_POSIXCHECK
738 # if HAVE_RAW_DECL_GETUSERSHELL
739 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
740 "use gnulib module getusershell for portability");
744 #if @GNULIB_GETUSERSHELL@
745 /* Rewind to pointer that is advanced at each getusershell() call. */
746 # if !@HAVE_GETUSERSHELL@
747 _GL_FUNCDECL_SYS (setusershell, void, (void));
749 _GL_CXXALIAS_SYS (setusershell, void, (void));
750 _GL_CXXALIASWARN (setusershell);
751 #elif defined GNULIB_POSIXCHECK
753 # if HAVE_RAW_DECL_SETUSERSHELL
754 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
755 "use gnulib module getusershell for portability");
759 #if @GNULIB_GETUSERSHELL@
760 /* Free the pointer that is advanced at each getusershell() call and
761 associated resources. */
762 # if !@HAVE_GETUSERSHELL@
763 _GL_FUNCDECL_SYS (endusershell, void, (void));
765 _GL_CXXALIAS_SYS (endusershell, void, (void));
766 _GL_CXXALIASWARN (endusershell);
767 #elif defined GNULIB_POSIXCHECK
769 # if HAVE_RAW_DECL_ENDUSERSHELL
770 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
771 "use gnulib module getusershell for portability");
777 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
778 to GID (if GID is not -1). Do not follow symbolic links.
779 Return 0 if successful, otherwise -1 and errno set.
780 See the POSIX:2001 specification
781 <http://www.opengroup.org/susv3xsh/lchown.html>. */
782 # if @REPLACE_LCHOWN@
783 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
785 # define lchown rpl_lchown
787 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
788 _GL_ARG_NONNULL ((1)));
789 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
792 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
793 _GL_ARG_NONNULL ((1)));
795 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
797 _GL_CXXALIASWARN (lchown);
798 #elif defined GNULIB_POSIXCHECK
800 # if HAVE_RAW_DECL_LCHOWN
801 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
802 "use gnulib module lchown for portability");
808 /* Create a new hard link for an existing file.
809 Return 0 if successful, otherwise -1 and errno set.
810 See POSIX:2001 specification
811 <http://www.opengroup.org/susv3xsh/link.html>. */
813 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
814 # define link rpl_link
816 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
817 _GL_ARG_NONNULL ((1, 2)));
818 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
821 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
822 _GL_ARG_NONNULL ((1, 2)));
824 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
826 _GL_CXXALIASWARN (link);
827 #elif defined GNULIB_POSIXCHECK
829 # if HAVE_RAW_DECL_LINK
830 _GL_WARN_ON_USE (link, "link is unportable - "
831 "use gnulib module link for portability");
837 /* Create a new hard link for an existing file, relative to two
838 directories. FLAG controls whether symlinks are followed.
839 Return 0 if successful, otherwise -1 and errno set. */
840 # if @REPLACE_LINKAT@
841 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
843 # define linkat rpl_linkat
845 _GL_FUNCDECL_RPL (linkat, int,
846 (int fd1, const char *path1, int fd2, const char *path2,
848 _GL_ARG_NONNULL ((2, 4)));
849 _GL_CXXALIAS_RPL (linkat, int,
850 (int fd1, const char *path1, int fd2, const char *path2,
854 _GL_FUNCDECL_SYS (linkat, int,
855 (int fd1, const char *path1, int fd2, const char *path2,
857 _GL_ARG_NONNULL ((2, 4)));
859 _GL_CXXALIAS_SYS (linkat, int,
860 (int fd1, const char *path1, int fd2, const char *path2,
863 _GL_CXXALIASWARN (linkat);
864 #elif defined GNULIB_POSIXCHECK
866 # if HAVE_RAW_DECL_LINKAT
867 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
868 "use gnulib module linkat for portability");
874 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
875 Return the new offset if successful, otherwise -1 and errno set.
876 See the POSIX:2001 specification
877 <http://www.opengroup.org/susv3xsh/lseek.html>. */
879 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
880 # define lseek rpl_lseek
882 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
883 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
885 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
887 _GL_CXXALIASWARN (lseek);
888 #elif defined GNULIB_POSIXCHECK
890 # if HAVE_RAW_DECL_LSEEK
891 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
892 "systems - use gnulib module lseek for portability");
898 /* Create a pipe, applying the given flags when opening the read-end of the
899 pipe and the write-end of the pipe.
900 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
901 and O_TEXT, O_BINARY (defined in "binary-io.h").
902 Store the read-end as fd[0] and the write-end as fd[1].
903 Return 0 upon success, or -1 with errno set upon failure.
904 See also the Linux man page at
905 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
907 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
908 # define pipe2 rpl_pipe2
910 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
911 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
913 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
914 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
916 _GL_CXXALIASWARN (pipe2);
917 #elif defined GNULIB_POSIXCHECK
919 # if HAVE_RAW_DECL_PIPE2
920 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
921 "use gnulib module pipe2 for portability");
927 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
928 Return the number of bytes placed into BUF if successful, otherwise
929 set errno and return -1. 0 indicates EOF. See the POSIX:2001
930 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
932 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
933 # define pread rpl_pread
935 _GL_FUNCDECL_RPL (pread, ssize_t,
936 (int fd, void *buf, size_t bufsize, off_t offset)
937 _GL_ARG_NONNULL ((2)));
938 _GL_CXXALIAS_RPL (pread, ssize_t,
939 (int fd, void *buf, size_t bufsize, off_t offset));
942 _GL_FUNCDECL_SYS (pread, ssize_t,
943 (int fd, void *buf, size_t bufsize, off_t offset)
944 _GL_ARG_NONNULL ((2)));
946 _GL_CXXALIAS_SYS (pread, ssize_t,
947 (int fd, void *buf, size_t bufsize, off_t offset));
949 _GL_CXXALIASWARN (pread);
950 #elif defined GNULIB_POSIXCHECK
952 # if HAVE_RAW_DECL_PREAD
953 _GL_WARN_ON_USE (pread, "pread is unportable - "
954 "use gnulib module pread for portability");
959 #if @GNULIB_READLINK@
960 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
961 bytes of it into BUF. Return the number of bytes placed into BUF if
962 successful, otherwise -1 and errno set.
963 See the POSIX:2001 specification
964 <http://www.opengroup.org/susv3xsh/readlink.html>. */
965 # if @REPLACE_READLINK@
966 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
967 # define readlink rpl_readlink
969 _GL_FUNCDECL_RPL (readlink, ssize_t,
970 (const char *file, char *buf, size_t bufsize)
971 _GL_ARG_NONNULL ((1, 2)));
972 _GL_CXXALIAS_RPL (readlink, ssize_t,
973 (const char *file, char *buf, size_t bufsize));
975 # if !@HAVE_READLINK@
976 _GL_FUNCDECL_SYS (readlink, ssize_t,
977 (const char *file, char *buf, size_t bufsize)
978 _GL_ARG_NONNULL ((1, 2)));
980 _GL_CXXALIAS_SYS (readlink, ssize_t,
981 (const char *file, char *buf, size_t bufsize));
983 _GL_CXXALIASWARN (readlink);
984 #elif defined GNULIB_POSIXCHECK
986 # if HAVE_RAW_DECL_READLINK
987 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
988 "use gnulib module readlink for portability");
993 #if @GNULIB_READLINKAT@
994 # if !@HAVE_READLINKAT@
995 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
996 (int fd, char const *file, char *buf, size_t len)
997 _GL_ARG_NONNULL ((2, 3)));
999 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1000 (int fd, char const *file, char *buf, size_t len));
1001 _GL_CXXALIASWARN (readlinkat);
1002 #elif defined GNULIB_POSIXCHECK
1004 # if HAVE_RAW_DECL_READLINKAT
1005 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1006 "use gnulib module symlinkat for portability");
1012 /* Remove the directory DIR. */
1013 # if @REPLACE_RMDIR@
1014 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1015 # define rmdir rpl_rmdir
1017 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1018 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1020 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1022 _GL_CXXALIASWARN (rmdir);
1023 #elif defined GNULIB_POSIXCHECK
1025 # if HAVE_RAW_DECL_RMDIR
1026 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1027 "use gnulib module rmdir for portability");
1033 /* Pause the execution of the current thread for N seconds.
1034 Returns the number of seconds left to sleep.
1035 See the POSIX:2001 specification
1036 <http://www.opengroup.org/susv3xsh/sleep.html>. */
1037 # if @REPLACE_SLEEP@
1038 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1040 # define sleep rpl_sleep
1042 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1043 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1046 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1048 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1050 _GL_CXXALIASWARN (sleep);
1051 #elif defined GNULIB_POSIXCHECK
1053 # if HAVE_RAW_DECL_SLEEP
1054 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1055 "use gnulib module sleep for portability");
1060 #if @GNULIB_SYMLINK@
1061 # if @REPLACE_SYMLINK@
1062 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1064 # define symlink rpl_symlink
1066 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1067 _GL_ARG_NONNULL ((1, 2)));
1068 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1070 # if !@HAVE_SYMLINK@
1071 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1072 _GL_ARG_NONNULL ((1, 2)));
1074 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1076 _GL_CXXALIASWARN (symlink);
1077 #elif defined GNULIB_POSIXCHECK
1079 # if HAVE_RAW_DECL_SYMLINK
1080 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1081 "use gnulib module symlink for portability");
1086 #if @GNULIB_SYMLINKAT@
1087 # if !@HAVE_SYMLINKAT@
1088 _GL_FUNCDECL_SYS (symlinkat, int,
1089 (char const *contents, int fd, char const *file)
1090 _GL_ARG_NONNULL ((1, 3)));
1092 _GL_CXXALIAS_SYS (symlinkat, int,
1093 (char const *contents, int fd, char const *file));
1094 _GL_CXXALIASWARN (symlinkat);
1095 #elif defined GNULIB_POSIXCHECK
1097 # if HAVE_RAW_DECL_SYMLINKAT
1098 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1099 "use gnulib module symlinkat for portability");
1105 # if @REPLACE_UNLINK@
1106 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1108 # define unlink rpl_unlink
1110 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1111 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
1113 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
1115 _GL_CXXALIASWARN (unlink);
1116 #elif defined GNULIB_POSIXCHECK
1118 # if HAVE_RAW_DECL_UNLINK
1119 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
1120 "use gnulib module unlink for portability");
1125 #if @GNULIB_UNLINKAT@
1126 # if @REPLACE_UNLINKAT@
1127 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1129 # define unlinkat rpl_unlinkat
1131 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1132 _GL_ARG_NONNULL ((2)));
1133 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1135 # if !@HAVE_UNLINKAT@
1136 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1137 _GL_ARG_NONNULL ((2)));
1139 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1141 _GL_CXXALIASWARN (unlinkat);
1142 #elif defined GNULIB_POSIXCHECK
1144 # if HAVE_RAW_DECL_UNLINKAT
1145 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1146 "use gnulib module openat for portability");
1152 /* Pause the execution of the current thread for N microseconds.
1153 Returns 0 on completion, or -1 on range error.
1154 See the POSIX:2001 specification
1155 <http://www.opengroup.org/susv3xsh/sleep.html>. */
1156 # if @REPLACE_USLEEP@
1157 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1159 # define usleep rpl_usleep
1161 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1162 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1165 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1167 _GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1169 _GL_CXXALIASWARN (usleep);
1170 #elif defined GNULIB_POSIXCHECK
1172 # if HAVE_RAW_DECL_USLEEP
1173 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1174 "use gnulib module usleep for portability");
1180 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1181 See the POSIX:2001 specification
1182 <http://www.opengroup.org/susv3xsh/write.html>. */
1183 # if @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
1184 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1186 # define write rpl_write
1188 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1189 _GL_ARG_NONNULL ((2)));
1190 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1192 _GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
1194 _GL_CXXALIASWARN (write);
1198 #endif /* _GL_UNISTD_H */
1199 #endif /* _GL_UNISTD_H */