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