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.
5 
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)
9    any later version.
10 
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.
15 
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.  */
19 
20 #ifndef _GL_UNISTD_H
21 
22 #if __GNUC__ >= 3
23 @PRAGMA_SYSTEM_HEADER@
24 #endif
25 
26 /* The include_next requires a split double-inclusion guard.  */
27 #if @HAVE_UNISTD_H@
28 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
29 #endif
30 
31 #ifndef _GL_UNISTD_H
32 #define _GL_UNISTD_H
33 
34 /* mingw doesn't define the SEEK_* macros in <unistd.h>.  */
35 #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
36 # include <stdio.h>
37 #endif
38 
39 /* mingw fails to declare _exit in <unistd.h>.  */
40 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>.  */
41 #include <stdlib.h>
42 
43 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
44 /* Get ssize_t.  */
45 # include <sys/types.h>
46 #endif
47 
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
53 #   undef socket
54 #   define socket		socket_used_without_including_sys_socket_h
55 #   undef connect
56 #   define connect		connect_used_without_including_sys_socket_h
57 #   undef accept
58 #   define accept		accept_used_without_including_sys_socket_h
59 #   undef bind
60 #   define bind			bind_used_without_including_sys_socket_h
61 #   undef getpeername
62 #   define getpeername		getpeername_used_without_including_sys_socket_h
63 #   undef getsockname
64 #   define getsockname		getsockname_used_without_including_sys_socket_h
65 #   undef getsockopt
66 #   define getsockopt		getsockopt_used_without_including_sys_socket_h
67 #   undef listen
68 #   define listen		listen_used_without_including_sys_socket_h
69 #   undef recv
70 #   define recv			recv_used_without_including_sys_socket_h
71 #   undef send
72 #   define send			send_used_without_including_sys_socket_h
73 #   undef recvfrom
74 #   define recvfrom		recvfrom_used_without_including_sys_socket_h
75 #   undef sendto
76 #   define sendto		sendto_used_without_including_sys_socket_h
77 #   undef setsockopt
78 #   define setsockopt		setsockopt_used_without_including_sys_socket_h
79 #   undef shutdown
80 #   define shutdown		shutdown_used_without_including_sys_socket_h
81 #  endif
82 #  if !defined _GL_SYS_SELECT_H
83 #   undef select
84 #   define select		select_used_without_including_sys_select_h
85 #  endif
86 # endif
87 #endif
88 
89 /* The definition of GL_LINK_WARNING is copied here.  */
90 
91 
92 /* Declare overridden functions.  */
93 
94 #ifdef __cplusplus
95 extern "C" {
96 #endif
97 
98 
99 #if @GNULIB_CHOWN@
100 # if @REPLACE_CHOWN@
101 #  ifndef REPLACE_CHOWN
102 #   define REPLACE_CHOWN 1
103 #  endif
104 #  if REPLACE_CHOWN
105 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
106    to GID (if GID is not -1).  Follow symbolic links.
107    Return 0 if successful, otherwise -1 and errno set.
108    See the POSIX:2001 specification
109    <http://www.opengroup.org/susv3xsh/chown.html>.  */
110 #   define chown rpl_chown
111 extern int chown (const char *file, uid_t uid, gid_t gid);
112 #  endif
113 # endif
114 #elif defined GNULIB_POSIXCHECK
115 # undef chown
116 # define chown(f,u,g) \
117     (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
118                       "doesn't treat a uid or gid of -1 on some systems - " \
119                       "use gnulib module chown for portability"), \
120      chown (f, u, g))
121 #endif
122 
123 
124 #if @GNULIB_CLOSE@
125 # if @UNISTD_H_HAVE_WINSOCK2_H@
126 /* Need a gnulib internal function.  */
127 #  define HAVE__GL_CLOSE_FD_MAYBE_SOCKET 1
128 # endif
129 # if @REPLACE_CLOSE@
130 /* Automatically included by modules that need a replacement for close.  */
131 #  undef close
132 #  define close rpl_close
133 extern int close (int);
134 # endif
135 #elif @UNISTD_H_HAVE_WINSOCK2_H@
136 # undef close
137 # define close close_used_without_requesting_gnulib_module_close
138 #elif defined GNULIB_POSIXCHECK
139 # undef close
140 # define close(f) \
141     (GL_LINK_WARNING ("close does not portably work on sockets - " \
142                       "use gnulib module close for portability"), \
143      close (f))
144 #endif
145 
146 
147 #if @GNULIB_DUP2@
148 # if !@HAVE_DUP2@
149 /* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
150    NEWFD = OLDFD, otherwise close NEWFD first if it is open.
151    Return 0 if successful, otherwise -1 and errno set.
152    See the POSIX:2001 specification
153    <http://www.opengroup.org/susv3xsh/dup2.html>.  */
154 extern int dup2 (int oldfd, int newfd);
155 # endif
156 #elif defined GNULIB_POSIXCHECK
157 # undef dup2
158 # define dup2(o,n) \
159     (GL_LINK_WARNING ("dup2 is unportable - " \
160                       "use gnulib module dup2 for portability"), \
161      dup2 (o, n))
162 #endif
163 
164 
165 #if @GNULIB_ENVIRON@
166 # if !@HAVE_DECL_ENVIRON@
167 /* Set of environment variables and values.  An array of strings of the form
168    "VARIABLE=VALUE", terminated with a NULL.  */
169 #  if defined __APPLE__ && defined __MACH__
170 #   include <crt_externs.h>
171 #   define environ (*_NSGetEnviron ())
172 #  else
173 extern char **environ;
174 #  endif
175 # endif
176 #elif defined GNULIB_POSIXCHECK
177 # undef environ
178 # define environ \
179     (GL_LINK_WARNING ("environ is unportable - " \
180                       "use gnulib module environ for portability"), \
181      environ)
182 #endif
183 
184 
185 #if @GNULIB_EUIDACCESS@
186 # if !@HAVE_EUIDACCESS@
187 /* Like access(), except that is uses the effective user id and group id of
188    the current process.  */
189 extern int euidaccess (const char *filename, int mode);
190 # endif
191 #elif defined GNULIB_POSIXCHECK
192 # undef euidaccess
193 # define euidaccess(f,m) \
194     (GL_LINK_WARNING ("euidaccess is unportable - " \
195                       "use gnulib module euidaccess for portability"), \
196      euidaccess (f, m))
197 #endif
198 
199 
200 #if @GNULIB_FCHDIR@
201 # if @REPLACE_FCHDIR@
202 
203 /* Change the process' current working directory to the directory on which
204    the given file descriptor is open.
205    Return 0 if successful, otherwise -1 and errno set.
206    See the POSIX:2001 specification
207    <http://www.opengroup.org/susv3xsh/fchdir.html>.  */
208 extern int fchdir (int /*fd*/);
209 
210 #  define dup rpl_dup
211 extern int dup (int);
212 #  define dup2 rpl_dup2
213 extern int dup2 (int, int);
214 
215 # endif
216 #elif defined GNULIB_POSIXCHECK
217 # undef fchdir
218 # define fchdir(f) \
219     (GL_LINK_WARNING ("fchdir is unportable - " \
220                       "use gnulib module fchdir for portability"), \
221      fchdir (f))
222 #endif
223 
224 
225 #if @GNULIB_FSYNC@
226 /* Synchronize changes to a file.
227    Return 0 if successful, otherwise -1 and errno set.
228    See POSIX:2001 specification
229    <http://www.opengroup.org/susv3xsh/fsync.html>.  */
230 # if !@HAVE_FSYNC@
231 extern int fsync (int fd);
232 # endif
233 #elif defined GNULIB_POSIXCHECK
234 # undef fsync
235 # define fsync(fd) \
236     (GL_LINK_WARNING ("fsync is unportable - " \
237                       "use gnulib module fsync for portability"), \
238      fsync (fd))
239 #endif
240 
241 
242 #if @GNULIB_FTRUNCATE@
243 # if !@HAVE_FTRUNCATE@
244 /* Change the size of the file to which FD is opened to become equal to LENGTH.
245    Return 0 if successful, otherwise -1 and errno set.
246    See the POSIX:2001 specification
247    <http://www.opengroup.org/susv3xsh/ftruncate.html>.  */
248 extern int ftruncate (int fd, off_t length);
249 # endif
250 #elif defined GNULIB_POSIXCHECK
251 # undef ftruncate
252 # define ftruncate(f,l) \
253     (GL_LINK_WARNING ("ftruncate is unportable - " \
254                       "use gnulib module ftruncate for portability"), \
255      ftruncate (f, l))
256 #endif
257 
258 
259 #if @GNULIB_GETCWD@
260 /* Include the headers that might declare getcwd so that they will not
261    cause confusion if included after this file.  */
262 # include <stdlib.h>
263 # if @REPLACE_GETCWD@
264 /* Get the name of the current working directory, and put it in SIZE bytes
265    of BUF.
266    Return BUF if successful, or NULL if the directory couldn't be determined
267    or SIZE was too small.
268    See the POSIX:2001 specification
269    <http://www.opengroup.org/susv3xsh/getcwd.html>.
270    Additionally, the gnulib module 'getcwd' guarantees the following GNU
271    extension: If BUF is NULL, an array is allocated with 'malloc'; the array
272    is SIZE bytes long, unless SIZE == 0, in which case it is as big as
273    necessary.  */
274 #  define getcwd rpl_getcwd
275 extern char * getcwd (char *buf, size_t size);
276 # endif
277 #elif defined GNULIB_POSIXCHECK
278 # undef getcwd
279 # define getcwd(b,s) \
280     (GL_LINK_WARNING ("getcwd is unportable - " \
281                       "use gnulib module getcwd for portability"), \
282      getcwd (b, s))
283 #endif
284 
285 
286 #if @GNULIB_GETDOMAINNAME@
287 /* Return the NIS domain name of the machine.
288    WARNING! The NIS domain name is unrelated to the fully qualified host name
289             of the machine.  It is also unrelated to email addresses.
290    WARNING! The NIS domain name is usually the empty string or "(none)" when
291             not using NIS.
292 
293    Put up to LEN bytes of the NIS domain name into NAME.
294    Null terminate it if the name is shorter than LEN.
295    If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
296    Return 0 if successful, otherwise set errno and return -1.  */
297 # if !@HAVE_GETDOMAINNAME@
298 extern int getdomainname(char *name, size_t len);
299 # endif
300 #elif defined GNULIB_POSIXCHECK
301 # undef getdomainname
302 # define getdomainname(n,l) \
303     (GL_LINK_WARNING ("getdomainname is unportable - " \
304                       "use gnulib module getdomainname for portability"), \
305      getdomainname (n, l))
306 #endif
307 
308 
309 #if @GNULIB_GETDTABLESIZE@
310 # if !@HAVE_GETDTABLESIZE@
311 /* Return the maximum number of file descriptors in the current process.  */
312 extern int getdtablesize (void);
313 # endif
314 #elif defined GNULIB_POSIXCHECK
315 # undef getdtablesize
316 # define getdtablesize() \
317     (GL_LINK_WARNING ("getdtablesize is unportable - " \
318                       "use gnulib module getdtablesize for portability"), \
319      getdtablesize ())
320 #endif
321 
322 
323 #if @GNULIB_GETHOSTNAME@
324 /* Return the standard host name of the machine.
325    WARNING! The host name may or may not be fully qualified.
326 
327    Put up to LEN bytes of the host name into NAME.
328    Null terminate it if the name is shorter than LEN.
329    If the host name is longer than LEN, set errno = EINVAL and return -1.
330    Return 0 if successful, otherwise set errno and return -1.  */
331 # if @UNISTD_H_HAVE_WINSOCK2_H@
332 #  undef gethostname
333 #  define gethostname rpl_gethostname
334 # endif
335 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
336 extern int gethostname(char *name, size_t len);
337 # endif
338 #elif @UNISTD_H_HAVE_WINSOCK2_H@
339 # undef gethostname
340 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
341 #elif defined GNULIB_POSIXCHECK
342 # undef gethostname
343 # define gethostname(n,l) \
344     (GL_LINK_WARNING ("gethostname is unportable - " \
345                       "use gnulib module gethostname for portability"), \
346      gethostname (n, l))
347 #endif
348 
349 
350 #if @GNULIB_GETLOGIN_R@
351 /* Copies the user's login name to NAME.
352    The array pointed to by NAME has room for SIZE bytes.
353 
354    Returns 0 if successful.  Upon error, an error number is returned, or -1 in
355    the case that the login name cannot be found but no specific error is
356    provided (this case is hopefully rare but is left open by the POSIX spec).
357 
358    See <http://www.opengroup.org/susv3xsh/getlogin.html>.
359  */
360 # if !@HAVE_DECL_GETLOGIN_R@
361 #  include <stddef.h>
362 extern int getlogin_r (char *name, size_t size);
363 # endif
364 #elif defined GNULIB_POSIXCHECK
365 # undef getlogin_r
366 # define getlogin_r(n,s) \
367     (GL_LINK_WARNING ("getlogin_r is unportable - " \
368                       "use gnulib module getlogin_r for portability"), \
369      getlogin_r (n, s))
370 #endif
371 
372 
373 #if @GNULIB_GETPAGESIZE@
374 # if @REPLACE_GETPAGESIZE@
375 #  define getpagesize rpl_getpagesize
376 extern int getpagesize (void);
377 # elif !@HAVE_GETPAGESIZE@
378 /* This is for POSIX systems.  */
379 #  if !defined getpagesize && defined _SC_PAGESIZE
380 #   if ! (defined __VMS && __VMS_VER < 70000000)
381 #    define getpagesize() sysconf (_SC_PAGESIZE)
382 #   endif
383 #  endif
384 /* This is for older VMS.  */
385 #  if !defined getpagesize && defined __VMS
386 #   ifdef __ALPHA
387 #    define getpagesize() 8192
388 #   else
389 #    define getpagesize() 512
390 #   endif
391 #  endif
392 /* This is for BeOS.  */
393 #  if !defined getpagesize && @HAVE_OS_H@
394 #   include <OS.h>
395 #   if defined B_PAGE_SIZE
396 #    define getpagesize() B_PAGE_SIZE
397 #   endif
398 #  endif
399 /* This is for AmigaOS4.0.  */
400 #  if !defined getpagesize && defined __amigaos4__
401 #   define getpagesize() 2048
402 #  endif
403 /* This is for older Unix systems.  */
404 #  if !defined getpagesize && @HAVE_SYS_PARAM_H@
405 #   include <sys/param.h>
406 #   ifdef EXEC_PAGESIZE
407 #    define getpagesize() EXEC_PAGESIZE
408 #   else
409 #    ifdef NBPG
410 #     ifndef CLSIZE
411 #      define CLSIZE 1
412 #     endif
413 #     define getpagesize() (NBPG * CLSIZE)
414 #    else
415 #     ifdef NBPC
416 #      define getpagesize() NBPC
417 #     endif
418 #    endif
419 #   endif
420 #  endif
421 # endif
422 #elif defined GNULIB_POSIXCHECK
423 # undef getpagesize
424 # define getpagesize() \
425     (GL_LINK_WARNING ("getpagesize is unportable - " \
426                       "use gnulib module getpagesize for portability"), \
427      getpagesize ())
428 #endif
429 
430 
431 #if @GNULIB_GETUSERSHELL@
432 # if !@HAVE_GETUSERSHELL@
433 /* Return the next valid login shell on the system, or NULL when the end of
434    the list has been reached.  */
435 extern char *getusershell (void);
436 /* Rewind to pointer that is advanced at each getusershell() call.  */
437 extern void setusershell (void);
438 /* Free the pointer that is advanced at each getusershell() call and
439    associated resources.  */
440 extern void endusershell (void);
441 # endif
442 #elif defined GNULIB_POSIXCHECK
443 # undef getusershell
444 # define getusershell() \
445     (GL_LINK_WARNING ("getusershell is unportable - " \
446                       "use gnulib module getusershell for portability"), \
447      getusershell ())
448 # undef setusershell
449 # define setusershell() \
450     (GL_LINK_WARNING ("setusershell is unportable - " \
451                       "use gnulib module getusershell for portability"), \
452      setusershell ())
453 # undef endusershell
454 # define endusershell() \
455     (GL_LINK_WARNING ("endusershell is unportable - " \
456                       "use gnulib module getusershell for portability"), \
457      endusershell ())
458 #endif
459 
460 
461 #if @GNULIB_LCHOWN@
462 # if @REPLACE_LCHOWN@
463 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
464    to GID (if GID is not -1).  Do not follow symbolic links.
465    Return 0 if successful, otherwise -1 and errno set.
466    See the POSIX:2001 specification
467    <http://www.opengroup.org/susv3xsh/lchown.html>.  */
468 #  define lchown rpl_lchown
469 extern int lchown (char const *file, uid_t owner, gid_t group);
470 # endif
471 #elif defined GNULIB_POSIXCHECK
472 # undef lchown
473 # define lchown(f,u,g) \
474     (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
475                       "systems - use gnulib module lchown for portability"), \
476      lchown (f, u, g))
477 #endif
478 
479 
480 #if @GNULIB_LSEEK@
481 # if @REPLACE_LSEEK@
482 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
483    Return the new offset if successful, otherwise -1 and errno set.
484    See the POSIX:2001 specification
485    <http://www.opengroup.org/susv3xsh/lseek.html>.  */
486 #  define lseek rpl_lseek
487    extern off_t lseek (int fd, off_t offset, int whence);
488 # endif
489 #elif defined GNULIB_POSIXCHECK
490 # undef lseek
491 # define lseek(f,o,w) \
492     (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
493                       "systems - use gnulib module lseek for portability"), \
494      lseek (f, o, w))
495 #endif
496 
497 
498 #if @GNULIB_READLINK@
499 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
500    bytes of it into BUF.  Return the number of bytes placed into BUF if
501    successful, otherwise -1 and errno set.
502    See the POSIX:2001 specification
503    <http://www.opengroup.org/susv3xsh/readlink.html>.  */
504 # if !@HAVE_READLINK@
505 #  include <stddef.h>
506 extern int readlink (const char *file, char *buf, size_t bufsize);
507 # endif
508 #elif defined GNULIB_POSIXCHECK
509 # undef readlink
510 # define readlink(f,b,s) \
511     (GL_LINK_WARNING ("readlink is unportable - " \
512                       "use gnulib module readlink for portability"), \
513      readlink (f, b, s))
514 #endif
515 
516 
517 #if @GNULIB_SLEEP@
518 /* Pause the execution of the current thread for N seconds.
519    Returns the number of seconds left to sleep.
520    See the POSIX:2001 specification
521    <http://www.opengroup.org/susv3xsh/sleep.html>.  */
522 # if !@HAVE_SLEEP@
523 extern unsigned int sleep (unsigned int n);
524 # endif
525 #elif defined GNULIB_POSIXCHECK
526 # undef sleep
527 # define sleep(n) \
528     (GL_LINK_WARNING ("sleep is unportable - " \
529                       "use gnulib module sleep for portability"), \
530      sleep (n))
531 #endif
532 
533 
534 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
535 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
536    See the POSIX:2001 specification
537    <http://www.opengroup.org/susv3xsh/write.html>.  */
538 # undef write
539 # define write rpl_write
540 extern ssize_t write (int fd, const void *buf, size_t count);
541 #endif
542 
543 
544 #ifdef FCHDIR_REPLACEMENT
545 /* gnulib internal function.  */
546 extern void _gl_unregister_fd (int fd);
547 #endif
548 
549 
550 #ifdef __cplusplus
551 }
552 #endif
553 
554 
555 #endif /* _GL_UNISTD_H */
556 #endif /* _GL_UNISTD_H */
557