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