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-2009 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 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
35 #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
39 /* mingw fails to declare _exit in <unistd.h>. */
40 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
43 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
45 # include <sys/types.h>
48 #if @GNULIB_GETHOSTNAME@
49 /* Get all possible declarations of gethostname(). */
50 # if @UNISTD_H_HAVE_WINSOCK2_H@
51 # include <winsock2.h>
52 # if !defined _GL_SYS_SOCKET_H
54 # define socket socket_used_without_including_sys_socket_h
56 # define connect connect_used_without_including_sys_socket_h
58 # define accept accept_used_without_including_sys_socket_h
60 # define bind bind_used_without_including_sys_socket_h
62 # define getpeername getpeername_used_without_including_sys_socket_h
64 # define getsockname getsockname_used_without_including_sys_socket_h
66 # define getsockopt getsockopt_used_without_including_sys_socket_h
68 # define listen listen_used_without_including_sys_socket_h
70 # define recv recv_used_without_including_sys_socket_h
72 # define send send_used_without_including_sys_socket_h
74 # define recvfrom recvfrom_used_without_including_sys_socket_h
76 # define sendto sendto_used_without_including_sys_socket_h
78 # define setsockopt setsockopt_used_without_including_sys_socket_h
80 # define shutdown shutdown_used_without_including_sys_socket_h
82 # if !defined _GL_SYS_SELECT_H
84 # define select select_used_without_including_sys_select_h
89 /* The definition of GL_LINK_WARNING is copied here. */
92 /* OS/2 EMX lacks these macros. */
94 # define STDIN_FILENO 0
97 # define STDOUT_FILENO 1
100 # define STDERR_FILENO 2
103 /* Declare overridden functions. */
112 # ifndef REPLACE_CHOWN
113 # define REPLACE_CHOWN 1
116 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
117 to GID (if GID is not -1). Follow symbolic links.
118 Return 0 if successful, otherwise -1 and errno set.
119 See the POSIX:2001 specification
120 <http://www.opengroup.org/susv3xsh/chown.html>. */
121 # define chown rpl_chown
122 extern int chown (const char *file, uid_t uid, gid_t gid);
125 #elif defined GNULIB_POSIXCHECK
127 # define chown(f,u,g) \
128 (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
129 "doesn't treat a uid or gid of -1 on some systems - " \
130 "use gnulib module chown for portability"), \
136 # if @UNISTD_H_HAVE_WINSOCK2_H@
137 /* Need a gnulib internal function. */
138 # define HAVE__GL_CLOSE_FD_MAYBE_SOCKET 1
141 /* Automatically included by modules that need a replacement for close. */
143 # define close rpl_close
144 extern int close (int);
146 #elif @UNISTD_H_HAVE_WINSOCK2_H@
148 # define close close_used_without_requesting_gnulib_module_close
149 #elif defined GNULIB_POSIXCHECK
152 (GL_LINK_WARNING ("close does not portably work on sockets - " \
153 "use gnulib module close for portability"), \
160 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
161 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
162 Return 0 if successful, otherwise -1 and errno set.
163 See the POSIX:2001 specification
164 <http://www.opengroup.org/susv3xsh/dup2.html>. */
165 extern int dup2 (int oldfd, int newfd);
167 #elif defined GNULIB_POSIXCHECK
170 (GL_LINK_WARNING ("dup2 is unportable - " \
171 "use gnulib module dup2 for portability"), \
177 # if !@HAVE_DECL_ENVIRON@
178 /* Set of environment variables and values. An array of strings of the form
179 "VARIABLE=VALUE", terminated with a NULL. */
180 # if defined __APPLE__ && defined __MACH__
181 # include <crt_externs.h>
182 # define environ (*_NSGetEnviron ())
184 extern char **environ;
187 #elif defined GNULIB_POSIXCHECK
190 (GL_LINK_WARNING ("environ is unportable - " \
191 "use gnulib module environ for portability"), \
196 #if @GNULIB_EUIDACCESS@
197 # if !@HAVE_EUIDACCESS@
198 /* Like access(), except that is uses the effective user id and group id of
199 the current process. */
200 extern int euidaccess (const char *filename, int mode);
202 #elif defined GNULIB_POSIXCHECK
204 # define euidaccess(f,m) \
205 (GL_LINK_WARNING ("euidaccess is unportable - " \
206 "use gnulib module euidaccess for portability"), \
212 # if @REPLACE_FCHDIR@
214 /* Change the process' current working directory to the directory on which
215 the given file descriptor is open.
216 Return 0 if successful, otherwise -1 and errno set.
217 See the POSIX:2001 specification
218 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
219 extern int fchdir (int /*fd*/);
222 extern int dup (int);
223 # define dup2 rpl_dup2
224 extern int dup2 (int, int);
227 #elif defined GNULIB_POSIXCHECK
230 (GL_LINK_WARNING ("fchdir is unportable - " \
231 "use gnulib module fchdir for portability"), \
237 /* Synchronize changes to a file.
238 Return 0 if successful, otherwise -1 and errno set.
239 See POSIX:2001 specification
240 <http://www.opengroup.org/susv3xsh/fsync.html>. */
242 extern int fsync (int fd);
244 #elif defined GNULIB_POSIXCHECK
247 (GL_LINK_WARNING ("fsync is unportable - " \
248 "use gnulib module fsync for portability"), \
253 #if @GNULIB_FTRUNCATE@
254 # if !@HAVE_FTRUNCATE@
255 /* Change the size of the file to which FD is opened to become equal to LENGTH.
256 Return 0 if successful, otherwise -1 and errno set.
257 See the POSIX:2001 specification
258 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
259 extern int ftruncate (int fd, off_t length);
261 #elif defined GNULIB_POSIXCHECK
263 # define ftruncate(f,l) \
264 (GL_LINK_WARNING ("ftruncate is unportable - " \
265 "use gnulib module ftruncate for portability"), \
271 /* Include the headers that might declare getcwd so that they will not
272 cause confusion if included after this file. */
274 # if @REPLACE_GETCWD@
275 /* Get the name of the current working directory, and put it in SIZE bytes
277 Return BUF if successful, or NULL if the directory couldn't be determined
278 or SIZE was too small.
279 See the POSIX:2001 specification
280 <http://www.opengroup.org/susv3xsh/getcwd.html>.
281 Additionally, the gnulib module 'getcwd' guarantees the following GNU
282 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
283 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
285 # define getcwd rpl_getcwd
286 extern char * getcwd (char *buf, size_t size);
288 #elif defined GNULIB_POSIXCHECK
290 # define getcwd(b,s) \
291 (GL_LINK_WARNING ("getcwd is unportable - " \
292 "use gnulib module getcwd for portability"), \
297 #if @GNULIB_GETDOMAINNAME@
298 /* Return the NIS domain name of the machine.
299 WARNING! The NIS domain name is unrelated to the fully qualified host name
300 of the machine. It is also unrelated to email addresses.
301 WARNING! The NIS domain name is usually the empty string or "(none)" when
304 Put up to LEN bytes of the NIS domain name into NAME.
305 Null terminate it if the name is shorter than LEN.
306 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
307 Return 0 if successful, otherwise set errno and return -1. */
308 # if !@HAVE_GETDOMAINNAME@
309 extern int getdomainname(char *name, size_t len);
311 #elif defined GNULIB_POSIXCHECK
312 # undef getdomainname
313 # define getdomainname(n,l) \
314 (GL_LINK_WARNING ("getdomainname is unportable - " \
315 "use gnulib module getdomainname for portability"), \
316 getdomainname (n, l))
320 #if @GNULIB_GETDTABLESIZE@
321 # if !@HAVE_GETDTABLESIZE@
322 /* Return the maximum number of file descriptors in the current process. */
323 extern int getdtablesize (void);
325 #elif defined GNULIB_POSIXCHECK
326 # undef getdtablesize
327 # define getdtablesize() \
328 (GL_LINK_WARNING ("getdtablesize is unportable - " \
329 "use gnulib module getdtablesize for portability"), \
334 #if @GNULIB_GETHOSTNAME@
335 /* Return the standard host name of the machine.
336 WARNING! The host name may or may not be fully qualified.
338 Put up to LEN bytes of the host name into NAME.
339 Null terminate it if the name is shorter than LEN.
340 If the host name is longer than LEN, set errno = EINVAL and return -1.
341 Return 0 if successful, otherwise set errno and return -1. */
342 # if @UNISTD_H_HAVE_WINSOCK2_H@
344 # define gethostname rpl_gethostname
346 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
347 extern int gethostname(char *name, size_t len);
349 #elif @UNISTD_H_HAVE_WINSOCK2_H@
351 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
352 #elif defined GNULIB_POSIXCHECK
354 # define gethostname(n,l) \
355 (GL_LINK_WARNING ("gethostname is unportable - " \
356 "use gnulib module gethostname for portability"), \
361 #if @GNULIB_GETLOGIN_R@
362 /* Copies the user's login name to NAME.
363 The array pointed to by NAME has room for SIZE bytes.
365 Returns 0 if successful. Upon error, an error number is returned, or -1 in
366 the case that the login name cannot be found but no specific error is
367 provided (this case is hopefully rare but is left open by the POSIX spec).
369 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
371 # if !@HAVE_DECL_GETLOGIN_R@
373 extern int getlogin_r (char *name, size_t size);
375 #elif defined GNULIB_POSIXCHECK
377 # define getlogin_r(n,s) \
378 (GL_LINK_WARNING ("getlogin_r is unportable - " \
379 "use gnulib module getlogin_r for portability"), \
384 #if @GNULIB_GETPAGESIZE@
385 # if @REPLACE_GETPAGESIZE@
386 # define getpagesize rpl_getpagesize
387 extern int getpagesize (void);
388 # elif !@HAVE_GETPAGESIZE@
389 /* This is for POSIX systems. */
390 # if !defined getpagesize && defined _SC_PAGESIZE
391 # if ! (defined __VMS && __VMS_VER < 70000000)
392 # define getpagesize() sysconf (_SC_PAGESIZE)
395 /* This is for older VMS. */
396 # if !defined getpagesize && defined __VMS
398 # define getpagesize() 8192
400 # define getpagesize() 512
403 /* This is for BeOS. */
404 # if !defined getpagesize && @HAVE_OS_H@
406 # if defined B_PAGE_SIZE
407 # define getpagesize() B_PAGE_SIZE
410 /* This is for AmigaOS4.0. */
411 # if !defined getpagesize && defined __amigaos4__
412 # define getpagesize() 2048
414 /* This is for older Unix systems. */
415 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
416 # include <sys/param.h>
417 # ifdef EXEC_PAGESIZE
418 # define getpagesize() EXEC_PAGESIZE
424 # define getpagesize() (NBPG * CLSIZE)
427 # define getpagesize() NBPC
433 #elif defined GNULIB_POSIXCHECK
435 # define getpagesize() \
436 (GL_LINK_WARNING ("getpagesize is unportable - " \
437 "use gnulib module getpagesize for portability"), \
442 #if @GNULIB_GETUSERSHELL@
443 # if !@HAVE_GETUSERSHELL@
444 /* Return the next valid login shell on the system, or NULL when the end of
445 the list has been reached. */
446 extern char *getusershell (void);
447 /* Rewind to pointer that is advanced at each getusershell() call. */
448 extern void setusershell (void);
449 /* Free the pointer that is advanced at each getusershell() call and
450 associated resources. */
451 extern void endusershell (void);
453 #elif defined GNULIB_POSIXCHECK
455 # define getusershell() \
456 (GL_LINK_WARNING ("getusershell is unportable - " \
457 "use gnulib module getusershell for portability"), \
460 # define setusershell() \
461 (GL_LINK_WARNING ("setusershell is unportable - " \
462 "use gnulib module getusershell for portability"), \
465 # define endusershell() \
466 (GL_LINK_WARNING ("endusershell is unportable - " \
467 "use gnulib module getusershell for portability"), \
473 # if @REPLACE_LCHOWN@
474 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
475 to GID (if GID is not -1). Do not follow symbolic links.
476 Return 0 if successful, otherwise -1 and errno set.
477 See the POSIX:2001 specification
478 <http://www.opengroup.org/susv3xsh/lchown.html>. */
479 # define lchown rpl_lchown
480 extern int lchown (char const *file, uid_t owner, gid_t group);
482 #elif defined GNULIB_POSIXCHECK
484 # define lchown(f,u,g) \
485 (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
486 "systems - use gnulib module lchown for portability"), \
492 /* Create a new hard link for an existing file.
493 Return 0 if successful, otherwise -1 and errno set.
494 See POSIX:2001 specification
495 <http://www.opengroup.org/susv3xsh/link.html>. */
497 extern int link (const char *path1, const char *path2);
499 #elif defined GNULIB_POSIXCHECK
501 # define link(path1,path2) \
502 (GL_LINK_WARNING ("link is unportable - " \
503 "use gnulib module link for portability"), \
510 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
511 Return the new offset if successful, otherwise -1 and errno set.
512 See the POSIX:2001 specification
513 <http://www.opengroup.org/susv3xsh/lseek.html>. */
514 # define lseek rpl_lseek
515 extern off_t lseek (int fd, off_t offset, int whence);
517 #elif defined GNULIB_POSIXCHECK
519 # define lseek(f,o,w) \
520 (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
521 "systems - use gnulib module lseek for portability"), \
526 #if @GNULIB_READLINK@
527 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
528 bytes of it into BUF. Return the number of bytes placed into BUF if
529 successful, otherwise -1 and errno set.
530 See the POSIX:2001 specification
531 <http://www.opengroup.org/susv3xsh/readlink.html>. */
532 # if !@HAVE_READLINK@
534 extern int readlink (const char *file, char *buf, size_t bufsize);
536 #elif defined GNULIB_POSIXCHECK
538 # define readlink(f,b,s) \
539 (GL_LINK_WARNING ("readlink is unportable - " \
540 "use gnulib module readlink for portability"), \
546 /* Pause the execution of the current thread for N seconds.
547 Returns the number of seconds left to sleep.
548 See the POSIX:2001 specification
549 <http://www.opengroup.org/susv3xsh/sleep.html>. */
551 extern unsigned int sleep (unsigned int n);
553 #elif defined GNULIB_POSIXCHECK
556 (GL_LINK_WARNING ("sleep is unportable - " \
557 "use gnulib module sleep for portability"), \
562 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
563 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
564 See the POSIX:2001 specification
565 <http://www.opengroup.org/susv3xsh/write.html>. */
567 # define write rpl_write
568 extern ssize_t write (int fd, const void *buf, size_t count);
572 #ifdef FCHDIR_REPLACEMENT
573 /* gnulib internal function. */
574 extern void _gl_unregister_fd (int fd);
583 #endif /* _GL_UNISTD_H */
584 #endif /* _GL_UNISTD_H */