unistd: Avoid #define replacements in C++ mode.
[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 #if __GNUC__ >= 3
19 @PRAGMA_SYSTEM_HEADER@
20 #endif
21
22 /* Special invocation convention:
23    - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
24      but we need to ensure that both the system <unistd.h> and <winsock2.h>
25      are completely included before we replace gethostname.  */
26 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
27   && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
28 /* <unistd.h> is being indirectly included for the first time from
29    <winsock2.h>; avoid declaring any overrides.  */
30 # if @HAVE_UNISTD_H@
31 #  @INCLUDE_NEXT@ @NEXT_UNISTD_H@
32 # else
33 #  error unexpected; report this to bug-gnulib@gnu.org
34 # endif
35 # define _GL_WINSOCK2_H_WITNESS
36
37 /* Normal invocation.  */
38 #elif !defined _GL_UNISTD_H
39
40 /* The include_next requires a split double-inclusion guard.  */
41 #if @HAVE_UNISTD_H@
42 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
43 #endif
44
45 /* Get all possible declarations of gethostname().  */
46 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
47   && !defined _GL_INCLUDING_WINSOCK2_H
48 # define _GL_INCLUDING_WINSOCK2_H
49 # include <winsock2.h>
50 # undef _GL_INCLUDING_WINSOCK2_H
51 #endif
52
53 #if !defined _GL_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
54 #define _GL_UNISTD_H
55
56 /* NetBSD 5.0 mis-defines NULL.  Also get size_t.  */
57 #include <stddef.h>
58
59 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>.  */
60 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>.  */
61 /* But avoid namespace pollution on glibc systems.  */
62 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
63      || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \
64     && ! defined __GLIBC__
65 # include <stdio.h>
66 #endif
67
68 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>.  */
69 /* But avoid namespace pollution on glibc systems.  */
70 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
71 # include <fcntl.h>
72 #endif
73
74 /* mingw fails to declare _exit in <unistd.h>.  */
75 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>.  */
76 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>.  */
77 /* But avoid namespace pollution on glibc systems.  */
78 #ifndef __GLIBC__
79 # include <stdlib.h>
80 #endif
81
82 /* mingw declares getcwd in <io.h>, not in <unistd.h>.  */
83 #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
84      && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
85 # include <io.h>
86 #endif
87
88 #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
89      || @GNULIB_PREAD@ || defined GNULIB_POSIXCHECK)
90 /* Get ssize_t.  */
91 # include <sys/types.h>
92 #endif
93
94 /* Get getopt(), optarg, optind, opterr, optopt.
95    But avoid namespace pollution on glibc systems.  */
96 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
97 # include <getopt.h>
98 #endif
99
100 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
101
102 /* The definition of _GL_ARG_NONNULL is copied here.  */
103
104 /* The definition of _GL_WARN_ON_USE is copied here.  */
105
106
107 #if @GNULIB_GETHOSTNAME@
108 /* Get all possible declarations of gethostname().  */
109 # if @UNISTD_H_HAVE_WINSOCK2_H@
110 #  if !defined _GL_SYS_SOCKET_H
111 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
112 #    undef socket
113 #    define socket              socket_used_without_including_sys_socket_h
114 #    undef connect
115 #    define connect             connect_used_without_including_sys_socket_h
116 #    undef accept
117 #    define accept              accept_used_without_including_sys_socket_h
118 #    undef bind
119 #    define bind                bind_used_without_including_sys_socket_h
120 #    undef getpeername
121 #    define getpeername         getpeername_used_without_including_sys_socket_h
122 #    undef getsockname
123 #    define getsockname         getsockname_used_without_including_sys_socket_h
124 #    undef getsockopt
125 #    define getsockopt          getsockopt_used_without_including_sys_socket_h
126 #    undef listen
127 #    define listen              listen_used_without_including_sys_socket_h
128 #    undef recv
129 #    define recv                recv_used_without_including_sys_socket_h
130 #    undef send
131 #    define send                send_used_without_including_sys_socket_h
132 #    undef recvfrom
133 #    define recvfrom            recvfrom_used_without_including_sys_socket_h
134 #    undef sendto
135 #    define sendto              sendto_used_without_including_sys_socket_h
136 #    undef setsockopt
137 #    define setsockopt          setsockopt_used_without_including_sys_socket_h
138 #    undef shutdown
139 #    define shutdown            shutdown_used_without_including_sys_socket_h
140 #   else
141      _GL_WARN_ON_USE (socket,
142                       "socket() used without including <sys/socket.h>");
143      _GL_WARN_ON_USE (connect,
144                       "connect() used without including <sys/socket.h>");
145      _GL_WARN_ON_USE (accept,
146                       "accept() used without including <sys/socket.h>");
147      _GL_WARN_ON_USE (bind,
148                       "bind() used without including <sys/socket.h>");
149      _GL_WARN_ON_USE (getpeername,
150                       "getpeername() used without including <sys/socket.h>");
151      _GL_WARN_ON_USE (getsockname,
152                       "getsockname() used without including <sys/socket.h>");
153      _GL_WARN_ON_USE (getsockopt,
154                       "getsockopt() used without including <sys/socket.h>");
155      _GL_WARN_ON_USE (listen,
156                       "listen() used without including <sys/socket.h>");
157      _GL_WARN_ON_USE (recv,
158                       "recv() used without including <sys/socket.h>");
159      _GL_WARN_ON_USE (send,
160                       "send() used without including <sys/socket.h>");
161      _GL_WARN_ON_USE (recvfrom,
162                       "recvfrom() used without including <sys/socket.h>");
163      _GL_WARN_ON_USE (sendto,
164                       "sendto() used without including <sys/socket.h>");
165      _GL_WARN_ON_USE (setsockopt,
166                       "setsockopt() used without including <sys/socket.h>");
167      _GL_WARN_ON_USE (shutdown,
168                       "shutdown() used without including <sys/socket.h>");
169 #   endif
170 #  endif
171 #  if !defined _GL_SYS_SELECT_H
172 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
173 #    undef select
174 #    define select              select_used_without_including_sys_select_h
175 #   else
176      _GL_WARN_ON_USE (select,
177                       "select() used without including <sys/select.h>");
178 #   endif
179 #  endif
180 # endif
181 #endif
182
183
184 /* OS/2 EMX lacks these macros.  */
185 #ifndef STDIN_FILENO
186 # define STDIN_FILENO 0
187 #endif
188 #ifndef STDOUT_FILENO
189 # define STDOUT_FILENO 1
190 #endif
191 #ifndef STDERR_FILENO
192 # define STDERR_FILENO 2
193 #endif
194
195 /* Ensure *_OK macros exist.  */
196 #ifndef F_OK
197 # define F_OK 0
198 # define X_OK 1
199 # define W_OK 2
200 # define R_OK 4
201 #endif
202
203
204 /* Declare overridden functions.  */
205
206
207 #if defined GNULIB_POSIXCHECK
208 /* The access() function is a security risk.  */
209 _GL_WARN_ON_USE (access, "the access function is a security risk - "
210                  "use the gnulib module faccessat instead");
211 #endif
212
213
214 #if @GNULIB_CHOWN@
215 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
216    to GID (if GID is not -1).  Follow symbolic links.
217    Return 0 if successful, otherwise -1 and errno set.
218    See the POSIX:2001 specification
219    <http://www.opengroup.org/susv3xsh/chown.html>.  */
220 # if @REPLACE_CHOWN@
221 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
222 #   undef chown
223 #   define chown rpl_chown
224 #  endif
225 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
226                               _GL_ARG_NONNULL ((1)));
227 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
228 # else
229 #  if !@HAVE_CHOWN@
230 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
231                               _GL_ARG_NONNULL ((1)));
232 #  endif
233 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
234 # endif
235 _GL_CXXALIASWARN (chown);
236 #elif defined GNULIB_POSIXCHECK
237 # undef chown
238 # if HAVE_RAW_DECL_CHOWN
239 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
240                  "doesn't treat a uid or gid of -1 on some systems - "
241                  "use gnulib module chown for portability");
242 # endif
243 #endif
244
245
246 #if @GNULIB_CLOSE@
247 # if @REPLACE_CLOSE@
248 /* Automatically included by modules that need a replacement for close.  */
249 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
250 #   undef close
251 #   define close rpl_close
252 #  endif
253 _GL_FUNCDECL_RPL (close, int, (int fd));
254 _GL_CXXALIAS_RPL (close, int, (int fd));
255 # else
256 _GL_CXXALIAS_SYS (close, int, (int fd));
257 # endif
258 _GL_CXXALIASWARN (close);
259 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
260 # undef close
261 # define close close_used_without_requesting_gnulib_module_close
262 #elif defined GNULIB_POSIXCHECK
263 # undef close
264 /* Assume close is always declared.  */
265 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
266                  "use gnulib module close for portability");
267 #endif
268
269
270 #if @REPLACE_DUP@
271 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
272 #  define dup rpl_dup
273 # endif
274 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
275 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
276 #else
277 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
278 #endif
279 _GL_CXXALIASWARN (dup);
280
281
282 #if @GNULIB_DUP2@
283 /* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
284    NEWFD = OLDFD, otherwise close NEWFD first if it is open.
285    Return newfd if successful, otherwise -1 and errno set.
286    See the POSIX:2001 specification
287    <http://www.opengroup.org/susv3xsh/dup2.html>.  */
288 # if @REPLACE_DUP2@
289 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
290 #   define dup2 rpl_dup2
291 #  endif
292 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
293 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
294 # else
295 #  if !@HAVE_DUP2@
296 _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
297 #  endif
298 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
299 # endif
300 _GL_CXXALIASWARN (dup2);
301 #elif defined GNULIB_POSIXCHECK
302 # undef dup2
303 # if HAVE_RAW_DECL_DUP2
304 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
305                  "use gnulib module dup2 for portability");
306 # endif
307 #endif
308
309
310 #if @GNULIB_DUP3@
311 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
312    specified flags.
313    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
314    and O_TEXT, O_BINARY (defined in "binary-io.h").
315    Close NEWFD first if it is open.
316    Return newfd if successful, otherwise -1 and errno set.
317    See the Linux man page at
318    <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */
319 # if @HAVE_DUP3@
320 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
321 #   define dup3 rpl_dup3
322 #  endif
323 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
324 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
325 # else
326 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
327 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
328 # endif
329 _GL_CXXALIASWARN (dup3);
330 #elif defined GNULIB_POSIXCHECK
331 # undef dup3
332 # if HAVE_RAW_DECL_DUP3
333 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
334                  "use gnulib module dup3 for portability");
335 # endif
336 #endif
337
338
339 #if @GNULIB_ENVIRON@
340 # if !@HAVE_DECL_ENVIRON@
341 /* Set of environment variables and values.  An array of strings of the form
342    "VARIABLE=VALUE", terminated with a NULL.  */
343 #  if defined __APPLE__ && defined __MACH__
344 #   include <crt_externs.h>
345 #   define environ (*_NSGetEnviron ())
346 #  else
347 #   ifdef __cplusplus
348 extern "C" {
349 #   endif
350 extern char **environ;
351 #   ifdef __cplusplus
352 }
353 #   endif
354 #  endif
355 # endif
356 #elif defined GNULIB_POSIXCHECK
357 # if HAVE_RAW_DECL_ENVIRON
358 static inline char ***
359 rpl_environ (void)
360 {
361   return &environ;
362 }
363 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
364                  "use gnulib module environ for portability");
365 #  undef environ
366 #  define environ (*rpl_environ ())
367 # endif
368 #endif
369
370
371 #if @GNULIB_EUIDACCESS@
372 /* Like access(), except that it uses the effective user id and group id of
373    the current process.  */
374 # if !@HAVE_EUIDACCESS@
375 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
376                                    _GL_ARG_NONNULL ((1)));
377 # endif
378 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
379 _GL_CXXALIASWARN (euidaccess);
380 # if defined GNULIB_POSIXCHECK
381 /* Like access(), this function is a security risk.  */
382 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
383                  "use the gnulib module faccessat instead");
384 # endif
385 #elif defined GNULIB_POSIXCHECK
386 # undef euidaccess
387 # if HAVE_RAW_DECL_EUIDACCESS
388 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
389                  "use gnulib module euidaccess for portability");
390 # endif
391 #endif
392
393
394 #if @GNULIB_FACCESSAT@
395 # if !@HAVE_FACCESSAT@
396 _GL_FUNCDECL_SYS (faccessat, int,
397                   (int fd, char const *file, int mode, int flag)
398                   _GL_ARG_NONNULL ((2)));
399 # endif
400 _GL_CXXALIAS_SYS (faccessat, int,
401                   (int fd, char const *file, int mode, int flag));
402 _GL_CXXALIASWARN (faccessat);
403 #elif defined GNULIB_POSIXCHECK
404 # undef faccessat
405 # if HAVE_RAW_DECL_FACCESSAT
406 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
407                  "use gnulib module faccessat for portability");
408 # endif
409 #endif
410
411
412 #if @GNULIB_FCHDIR@
413 /* Change the process' current working directory to the directory on which
414    the given file descriptor is open.
415    Return 0 if successful, otherwise -1 and errno set.
416    See the POSIX:2001 specification
417    <http://www.opengroup.org/susv3xsh/fchdir.html>.  */
418 # if @REPLACE_FCHDIR@
419 _GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/));
420 _GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/));
421
422 /* Gnulib internal hooks needed to maintain the fchdir metadata.  */
423 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
424      _GL_ARG_NONNULL ((2));
425 _GL_EXTERN_C void _gl_unregister_fd (int fd);
426 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
427 _GL_EXTERN_C const char *_gl_directory_name (int fd);
428
429 # else
430 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
431 # endif
432 _GL_CXXALIASWARN (fchdir);
433 #elif defined GNULIB_POSIXCHECK
434 # undef fchdir
435 # if HAVE_RAW_DECL_FCHDIR
436 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
437                  "use gnulib module fchdir for portability");
438 # endif
439 #endif
440
441
442 #if @GNULIB_FCHOWNAT@
443 # if @REPLACE_FCHOWNAT@
444 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
445 #   undef fchownat
446 #   define fchownat rpl_fchownat
447 #  endif
448 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
449                                   uid_t owner, gid_t group, int flag)
450                                  _GL_ARG_NONNULL ((2)));
451 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
452                                   uid_t owner, gid_t group, int flag));
453 # else
454 #  if !@HAVE_FCHOWNAT@
455 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
456                                   uid_t owner, gid_t group, int flag)
457                                  _GL_ARG_NONNULL ((2)));
458 #  endif
459 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
460                                   uid_t owner, gid_t group, int flag));
461 # endif
462 _GL_CXXALIASWARN (fchownat);
463 #elif defined GNULIB_POSIXCHECK
464 # undef fchownat
465 # if HAVE_RAW_DECL_FCHOWNAT
466 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
467                  "use gnulib module openat for portability");
468 # endif
469 #endif
470
471
472 #if @GNULIB_FSYNC@
473 /* Synchronize changes to a file.
474    Return 0 if successful, otherwise -1 and errno set.
475    See POSIX:2001 specification
476    <http://www.opengroup.org/susv3xsh/fsync.html>.  */
477 # if !@HAVE_FSYNC@
478 _GL_FUNCDECL_SYS (fsync, int, (int fd));
479 # endif
480 _GL_CXXALIAS_SYS (fsync, int, (int fd));
481 _GL_CXXALIASWARN (fsync);
482 #elif defined GNULIB_POSIXCHECK
483 # undef fsync
484 # if HAVE_RAW_DECL_FSYNC
485 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
486                  "use gnulib module fsync for portability");
487 # endif
488 #endif
489
490
491 #if @GNULIB_FTRUNCATE@
492 /* Change the size of the file to which FD is opened to become equal to LENGTH.
493    Return 0 if successful, otherwise -1 and errno set.
494    See the POSIX:2001 specification
495    <http://www.opengroup.org/susv3xsh/ftruncate.html>.  */
496 # if !@HAVE_FTRUNCATE@
497 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
498 # endif
499 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
500 _GL_CXXALIASWARN (ftruncate);
501 #elif defined GNULIB_POSIXCHECK
502 # undef ftruncate
503 # if HAVE_RAW_DECL_FTRUNCATE
504 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
505                  "use gnulib module ftruncate for portability");
506 # endif
507 #endif
508
509
510 #if @GNULIB_GETCWD@
511 /* Get the name of the current working directory, and put it in SIZE bytes
512    of BUF.
513    Return BUF if successful, or NULL if the directory couldn't be determined
514    or SIZE was too small.
515    See the POSIX:2001 specification
516    <http://www.opengroup.org/susv3xsh/getcwd.html>.
517    Additionally, the gnulib module 'getcwd' guarantees the following GNU
518    extension: If BUF is NULL, an array is allocated with 'malloc'; the array
519    is SIZE bytes long, unless SIZE == 0, in which case it is as big as
520    necessary.  */
521 # if @REPLACE_GETCWD@
522 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
523 #   define getcwd rpl_getcwd
524 #  endif
525 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
526 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
527 # else
528 _GL_CXXALIAS_SYS (getcwd, char *, (char *buf, size_t size));
529 # endif
530 _GL_CXXALIASWARN (getcwd);
531 #elif defined GNULIB_POSIXCHECK
532 # undef getcwd
533 # if HAVE_RAW_DECL_GETCWD
534 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
535                  "use gnulib module getcwd for portability");
536 # endif
537 #endif
538
539
540 #if @GNULIB_GETDOMAINNAME@
541 /* Return the NIS domain name of the machine.
542    WARNING! The NIS domain name is unrelated to the fully qualified host name
543             of the machine.  It is also unrelated to email addresses.
544    WARNING! The NIS domain name is usually the empty string or "(none)" when
545             not using NIS.
546
547    Put up to LEN bytes of the NIS domain name into NAME.
548    Null terminate it if the name is shorter than LEN.
549    If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
550    Return 0 if successful, otherwise set errno and return -1.  */
551 # if !@HAVE_GETDOMAINNAME@
552 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
553                                       _GL_ARG_NONNULL ((1)));
554 # endif
555 /* Need to cast, because on MacOS X 10.5 systems, the second parameter is
556                                                         int len.  */
557 _GL_CXXALIAS_SYS_CAST (getdomainname, int, (char *name, size_t len));
558 _GL_CXXALIASWARN (getdomainname);
559 #elif defined GNULIB_POSIXCHECK
560 # undef getdomainname
561 # if HAVE_RAW_DECL_GETDOMAINNAME
562 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
563                  "use gnulib module getdomainname for portability");
564 # endif
565 #endif
566
567
568 #if @GNULIB_GETDTABLESIZE@
569 /* Return the maximum number of file descriptors in the current process.
570    In POSIX, this is same as sysconf (_SC_OPEN_MAX).  */
571 # if !@HAVE_GETDTABLESIZE@
572 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
573 # endif
574 _GL_CXXALIAS_SYS (getdtablesize, int, (void));
575 _GL_CXXALIASWARN (getdtablesize);
576 #elif defined GNULIB_POSIXCHECK
577 # undef getdtablesize
578 # if HAVE_RAW_DECL_GETDTABLESIZE
579 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
580                  "use gnulib module getdtablesize for portability");
581 # endif
582 #endif
583
584
585 #if @GNULIB_GETGROUPS@
586 /* Return the supplemental groups that the current process belongs to.
587    It is unspecified whether the effective group id is in the list.
588    If N is 0, return the group count; otherwise, N describes how many
589    entries are available in GROUPS.  Return -1 and set errno if N is
590    not 0 and not large enough.  Fails with ENOSYS on some systems.  */
591 # if @REPLACE_GETGROUPS@
592 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
593 #   undef getgroups
594 #   define getgroups rpl_getgroups
595 #  endif
596 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
597 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
598 # else
599 #  if !@HAVE_GETGROUPS@
600 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
601 #  endif
602 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
603 # endif
604 _GL_CXXALIASWARN (getgroups);
605 #elif defined GNULIB_POSIXCHECK
606 # undef getgroups
607 # if HAVE_RAW_DECL_GETGROUPS
608 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
609                  "use gnulib module getgroups for portability");
610 # endif
611 #endif
612
613
614 #if @GNULIB_GETHOSTNAME@
615 /* Return the standard host name of the machine.
616    WARNING! The host name may or may not be fully qualified.
617
618    Put up to LEN bytes of the host name into NAME.
619    Null terminate it if the name is shorter than LEN.
620    If the host name is longer than LEN, set errno = EINVAL and return -1.
621    Return 0 if successful, otherwise set errno and return -1.  */
622 # if @UNISTD_H_HAVE_WINSOCK2_H@
623 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
624 #   undef gethostname
625 #   define gethostname rpl_gethostname
626 #  endif
627 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
628                                     _GL_ARG_NONNULL ((1)));
629 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
630 # else
631 #  if !@HAVE_GETHOSTNAME@
632 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
633                                     _GL_ARG_NONNULL ((1)));
634 #  endif
635 /* Need to cast, because on Solaris 10 systems, the second parameter is
636                                                       int len.  */
637 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
638 # endif
639 _GL_CXXALIASWARN (gethostname);
640 #elif @UNISTD_H_HAVE_WINSOCK2_H@
641 # undef gethostname
642 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
643 #elif defined GNULIB_POSIXCHECK
644 # undef gethostname
645 # if HAVE_RAW_DECL_GETHOSTNAME
646 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
647                  "use gnulib module gethostname for portability");
648 # endif
649 #endif
650
651
652 #if @GNULIB_GETLOGIN@
653 /* Returns the user's login name, or NULL if it cannot be found.  Upon error,
654    returns NULL with errno set.
655
656    See <http://www.opengroup.org/susv3xsh/getlogin.html>.
657
658    Most programs don't need to use this function, because the information is
659    available through environment variables:
660      ${LOGNAME-$USER}        on Unix platforms,
661      $USERNAME               on native Windows platforms.
662  */
663 # if !@HAVE_GETLOGIN@
664 _GL_FUNCDECL_SYS (getlogin, char *, (void));
665 # endif
666 _GL_CXXALIAS_SYS (getlogin, char *, (void));
667 _GL_CXXALIASWARN (getlogin);
668 #elif defined GNULIB_POSIXCHECK
669 # undef getlogin
670 # if HAVE_RAW_DECL_GETLOGIN
671 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
672                  "use gnulib module getlogin for portability");
673 # endif
674 #endif
675
676
677 #if @GNULIB_GETLOGIN_R@
678 /* Copies the user's login name to NAME.
679    The array pointed to by NAME has room for SIZE bytes.
680
681    Returns 0 if successful.  Upon error, an error number is returned, or -1 in
682    the case that the login name cannot be found but no specific error is
683    provided (this case is hopefully rare but is left open by the POSIX spec).
684
685    See <http://www.opengroup.org/susv3xsh/getlogin.html>.
686
687    Most programs don't need to use this function, because the information is
688    available through environment variables:
689      ${LOGNAME-$USER}        on Unix platforms,
690      $USERNAME               on native Windows platforms.
691  */
692 # if !@HAVE_DECL_GETLOGIN_R@
693 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
694                                    _GL_ARG_NONNULL ((1)));
695 # endif
696 /* Need to cast, because on Solaris 10 systems, the second argument is
697                                                      int size.  */
698 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
699 _GL_CXXALIASWARN (getlogin_r);
700 #elif defined GNULIB_POSIXCHECK
701 # undef getlogin_r
702 # if HAVE_RAW_DECL_GETLOGIN_R
703 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
704                  "use gnulib module getlogin_r for portability");
705 # endif
706 #endif
707
708
709 #if @GNULIB_GETPAGESIZE@
710 # if @REPLACE_GETPAGESIZE@
711 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
712 #   define getpagesize rpl_getpagesize
713 #  endif
714 _GL_FUNCDECL_RPL (getpagesize, int, (void));
715 _GL_CXXALIAS_RPL (getpagesize, int, (void));
716 # else
717 #  if !@HAVE_GETPAGESIZE@
718 #   if !defined getpagesize
719 /* This is for POSIX systems.  */
720 #    if !defined _gl_getpagesize && defined _SC_PAGESIZE
721 #     if ! (defined __VMS && __VMS_VER < 70000000)
722 #      define _gl_getpagesize() sysconf (_SC_PAGESIZE)
723 #     endif
724 #    endif
725 /* This is for older VMS.  */
726 #    if !defined _gl_getpagesize && defined __VMS
727 #     ifdef __ALPHA
728 #      define _gl_getpagesize() 8192
729 #     else
730 #      define _gl_getpagesize() 512
731 #     endif
732 #    endif
733 /* This is for BeOS.  */
734 #    if !defined _gl_getpagesize && @HAVE_OS_H@
735 #     include <OS.h>
736 #     if defined B_PAGE_SIZE
737 #      define _gl_getpagesize() B_PAGE_SIZE
738 #     endif
739 #    endif
740 /* This is for AmigaOS4.0.  */
741 #    if !defined _gl_getpagesize && defined __amigaos4__
742 #     define _gl_getpagesize() 2048
743 #    endif
744 /* This is for older Unix systems.  */
745 #    if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
746 #     include <sys/param.h>
747 #     ifdef EXEC_PAGESIZE
748 #      define _gl_getpagesize() EXEC_PAGESIZE
749 #     else
750 #      ifdef NBPG
751 #       ifndef CLSIZE
752 #        define CLSIZE 1
753 #       endif
754 #       define _gl_getpagesize() (NBPG * CLSIZE)
755 #      else
756 #       ifdef NBPC
757 #        define _gl_getpagesize() NBPC
758 #       endif
759 #      endif
760 #     endif
761 #    endif
762 #    if !(defined __cplusplus && defined GNULIB_NAMESPACE)
763 #     define getpagesize() _gl_getpagesize ()
764 #    else
765 static inline int
766 getpagesize ()
767 {
768   return _gl_getpagesize ();
769 }
770 #    endif
771 #   endif
772 #  endif
773 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t.  */
774 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
775 # endif
776 _GL_CXXALIASWARN (getpagesize);
777 #elif defined GNULIB_POSIXCHECK
778 # undef getpagesize
779 # if HAVE_RAW_DECL_GETPAGESIZE
780 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
781                  "use gnulib module getpagesize for portability");
782 # endif
783 #endif
784
785
786 #if @GNULIB_GETUSERSHELL@
787 /* Return the next valid login shell on the system, or NULL when the end of
788    the list has been reached.  */
789 # if !@HAVE_DECL_GETUSERSHELL@
790 _GL_FUNCDECL_SYS (getusershell, char *, (void));
791 # endif
792 _GL_CXXALIAS_SYS (getusershell, char *, (void));
793 _GL_CXXALIASWARN (getusershell);
794 #elif defined GNULIB_POSIXCHECK
795 # undef getusershell
796 # if HAVE_RAW_DECL_GETUSERSHELL
797 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
798                  "use gnulib module getusershell for portability");
799 # endif
800 #endif
801
802 #if @GNULIB_GETUSERSHELL@
803 /* Rewind to pointer that is advanced at each getusershell() call.  */
804 # if !@HAVE_DECL_GETUSERSHELL@
805 _GL_FUNCDECL_SYS (setusershell, void, (void));
806 # endif
807 _GL_CXXALIAS_SYS (setusershell, void, (void));
808 _GL_CXXALIASWARN (setusershell);
809 #elif defined GNULIB_POSIXCHECK
810 # undef setusershell
811 # if HAVE_RAW_DECL_SETUSERSHELL
812 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
813                  "use gnulib module getusershell for portability");
814 # endif
815 #endif
816
817 #if @GNULIB_GETUSERSHELL@
818 /* Free the pointer that is advanced at each getusershell() call and
819    associated resources.  */
820 # if !@HAVE_DECL_GETUSERSHELL@
821 _GL_FUNCDECL_SYS (endusershell, void, (void));
822 # endif
823 _GL_CXXALIAS_SYS (endusershell, void, (void));
824 _GL_CXXALIASWARN (endusershell);
825 #elif defined GNULIB_POSIXCHECK
826 # undef endusershell
827 # if HAVE_RAW_DECL_ENDUSERSHELL
828 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
829                  "use gnulib module getusershell for portability");
830 # endif
831 #endif
832
833
834 #if @GNULIB_LCHOWN@
835 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
836    to GID (if GID is not -1).  Do not follow symbolic links.
837    Return 0 if successful, otherwise -1 and errno set.
838    See the POSIX:2001 specification
839    <http://www.opengroup.org/susv3xsh/lchown.html>.  */
840 # if @REPLACE_LCHOWN@
841 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
842 #   undef lchown
843 #   define lchown rpl_lchown
844 #  endif
845 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
846                                _GL_ARG_NONNULL ((1)));
847 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
848 # else
849 #  if !@HAVE_LCHOWN@
850 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
851                                _GL_ARG_NONNULL ((1)));
852 #  endif
853 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
854 # endif
855 _GL_CXXALIASWARN (lchown);
856 #elif defined GNULIB_POSIXCHECK
857 # undef lchown
858 # if HAVE_RAW_DECL_LCHOWN
859 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
860                  "use gnulib module lchown for portability");
861 # endif
862 #endif
863
864
865 #if @GNULIB_LINK@
866 /* Create a new hard link for an existing file.
867    Return 0 if successful, otherwise -1 and errno set.
868    See POSIX:2001 specification
869    <http://www.opengroup.org/susv3xsh/link.html>.  */
870 # if @REPLACE_LINK@
871 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
872 #   define link rpl_link
873 #  endif
874 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
875                              _GL_ARG_NONNULL ((1, 2)));
876 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
877 # else
878 #  if !@HAVE_LINK@
879 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
880                              _GL_ARG_NONNULL ((1, 2)));
881 #  endif
882 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
883 # endif
884 _GL_CXXALIASWARN (link);
885 #elif defined GNULIB_POSIXCHECK
886 # undef link
887 # if HAVE_RAW_DECL_LINK
888 _GL_WARN_ON_USE (link, "link is unportable - "
889                  "use gnulib module link for portability");
890 # endif
891 #endif
892
893
894 #if @GNULIB_LINKAT@
895 /* Create a new hard link for an existing file, relative to two
896    directories.  FLAG controls whether symlinks are followed.
897    Return 0 if successful, otherwise -1 and errno set.  */
898 # if @REPLACE_LINKAT@
899 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
900 #   undef linkat
901 #   define linkat rpl_linkat
902 #  endif
903 _GL_FUNCDECL_RPL (linkat, int,
904                   (int fd1, const char *path1, int fd2, const char *path2,
905                    int flag)
906                   _GL_ARG_NONNULL ((2, 4)));
907 _GL_CXXALIAS_RPL (linkat, int,
908                   (int fd1, const char *path1, int fd2, const char *path2,
909                    int flag));
910 # else
911 #  if !@HAVE_LINKAT@
912 _GL_FUNCDECL_SYS (linkat, int,
913                   (int fd1, const char *path1, int fd2, const char *path2,
914                    int flag)
915                   _GL_ARG_NONNULL ((2, 4)));
916 #  endif
917 _GL_CXXALIAS_SYS (linkat, int,
918                   (int fd1, const char *path1, int fd2, const char *path2,
919                    int flag));
920 # endif
921 _GL_CXXALIASWARN (linkat);
922 #elif defined GNULIB_POSIXCHECK
923 # undef linkat
924 # if HAVE_RAW_DECL_LINKAT
925 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
926                  "use gnulib module linkat for portability");
927 # endif
928 #endif
929
930
931 #if @GNULIB_LSEEK@
932 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
933    Return the new offset if successful, otherwise -1 and errno set.
934    See the POSIX:2001 specification
935    <http://www.opengroup.org/susv3xsh/lseek.html>.  */
936 # if @REPLACE_LSEEK@
937 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
938 #   define lseek rpl_lseek
939 #  endif
940 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
941 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
942 # else
943 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
944 # endif
945 _GL_CXXALIASWARN (lseek);
946 #elif defined GNULIB_POSIXCHECK
947 # undef lseek
948 # if HAVE_RAW_DECL_LSEEK
949 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
950                  "systems - use gnulib module lseek for portability");
951 # endif
952 #endif
953
954
955 #if @GNULIB_PIPE2@
956 /* Create a pipe, applying the given flags when opening the read-end of the
957    pipe and the write-end of the pipe.
958    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
959    and O_TEXT, O_BINARY (defined in "binary-io.h").
960    Store the read-end as fd[0] and the write-end as fd[1].
961    Return 0 upon success, or -1 with errno set upon failure.
962    See also the Linux man page at
963    <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
964 # if @HAVE_PIPE2@
965 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
966 #   define pipe2 rpl_pipe2
967 #  endif
968 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
969 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
970 # else
971 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
972 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
973 # endif
974 _GL_CXXALIASWARN (pipe2);
975 #elif defined GNULIB_POSIXCHECK
976 # undef pipe2
977 # if HAVE_RAW_DECL_PIPE2
978 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
979                  "use gnulib module pipe2 for portability");
980 # endif
981 #endif
982
983
984 #if @GNULIB_PREAD@
985 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
986    Return the number of bytes placed into BUF if successful, otherwise
987    set errno and return -1.  0 indicates EOF.  See the POSIX:2001
988    specification <http://www.opengroup.org/susv3xsh/pread.html>.  */
989 # if @REPLACE_PREAD@
990 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
991 #   define pread rpl_pread
992 #  endif
993 _GL_FUNCDECL_RPL (pread, ssize_t,
994                   (int fd, void *buf, size_t bufsize, off_t offset)
995                   _GL_ARG_NONNULL ((2)));
996 _GL_CXXALIAS_RPL (pread, ssize_t,
997                   (int fd, void *buf, size_t bufsize, off_t offset));
998 # else
999 #  if !@HAVE_PREAD@
1000 _GL_FUNCDECL_SYS (pread, ssize_t,
1001                   (int fd, void *buf, size_t bufsize, off_t offset)
1002                   _GL_ARG_NONNULL ((2)));
1003 #  endif
1004 _GL_CXXALIAS_SYS (pread, ssize_t,
1005                   (int fd, void *buf, size_t bufsize, off_t offset));
1006 # endif
1007 _GL_CXXALIASWARN (pread);
1008 #elif defined GNULIB_POSIXCHECK
1009 # undef pread
1010 # if HAVE_RAW_DECL_PREAD
1011 _GL_WARN_ON_USE (pread, "pread is unportable - "
1012                  "use gnulib module pread for portability");
1013 # endif
1014 #endif
1015
1016
1017 #if @GNULIB_READLINK@
1018 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1019    bytes of it into BUF.  Return the number of bytes placed into BUF if
1020    successful, otherwise -1 and errno set.
1021    See the POSIX:2001 specification
1022    <http://www.opengroup.org/susv3xsh/readlink.html>.  */
1023 # if @REPLACE_READLINK@
1024 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1025 #   define readlink rpl_readlink
1026 #  endif
1027 _GL_FUNCDECL_RPL (readlink, ssize_t,
1028                   (const char *file, char *buf, size_t bufsize)
1029                   _GL_ARG_NONNULL ((1, 2)));
1030 _GL_CXXALIAS_RPL (readlink, ssize_t,
1031                   (const char *file, char *buf, size_t bufsize));
1032 # else
1033 #  if !@HAVE_READLINK@
1034 _GL_FUNCDECL_SYS (readlink, ssize_t,
1035                   (const char *file, char *buf, size_t bufsize)
1036                   _GL_ARG_NONNULL ((1, 2)));
1037 #  endif
1038 _GL_CXXALIAS_SYS (readlink, ssize_t,
1039                   (const char *file, char *buf, size_t bufsize));
1040 # endif
1041 _GL_CXXALIASWARN (readlink);
1042 #elif defined GNULIB_POSIXCHECK
1043 # undef readlink
1044 # if HAVE_RAW_DECL_READLINK
1045 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1046                  "use gnulib module readlink for portability");
1047 # endif
1048 #endif
1049
1050
1051 #if @GNULIB_READLINKAT@
1052 # if !@HAVE_READLINKAT@
1053 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
1054                   (int fd, char const *file, char *buf, size_t len)
1055                   _GL_ARG_NONNULL ((2, 3)));
1056 # endif
1057 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1058                   (int fd, char const *file, char *buf, size_t len));
1059 _GL_CXXALIASWARN (readlinkat);
1060 #elif defined GNULIB_POSIXCHECK
1061 # undef readlinkat
1062 # if HAVE_RAW_DECL_READLINKAT
1063 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1064                  "use gnulib module symlinkat for portability");
1065 # endif
1066 #endif
1067
1068
1069 #if @GNULIB_RMDIR@
1070 /* Remove the directory DIR.  */
1071 # if @REPLACE_RMDIR@
1072 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1073 #   define rmdir rpl_rmdir
1074 #  endif
1075 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1076 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1077 # else
1078 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1079 # endif
1080 _GL_CXXALIASWARN (rmdir);
1081 #elif defined GNULIB_POSIXCHECK
1082 # undef rmdir
1083 # if HAVE_RAW_DECL_RMDIR
1084 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1085                  "use gnulib module rmdir for portability");
1086 # endif
1087 #endif
1088
1089
1090 #if @GNULIB_SLEEP@
1091 /* Pause the execution of the current thread for N seconds.
1092    Returns the number of seconds left to sleep.
1093    See the POSIX:2001 specification
1094    <http://www.opengroup.org/susv3xsh/sleep.html>.  */
1095 # if @REPLACE_SLEEP@
1096 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1097 #   undef sleep
1098 #   define sleep rpl_sleep
1099 #  endif
1100 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1101 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1102 # else
1103 #  if !@HAVE_SLEEP@
1104 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1105 #  endif
1106 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1107 # endif
1108 _GL_CXXALIASWARN (sleep);
1109 #elif defined GNULIB_POSIXCHECK
1110 # undef sleep
1111 # if HAVE_RAW_DECL_SLEEP
1112 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1113                  "use gnulib module sleep for portability");
1114 # endif
1115 #endif
1116
1117
1118 #if @GNULIB_SYMLINK@
1119 # if @REPLACE_SYMLINK@
1120 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1121 #   undef symlink
1122 #   define symlink rpl_symlink
1123 #  endif
1124 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1125                                 _GL_ARG_NONNULL ((1, 2)));
1126 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1127 # else
1128 #  if !@HAVE_SYMLINK@
1129 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1130                                 _GL_ARG_NONNULL ((1, 2)));
1131 #  endif
1132 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1133 # endif
1134 _GL_CXXALIASWARN (symlink);
1135 #elif defined GNULIB_POSIXCHECK
1136 # undef symlink
1137 # if HAVE_RAW_DECL_SYMLINK
1138 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1139                  "use gnulib module symlink for portability");
1140 # endif
1141 #endif
1142
1143
1144 #if @GNULIB_SYMLINKAT@
1145 # if !@HAVE_SYMLINKAT@
1146 _GL_FUNCDECL_SYS (symlinkat, int,
1147                   (char const *contents, int fd, char const *file)
1148                   _GL_ARG_NONNULL ((1, 3)));
1149 # endif
1150 _GL_CXXALIAS_SYS (symlinkat, int,
1151                   (char const *contents, int fd, char const *file));
1152 _GL_CXXALIASWARN (symlinkat);
1153 #elif defined GNULIB_POSIXCHECK
1154 # undef symlinkat
1155 # if HAVE_RAW_DECL_SYMLINKAT
1156 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1157                  "use gnulib module symlinkat for portability");
1158 # endif
1159 #endif
1160
1161
1162 #if @GNULIB_TTYNAME_R@
1163 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1164    open on in BUF.  Return 0 on success, otherwise an error number.  */
1165 # if !@HAVE_TTYNAME_R@
1166 _GL_FUNCDECL_SYS (ttyname_r, int,
1167                   (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1168 # endif
1169 _GL_CXXALIAS_SYS (ttyname_r, int,
1170                   (int fd, char *buf, size_t buflen));
1171 _GL_CXXALIASWARN (ttyname_r);
1172 #elif defined GNULIB_POSIXCHECK
1173 # undef ttyname_r
1174 # if HAVE_RAW_DECL_TTYNAME_R
1175 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1176                  "use gnulib module ttyname_r for portability");
1177 # endif
1178 #endif
1179
1180
1181 #if @GNULIB_UNLINK@
1182 # if @REPLACE_UNLINK@
1183 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1184 #   undef unlink
1185 #   define unlink rpl_unlink
1186 #  endif
1187 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1188 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
1189 # else
1190 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
1191 # endif
1192 _GL_CXXALIASWARN (unlink);
1193 #elif defined GNULIB_POSIXCHECK
1194 # undef unlink
1195 # if HAVE_RAW_DECL_UNLINK
1196 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
1197                  "use gnulib module unlink for portability");
1198 # endif
1199 #endif
1200
1201
1202 #if @GNULIB_UNLINKAT@
1203 # if @REPLACE_UNLINKAT@
1204 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1205 #   undef unlinkat
1206 #   define unlinkat rpl_unlinkat
1207 #  endif
1208 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1209                                  _GL_ARG_NONNULL ((2)));
1210 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1211 # else
1212 #  if !@HAVE_UNLINKAT@
1213 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1214                                  _GL_ARG_NONNULL ((2)));
1215 #  endif
1216 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1217 # endif
1218 _GL_CXXALIASWARN (unlinkat);
1219 #elif defined GNULIB_POSIXCHECK
1220 # undef unlinkat
1221 # if HAVE_RAW_DECL_UNLINKAT
1222 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1223                  "use gnulib module openat for portability");
1224 # endif
1225 #endif
1226
1227
1228 #if @GNULIB_USLEEP@
1229 /* Pause the execution of the current thread for N microseconds.
1230    Returns 0 on completion, or -1 on range error.
1231    See the POSIX:2001 specification
1232    <http://www.opengroup.org/susv3xsh/sleep.html>.  */
1233 # if @REPLACE_USLEEP@
1234 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1235 #   undef usleep
1236 #   define usleep rpl_usleep
1237 #  endif
1238 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1239 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1240 # else
1241 #  if !@HAVE_USLEEP@
1242 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1243 #  endif
1244 _GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1245 # endif
1246 _GL_CXXALIASWARN (usleep);
1247 #elif defined GNULIB_POSIXCHECK
1248 # undef usleep
1249 # if HAVE_RAW_DECL_USLEEP
1250 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1251                  "use gnulib module usleep for portability");
1252 # endif
1253 #endif
1254
1255
1256 #if @GNULIB_WRITE@
1257 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1258    See the POSIX:2001 specification
1259    <http://www.opengroup.org/susv3xsh/write.html>.  */
1260 # if @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
1261 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1262 #   undef write
1263 #   define write rpl_write
1264 #  endif
1265 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1266                                   _GL_ARG_NONNULL ((2)));
1267 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1268 # else
1269 _GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
1270 # endif
1271 _GL_CXXALIASWARN (write);
1272 #endif
1273
1274
1275 #endif /* _GL_UNISTD_H */
1276 #endif /* _GL_UNISTD_H */