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