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