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-2008 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_* macros in <unistd.h>. */
35 #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
39 /* mingw fails to declare _exit in <unistd.h>. */
42 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
44 # include <sys/types.h>
47 #if @GNULIB_GETHOSTNAME@
48 /* Get all possible declarations of gethostname(). */
49 # if @UNISTD_H_HAVE_WINSOCK2_H@
50 # include <winsock2.h>
51 # if !defined _GL_SYS_SOCKET_H
53 # define socket socket_used_without_including_sys_socket_h
55 # define connect connect_used_without_including_sys_socket_h
57 # define accept accept_used_without_including_sys_socket_h
59 # define bind bind_used_without_including_sys_socket_h
61 # define getpeername getpeername_used_without_including_sys_socket_h
63 # define getsockname getsockname_used_without_including_sys_socket_h
65 # define getsockopt getsockopt_used_without_including_sys_socket_h
67 # define listen listen_used_without_including_sys_socket_h
69 # define recv recv_used_without_including_sys_socket_h
71 # define send send_used_without_including_sys_socket_h
73 # define recvfrom recvfrom_used_without_including_sys_socket_h
75 # define sendto sendto_used_without_including_sys_socket_h
77 # define setsockopt setsockopt_used_without_including_sys_socket_h
79 # define shutdown shutdown_used_without_including_sys_socket_h
81 # if !defined _GL_SYS_SELECT_H
83 # define select select_used_without_including_sys_select_h
88 /* The definition of GL_LINK_WARNING is copied here. */
91 /* Declare overridden functions. */
100 # ifndef REPLACE_CHOWN
101 # define REPLACE_CHOWN 1
104 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
105 to GID (if GID is not -1). Follow symbolic links.
106 Return 0 if successful, otherwise -1 and errno set.
107 See the POSIX:2001 specification
108 <http://www.opengroup.org/susv3xsh/chown.html>. */
109 # define chown rpl_chown
110 extern int chown (const char *file, uid_t uid, gid_t gid);
113 #elif defined GNULIB_POSIXCHECK
115 # define chown(f,u,g) \
116 (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
117 "doesn't treat a uid or gid of -1 on some systems - " \
118 "use gnulib module chown for portability"), \
124 # if @UNISTD_H_HAVE_WINSOCK2_H@
125 /* Need a gnulib internal function. */
126 # define HAVE__GL_CLOSE_FD_MAYBE_SOCKET 1
129 /* Automatically included by modules that need a replacement for close. */
131 # define close rpl_close
132 extern int close (int);
134 #elif @UNISTD_H_HAVE_WINSOCK2_H@
136 # define close close_used_without_requesting_gnulib_module_close
137 #elif defined GNULIB_POSIXCHECK
140 (GL_LINK_WARNING ("close does not portably work on sockets - " \
141 "use gnulib module close for portability"), \
148 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
149 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
150 Return 0 if successful, otherwise -1 and errno set.
151 See the POSIX:2001 specification
152 <http://www.opengroup.org/susv3xsh/dup2.html>. */
153 extern int dup2 (int oldfd, int newfd);
155 #elif defined GNULIB_POSIXCHECK
158 (GL_LINK_WARNING ("dup2 is unportable - " \
159 "use gnulib module dup2 for portability"), \
165 # if !@HAVE_DECL_ENVIRON@
166 /* Set of environment variables and values. An array of strings of the form
167 "VARIABLE=VALUE", terminated with a NULL. */
168 # if defined __APPLE__ && defined __MACH__
169 # include <crt_externs.h>
170 # define environ (*_NSGetEnviron ())
172 extern char **environ;
175 #elif defined GNULIB_POSIXCHECK
178 (GL_LINK_WARNING ("environ is unportable - " \
179 "use gnulib module environ for portability"), \
184 #if @GNULIB_EUIDACCESS@
185 # if !@HAVE_EUIDACCESS@
186 /* Like access(), except that is uses the effective user id and group id of
187 the current process. */
188 extern int euidaccess (const char *filename, int mode);
190 #elif defined GNULIB_POSIXCHECK
192 # define euidaccess(f,m) \
193 (GL_LINK_WARNING ("euidaccess is unportable - " \
194 "use gnulib module euidaccess for portability"), \
200 # if @REPLACE_FCHDIR@
202 /* Change the process' current working directory to the directory on which
203 the given file descriptor is open.
204 Return 0 if successful, otherwise -1 and errno set.
205 See the POSIX:2001 specification
206 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
207 extern int fchdir (int /*fd*/);
210 extern int dup (int);
211 # define dup2 rpl_dup2
212 extern int dup2 (int, int);
215 #elif defined GNULIB_POSIXCHECK
218 (GL_LINK_WARNING ("fchdir is unportable - " \
219 "use gnulib module fchdir for portability"), \
225 /* Synchronize changes to a file.
226 Return 0 if successful, otherwise -1 and errno set.
227 See POSIX:2001 specification
228 <http://www.opengroup.org/susv3xsh/fsync.html>. */
230 extern int fsync (int fd);
232 #elif defined GNULIB_POSIXCHECK
235 (GL_LINK_WARNING ("fsync is unportable - " \
236 "use gnulib module fsync for portability"), \
241 #if @GNULIB_FTRUNCATE@
242 # if !@HAVE_FTRUNCATE@
243 /* Change the size of the file to which FD is opened to become equal to LENGTH.
244 Return 0 if successful, otherwise -1 and errno set.
245 See the POSIX:2001 specification
246 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
247 extern int ftruncate (int fd, off_t length);
249 #elif defined GNULIB_POSIXCHECK
251 # define ftruncate(f,l) \
252 (GL_LINK_WARNING ("ftruncate is unportable - " \
253 "use gnulib module ftruncate for portability"), \
259 /* Include the headers that might declare getcwd so that they will not
260 cause confusion if included after this file. */
262 # if @REPLACE_GETCWD@
263 /* Get the name of the current working directory, and put it in SIZE bytes
265 Return BUF if successful, or NULL if the directory couldn't be determined
266 or SIZE was too small.
267 See the POSIX:2001 specification
268 <http://www.opengroup.org/susv3xsh/getcwd.html>.
269 Additionally, the gnulib module 'getcwd' guarantees the following GNU
270 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
271 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
273 # define getcwd rpl_getcwd
274 extern char * getcwd (char *buf, size_t size);
276 #elif defined GNULIB_POSIXCHECK
278 # define getcwd(b,s) \
279 (GL_LINK_WARNING ("getcwd is unportable - " \
280 "use gnulib module getcwd for portability"), \
285 #if @GNULIB_GETDOMAINNAME@
286 /* Return the NIS domain name of the machine.
287 WARNING! The NIS domain name is unrelated to the fully qualified host name
288 of the machine. It is also unrelated to email addresses.
289 WARNING! The NIS domain name is usually the empty string or "(none)" when
292 Put up to LEN bytes of the NIS domain name into NAME.
293 Null terminate it if the name is shorter than LEN.
294 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
295 Return 0 if successful, otherwise set errno and return -1. */
296 # if !@HAVE_GETDOMAINNAME@
297 extern int getdomainname(char *name, size_t len);
299 #elif defined GNULIB_POSIXCHECK
300 # undef getdomainname
301 # define getdomainname(n,l) \
302 (GL_LINK_WARNING ("getdomainname is unportable - " \
303 "use gnulib module getdomainname for portability"), \
304 getdomainname (n, l))
308 #if @GNULIB_GETDTABLESIZE@
309 # if !@HAVE_GETDTABLESIZE@
310 /* Return the maximum number of file descriptors in the current process. */
311 extern int getdtablesize (void);
313 #elif defined GNULIB_POSIXCHECK
314 # undef getdtablesize
315 # define getdtablesize() \
316 (GL_LINK_WARNING ("getdtablesize is unportable - " \
317 "use gnulib module getdtablesize for portability"), \
322 #if @GNULIB_GETHOSTNAME@
323 /* Return the standard host name of the machine.
324 WARNING! The host name may or may not be fully qualified.
326 Put up to LEN bytes of the host name into NAME.
327 Null terminate it if the name is shorter than LEN.
328 If the host name is longer than LEN, set errno = EINVAL and return -1.
329 Return 0 if successful, otherwise set errno and return -1. */
330 # if @UNISTD_H_HAVE_WINSOCK2_H@
332 # define gethostname rpl_gethostname
334 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
335 extern int gethostname(char *name, size_t len);
337 #elif @UNISTD_H_HAVE_WINSOCK2_H@
339 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
340 #elif defined GNULIB_POSIXCHECK
342 # define gethostname(n,l) \
343 (GL_LINK_WARNING ("gethostname is unportable - " \
344 "use gnulib module gethostname for portability"), \
349 #if @GNULIB_GETLOGIN_R@
350 /* Copies the user's login name to NAME.
351 The array pointed to by NAME has room for SIZE bytes.
353 Returns 0 if successful. Upon error, an error number is returned, or -1 in
354 the case that the login name cannot be found but no specific error is
355 provided (this case is hopefully rare but is left open by the POSIX spec).
357 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
359 # if !@HAVE_DECL_GETLOGIN_R@
361 extern int getlogin_r (char *name, size_t size);
363 #elif defined GNULIB_POSIXCHECK
365 # define getlogin_r(n,s) \
366 (GL_LINK_WARNING ("getlogin_r is unportable - " \
367 "use gnulib module getlogin_r for portability"), \
372 #if @GNULIB_GETPAGESIZE@
373 # if @REPLACE_GETPAGESIZE@
374 # define getpagesize rpl_getpagesize
375 extern int getpagesize (void);
376 # elif !@HAVE_GETPAGESIZE@
377 /* This is for POSIX systems. */
378 # if !defined getpagesize && defined _SC_PAGESIZE
379 # if ! (defined __VMS && __VMS_VER < 70000000)
380 # define getpagesize() sysconf (_SC_PAGESIZE)
383 /* This is for older VMS. */
384 # if !defined getpagesize && defined __VMS
386 # define getpagesize() 8192
388 # define getpagesize() 512
391 /* This is for BeOS. */
392 # if !defined getpagesize && @HAVE_OS_H@
394 # if defined B_PAGE_SIZE
395 # define getpagesize() B_PAGE_SIZE
398 /* This is for AmigaOS4.0. */
399 # if !defined getpagesize && defined __amigaos4__
400 # define getpagesize() 2048
402 /* This is for older Unix systems. */
403 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
404 # include <sys/param.h>
405 # ifdef EXEC_PAGESIZE
406 # define getpagesize() EXEC_PAGESIZE
412 # define getpagesize() (NBPG * CLSIZE)
415 # define getpagesize() NBPC
421 #elif defined GNULIB_POSIXCHECK
423 # define getpagesize() \
424 (GL_LINK_WARNING ("getpagesize is unportable - " \
425 "use gnulib module getpagesize for portability"), \
430 #if @GNULIB_GETUSERSHELL@
431 # if !@HAVE_GETUSERSHELL@
432 /* Return the next valid login shell on the system, or NULL when the end of
433 the list has been reached. */
434 extern char *getusershell (void);
435 /* Rewind to pointer that is advanced at each getusershell() call. */
436 extern void setusershell (void);
437 /* Free the pointer that is advanced at each getusershell() call and
438 associated resources. */
439 extern void endusershell (void);
441 #elif defined GNULIB_POSIXCHECK
443 # define getusershell() \
444 (GL_LINK_WARNING ("getusershell is unportable - " \
445 "use gnulib module getusershell for portability"), \
448 # define setusershell() \
449 (GL_LINK_WARNING ("setusershell is unportable - " \
450 "use gnulib module getusershell for portability"), \
453 # define endusershell() \
454 (GL_LINK_WARNING ("endusershell is unportable - " \
455 "use gnulib module getusershell for portability"), \
461 # if @REPLACE_LCHOWN@
462 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
463 to GID (if GID is not -1). Do not follow symbolic links.
464 Return 0 if successful, otherwise -1 and errno set.
465 See the POSIX:2001 specification
466 <http://www.opengroup.org/susv3xsh/lchown.html>. */
467 # define lchown rpl_lchown
468 extern int lchown (char const *file, uid_t owner, gid_t group);
470 #elif defined GNULIB_POSIXCHECK
472 # define lchown(f,u,g) \
473 (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
474 "systems - use gnulib module lchown for portability"), \
481 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
482 Return the new offset if successful, otherwise -1 and errno set.
483 See the POSIX:2001 specification
484 <http://www.opengroup.org/susv3xsh/lseek.html>. */
485 # define lseek rpl_lseek
486 extern off_t lseek (int fd, off_t offset, int whence);
488 #elif defined GNULIB_POSIXCHECK
490 # define lseek(f,o,w) \
491 (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
492 "systems - use gnulib module lseek for portability"), \
497 #if @GNULIB_READLINK@
498 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
499 bytes of it into BUF. Return the number of bytes placed into BUF if
500 successful, otherwise -1 and errno set.
501 See the POSIX:2001 specification
502 <http://www.opengroup.org/susv3xsh/readlink.html>. */
503 # if !@HAVE_READLINK@
505 extern int readlink (const char *file, char *buf, size_t bufsize);
507 #elif defined GNULIB_POSIXCHECK
509 # define readlink(f,b,s) \
510 (GL_LINK_WARNING ("readlink is unportable - " \
511 "use gnulib module readlink for portability"), \
517 /* Pause the execution of the current thread for N seconds.
518 Returns the number of seconds left to sleep.
519 See the POSIX:2001 specification
520 <http://www.opengroup.org/susv3xsh/sleep.html>. */
522 extern unsigned int sleep (unsigned int n);
524 #elif defined GNULIB_POSIXCHECK
527 (GL_LINK_WARNING ("sleep is unportable - " \
528 "use gnulib module sleep for portability"), \
533 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
534 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
535 See the POSIX:2001 specification
536 <http://www.opengroup.org/susv3xsh/write.html>. */
538 # define write rpl_write
539 extern ssize_t write (int fd, const void *buf, size_t count);
543 #ifdef FCHDIR_REPLACEMENT
544 /* gnulib internal function. */
545 extern void _gl_unregister_fd (int fd);
554 #endif /* _GL_UNISTD_H */
555 #endif /* _GL_UNISTD_H */