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