]> git.cworth.org Git - tar/blob - lib/unistd.in.h
Imported Upstream version 1.21
[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-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 #include <stdlib.h>
41
42 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
43 /* Get ssize_t.  */
44 # include <sys/types.h>
45 #endif
46
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
52 #   undef socket
53 #   define socket               socket_used_without_including_sys_socket_h
54 #   undef connect
55 #   define connect              connect_used_without_including_sys_socket_h
56 #   undef accept
57 #   define accept               accept_used_without_including_sys_socket_h
58 #   undef bind
59 #   define bind                 bind_used_without_including_sys_socket_h
60 #   undef getpeername
61 #   define getpeername          getpeername_used_without_including_sys_socket_h
62 #   undef getsockname
63 #   define getsockname          getsockname_used_without_including_sys_socket_h
64 #   undef getsockopt
65 #   define getsockopt           getsockopt_used_without_including_sys_socket_h
66 #   undef listen
67 #   define listen               listen_used_without_including_sys_socket_h
68 #   undef recv
69 #   define recv                 recv_used_without_including_sys_socket_h
70 #   undef send
71 #   define send                 send_used_without_including_sys_socket_h
72 #   undef recvfrom
73 #   define recvfrom             recvfrom_used_without_including_sys_socket_h
74 #   undef sendto
75 #   define sendto               sendto_used_without_including_sys_socket_h
76 #   undef setsockopt
77 #   define setsockopt           setsockopt_used_without_including_sys_socket_h
78 #   undef shutdown
79 #   define shutdown             shutdown_used_without_including_sys_socket_h
80 #  endif
81 #  if !defined _GL_SYS_SELECT_H
82 #   undef select
83 #   define select               select_used_without_including_sys_select_h
84 #  endif
85 # endif
86 #endif
87
88 /* The definition of GL_LINK_WARNING is copied here.  */
89
90
91 /* Declare overridden functions.  */
92
93 #ifdef __cplusplus
94 extern "C" {
95 #endif
96
97
98 #if @GNULIB_CHOWN@
99 # if @REPLACE_CHOWN@
100 #  ifndef REPLACE_CHOWN
101 #   define REPLACE_CHOWN 1
102 #  endif
103 #  if REPLACE_CHOWN
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);
111 #  endif
112 # endif
113 #elif defined GNULIB_POSIXCHECK
114 # undef chown
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"), \
119      chown (f, u, g))
120 #endif
121
122
123 #if @GNULIB_CLOSE@
124 # if @UNISTD_H_HAVE_WINSOCK2_H@
125 /* Need a gnulib internal function.  */
126 #  define HAVE__GL_CLOSE_FD_MAYBE_SOCKET 1
127 # endif
128 # if @REPLACE_CLOSE@
129 /* Automatically included by modules that need a replacement for close.  */
130 #  undef close
131 #  define close rpl_close
132 extern int close (int);
133 # endif
134 #elif @UNISTD_H_HAVE_WINSOCK2_H@
135 # undef close
136 # define close close_used_without_requesting_gnulib_module_close
137 #elif defined GNULIB_POSIXCHECK
138 # undef close
139 # define close(f) \
140     (GL_LINK_WARNING ("close does not portably work on sockets - " \
141                       "use gnulib module close for portability"), \
142      close (f))
143 #endif
144
145
146 #if @GNULIB_DUP2@
147 # if !@HAVE_DUP2@
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);
154 # endif
155 #elif defined GNULIB_POSIXCHECK
156 # undef dup2
157 # define dup2(o,n) \
158     (GL_LINK_WARNING ("dup2 is unportable - " \
159                       "use gnulib module dup2 for portability"), \
160      dup2 (o, n))
161 #endif
162
163
164 #if @GNULIB_ENVIRON@
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 ())
171 #  else
172 extern char **environ;
173 #  endif
174 # endif
175 #elif defined GNULIB_POSIXCHECK
176 # undef environ
177 # define environ \
178     (GL_LINK_WARNING ("environ is unportable - " \
179                       "use gnulib module environ for portability"), \
180      environ)
181 #endif
182
183
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);
189 # endif
190 #elif defined GNULIB_POSIXCHECK
191 # undef euidaccess
192 # define euidaccess(f,m) \
193     (GL_LINK_WARNING ("euidaccess is unportable - " \
194                       "use gnulib module euidaccess for portability"), \
195      euidaccess (f, m))
196 #endif
197
198
199 #if @GNULIB_FCHDIR@
200 # if @REPLACE_FCHDIR@
201
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*/);
208
209 #  define dup rpl_dup
210 extern int dup (int);
211 #  define dup2 rpl_dup2
212 extern int dup2 (int, int);
213
214 # endif
215 #elif defined GNULIB_POSIXCHECK
216 # undef fchdir
217 # define fchdir(f) \
218     (GL_LINK_WARNING ("fchdir is unportable - " \
219                       "use gnulib module fchdir for portability"), \
220      fchdir (f))
221 #endif
222
223
224 #if @GNULIB_FSYNC@
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>.  */
229 # if !@HAVE_FSYNC@
230 extern int fsync (int fd);
231 # endif
232 #elif defined GNULIB_POSIXCHECK
233 # undef fsync
234 # define fsync(fd) \
235     (GL_LINK_WARNING ("fsync is unportable - " \
236                       "use gnulib module fsync for portability"), \
237      fsync (fd))
238 #endif
239
240
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);
248 # endif
249 #elif defined GNULIB_POSIXCHECK
250 # undef ftruncate
251 # define ftruncate(f,l) \
252     (GL_LINK_WARNING ("ftruncate is unportable - " \
253                       "use gnulib module ftruncate for portability"), \
254      ftruncate (f, l))
255 #endif
256
257
258 #if @GNULIB_GETCWD@
259 /* Include the headers that might declare getcwd so that they will not
260    cause confusion if included after this file.  */
261 # include <stdlib.h>
262 # if @REPLACE_GETCWD@
263 /* Get the name of the current working directory, and put it in SIZE bytes
264    of BUF.
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
272    necessary.  */
273 #  define getcwd rpl_getcwd
274 extern char * getcwd (char *buf, size_t size);
275 # endif
276 #elif defined GNULIB_POSIXCHECK
277 # undef getcwd
278 # define getcwd(b,s) \
279     (GL_LINK_WARNING ("getcwd is unportable - " \
280                       "use gnulib module getcwd for portability"), \
281      getcwd (b, s))
282 #endif
283
284
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
290             not using NIS.
291
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);
298 # endif
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))
305 #endif
306
307
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);
312 # endif
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"), \
318      getdtablesize ())
319 #endif
320
321
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.
325
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@
331 #  undef gethostname
332 #  define gethostname rpl_gethostname
333 # endif
334 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
335 extern int gethostname(char *name, size_t len);
336 # endif
337 #elif @UNISTD_H_HAVE_WINSOCK2_H@
338 # undef gethostname
339 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
340 #elif defined GNULIB_POSIXCHECK
341 # undef gethostname
342 # define gethostname(n,l) \
343     (GL_LINK_WARNING ("gethostname is unportable - " \
344                       "use gnulib module gethostname for portability"), \
345      gethostname (n, l))
346 #endif
347
348
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.
352
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).
356
357    See <http://www.opengroup.org/susv3xsh/getlogin.html>.
358  */
359 # if !@HAVE_DECL_GETLOGIN_R@
360 #  include <stddef.h>
361 extern int getlogin_r (char *name, size_t size);
362 # endif
363 #elif defined GNULIB_POSIXCHECK
364 # undef getlogin_r
365 # define getlogin_r(n,s) \
366     (GL_LINK_WARNING ("getlogin_r is unportable - " \
367                       "use gnulib module getlogin_r for portability"), \
368      getlogin_r (n, s))
369 #endif
370
371
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)
381 #   endif
382 #  endif
383 /* This is for older VMS.  */
384 #  if !defined getpagesize && defined __VMS
385 #   ifdef __ALPHA
386 #    define getpagesize() 8192
387 #   else
388 #    define getpagesize() 512
389 #   endif
390 #  endif
391 /* This is for BeOS.  */
392 #  if !defined getpagesize && @HAVE_OS_H@
393 #   include <OS.h>
394 #   if defined B_PAGE_SIZE
395 #    define getpagesize() B_PAGE_SIZE
396 #   endif
397 #  endif
398 /* This is for AmigaOS4.0.  */
399 #  if !defined getpagesize && defined __amigaos4__
400 #   define getpagesize() 2048
401 #  endif
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
407 #   else
408 #    ifdef NBPG
409 #     ifndef CLSIZE
410 #      define CLSIZE 1
411 #     endif
412 #     define getpagesize() (NBPG * CLSIZE)
413 #    else
414 #     ifdef NBPC
415 #      define getpagesize() NBPC
416 #     endif
417 #    endif
418 #   endif
419 #  endif
420 # endif
421 #elif defined GNULIB_POSIXCHECK
422 # undef getpagesize
423 # define getpagesize() \
424     (GL_LINK_WARNING ("getpagesize is unportable - " \
425                       "use gnulib module getpagesize for portability"), \
426      getpagesize ())
427 #endif
428
429
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);
440 # endif
441 #elif defined GNULIB_POSIXCHECK
442 # undef getusershell
443 # define getusershell() \
444     (GL_LINK_WARNING ("getusershell is unportable - " \
445                       "use gnulib module getusershell for portability"), \
446      getusershell ())
447 # undef setusershell
448 # define setusershell() \
449     (GL_LINK_WARNING ("setusershell is unportable - " \
450                       "use gnulib module getusershell for portability"), \
451      setusershell ())
452 # undef endusershell
453 # define endusershell() \
454     (GL_LINK_WARNING ("endusershell is unportable - " \
455                       "use gnulib module getusershell for portability"), \
456      endusershell ())
457 #endif
458
459
460 #if @GNULIB_LCHOWN@
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);
469 # endif
470 #elif defined GNULIB_POSIXCHECK
471 # undef lchown
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"), \
475      lchown (f, u, g))
476 #endif
477
478
479 #if @GNULIB_LSEEK@
480 # if @REPLACE_LSEEK@
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);
487 # endif
488 #elif defined GNULIB_POSIXCHECK
489 # undef lseek
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"), \
493      lseek (f, o, w))
494 #endif
495
496
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@
504 #  include <stddef.h>
505 extern int readlink (const char *file, char *buf, size_t bufsize);
506 # endif
507 #elif defined GNULIB_POSIXCHECK
508 # undef readlink
509 # define readlink(f,b,s) \
510     (GL_LINK_WARNING ("readlink is unportable - " \
511                       "use gnulib module readlink for portability"), \
512      readlink (f, b, s))
513 #endif
514
515
516 #if @GNULIB_SLEEP@
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>.  */
521 # if !@HAVE_SLEEP@
522 extern unsigned int sleep (unsigned int n);
523 # endif
524 #elif defined GNULIB_POSIXCHECK
525 # undef sleep
526 # define sleep(n) \
527     (GL_LINK_WARNING ("sleep is unportable - " \
528                       "use gnulib module sleep for portability"), \
529      sleep (n))
530 #endif
531
532
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>.  */
537 # undef write
538 # define write rpl_write
539 extern ssize_t write (int fd, const void *buf, size_t count);
540 #endif
541
542
543 #ifdef FCHDIR_REPLACEMENT
544 /* gnulib internal function.  */
545 extern void _gl_unregister_fd (int fd);
546 #endif
547
548
549 #ifdef __cplusplus
550 }
551 #endif
552
553
554 #endif /* _GL_UNISTD_H */
555 #endif /* _GL_UNISTD_H */