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