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