unlink: new module, for Solaris 9 bug
[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_FCHOWNAT@
151 # if @REPLACE_FCHOWNAT@
152 #  undef fchownat
153 #  define fchownat rpl_fchownat
154 # endif
155 # if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
156 extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag);
157 # endif
158 #elif defined GNULIB_POSIXCHECK
159 # undef fchownat
160 # define fchownat(d,n,o,g,f)                        \
161     (GL_LINK_WARNING ("fchownat is not portable - " \
162                       "use gnulib module openat for portability"), \
163      fchownat (d, n, o, g, f))
164 #endif
165
166
167 #if @GNULIB_UNLINK@
168 # if @REPLACE_UNLINK@
169 #  undef unlink
170 #  define unlink rpl_unlink
171 extern int unlink (char const *file);
172 # endif
173 #elif defined GNULIB_POSIXCHECK
174 # undef unlink
175 # define unlink(n)                         \
176     (GL_LINK_WARNING ("unlink is not portable - " \
177                       "use gnulib module unlink for portability"), \
178      unlink (n))
179 #endif
180
181
182 #if @GNULIB_UNLINKAT@
183 # if !@HAVE_UNLINKAT@
184 extern int unlinkat (int fd, char const *file, int flag);
185 # endif
186 #elif defined GNULIB_POSIXCHECK
187 # undef unlinkat
188 # define unlinkat(d,n,f)                         \
189     (GL_LINK_WARNING ("unlinkat is not portable - " \
190                       "use gnulib module openat for portability"), \
191      unlinkat (d, n, f))
192 #endif
193
194
195 #if @GNULIB_FACCESSAT@
196 # if !@HAVE_FACCESSAT@
197 int faccessat (int fd, char const *file, int mode, int flag);
198 # endif
199 #elif defined GNULIB_POSIXCHECK
200 # undef faccessat
201 # define faccessat(d,n,m,f)                         \
202     (GL_LINK_WARNING ("faccessat is not portable - " \
203                       "use gnulib module faccessat for portability"), \
204      faccessat (d, n, m, f))
205 #endif
206
207 #if @GNULIB_SYMLINKAT@
208 # if !@HAVE_SYMLINKAT@
209 int symlinkat (char const *contents, int fd, char const *file);
210 # endif
211 #elif defined GNULIB_POSIXCHECK
212 # undef symlinkat
213 # define symlinkat(c,d,n)                            \
214     (GL_LINK_WARNING ("symlinkat is not portable - " \
215                       "use gnulib module symlinkat for portability"), \
216      symlinkat (c, d, n))
217 #endif
218
219 #if @GNULIB_READLINKAT@
220 # if !@HAVE_READLINKAT@
221 ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
222 # endif
223 #elif defined GNULIB_POSIXCHECK
224 # undef readlinkat
225 # define readlinkat(d,n,b,l)                         \
226     (GL_LINK_WARNING ("readlinkat is not portable - " \
227                       "use gnulib module symlinkat for portability"), \
228      readlinkat (d, n, b, l))
229 #endif
230
231 #if @GNULIB_CLOSE@
232 # if @REPLACE_CLOSE@
233 /* Automatically included by modules that need a replacement for close.  */
234 #  undef close
235 #  define close rpl_close
236 extern int close (int);
237 # endif
238 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
239 # undef close
240 # define close close_used_without_requesting_gnulib_module_close
241 #elif defined GNULIB_POSIXCHECK
242 # undef close
243 # define close(f) \
244     (GL_LINK_WARNING ("close does not portably work on sockets - " \
245                       "use gnulib module close for portability"), \
246      close (f))
247 #endif
248
249 #if @REPLACE_DUP@
250 # define dup rpl_dup
251 extern int dup (int);
252 #endif
253
254 #if @GNULIB_DUP2@
255 # if @REPLACE_DUP2@
256 #  define dup2 rpl_dup2
257 # endif
258 # if !@HAVE_DUP2@ || @REPLACE_DUP2@
259 /* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
260    NEWFD = OLDFD, otherwise close NEWFD first if it is open.
261    Return newfd if successful, otherwise -1 and errno set.
262    See the POSIX:2001 specification
263    <http://www.opengroup.org/susv3xsh/dup2.html>.  */
264 extern int dup2 (int oldfd, int newfd);
265 # endif
266 #elif defined GNULIB_POSIXCHECK
267 # undef dup2
268 # define dup2(o,n) \
269     (GL_LINK_WARNING ("dup2 is unportable - " \
270                       "use gnulib module dup2 for portability"), \
271      dup2 (o, n))
272 #endif
273
274
275 #if @GNULIB_DUP3@
276 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
277    specified flags.
278    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
279    and O_TEXT, O_BINARY (defined in "binary-io.h").
280    Close NEWFD first if it is open.
281    Return newfd if successful, otherwise -1 and errno set.
282    See the Linux man page at
283    <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */
284 # if @HAVE_DUP3@
285 #  define dup3 rpl_dup3
286 # endif
287 extern int dup3 (int oldfd, int newfd, int flags);
288 #elif defined GNULIB_POSIXCHECK
289 # undef dup3
290 # define dup3(o,n,f) \
291     (GL_LINK_WARNING ("dup3 is unportable - " \
292                       "use gnulib module dup3 for portability"), \
293      dup3 (o, n, f))
294 #endif
295
296
297 #if @GNULIB_ENVIRON@
298 # if !@HAVE_DECL_ENVIRON@
299 /* Set of environment variables and values.  An array of strings of the form
300    "VARIABLE=VALUE", terminated with a NULL.  */
301 #  if defined __APPLE__ && defined __MACH__
302 #   include <crt_externs.h>
303 #   define environ (*_NSGetEnviron ())
304 #  else
305 extern char **environ;
306 #  endif
307 # endif
308 #elif defined GNULIB_POSIXCHECK
309 # undef environ
310 # define environ \
311     (GL_LINK_WARNING ("environ is unportable - " \
312                       "use gnulib module environ for portability"), \
313      environ)
314 #endif
315
316
317 #if @GNULIB_EUIDACCESS@
318 # if !@HAVE_EUIDACCESS@
319 /* Like access(), except that is uses the effective user id and group id of
320    the current process.  */
321 extern int euidaccess (const char *filename, int mode);
322 # endif
323 #elif defined GNULIB_POSIXCHECK
324 # undef euidaccess
325 # define euidaccess(f,m) \
326     (GL_LINK_WARNING ("euidaccess is unportable - " \
327                       "use gnulib module euidaccess for portability"), \
328      euidaccess (f, m))
329 #endif
330
331
332 #if @GNULIB_FCHDIR@
333 # if @REPLACE_FCHDIR@
334 /* Change the process' current working directory to the directory on which
335    the given file descriptor is open.
336    Return 0 if successful, otherwise -1 and errno set.
337    See the POSIX:2001 specification
338    <http://www.opengroup.org/susv3xsh/fchdir.html>.  */
339 extern int fchdir (int /*fd*/);
340
341 /* Gnulib internal hooks needed to maintain the fchdir metadata.  */
342 extern int _gl_register_fd (int fd, const char *filename);
343 extern void _gl_unregister_fd (int fd);
344 extern int _gl_register_dup (int oldfd, int newfd);
345 extern const char *_gl_directory_name (int fd);
346
347 # endif
348 #elif defined GNULIB_POSIXCHECK
349 # undef fchdir
350 # define fchdir(f) \
351     (GL_LINK_WARNING ("fchdir is unportable - " \
352                       "use gnulib module fchdir for portability"), \
353      fchdir (f))
354 #endif
355
356
357 #if @GNULIB_FSYNC@
358 /* Synchronize changes to a file.
359    Return 0 if successful, otherwise -1 and errno set.
360    See POSIX:2001 specification
361    <http://www.opengroup.org/susv3xsh/fsync.html>.  */
362 # if !@HAVE_FSYNC@
363 extern int fsync (int fd);
364 # endif
365 #elif defined GNULIB_POSIXCHECK
366 # undef fsync
367 # define fsync(fd) \
368     (GL_LINK_WARNING ("fsync is unportable - " \
369                       "use gnulib module fsync for portability"), \
370      fsync (fd))
371 #endif
372
373
374 #if @GNULIB_FTRUNCATE@
375 # if !@HAVE_FTRUNCATE@
376 /* Change the size of the file to which FD is opened to become equal to LENGTH.
377    Return 0 if successful, otherwise -1 and errno set.
378    See the POSIX:2001 specification
379    <http://www.opengroup.org/susv3xsh/ftruncate.html>.  */
380 extern int ftruncate (int fd, off_t length);
381 # endif
382 #elif defined GNULIB_POSIXCHECK
383 # undef ftruncate
384 # define ftruncate(f,l) \
385     (GL_LINK_WARNING ("ftruncate is unportable - " \
386                       "use gnulib module ftruncate for portability"), \
387      ftruncate (f, l))
388 #endif
389
390
391 #if @GNULIB_GETCWD@
392 /* Include the headers that might declare getcwd so that they will not
393    cause confusion if included after this file.  */
394 # include <stdlib.h>
395 # if @REPLACE_GETCWD@
396 /* Get the name of the current working directory, and put it in SIZE bytes
397    of BUF.
398    Return BUF if successful, or NULL if the directory couldn't be determined
399    or SIZE was too small.
400    See the POSIX:2001 specification
401    <http://www.opengroup.org/susv3xsh/getcwd.html>.
402    Additionally, the gnulib module 'getcwd' guarantees the following GNU
403    extension: If BUF is NULL, an array is allocated with 'malloc'; the array
404    is SIZE bytes long, unless SIZE == 0, in which case it is as big as
405    necessary.  */
406 #  define getcwd rpl_getcwd
407 extern char * getcwd (char *buf, size_t size);
408 # endif
409 #elif defined GNULIB_POSIXCHECK
410 # undef getcwd
411 # define getcwd(b,s) \
412     (GL_LINK_WARNING ("getcwd is unportable - " \
413                       "use gnulib module getcwd for portability"), \
414      getcwd (b, s))
415 #endif
416
417
418 #if @GNULIB_GETDOMAINNAME@
419 /* Return the NIS domain name of the machine.
420    WARNING! The NIS domain name is unrelated to the fully qualified host name
421             of the machine.  It is also unrelated to email addresses.
422    WARNING! The NIS domain name is usually the empty string or "(none)" when
423             not using NIS.
424
425    Put up to LEN bytes of the NIS domain name into NAME.
426    Null terminate it if the name is shorter than LEN.
427    If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
428    Return 0 if successful, otherwise set errno and return -1.  */
429 # if !@HAVE_GETDOMAINNAME@
430 extern int getdomainname(char *name, size_t len);
431 # endif
432 #elif defined GNULIB_POSIXCHECK
433 # undef getdomainname
434 # define getdomainname(n,l) \
435     (GL_LINK_WARNING ("getdomainname is unportable - " \
436                       "use gnulib module getdomainname for portability"), \
437      getdomainname (n, l))
438 #endif
439
440
441 #if @GNULIB_GETDTABLESIZE@
442 # if !@HAVE_GETDTABLESIZE@
443 /* Return the maximum number of file descriptors in the current process.
444    In POSIX, this is same as sysconf (_SC_OPEN_MAX).  */
445 extern int getdtablesize (void);
446 # endif
447 #elif defined GNULIB_POSIXCHECK
448 # undef getdtablesize
449 # define getdtablesize() \
450     (GL_LINK_WARNING ("getdtablesize is unportable - " \
451                       "use gnulib module getdtablesize for portability"), \
452      getdtablesize ())
453 #endif
454
455
456 #if @GNULIB_GETHOSTNAME@
457 /* Return the standard host name of the machine.
458    WARNING! The host name may or may not be fully qualified.
459
460    Put up to LEN bytes of the host name into NAME.
461    Null terminate it if the name is shorter than LEN.
462    If the host name is longer than LEN, set errno = EINVAL and return -1.
463    Return 0 if successful, otherwise set errno and return -1.  */
464 # if @UNISTD_H_HAVE_WINSOCK2_H@
465 #  undef gethostname
466 #  define gethostname rpl_gethostname
467 # endif
468 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
469 extern int gethostname(char *name, size_t len);
470 # endif
471 #elif @UNISTD_H_HAVE_WINSOCK2_H@
472 # undef gethostname
473 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
474 #elif defined GNULIB_POSIXCHECK
475 # undef gethostname
476 # define gethostname(n,l) \
477     (GL_LINK_WARNING ("gethostname is unportable - " \
478                       "use gnulib module gethostname for portability"), \
479      gethostname (n, l))
480 #endif
481
482
483 #if @GNULIB_GETLOGIN_R@
484 /* Copies the user's login name to NAME.
485    The array pointed to by NAME has room for SIZE bytes.
486
487    Returns 0 if successful.  Upon error, an error number is returned, or -1 in
488    the case that the login name cannot be found but no specific error is
489    provided (this case is hopefully rare but is left open by the POSIX spec).
490
491    See <http://www.opengroup.org/susv3xsh/getlogin.html>.
492  */
493 # if !@HAVE_DECL_GETLOGIN_R@
494 extern int getlogin_r (char *name, size_t size);
495 # endif
496 #elif defined GNULIB_POSIXCHECK
497 # undef getlogin_r
498 # define getlogin_r(n,s) \
499     (GL_LINK_WARNING ("getlogin_r is unportable - " \
500                       "use gnulib module getlogin_r for portability"), \
501      getlogin_r (n, s))
502 #endif
503
504
505 #if @GNULIB_GETPAGESIZE@
506 # if @REPLACE_GETPAGESIZE@
507 #  define getpagesize rpl_getpagesize
508 extern int getpagesize (void);
509 # elif !@HAVE_GETPAGESIZE@
510 /* This is for POSIX systems.  */
511 #  if !defined getpagesize && defined _SC_PAGESIZE
512 #   if ! (defined __VMS && __VMS_VER < 70000000)
513 #    define getpagesize() sysconf (_SC_PAGESIZE)
514 #   endif
515 #  endif
516 /* This is for older VMS.  */
517 #  if !defined getpagesize && defined __VMS
518 #   ifdef __ALPHA
519 #    define getpagesize() 8192
520 #   else
521 #    define getpagesize() 512
522 #   endif
523 #  endif
524 /* This is for BeOS.  */
525 #  if !defined getpagesize && @HAVE_OS_H@
526 #   include <OS.h>
527 #   if defined B_PAGE_SIZE
528 #    define getpagesize() B_PAGE_SIZE
529 #   endif
530 #  endif
531 /* This is for AmigaOS4.0.  */
532 #  if !defined getpagesize && defined __amigaos4__
533 #   define getpagesize() 2048
534 #  endif
535 /* This is for older Unix systems.  */
536 #  if !defined getpagesize && @HAVE_SYS_PARAM_H@
537 #   include <sys/param.h>
538 #   ifdef EXEC_PAGESIZE
539 #    define getpagesize() EXEC_PAGESIZE
540 #   else
541 #    ifdef NBPG
542 #     ifndef CLSIZE
543 #      define CLSIZE 1
544 #     endif
545 #     define getpagesize() (NBPG * CLSIZE)
546 #    else
547 #     ifdef NBPC
548 #      define getpagesize() NBPC
549 #     endif
550 #    endif
551 #   endif
552 #  endif
553 # endif
554 #elif defined GNULIB_POSIXCHECK
555 # undef getpagesize
556 # define getpagesize() \
557     (GL_LINK_WARNING ("getpagesize is unportable - " \
558                       "use gnulib module getpagesize for portability"), \
559      getpagesize ())
560 #endif
561
562
563 #if @GNULIB_GETUSERSHELL@
564 # if !@HAVE_GETUSERSHELL@
565 /* Return the next valid login shell on the system, or NULL when the end of
566    the list has been reached.  */
567 extern char *getusershell (void);
568 /* Rewind to pointer that is advanced at each getusershell() call.  */
569 extern void setusershell (void);
570 /* Free the pointer that is advanced at each getusershell() call and
571    associated resources.  */
572 extern void endusershell (void);
573 # endif
574 #elif defined GNULIB_POSIXCHECK
575 # undef getusershell
576 # define getusershell() \
577     (GL_LINK_WARNING ("getusershell is unportable - " \
578                       "use gnulib module getusershell for portability"), \
579      getusershell ())
580 # undef setusershell
581 # define setusershell() \
582     (GL_LINK_WARNING ("setusershell is unportable - " \
583                       "use gnulib module getusershell for portability"), \
584      setusershell ())
585 # undef endusershell
586 # define endusershell() \
587     (GL_LINK_WARNING ("endusershell is unportable - " \
588                       "use gnulib module getusershell for portability"), \
589      endusershell ())
590 #endif
591
592
593 #if @GNULIB_LCHOWN@
594 # if @REPLACE_LCHOWN@
595 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
596    to GID (if GID is not -1).  Do not follow symbolic links.
597    Return 0 if successful, otherwise -1 and errno set.
598    See the POSIX:2001 specification
599    <http://www.opengroup.org/susv3xsh/lchown.html>.  */
600 #  define lchown rpl_lchown
601 extern int lchown (char const *file, uid_t owner, gid_t group);
602 # endif
603 #elif defined GNULIB_POSIXCHECK
604 # undef lchown
605 # define lchown(f,u,g) \
606     (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
607                       "systems - use gnulib module lchown for portability"), \
608      lchown (f, u, g))
609 #endif
610
611
612 #if @GNULIB_LINK@
613 # if @REPLACE_LINK@
614 #  define link rpl_link
615 # endif
616 /* Create a new hard link for an existing file.
617    Return 0 if successful, otherwise -1 and errno set.
618    See POSIX:2001 specification
619    <http://www.opengroup.org/susv3xsh/link.html>.  */
620 # if !@HAVE_LINK@ || @REPLACE_LINK@
621 extern int link (const char *path1, const char *path2);
622 # endif
623 #elif defined GNULIB_POSIXCHECK
624 # undef link
625 # define link(path1,path2) \
626     (GL_LINK_WARNING ("link is unportable - " \
627                       "use gnulib module link for portability"), \
628      link (path1, path2))
629 #endif
630
631
632 #if @GNULIB_LSEEK@
633 # if @REPLACE_LSEEK@
634 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
635    Return the new offset if successful, otherwise -1 and errno set.
636    See the POSIX:2001 specification
637    <http://www.opengroup.org/susv3xsh/lseek.html>.  */
638 #  define lseek rpl_lseek
639    extern off_t lseek (int fd, off_t offset, int whence);
640 # endif
641 #elif defined GNULIB_POSIXCHECK
642 # undef lseek
643 # define lseek(f,o,w) \
644     (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
645                       "systems - use gnulib module lseek for portability"), \
646      lseek (f, o, w))
647 #endif
648
649
650 #if @GNULIB_PIPE2@
651 /* Create a pipe, applying the given flags when opening the read-end of the
652    pipe and the write-end of the pipe.
653    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
654    and O_TEXT, O_BINARY (defined in "binary-io.h").
655    Store the read-end as fd[0] and the write-end as fd[1].
656    Return 0 upon success, or -1 with errno set upon failure.
657    See also the Linux man page at
658    <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
659 # if @HAVE_PIPE2@
660 #  define pipe2 rpl_pipe2
661 # endif
662 extern int pipe2 (int fd[2], int flags);
663 #elif defined GNULIB_POSIXCHECK
664 # undef pipe2
665 # define pipe2(f,o) \
666     (GL_LINK_WARNING ("pipe2 is unportable - " \
667                       "use gnulib module pipe2 for portability"), \
668      pipe2 (f, o))
669 #endif
670
671
672 #if @GNULIB_READLINK@
673 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
674    bytes of it into BUF.  Return the number of bytes placed into BUF if
675    successful, otherwise -1 and errno set.
676    See the POSIX:2001 specification
677    <http://www.opengroup.org/susv3xsh/readlink.html>.  */
678 # if !@HAVE_READLINK@
679 extern int readlink (const char *file, char *buf, size_t bufsize);
680 # endif
681 #elif defined GNULIB_POSIXCHECK
682 # undef readlink
683 # define readlink(f,b,s) \
684     (GL_LINK_WARNING ("readlink is unportable - " \
685                       "use gnulib module readlink for portability"), \
686      readlink (f, b, s))
687 #endif
688
689
690 #if @GNULIB_RMDIR@
691 # if @REPLACE_RMDIR@
692 #  define rmdir rpl_rmdir
693 /* Remove the directory DIR.  */
694 extern int rmdir (char const *name);
695 # endif
696 #elif defined GNULIB_POSIXCHECK
697 # undef rmdir
698 # define rmdir(n) \
699     (GL_LINK_WARNING ("rmdir is unportable - " \
700                       "use gnulib module rmdir for portability"), \
701      rmdir (n))
702 #endif
703
704
705 #if @GNULIB_SLEEP@
706 /* Pause the execution of the current thread for N seconds.
707    Returns the number of seconds left to sleep.
708    See the POSIX:2001 specification
709    <http://www.opengroup.org/susv3xsh/sleep.html>.  */
710 # if !@HAVE_SLEEP@
711 extern unsigned int sleep (unsigned int n);
712 # endif
713 #elif defined GNULIB_POSIXCHECK
714 # undef sleep
715 # define sleep(n) \
716     (GL_LINK_WARNING ("sleep is unportable - " \
717                       "use gnulib module sleep for portability"), \
718      sleep (n))
719 #endif
720
721
722 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
723 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
724    See the POSIX:2001 specification
725    <http://www.opengroup.org/susv3xsh/write.html>.  */
726 # undef write
727 # define write rpl_write
728 extern ssize_t write (int fd, const void *buf, size_t count);
729 #endif
730
731
732 #ifdef __cplusplus
733 }
734 #endif
735
736
737 #endif /* _GL_UNISTD_H */
738 #endif /* _GL_UNISTD_H */