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