]> git.cworth.org Git - tar/blob - lib/unistd.in.h
Imported Upstream version 1.20
[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) 2004-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 /* The include_next requires a split double-inclusion guard.  */
23 #if @HAVE_UNISTD_H@
24 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
25 #endif
26
27 #ifndef _GL_UNISTD_H
28 #define _GL_UNISTD_H
29
30 /* mingw doesn't define the SEEK_* macros in <unistd.h>.  */
31 #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
32 # include <stdio.h>
33 #endif
34
35 /* mingw fails to declare _exit in <unistd.h>.  */
36 #include <stdlib.h>
37
38 /* The definition of GL_LINK_WARNING is copied here.  */
39
40
41 /* Declare overridden functions.  */
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47
48 #if @GNULIB_CHOWN@
49 # if @REPLACE_CHOWN@
50 #  ifndef REPLACE_CHOWN
51 #   define REPLACE_CHOWN 1
52 #  endif
53 #  if REPLACE_CHOWN
54 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
55    to GID (if GID is not -1).  Follow symbolic links.
56    Return 0 if successful, otherwise -1 and errno set.
57    See the POSIX:2001 specification
58    <http://www.opengroup.org/susv3xsh/chown.html>.  */
59 #   define chown rpl_chown
60 extern int chown (const char *file, uid_t uid, gid_t gid);
61 #  endif
62 # endif
63 #elif defined GNULIB_POSIXCHECK
64 # undef chown
65 # define chown(f,u,g) \
66     (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
67                       "doesn't treat a uid or gid of -1 on some systems - " \
68                       "use gnulib module chown for portability"), \
69      chown (f, u, g))
70 #endif
71
72
73 #if @GNULIB_DUP2@
74 # if !@HAVE_DUP2@
75 /* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
76    NEWFD = OLDFD, otherwise close NEWFD first if it is open.
77    Return 0 if successful, otherwise -1 and errno set.
78    See the POSIX:2001 specification
79    <http://www.opengroup.org/susv3xsh/dup2.html>.  */
80 extern int dup2 (int oldfd, int newfd);
81 # endif
82 #elif defined GNULIB_POSIXCHECK
83 # undef dup2
84 # define dup2(o,n) \
85     (GL_LINK_WARNING ("dup2 is unportable - " \
86                       "use gnulib module dup2 for portability"), \
87      dup2 (o, n))
88 #endif
89
90
91 #if @GNULIB_ENVIRON@
92 # if !@HAVE_DECL_ENVIRON@
93 /* Set of environment variables and values.  An array of strings of the form
94    "VARIABLE=VALUE", terminated with a NULL.  */
95 #  if defined __APPLE__ && defined __MACH__
96 #   include <crt_externs.h>
97 #   define environ (*_NSGetEnviron ())
98 #  else
99 extern char **environ;
100 #  endif
101 # endif
102 #elif defined GNULIB_POSIXCHECK
103 # undef environ
104 # define environ \
105     (GL_LINK_WARNING ("environ is unportable - " \
106                       "use gnulib module environ for portability"), \
107      environ)
108 #endif
109
110
111 #if @GNULIB_FCHDIR@
112 # if @REPLACE_FCHDIR@
113
114 /* Change the process' current working directory to the directory on which
115    the given file descriptor is open.
116    Return 0 if successful, otherwise -1 and errno set.
117    See the POSIX:2001 specification
118    <http://www.opengroup.org/susv3xsh/fchdir.html>.  */
119 extern int fchdir (int /*fd*/);
120
121 #  define close rpl_close
122 extern int close (int);
123 #  define dup rpl_dup
124 extern int dup (int);
125 #  define dup2 rpl_dup2
126 extern int dup2 (int, int);
127
128 # endif
129 #elif defined GNULIB_POSIXCHECK
130 # undef fchdir
131 # define fchdir(f) \
132     (GL_LINK_WARNING ("fchdir is unportable - " \
133                       "use gnulib module fchdir for portability"), \
134      fchdir (f))
135 #endif
136
137
138 #if @GNULIB_FTRUNCATE@
139 # if !@HAVE_FTRUNCATE@
140 /* Change the size of the file to which FD is opened to become equal to LENGTH.
141    Return 0 if successful, otherwise -1 and errno set.
142    See the POSIX:2001 specification
143    <http://www.opengroup.org/susv3xsh/ftruncate.html>.  */
144 extern int ftruncate (int fd, off_t length);
145 # endif
146 #elif defined GNULIB_POSIXCHECK
147 # undef ftruncate
148 # define ftruncate(f,l) \
149     (GL_LINK_WARNING ("ftruncate is unportable - " \
150                       "use gnulib module ftruncate for portability"), \
151      ftruncate (f, l))
152 #endif
153
154
155 #if @GNULIB_GETCWD@
156 /* Include the headers that might declare getcwd so that they will not
157    cause confusion if included after this file.  */
158 # include <stdlib.h>
159 # if @REPLACE_GETCWD@
160 /* Get the name of the current working directory, and put it in SIZE bytes
161    of BUF.
162    Return BUF if successful, or NULL if the directory couldn't be determined
163    or SIZE was too small.
164    See the POSIX:2001 specification
165    <http://www.opengroup.org/susv3xsh/getcwd.html>.
166    Additionally, the gnulib module 'getcwd' guarantees the following GNU
167    extension: If BUF is NULL, an array is allocated with 'malloc'; the array
168    is SIZE bytes long, unless SIZE == 0, in which case it is as big as
169    necessary.  */
170 #  define getcwd rpl_getcwd
171 extern char * getcwd (char *buf, size_t size);
172 # endif
173 #elif defined GNULIB_POSIXCHECK
174 # undef getcwd
175 # define getcwd(b,s) \
176     (GL_LINK_WARNING ("getcwd is unportable - " \
177                       "use gnulib module getcwd for portability"), \
178      getcwd (b, s))
179 #endif
180
181
182 #if @GNULIB_GETLOGIN_R@
183 /* Copies the user's login name to NAME.
184    The array pointed to by NAME has room for SIZE bytes.
185
186    Returns 0 if successful.  Upon error, an error number is returned, or -1 in
187    the case that the login name cannot be found but no specific error is
188    provided (this case is hopefully rare but is left open by the POSIX spec).
189
190    See <http://www.opengroup.org/susv3xsh/getlogin.html>.
191  */
192 # if !@HAVE_DECL_GETLOGIN_R@
193 #  include <stddef.h>
194 extern int getlogin_r (char *name, size_t size);
195 # endif
196 #elif defined GNULIB_POSIXCHECK
197 # undef getlogin_r
198 # define getlogin_r(n,s) \
199     (GL_LINK_WARNING ("getlogin_r is unportable - " \
200                       "use gnulib module getlogin_r for portability"), \
201      getlogin_r (n, s))
202 #endif
203
204
205 #if @GNULIB_GETPAGESIZE@
206 # if @REPLACE_GETPAGESIZE@
207 #  define getpagesize rpl_getpagesize
208 extern int getpagesize (void);
209 # elif !@HAVE_GETPAGESIZE@
210 /* This is for POSIX systems.  */
211 #  if !defined getpagesize && defined _SC_PAGESIZE
212 #   if ! (defined __VMS && __VMS_VER < 70000000)
213 #    define getpagesize() sysconf (_SC_PAGESIZE)
214 #   endif
215 #  endif
216 /* This is for older VMS.  */
217 #  if !defined getpagesize && defined __VMS
218 #   ifdef __ALPHA
219 #    define getpagesize() 8192
220 #   else
221 #    define getpagesize() 512
222 #   endif
223 #  endif
224 /* This is for BeOS.  */
225 #  if !defined getpagesize && @HAVE_OS_H@
226 #   include <OS.h>
227 #   if defined B_PAGE_SIZE
228 #    define getpagesize() B_PAGE_SIZE
229 #   endif
230 #  endif
231 /* This is for AmigaOS4.0.  */
232 #  if !defined getpagesize && defined __amigaos4__
233 #   define getpagesize() 2048
234 #  endif
235 /* This is for older Unix systems.  */
236 #  if !defined getpagesize && @HAVE_SYS_PARAM_H@
237 #   include <sys/param.h>
238 #   ifdef EXEC_PAGESIZE
239 #    define getpagesize() EXEC_PAGESIZE
240 #   else
241 #    ifdef NBPG
242 #     ifndef CLSIZE
243 #      define CLSIZE 1
244 #     endif
245 #     define getpagesize() (NBPG * CLSIZE)
246 #    else
247 #     ifdef NBPC
248 #      define getpagesize() NBPC
249 #     endif
250 #    endif
251 #   endif
252 #  endif
253 # endif
254 #elif defined GNULIB_POSIXCHECK
255 # undef getpagesize
256 # define getpagesize() \
257     (GL_LINK_WARNING ("getpagesize is unportable - " \
258                       "use gnulib module getpagesize for portability"), \
259      getpagesize ())
260 #endif
261
262
263 #if @GNULIB_LCHOWN@
264 # if @REPLACE_LCHOWN@
265 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
266    to GID (if GID is not -1).  Do not follow symbolic links.
267    Return 0 if successful, otherwise -1 and errno set.
268    See the POSIX:2001 specification
269    <http://www.opengroup.org/susv3xsh/lchown.html>.  */
270 #  define lchown rpl_lchown
271 extern int lchown (char const *file, uid_t owner, gid_t group);
272 # endif
273 #elif defined GNULIB_POSIXCHECK
274 # undef lchown
275 # define lchown(f,u,g) \
276     (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
277                       "systems - use gnulib module lchown for portability"), \
278      lchown (f, u, g))
279 #endif
280
281
282 #if @GNULIB_LSEEK@
283 # if @REPLACE_LSEEK@
284 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
285    Return the new offset if successful, otherwise -1 and errno set.
286    See the POSIX:2001 specification
287    <http://www.opengroup.org/susv3xsh/lseek.html>.  */
288 #  define lseek rpl_lseek
289    extern off_t lseek (int fd, off_t offset, int whence);
290 # endif
291 #elif defined GNULIB_POSIXCHECK
292 # undef lseek
293 # define lseek(f,o,w) \
294     (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
295                       "systems - use gnulib module lseek for portability"), \
296      lseek (f, o, w))
297 #endif
298
299
300 #if @GNULIB_READLINK@
301 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
302    bytes of it into BUF.  Return the number of bytes placed into BUF if
303    successful, otherwise -1 and errno set.
304    See the POSIX:2001 specification
305    <http://www.opengroup.org/susv3xsh/readlink.html>.  */
306 # if !@HAVE_READLINK@
307 #  include <stddef.h>
308 extern int readlink (const char *file, char *buf, size_t bufsize);
309 # endif
310 #elif defined GNULIB_POSIXCHECK
311 # undef readlink
312 # define readlink(f,b,s) \
313     (GL_LINK_WARNING ("readlink is unportable - " \
314                       "use gnulib module readlink for portability"), \
315      readlink (f, b, s))
316 #endif
317
318
319 #if @GNULIB_SLEEP@
320 /* Pause the execution of the current thread for N seconds.
321    Returns the number of seconds left to sleep.
322    See the POSIX:2001 specification
323    <http://www.opengroup.org/susv3xsh/sleep.html>.  */
324 # if !@HAVE_SLEEP@
325 extern unsigned int sleep (unsigned int n);
326 # endif
327 #elif defined GNULIB_POSIXCHECK
328 # undef sleep
329 # define sleep(n) \
330     (GL_LINK_WARNING ("sleep is unportable - " \
331                       "use gnulib module sleep for portability"), \
332      sleep (n))
333 #endif
334
335
336 #ifdef __cplusplus
337 }
338 #endif
339
340
341 #endif /* _GL_UNISTD_H */
342 #endif /* _GL_UNISTD_H */