]> git.cworth.org Git - tar/blob - lib/unistd.in.h
Imported Upstream version 1.22
[tar] / lib / unistd.in.h
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 @UNISTD_H_HAVE_WINSOCK2_H@
137 /* Need a gnulib internal function.  */
138 #  define HAVE__GL_CLOSE_FD_MAYBE_SOCKET 1
139 # endif
140 # if @REPLACE_CLOSE@
141 /* Automatically included by modules that need a replacement for close.  */
142 #  undef close
143 #  define close rpl_close
144 extern int close (int);
145 # endif
146 #elif @UNISTD_H_HAVE_WINSOCK2_H@
147 # undef close
148 # define close close_used_without_requesting_gnulib_module_close
149 #elif defined GNULIB_POSIXCHECK
150 # undef close
151 # define close(f) \
152     (GL_LINK_WARNING ("close does not portably work on sockets - " \
153                       "use gnulib module close for portability"), \
154      close (f))
155 #endif
156
157
158 #if @GNULIB_DUP2@
159 # if !@HAVE_DUP2@
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);
166 # endif
167 #elif defined GNULIB_POSIXCHECK
168 # undef dup2
169 # define dup2(o,n) \
170     (GL_LINK_WARNING ("dup2 is unportable - " \
171                       "use gnulib module dup2 for portability"), \
172      dup2 (o, n))
173 #endif
174
175
176 #if @GNULIB_ENVIRON@
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 ())
183 #  else
184 extern char **environ;
185 #  endif
186 # endif
187 #elif defined GNULIB_POSIXCHECK
188 # undef environ
189 # define environ \
190     (GL_LINK_WARNING ("environ is unportable - " \
191                       "use gnulib module environ for portability"), \
192      environ)
193 #endif
194
195
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);
201 # endif
202 #elif defined GNULIB_POSIXCHECK
203 # undef euidaccess
204 # define euidaccess(f,m) \
205     (GL_LINK_WARNING ("euidaccess is unportable - " \
206                       "use gnulib module euidaccess for portability"), \
207      euidaccess (f, m))
208 #endif
209
210
211 #if @GNULIB_FCHDIR@
212 # if @REPLACE_FCHDIR@
213
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*/);
220
221 #  define dup rpl_dup
222 extern int dup (int);
223 #  define dup2 rpl_dup2
224 extern int dup2 (int, int);
225
226 # endif
227 #elif defined GNULIB_POSIXCHECK
228 # undef fchdir
229 # define fchdir(f) \
230     (GL_LINK_WARNING ("fchdir is unportable - " \
231                       "use gnulib module fchdir for portability"), \
232      fchdir (f))
233 #endif
234
235
236 #if @GNULIB_FSYNC@
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>.  */
241 # if !@HAVE_FSYNC@
242 extern int fsync (int fd);
243 # endif
244 #elif defined GNULIB_POSIXCHECK
245 # undef fsync
246 # define fsync(fd) \
247     (GL_LINK_WARNING ("fsync is unportable - " \
248                       "use gnulib module fsync for portability"), \
249      fsync (fd))
250 #endif
251
252
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);
260 # endif
261 #elif defined GNULIB_POSIXCHECK
262 # undef ftruncate
263 # define ftruncate(f,l) \
264     (GL_LINK_WARNING ("ftruncate is unportable - " \
265                       "use gnulib module ftruncate for portability"), \
266      ftruncate (f, l))
267 #endif
268
269
270 #if @GNULIB_GETCWD@
271 /* Include the headers that might declare getcwd so that they will not
272    cause confusion if included after this file.  */
273 # include <stdlib.h>
274 # if @REPLACE_GETCWD@
275 /* Get the name of the current working directory, and put it in SIZE bytes
276    of BUF.
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
284    necessary.  */
285 #  define getcwd rpl_getcwd
286 extern char * getcwd (char *buf, size_t size);
287 # endif
288 #elif defined GNULIB_POSIXCHECK
289 # undef getcwd
290 # define getcwd(b,s) \
291     (GL_LINK_WARNING ("getcwd is unportable - " \
292                       "use gnulib module getcwd for portability"), \
293      getcwd (b, s))
294 #endif
295
296
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
302             not using NIS.
303
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);
310 # endif
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))
317 #endif
318
319
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);
324 # endif
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"), \
330      getdtablesize ())
331 #endif
332
333
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.
337
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@
343 #  undef gethostname
344 #  define gethostname rpl_gethostname
345 # endif
346 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
347 extern int gethostname(char *name, size_t len);
348 # endif
349 #elif @UNISTD_H_HAVE_WINSOCK2_H@
350 # undef gethostname
351 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
352 #elif defined GNULIB_POSIXCHECK
353 # undef gethostname
354 # define gethostname(n,l) \
355     (GL_LINK_WARNING ("gethostname is unportable - " \
356                       "use gnulib module gethostname for portability"), \
357      gethostname (n, l))
358 #endif
359
360
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.
364
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).
368
369    See <http://www.opengroup.org/susv3xsh/getlogin.html>.
370  */
371 # if !@HAVE_DECL_GETLOGIN_R@
372 #  include <stddef.h>
373 extern int getlogin_r (char *name, size_t size);
374 # endif
375 #elif defined GNULIB_POSIXCHECK
376 # undef getlogin_r
377 # define getlogin_r(n,s) \
378     (GL_LINK_WARNING ("getlogin_r is unportable - " \
379                       "use gnulib module getlogin_r for portability"), \
380      getlogin_r (n, s))
381 #endif
382
383
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)
393 #   endif
394 #  endif
395 /* This is for older VMS.  */
396 #  if !defined getpagesize && defined __VMS
397 #   ifdef __ALPHA
398 #    define getpagesize() 8192
399 #   else
400 #    define getpagesize() 512
401 #   endif
402 #  endif
403 /* This is for BeOS.  */
404 #  if !defined getpagesize && @HAVE_OS_H@
405 #   include <OS.h>
406 #   if defined B_PAGE_SIZE
407 #    define getpagesize() B_PAGE_SIZE
408 #   endif
409 #  endif
410 /* This is for AmigaOS4.0.  */
411 #  if !defined getpagesize && defined __amigaos4__
412 #   define getpagesize() 2048
413 #  endif
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
419 #   else
420 #    ifdef NBPG
421 #     ifndef CLSIZE
422 #      define CLSIZE 1
423 #     endif
424 #     define getpagesize() (NBPG * CLSIZE)
425 #    else
426 #     ifdef NBPC
427 #      define getpagesize() NBPC
428 #     endif
429 #    endif
430 #   endif
431 #  endif
432 # endif
433 #elif defined GNULIB_POSIXCHECK
434 # undef getpagesize
435 # define getpagesize() \
436     (GL_LINK_WARNING ("getpagesize is unportable - " \
437                       "use gnulib module getpagesize for portability"), \
438      getpagesize ())
439 #endif
440
441
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);
452 # endif
453 #elif defined GNULIB_POSIXCHECK
454 # undef getusershell
455 # define getusershell() \
456     (GL_LINK_WARNING ("getusershell is unportable - " \
457                       "use gnulib module getusershell for portability"), \
458      getusershell ())
459 # undef setusershell
460 # define setusershell() \
461     (GL_LINK_WARNING ("setusershell is unportable - " \
462                       "use gnulib module getusershell for portability"), \
463      setusershell ())
464 # undef endusershell
465 # define endusershell() \
466     (GL_LINK_WARNING ("endusershell is unportable - " \
467                       "use gnulib module getusershell for portability"), \
468      endusershell ())
469 #endif
470
471
472 #if @GNULIB_LCHOWN@
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);
481 # endif
482 #elif defined GNULIB_POSIXCHECK
483 # undef lchown
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"), \
487      lchown (f, u, g))
488 #endif
489
490
491 #if @GNULIB_LINK@
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>.  */
496 # if !@HAVE_LINK@
497 extern int link (const char *path1, const char *path2);
498 # endif
499 #elif defined GNULIB_POSIXCHECK
500 # undef link
501 # define link(path1,path2) \
502     (GL_LINK_WARNING ("link is unportable - " \
503                       "use gnulib module link for portability"), \
504      link (path1, path2))
505 #endif
506
507
508 #if @GNULIB_LSEEK@
509 # if @REPLACE_LSEEK@
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);
516 # endif
517 #elif defined GNULIB_POSIXCHECK
518 # undef lseek
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"), \
522      lseek (f, o, w))
523 #endif
524
525
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@
533 #  include <stddef.h>
534 extern int readlink (const char *file, char *buf, size_t bufsize);
535 # endif
536 #elif defined GNULIB_POSIXCHECK
537 # undef readlink
538 # define readlink(f,b,s) \
539     (GL_LINK_WARNING ("readlink is unportable - " \
540                       "use gnulib module readlink for portability"), \
541      readlink (f, b, s))
542 #endif
543
544
545 #if @GNULIB_SLEEP@
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>.  */
550 # if !@HAVE_SLEEP@
551 extern unsigned int sleep (unsigned int n);
552 # endif
553 #elif defined GNULIB_POSIXCHECK
554 # undef sleep
555 # define sleep(n) \
556     (GL_LINK_WARNING ("sleep is unportable - " \
557                       "use gnulib module sleep for portability"), \
558      sleep (n))
559 #endif
560
561
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>.  */
566 # undef write
567 # define write rpl_write
568 extern ssize_t write (int fd, const void *buf, size_t count);
569 #endif
570
571
572 #ifdef FCHDIR_REPLACEMENT
573 /* gnulib internal function.  */
574 extern void _gl_unregister_fd (int fd);
575 #endif
576
577
578 #ifdef __cplusplus
579 }
580 #endif
581
582
583 #endif /* _GL_UNISTD_H */
584 #endif /* _GL_UNISTD_H */