* lisp/ielm.el: Bring up the debugger when requested
[emacs.git] / lib / unistd.in.h
blobae59cb2e62749b6675a135964732383b5324c7a0
1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2018 Free Software Foundation, Inc.
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.
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.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <https://www.gnu.org/licenses/>. */
17 #ifndef _@GUARD_PREFIX@_UNISTD_H
19 #if __GNUC__ >= 3
20 @PRAGMA_SYSTEM_HEADER@
21 #endif
22 @PRAGMA_COLUMNS@
24 #ifdef _GL_INCLUDING_UNISTD_H
25 /* Special invocation convention:
26 - On Mac OS X 10.3.9 we have a sequence of nested includes
27 <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>
28 In this situation, the functions are not yet declared, therefore we cannot
29 provide the C++ aliases. */
31 #@INCLUDE_NEXT@ @NEXT_UNISTD_H@
33 #else
34 /* Normal invocation convention. */
36 /* The include_next requires a split double-inclusion guard. */
37 #if @HAVE_UNISTD_H@
38 # define _GL_INCLUDING_UNISTD_H
39 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
40 # undef _GL_INCLUDING_UNISTD_H
41 #endif
43 /* Get all possible declarations of gethostname(). */
44 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
45 && !defined _GL_INCLUDING_WINSOCK2_H
46 # define _GL_INCLUDING_WINSOCK2_H
47 # include <winsock2.h>
48 # undef _GL_INCLUDING_WINSOCK2_H
49 #endif
51 #if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
52 #define _@GUARD_PREFIX@_UNISTD_H
54 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
55 #include <stddef.h>
57 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
58 /* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>. We must include
59 it before we #define unlink rpl_unlink. */
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_UNLINK@ || defined GNULIB_POSIXCHECK) \
64 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) \
65 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
66 && defined __CYGWIN__)) \
67 && ! defined __GLIBC__
68 # include <stdio.h>
69 #endif
71 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
72 /* But avoid namespace pollution on glibc systems. */
73 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
74 && ! defined __GLIBC__
75 # include <fcntl.h>
76 #endif
78 /* mingw fails to declare _exit in <unistd.h>. */
79 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
80 <unistd.h>. */
81 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
82 /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
83 included here. */
84 /* But avoid namespace pollution on glibc systems. */
85 #if !defined __GLIBC__ && !defined __osf__
86 # define __need_system_stdlib_h
87 # include <stdlib.h>
88 # undef __need_system_stdlib_h
89 #endif
91 /* Native Windows platforms declare chdir, getcwd, rmdir in
92 <io.h> and/or <direct.h>, not in <unistd.h>.
93 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
94 lseek(), read(), unlink(), write() in <io.h>. */
95 #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
96 || defined GNULIB_POSIXCHECK) \
97 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
98 # include <io.h> /* mingw32, mingw64 */
99 # include <direct.h> /* mingw64, MSVC 9 */
100 #elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
101 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
102 || defined GNULIB_POSIXCHECK) \
103 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
104 # include <io.h>
105 #endif
107 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
108 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
109 /* But avoid namespace pollution on glibc systems. */
110 #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
111 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
112 && !defined __GLIBC__
113 # include <netdb.h>
114 #endif
116 /* MSVC defines off_t in <sys/types.h>.
117 May also define off_t to a 64-bit type on native Windows. */
118 #if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
119 /* Get off_t. */
120 # include <sys/types.h>
121 #endif
123 #if (@GNULIB_READ@ || @GNULIB_WRITE@ \
124 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
125 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
126 /* Get ssize_t. */
127 # include <sys/types.h>
128 #endif
130 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
132 /* The definition of _GL_ARG_NONNULL is copied here. */
134 /* The definition of _GL_WARN_ON_USE is copied here. */
137 /* Get getopt(), optarg, optind, opterr, optopt. */
138 #if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
139 # include <getopt-cdefs.h>
140 # include <getopt-pfx-core.h>
141 #endif
143 #ifndef _GL_INLINE_HEADER_BEGIN
144 #error "Please include config.h first."
145 #endif
146 _GL_INLINE_HEADER_BEGIN
147 #ifndef _GL_UNISTD_INLINE
148 # define _GL_UNISTD_INLINE _GL_INLINE
149 #endif
151 /* Hide some function declarations from <winsock2.h>. */
153 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
154 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
155 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
156 # undef socket
157 # define socket socket_used_without_including_sys_socket_h
158 # undef connect
159 # define connect connect_used_without_including_sys_socket_h
160 # undef accept
161 # define accept accept_used_without_including_sys_socket_h
162 # undef bind
163 # define bind bind_used_without_including_sys_socket_h
164 # undef getpeername
165 # define getpeername getpeername_used_without_including_sys_socket_h
166 # undef getsockname
167 # define getsockname getsockname_used_without_including_sys_socket_h
168 # undef getsockopt
169 # define getsockopt getsockopt_used_without_including_sys_socket_h
170 # undef listen
171 # define listen listen_used_without_including_sys_socket_h
172 # undef recv
173 # define recv recv_used_without_including_sys_socket_h
174 # undef send
175 # define send send_used_without_including_sys_socket_h
176 # undef recvfrom
177 # define recvfrom recvfrom_used_without_including_sys_socket_h
178 # undef sendto
179 # define sendto sendto_used_without_including_sys_socket_h
180 # undef setsockopt
181 # define setsockopt setsockopt_used_without_including_sys_socket_h
182 # undef shutdown
183 # define shutdown shutdown_used_without_including_sys_socket_h
184 # else
185 _GL_WARN_ON_USE (socket,
186 "socket() used without including <sys/socket.h>");
187 _GL_WARN_ON_USE (connect,
188 "connect() used without including <sys/socket.h>");
189 _GL_WARN_ON_USE (accept,
190 "accept() used without including <sys/socket.h>");
191 _GL_WARN_ON_USE (bind,
192 "bind() used without including <sys/socket.h>");
193 _GL_WARN_ON_USE (getpeername,
194 "getpeername() used without including <sys/socket.h>");
195 _GL_WARN_ON_USE (getsockname,
196 "getsockname() used without including <sys/socket.h>");
197 _GL_WARN_ON_USE (getsockopt,
198 "getsockopt() used without including <sys/socket.h>");
199 _GL_WARN_ON_USE (listen,
200 "listen() used without including <sys/socket.h>");
201 _GL_WARN_ON_USE (recv,
202 "recv() used without including <sys/socket.h>");
203 _GL_WARN_ON_USE (send,
204 "send() used without including <sys/socket.h>");
205 _GL_WARN_ON_USE (recvfrom,
206 "recvfrom() used without including <sys/socket.h>");
207 _GL_WARN_ON_USE (sendto,
208 "sendto() used without including <sys/socket.h>");
209 _GL_WARN_ON_USE (setsockopt,
210 "setsockopt() used without including <sys/socket.h>");
211 _GL_WARN_ON_USE (shutdown,
212 "shutdown() used without including <sys/socket.h>");
213 # endif
214 # endif
215 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
216 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
217 # undef select
218 # define select select_used_without_including_sys_select_h
219 # else
220 _GL_WARN_ON_USE (select,
221 "select() used without including <sys/select.h>");
222 # endif
223 # endif
224 #endif
227 /* OS/2 EMX lacks these macros. */
228 #ifndef STDIN_FILENO
229 # define STDIN_FILENO 0
230 #endif
231 #ifndef STDOUT_FILENO
232 # define STDOUT_FILENO 1
233 #endif
234 #ifndef STDERR_FILENO
235 # define STDERR_FILENO 2
236 #endif
238 /* Ensure *_OK macros exist. */
239 #ifndef F_OK
240 # define F_OK 0
241 # define X_OK 1
242 # define W_OK 2
243 # define R_OK 4
244 #endif
247 /* Declare overridden functions. */
250 #if defined GNULIB_POSIXCHECK
251 /* The access() function is a security risk. */
252 _GL_WARN_ON_USE (access, "the access function is a security risk - "
253 "use the gnulib module faccessat instead");
254 #endif
257 #if @GNULIB_CHDIR@
258 _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
259 _GL_CXXALIASWARN (chdir);
260 #elif defined GNULIB_POSIXCHECK
261 # undef chdir
262 # if HAVE_RAW_DECL_CHDIR
263 _GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
264 "use gnulib module chdir for portability");
265 # endif
266 #endif
269 #if @GNULIB_CHOWN@
270 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
271 to GID (if GID is not -1). Follow symbolic links.
272 Return 0 if successful, otherwise -1 and errno set.
273 See the POSIX:2008 specification
274 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
275 # if @REPLACE_CHOWN@
276 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
277 # undef chown
278 # define chown rpl_chown
279 # endif
280 _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
281 _GL_ARG_NONNULL ((1)));
282 _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
283 # else
284 # if !@HAVE_CHOWN@
285 _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
286 _GL_ARG_NONNULL ((1)));
287 # endif
288 _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
289 # endif
290 _GL_CXXALIASWARN (chown);
291 #elif defined GNULIB_POSIXCHECK
292 # undef chown
293 # if HAVE_RAW_DECL_CHOWN
294 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
295 "doesn't treat a uid or gid of -1 on some systems - "
296 "use gnulib module chown for portability");
297 # endif
298 #endif
301 #if @GNULIB_CLOSE@
302 # if @REPLACE_CLOSE@
303 /* Automatically included by modules that need a replacement for close. */
304 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
305 # undef close
306 # define close rpl_close
307 # endif
308 _GL_FUNCDECL_RPL (close, int, (int fd));
309 _GL_CXXALIAS_RPL (close, int, (int fd));
310 # else
311 _GL_CXXALIAS_SYS (close, int, (int fd));
312 # endif
313 _GL_CXXALIASWARN (close);
314 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
315 # undef close
316 # define close close_used_without_requesting_gnulib_module_close
317 #elif defined GNULIB_POSIXCHECK
318 # undef close
319 /* Assume close is always declared. */
320 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
321 "use gnulib module close for portability");
322 #endif
325 #if @GNULIB_DUP@
326 # if @REPLACE_DUP@
327 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
328 # define dup rpl_dup
329 # endif
330 _GL_FUNCDECL_RPL (dup, int, (int oldfd));
331 _GL_CXXALIAS_RPL (dup, int, (int oldfd));
332 # else
333 _GL_CXXALIAS_SYS (dup, int, (int oldfd));
334 # endif
335 _GL_CXXALIASWARN (dup);
336 #elif defined GNULIB_POSIXCHECK
337 # undef dup
338 # if HAVE_RAW_DECL_DUP
339 _GL_WARN_ON_USE (dup, "dup is unportable - "
340 "use gnulib module dup for portability");
341 # endif
342 #endif
345 #if @GNULIB_DUP2@
346 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
347 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
348 Return newfd if successful, otherwise -1 and errno set.
349 See the POSIX:2008 specification
350 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
351 # if @REPLACE_DUP2@
352 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
353 # define dup2 rpl_dup2
354 # endif
355 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
356 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
357 # else
358 # if !@HAVE_DUP2@
359 _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
360 # endif
361 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
362 # endif
363 _GL_CXXALIASWARN (dup2);
364 #elif defined GNULIB_POSIXCHECK
365 # undef dup2
366 # if HAVE_RAW_DECL_DUP2
367 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
368 "use gnulib module dup2 for portability");
369 # endif
370 #endif
373 #if @GNULIB_DUP3@
374 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
375 specified flags.
376 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
377 and O_TEXT, O_BINARY (defined in "binary-io.h").
378 Close NEWFD first if it is open.
379 Return newfd if successful, otherwise -1 and errno set.
380 See the Linux man page at
381 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
382 # if @HAVE_DUP3@
383 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
384 # define dup3 rpl_dup3
385 # endif
386 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
387 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
388 # else
389 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
390 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
391 # endif
392 _GL_CXXALIASWARN (dup3);
393 #elif defined GNULIB_POSIXCHECK
394 # undef dup3
395 # if HAVE_RAW_DECL_DUP3
396 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
397 "use gnulib module dup3 for portability");
398 # endif
399 #endif
402 #if @GNULIB_ENVIRON@
403 # if !@HAVE_DECL_ENVIRON@
404 /* Set of environment variables and values. An array of strings of the form
405 "VARIABLE=VALUE", terminated with a NULL. */
406 # if defined __APPLE__ && defined __MACH__
407 # include <TargetConditionals.h>
408 # if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
409 # define _GL_USE_CRT_EXTERNS
410 # endif
411 # endif
412 # ifdef _GL_USE_CRT_EXTERNS
413 # include <crt_externs.h>
414 # define environ (*_NSGetEnviron ())
415 # else
416 # ifdef __cplusplus
417 extern "C" {
418 # endif
419 extern char **environ;
420 # ifdef __cplusplus
422 # endif
423 # endif
424 # endif
425 #elif defined GNULIB_POSIXCHECK
426 # if HAVE_RAW_DECL_ENVIRON
427 _GL_UNISTD_INLINE char ***
428 rpl_environ (void)
430 return &environ;
432 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
433 "use gnulib module environ for portability");
434 # undef environ
435 # define environ (*rpl_environ ())
436 # endif
437 #endif
440 #if @GNULIB_EUIDACCESS@
441 /* Like access(), except that it uses the effective user id and group id of
442 the current process. */
443 # if !@HAVE_EUIDACCESS@
444 _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
445 _GL_ARG_NONNULL ((1)));
446 # endif
447 _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
448 _GL_CXXALIASWARN (euidaccess);
449 # if defined GNULIB_POSIXCHECK
450 /* Like access(), this function is a security risk. */
451 _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
452 "use the gnulib module faccessat instead");
453 # endif
454 #elif defined GNULIB_POSIXCHECK
455 # undef euidaccess
456 # if HAVE_RAW_DECL_EUIDACCESS
457 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
458 "use gnulib module euidaccess for portability");
459 # endif
460 #endif
463 #if @GNULIB_FACCESSAT@
464 # if @REPLACE_FACCESSAT@
465 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
466 # undef faccessat
467 # define faccessat rpl_faccessat
468 # endif
469 _GL_FUNCDECL_RPL (faccessat, int,
470 (int fd, char const *name, int mode, int flag)
471 _GL_ARG_NONNULL ((2)));
472 _GL_CXXALIAS_RPL (faccessat, int,
473 (int fd, char const *name, int mode, int flag));
474 # else
475 # if !@HAVE_FACCESSAT@
476 _GL_FUNCDECL_SYS (faccessat, int,
477 (int fd, char const *file, int mode, int flag)
478 _GL_ARG_NONNULL ((2)));
479 # endif
480 _GL_CXXALIAS_SYS (faccessat, int,
481 (int fd, char const *file, int mode, int flag));
482 # endif
483 _GL_CXXALIASWARN (faccessat);
484 #elif defined GNULIB_POSIXCHECK
485 # undef faccessat
486 # if HAVE_RAW_DECL_FACCESSAT
487 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
488 "use gnulib module faccessat for portability");
489 # endif
490 #endif
493 #if @GNULIB_FCHDIR@
494 /* Change the process' current working directory to the directory on which
495 the given file descriptor is open.
496 Return 0 if successful, otherwise -1 and errno set.
497 See the POSIX:2008 specification
498 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
499 # if ! @HAVE_FCHDIR@
500 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
502 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
503 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
504 _GL_ARG_NONNULL ((2));
505 _GL_EXTERN_C void _gl_unregister_fd (int fd);
506 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
507 _GL_EXTERN_C const char *_gl_directory_name (int fd);
509 # else
510 # if !@HAVE_DECL_FCHDIR@
511 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
512 # endif
513 # endif
514 _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
515 _GL_CXXALIASWARN (fchdir);
516 #elif defined GNULIB_POSIXCHECK
517 # undef fchdir
518 # if HAVE_RAW_DECL_FCHDIR
519 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
520 "use gnulib module fchdir for portability");
521 # endif
522 #endif
525 #if @GNULIB_FCHOWNAT@
526 # if @REPLACE_FCHOWNAT@
527 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
528 # undef fchownat
529 # define fchownat rpl_fchownat
530 # endif
531 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
532 uid_t owner, gid_t group, int flag)
533 _GL_ARG_NONNULL ((2)));
534 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
535 uid_t owner, gid_t group, int flag));
536 # else
537 # if !@HAVE_FCHOWNAT@
538 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
539 uid_t owner, gid_t group, int flag)
540 _GL_ARG_NONNULL ((2)));
541 # endif
542 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
543 uid_t owner, gid_t group, int flag));
544 # endif
545 _GL_CXXALIASWARN (fchownat);
546 #elif defined GNULIB_POSIXCHECK
547 # undef fchownat
548 # if HAVE_RAW_DECL_FCHOWNAT
549 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
550 "use gnulib module openat for portability");
551 # endif
552 #endif
555 #if @GNULIB_FDATASYNC@
556 /* Synchronize changes to a file.
557 Return 0 if successful, otherwise -1 and errno set.
558 See POSIX:2008 specification
559 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
560 # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
561 _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
562 # endif
563 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
564 _GL_CXXALIASWARN (fdatasync);
565 #elif defined GNULIB_POSIXCHECK
566 # undef fdatasync
567 # if HAVE_RAW_DECL_FDATASYNC
568 _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
569 "use gnulib module fdatasync for portability");
570 # endif
571 #endif
574 #if @GNULIB_FSYNC@
575 /* Synchronize changes, including metadata, to a file.
576 Return 0 if successful, otherwise -1 and errno set.
577 See POSIX:2008 specification
578 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
579 # if !@HAVE_FSYNC@
580 _GL_FUNCDECL_SYS (fsync, int, (int fd));
581 # endif
582 _GL_CXXALIAS_SYS (fsync, int, (int fd));
583 _GL_CXXALIASWARN (fsync);
584 #elif defined GNULIB_POSIXCHECK
585 # undef fsync
586 # if HAVE_RAW_DECL_FSYNC
587 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
588 "use gnulib module fsync for portability");
589 # endif
590 #endif
593 #if @GNULIB_FTRUNCATE@
594 /* Change the size of the file to which FD is opened to become equal to LENGTH.
595 Return 0 if successful, otherwise -1 and errno set.
596 See the POSIX:2008 specification
597 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
598 # if @REPLACE_FTRUNCATE@
599 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
600 # undef ftruncate
601 # define ftruncate rpl_ftruncate
602 # endif
603 _GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
604 _GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
605 # else
606 # if !@HAVE_FTRUNCATE@
607 _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
608 # endif
609 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
610 # endif
611 _GL_CXXALIASWARN (ftruncate);
612 #elif defined GNULIB_POSIXCHECK
613 # undef ftruncate
614 # if HAVE_RAW_DECL_FTRUNCATE
615 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
616 "use gnulib module ftruncate for portability");
617 # endif
618 #endif
621 #if @GNULIB_GETCWD@
622 /* Get the name of the current working directory, and put it in SIZE bytes
623 of BUF.
624 Return BUF if successful, or NULL if the directory couldn't be determined
625 or SIZE was too small.
626 See the POSIX:2008 specification
627 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
628 Additionally, the gnulib module 'getcwd' guarantees the following GNU
629 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
630 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
631 necessary. */
632 # if @REPLACE_GETCWD@
633 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
634 # define getcwd rpl_getcwd
635 # endif
636 _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
637 _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
638 # else
639 /* Need to cast, because on mingw, the second parameter is
640 int size. */
641 _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
642 # endif
643 _GL_CXXALIASWARN (getcwd);
644 #elif defined GNULIB_POSIXCHECK
645 # undef getcwd
646 # if HAVE_RAW_DECL_GETCWD
647 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
648 "use gnulib module getcwd for portability");
649 # endif
650 #endif
653 #if @GNULIB_GETDOMAINNAME@
654 /* Return the NIS domain name of the machine.
655 WARNING! The NIS domain name is unrelated to the fully qualified host name
656 of the machine. It is also unrelated to email addresses.
657 WARNING! The NIS domain name is usually the empty string or "(none)" when
658 not using NIS.
660 Put up to LEN bytes of the NIS domain name into NAME.
661 Null terminate it if the name is shorter than LEN.
662 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
663 Return 0 if successful, otherwise set errno and return -1. */
664 # if @REPLACE_GETDOMAINNAME@
665 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
666 # undef getdomainname
667 # define getdomainname rpl_getdomainname
668 # endif
669 _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
670 _GL_ARG_NONNULL ((1)));
671 _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
672 # else
673 # if !@HAVE_DECL_GETDOMAINNAME@
674 _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
675 _GL_ARG_NONNULL ((1)));
676 # endif
677 _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
678 # endif
679 _GL_CXXALIASWARN (getdomainname);
680 #elif defined GNULIB_POSIXCHECK
681 # undef getdomainname
682 # if HAVE_RAW_DECL_GETDOMAINNAME
683 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
684 "use gnulib module getdomainname for portability");
685 # endif
686 #endif
689 #if @GNULIB_GETDTABLESIZE@
690 /* Return the maximum number of file descriptors in the current process.
691 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
692 # if @REPLACE_GETDTABLESIZE@
693 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
694 # undef getdtablesize
695 # define getdtablesize rpl_getdtablesize
696 # endif
697 _GL_FUNCDECL_RPL (getdtablesize, int, (void));
698 _GL_CXXALIAS_RPL (getdtablesize, int, (void));
699 # else
700 # if !@HAVE_GETDTABLESIZE@
701 _GL_FUNCDECL_SYS (getdtablesize, int, (void));
702 # endif
703 _GL_CXXALIAS_SYS (getdtablesize, int, (void));
704 # endif
705 _GL_CXXALIASWARN (getdtablesize);
706 #elif defined GNULIB_POSIXCHECK
707 # undef getdtablesize
708 # if HAVE_RAW_DECL_GETDTABLESIZE
709 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
710 "use gnulib module getdtablesize for portability");
711 # endif
712 #endif
715 #if @GNULIB_GETGROUPS@
716 /* Return the supplemental groups that the current process belongs to.
717 It is unspecified whether the effective group id is in the list.
718 If N is 0, return the group count; otherwise, N describes how many
719 entries are available in GROUPS. Return -1 and set errno if N is
720 not 0 and not large enough. Fails with ENOSYS on some systems. */
721 # if @REPLACE_GETGROUPS@
722 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
723 # undef getgroups
724 # define getgroups rpl_getgroups
725 # endif
726 _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
727 _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
728 # else
729 # if !@HAVE_GETGROUPS@
730 _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
731 # endif
732 _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
733 # endif
734 _GL_CXXALIASWARN (getgroups);
735 #elif defined GNULIB_POSIXCHECK
736 # undef getgroups
737 # if HAVE_RAW_DECL_GETGROUPS
738 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
739 "use gnulib module getgroups for portability");
740 # endif
741 #endif
744 #if @GNULIB_GETHOSTNAME@
745 /* Return the standard host name of the machine.
746 WARNING! The host name may or may not be fully qualified.
748 Put up to LEN bytes of the host name into NAME.
749 Null terminate it if the name is shorter than LEN.
750 If the host name is longer than LEN, set errno = EINVAL and return -1.
751 Return 0 if successful, otherwise set errno and return -1. */
752 # if @UNISTD_H_HAVE_WINSOCK2_H@
753 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
754 # undef gethostname
755 # define gethostname rpl_gethostname
756 # endif
757 _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
758 _GL_ARG_NONNULL ((1)));
759 _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
760 # else
761 # if !@HAVE_GETHOSTNAME@
762 _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
763 _GL_ARG_NONNULL ((1)));
764 # endif
765 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
766 parameter is
767 int len. */
768 _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
769 # endif
770 _GL_CXXALIASWARN (gethostname);
771 #elif @UNISTD_H_HAVE_WINSOCK2_H@
772 # undef gethostname
773 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
774 #elif defined GNULIB_POSIXCHECK
775 # undef gethostname
776 # if HAVE_RAW_DECL_GETHOSTNAME
777 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
778 "use gnulib module gethostname for portability");
779 # endif
780 #endif
783 #if @GNULIB_GETLOGIN@
784 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
785 returns NULL with errno set.
787 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
789 Most programs don't need to use this function, because the information is
790 available through environment variables:
791 ${LOGNAME-$USER} on Unix platforms,
792 $USERNAME on native Windows platforms.
794 # if !@HAVE_DECL_GETLOGIN@
795 _GL_FUNCDECL_SYS (getlogin, char *, (void));
796 # endif
797 _GL_CXXALIAS_SYS (getlogin, char *, (void));
798 _GL_CXXALIASWARN (getlogin);
799 #elif defined GNULIB_POSIXCHECK
800 # undef getlogin
801 # if HAVE_RAW_DECL_GETLOGIN
802 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
803 "use gnulib module getlogin for portability");
804 # endif
805 #endif
808 #if @GNULIB_GETLOGIN_R@
809 /* Copies the user's login name to NAME.
810 The array pointed to by NAME has room for SIZE bytes.
812 Returns 0 if successful. Upon error, an error number is returned, or -1 in
813 the case that the login name cannot be found but no specific error is
814 provided (this case is hopefully rare but is left open by the POSIX spec).
816 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
818 Most programs don't need to use this function, because the information is
819 available through environment variables:
820 ${LOGNAME-$USER} on Unix platforms,
821 $USERNAME on native Windows platforms.
823 # if @REPLACE_GETLOGIN_R@
824 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
825 # define getlogin_r rpl_getlogin_r
826 # endif
827 _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
828 _GL_ARG_NONNULL ((1)));
829 _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
830 # else
831 # if !@HAVE_DECL_GETLOGIN_R@
832 _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
833 _GL_ARG_NONNULL ((1)));
834 # endif
835 /* Need to cast, because on Solaris 10 systems, the second argument is
836 int size. */
837 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
838 # endif
839 _GL_CXXALIASWARN (getlogin_r);
840 #elif defined GNULIB_POSIXCHECK
841 # undef getlogin_r
842 # if HAVE_RAW_DECL_GETLOGIN_R
843 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
844 "use gnulib module getlogin_r for portability");
845 # endif
846 #endif
849 #if @GNULIB_GETPAGESIZE@
850 # if @REPLACE_GETPAGESIZE@
851 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
852 # define getpagesize rpl_getpagesize
853 # endif
854 _GL_FUNCDECL_RPL (getpagesize, int, (void));
855 _GL_CXXALIAS_RPL (getpagesize, int, (void));
856 # else
857 # if !@HAVE_GETPAGESIZE@
858 # if !defined getpagesize
859 /* This is for POSIX systems. */
860 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
861 # if ! (defined __VMS && __VMS_VER < 70000000)
862 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
863 # endif
864 # endif
865 /* This is for older VMS. */
866 # if !defined _gl_getpagesize && defined __VMS
867 # ifdef __ALPHA
868 # define _gl_getpagesize() 8192
869 # else
870 # define _gl_getpagesize() 512
871 # endif
872 # endif
873 /* This is for BeOS. */
874 # if !defined _gl_getpagesize && @HAVE_OS_H@
875 # include <OS.h>
876 # if defined B_PAGE_SIZE
877 # define _gl_getpagesize() B_PAGE_SIZE
878 # endif
879 # endif
880 /* This is for AmigaOS4.0. */
881 # if !defined _gl_getpagesize && defined __amigaos4__
882 # define _gl_getpagesize() 2048
883 # endif
884 /* This is for older Unix systems. */
885 # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
886 # include <sys/param.h>
887 # ifdef EXEC_PAGESIZE
888 # define _gl_getpagesize() EXEC_PAGESIZE
889 # else
890 # ifdef NBPG
891 # ifndef CLSIZE
892 # define CLSIZE 1
893 # endif
894 # define _gl_getpagesize() (NBPG * CLSIZE)
895 # else
896 # ifdef NBPC
897 # define _gl_getpagesize() NBPC
898 # endif
899 # endif
900 # endif
901 # endif
902 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
903 # define getpagesize() _gl_getpagesize ()
904 # else
905 # if !GNULIB_defined_getpagesize_function
906 _GL_UNISTD_INLINE int
907 getpagesize ()
909 return _gl_getpagesize ();
911 # define GNULIB_defined_getpagesize_function 1
912 # endif
913 # endif
914 # endif
915 # endif
916 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
917 _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
918 # endif
919 # if @HAVE_DECL_GETPAGESIZE@
920 _GL_CXXALIASWARN (getpagesize);
921 # endif
922 #elif defined GNULIB_POSIXCHECK
923 # undef getpagesize
924 # if HAVE_RAW_DECL_GETPAGESIZE
925 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
926 "use gnulib module getpagesize for portability");
927 # endif
928 #endif
931 #if @GNULIB_GETUSERSHELL@
932 /* Return the next valid login shell on the system, or NULL when the end of
933 the list has been reached. */
934 # if !@HAVE_DECL_GETUSERSHELL@
935 _GL_FUNCDECL_SYS (getusershell, char *, (void));
936 # endif
937 _GL_CXXALIAS_SYS (getusershell, char *, (void));
938 _GL_CXXALIASWARN (getusershell);
939 #elif defined GNULIB_POSIXCHECK
940 # undef getusershell
941 # if HAVE_RAW_DECL_GETUSERSHELL
942 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
943 "use gnulib module getusershell for portability");
944 # endif
945 #endif
947 #if @GNULIB_GETUSERSHELL@
948 /* Rewind to pointer that is advanced at each getusershell() call. */
949 # if !@HAVE_DECL_GETUSERSHELL@
950 _GL_FUNCDECL_SYS (setusershell, void, (void));
951 # endif
952 _GL_CXXALIAS_SYS (setusershell, void, (void));
953 _GL_CXXALIASWARN (setusershell);
954 #elif defined GNULIB_POSIXCHECK
955 # undef setusershell
956 # if HAVE_RAW_DECL_SETUSERSHELL
957 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
958 "use gnulib module getusershell for portability");
959 # endif
960 #endif
962 #if @GNULIB_GETUSERSHELL@
963 /* Free the pointer that is advanced at each getusershell() call and
964 associated resources. */
965 # if !@HAVE_DECL_GETUSERSHELL@
966 _GL_FUNCDECL_SYS (endusershell, void, (void));
967 # endif
968 _GL_CXXALIAS_SYS (endusershell, void, (void));
969 _GL_CXXALIASWARN (endusershell);
970 #elif defined GNULIB_POSIXCHECK
971 # undef endusershell
972 # if HAVE_RAW_DECL_ENDUSERSHELL
973 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
974 "use gnulib module getusershell for portability");
975 # endif
976 #endif
979 #if @GNULIB_GROUP_MEMBER@
980 /* Determine whether group id is in calling user's group list. */
981 # if !@HAVE_GROUP_MEMBER@
982 _GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
983 # endif
984 _GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
985 _GL_CXXALIASWARN (group_member);
986 #elif defined GNULIB_POSIXCHECK
987 # undef group_member
988 # if HAVE_RAW_DECL_GROUP_MEMBER
989 _GL_WARN_ON_USE (group_member, "group_member is unportable - "
990 "use gnulib module group-member for portability");
991 # endif
992 #endif
995 #if @GNULIB_ISATTY@
996 # if @REPLACE_ISATTY@
997 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
998 # undef isatty
999 # define isatty rpl_isatty
1000 # endif
1001 _GL_FUNCDECL_RPL (isatty, int, (int fd));
1002 _GL_CXXALIAS_RPL (isatty, int, (int fd));
1003 # else
1004 _GL_CXXALIAS_SYS (isatty, int, (int fd));
1005 # endif
1006 _GL_CXXALIASWARN (isatty);
1007 #elif defined GNULIB_POSIXCHECK
1008 # undef isatty
1009 # if HAVE_RAW_DECL_ISATTY
1010 _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
1011 "use gnulib module isatty for portability");
1012 # endif
1013 #endif
1016 #if @GNULIB_LCHOWN@
1017 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1018 to GID (if GID is not -1). Do not follow symbolic links.
1019 Return 0 if successful, otherwise -1 and errno set.
1020 See the POSIX:2008 specification
1021 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1022 # if @REPLACE_LCHOWN@
1023 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1024 # undef lchown
1025 # define lchown rpl_lchown
1026 # endif
1027 _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
1028 _GL_ARG_NONNULL ((1)));
1029 _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
1030 # else
1031 # if !@HAVE_LCHOWN@
1032 _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
1033 _GL_ARG_NONNULL ((1)));
1034 # endif
1035 _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
1036 # endif
1037 _GL_CXXALIASWARN (lchown);
1038 #elif defined GNULIB_POSIXCHECK
1039 # undef lchown
1040 # if HAVE_RAW_DECL_LCHOWN
1041 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1042 "use gnulib module lchown for portability");
1043 # endif
1044 #endif
1047 #if @GNULIB_LINK@
1048 /* Create a new hard link for an existing file.
1049 Return 0 if successful, otherwise -1 and errno set.
1050 See POSIX:2008 specification
1051 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1052 # if @REPLACE_LINK@
1053 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1054 # define link rpl_link
1055 # endif
1056 _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
1057 _GL_ARG_NONNULL ((1, 2)));
1058 _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
1059 # else
1060 # if !@HAVE_LINK@
1061 _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
1062 _GL_ARG_NONNULL ((1, 2)));
1063 # endif
1064 _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
1065 # endif
1066 _GL_CXXALIASWARN (link);
1067 #elif defined GNULIB_POSIXCHECK
1068 # undef link
1069 # if HAVE_RAW_DECL_LINK
1070 _GL_WARN_ON_USE (link, "link is unportable - "
1071 "use gnulib module link for portability");
1072 # endif
1073 #endif
1076 #if @GNULIB_LINKAT@
1077 /* Create a new hard link for an existing file, relative to two
1078 directories. FLAG controls whether symlinks are followed.
1079 Return 0 if successful, otherwise -1 and errno set. */
1080 # if @REPLACE_LINKAT@
1081 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1082 # undef linkat
1083 # define linkat rpl_linkat
1084 # endif
1085 _GL_FUNCDECL_RPL (linkat, int,
1086 (int fd1, const char *path1, int fd2, const char *path2,
1087 int flag)
1088 _GL_ARG_NONNULL ((2, 4)));
1089 _GL_CXXALIAS_RPL (linkat, int,
1090 (int fd1, const char *path1, int fd2, const char *path2,
1091 int flag));
1092 # else
1093 # if !@HAVE_LINKAT@
1094 _GL_FUNCDECL_SYS (linkat, int,
1095 (int fd1, const char *path1, int fd2, const char *path2,
1096 int flag)
1097 _GL_ARG_NONNULL ((2, 4)));
1098 # endif
1099 _GL_CXXALIAS_SYS (linkat, int,
1100 (int fd1, const char *path1, int fd2, const char *path2,
1101 int flag));
1102 # endif
1103 _GL_CXXALIASWARN (linkat);
1104 #elif defined GNULIB_POSIXCHECK
1105 # undef linkat
1106 # if HAVE_RAW_DECL_LINKAT
1107 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1108 "use gnulib module linkat for portability");
1109 # endif
1110 #endif
1113 #if @GNULIB_LSEEK@
1114 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1115 Return the new offset if successful, otherwise -1 and errno set.
1116 See the POSIX:2008 specification
1117 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1118 # if @REPLACE_LSEEK@
1119 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1120 # define lseek rpl_lseek
1121 # endif
1122 _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1123 _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1124 # else
1125 _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1126 # endif
1127 _GL_CXXALIASWARN (lseek);
1128 #elif defined GNULIB_POSIXCHECK
1129 # undef lseek
1130 # if HAVE_RAW_DECL_LSEEK
1131 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1132 "systems - use gnulib module lseek for portability");
1133 # endif
1134 #endif
1137 #if @GNULIB_PIPE@
1138 /* Create a pipe, defaulting to O_BINARY mode.
1139 Store the read-end as fd[0] and the write-end as fd[1].
1140 Return 0 upon success, or -1 with errno set upon failure. */
1141 # if !@HAVE_PIPE@
1142 _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1143 # endif
1144 _GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1145 _GL_CXXALIASWARN (pipe);
1146 #elif defined GNULIB_POSIXCHECK
1147 # undef pipe
1148 # if HAVE_RAW_DECL_PIPE
1149 _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1150 "use gnulib module pipe-posix for portability");
1151 # endif
1152 #endif
1155 #if @GNULIB_PIPE2@
1156 /* Create a pipe, applying the given flags when opening the read-end of the
1157 pipe and the write-end of the pipe.
1158 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1159 and O_TEXT, O_BINARY (defined in "binary-io.h").
1160 Store the read-end as fd[0] and the write-end as fd[1].
1161 Return 0 upon success, or -1 with errno set upon failure.
1162 See also the Linux man page at
1163 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1164 # if @HAVE_PIPE2@
1165 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1166 # define pipe2 rpl_pipe2
1167 # endif
1168 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1169 _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1170 # else
1171 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1172 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1173 # endif
1174 _GL_CXXALIASWARN (pipe2);
1175 #elif defined GNULIB_POSIXCHECK
1176 # undef pipe2
1177 # if HAVE_RAW_DECL_PIPE2
1178 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1179 "use gnulib module pipe2 for portability");
1180 # endif
1181 #endif
1184 #if @GNULIB_PREAD@
1185 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1186 Return the number of bytes placed into BUF if successful, otherwise
1187 set errno and return -1. 0 indicates EOF.
1188 See the POSIX:2008 specification
1189 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1190 # if @REPLACE_PREAD@
1191 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1192 # undef pread
1193 # define pread rpl_pread
1194 # endif
1195 _GL_FUNCDECL_RPL (pread, ssize_t,
1196 (int fd, void *buf, size_t bufsize, off_t offset)
1197 _GL_ARG_NONNULL ((2)));
1198 _GL_CXXALIAS_RPL (pread, ssize_t,
1199 (int fd, void *buf, size_t bufsize, off_t offset));
1200 # else
1201 # if !@HAVE_PREAD@
1202 _GL_FUNCDECL_SYS (pread, ssize_t,
1203 (int fd, void *buf, size_t bufsize, off_t offset)
1204 _GL_ARG_NONNULL ((2)));
1205 # endif
1206 _GL_CXXALIAS_SYS (pread, ssize_t,
1207 (int fd, void *buf, size_t bufsize, off_t offset));
1208 # endif
1209 _GL_CXXALIASWARN (pread);
1210 #elif defined GNULIB_POSIXCHECK
1211 # undef pread
1212 # if HAVE_RAW_DECL_PREAD
1213 _GL_WARN_ON_USE (pread, "pread is unportable - "
1214 "use gnulib module pread for portability");
1215 # endif
1216 #endif
1219 #if @GNULIB_PWRITE@
1220 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1221 Return the number of bytes written if successful, otherwise
1222 set errno and return -1. 0 indicates nothing written. See the
1223 POSIX:2008 specification
1224 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1225 # if @REPLACE_PWRITE@
1226 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1227 # undef pwrite
1228 # define pwrite rpl_pwrite
1229 # endif
1230 _GL_FUNCDECL_RPL (pwrite, ssize_t,
1231 (int fd, const void *buf, size_t bufsize, off_t offset)
1232 _GL_ARG_NONNULL ((2)));
1233 _GL_CXXALIAS_RPL (pwrite, ssize_t,
1234 (int fd, const void *buf, size_t bufsize, off_t offset));
1235 # else
1236 # if !@HAVE_PWRITE@
1237 _GL_FUNCDECL_SYS (pwrite, ssize_t,
1238 (int fd, const void *buf, size_t bufsize, off_t offset)
1239 _GL_ARG_NONNULL ((2)));
1240 # endif
1241 _GL_CXXALIAS_SYS (pwrite, ssize_t,
1242 (int fd, const void *buf, size_t bufsize, off_t offset));
1243 # endif
1244 _GL_CXXALIASWARN (pwrite);
1245 #elif defined GNULIB_POSIXCHECK
1246 # undef pwrite
1247 # if HAVE_RAW_DECL_PWRITE
1248 _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1249 "use gnulib module pwrite for portability");
1250 # endif
1251 #endif
1254 #if @GNULIB_READ@
1255 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1256 at BUF. See the POSIX:2008 specification
1257 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1258 # if @REPLACE_READ@
1259 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1260 # undef read
1261 # define read rpl_read
1262 # endif
1263 _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1264 _GL_ARG_NONNULL ((2)));
1265 _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1266 # else
1267 /* Need to cast, because on mingw, the third parameter is
1268 unsigned int count
1269 and the return type is 'int'. */
1270 _GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1271 # endif
1272 _GL_CXXALIASWARN (read);
1273 #endif
1276 #if @GNULIB_READLINK@
1277 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1278 bytes of it into BUF. Return the number of bytes placed into BUF if
1279 successful, otherwise -1 and errno set.
1280 See the POSIX:2008 specification
1281 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1282 # if @REPLACE_READLINK@
1283 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1284 # define readlink rpl_readlink
1285 # endif
1286 _GL_FUNCDECL_RPL (readlink, ssize_t,
1287 (const char *file, char *buf, size_t bufsize)
1288 _GL_ARG_NONNULL ((1, 2)));
1289 _GL_CXXALIAS_RPL (readlink, ssize_t,
1290 (const char *file, char *buf, size_t bufsize));
1291 # else
1292 # if !@HAVE_READLINK@
1293 _GL_FUNCDECL_SYS (readlink, ssize_t,
1294 (const char *file, char *buf, size_t bufsize)
1295 _GL_ARG_NONNULL ((1, 2)));
1296 # endif
1297 _GL_CXXALIAS_SYS (readlink, ssize_t,
1298 (const char *file, char *buf, size_t bufsize));
1299 # endif
1300 _GL_CXXALIASWARN (readlink);
1301 #elif defined GNULIB_POSIXCHECK
1302 # undef readlink
1303 # if HAVE_RAW_DECL_READLINK
1304 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1305 "use gnulib module readlink for portability");
1306 # endif
1307 #endif
1310 #if @GNULIB_READLINKAT@
1311 # if @REPLACE_READLINKAT@
1312 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1313 # define readlinkat rpl_readlinkat
1314 # endif
1315 _GL_FUNCDECL_RPL (readlinkat, ssize_t,
1316 (int fd, char const *file, char *buf, size_t len)
1317 _GL_ARG_NONNULL ((2, 3)));
1318 _GL_CXXALIAS_RPL (readlinkat, ssize_t,
1319 (int fd, char const *file, char *buf, size_t len));
1320 # else
1321 # if !@HAVE_READLINKAT@
1322 _GL_FUNCDECL_SYS (readlinkat, ssize_t,
1323 (int fd, char const *file, char *buf, size_t len)
1324 _GL_ARG_NONNULL ((2, 3)));
1325 # endif
1326 _GL_CXXALIAS_SYS (readlinkat, ssize_t,
1327 (int fd, char const *file, char *buf, size_t len));
1328 # endif
1329 _GL_CXXALIASWARN (readlinkat);
1330 #elif defined GNULIB_POSIXCHECK
1331 # undef readlinkat
1332 # if HAVE_RAW_DECL_READLINKAT
1333 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1334 "use gnulib module readlinkat for portability");
1335 # endif
1336 #endif
1339 #if @GNULIB_RMDIR@
1340 /* Remove the directory DIR. */
1341 # if @REPLACE_RMDIR@
1342 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1343 # define rmdir rpl_rmdir
1344 # endif
1345 _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1346 _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1347 # else
1348 _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1349 # endif
1350 _GL_CXXALIASWARN (rmdir);
1351 #elif defined GNULIB_POSIXCHECK
1352 # undef rmdir
1353 # if HAVE_RAW_DECL_RMDIR
1354 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1355 "use gnulib module rmdir for portability");
1356 # endif
1357 #endif
1360 #if @GNULIB_SETHOSTNAME@
1361 /* Set the host name of the machine.
1362 The host name may or may not be fully qualified.
1364 Put LEN bytes of NAME into the host name.
1365 Return 0 if successful, otherwise, set errno and return -1.
1367 Platforms with no ability to set the hostname return -1 and set
1368 errno = ENOSYS. */
1369 # if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1370 _GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
1371 _GL_ARG_NONNULL ((1)));
1372 # endif
1373 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1374 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1375 2011-10, the first parameter is not const. */
1376 _GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
1377 _GL_CXXALIASWARN (sethostname);
1378 #elif defined GNULIB_POSIXCHECK
1379 # undef sethostname
1380 # if HAVE_RAW_DECL_SETHOSTNAME
1381 _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1382 "use gnulib module sethostname for portability");
1383 # endif
1384 #endif
1387 #if @GNULIB_SLEEP@
1388 /* Pause the execution of the current thread for N seconds.
1389 Returns the number of seconds left to sleep.
1390 See the POSIX:2008 specification
1391 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1392 # if @REPLACE_SLEEP@
1393 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1394 # undef sleep
1395 # define sleep rpl_sleep
1396 # endif
1397 _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1398 _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1399 # else
1400 # if !@HAVE_SLEEP@
1401 _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1402 # endif
1403 _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1404 # endif
1405 _GL_CXXALIASWARN (sleep);
1406 #elif defined GNULIB_POSIXCHECK
1407 # undef sleep
1408 # if HAVE_RAW_DECL_SLEEP
1409 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1410 "use gnulib module sleep for portability");
1411 # endif
1412 #endif
1415 #if @GNULIB_SYMLINK@
1416 # if @REPLACE_SYMLINK@
1417 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1418 # undef symlink
1419 # define symlink rpl_symlink
1420 # endif
1421 _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1422 _GL_ARG_NONNULL ((1, 2)));
1423 _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1424 # else
1425 # if !@HAVE_SYMLINK@
1426 _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1427 _GL_ARG_NONNULL ((1, 2)));
1428 # endif
1429 _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1430 # endif
1431 _GL_CXXALIASWARN (symlink);
1432 #elif defined GNULIB_POSIXCHECK
1433 # undef symlink
1434 # if HAVE_RAW_DECL_SYMLINK
1435 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1436 "use gnulib module symlink for portability");
1437 # endif
1438 #endif
1441 #if @GNULIB_SYMLINKAT@
1442 # if @REPLACE_SYMLINKAT@
1443 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1444 # undef symlinkat
1445 # define symlinkat rpl_symlinkat
1446 # endif
1447 _GL_FUNCDECL_RPL (symlinkat, int,
1448 (char const *contents, int fd, char const *file)
1449 _GL_ARG_NONNULL ((1, 3)));
1450 _GL_CXXALIAS_RPL (symlinkat, int,
1451 (char const *contents, int fd, char const *file));
1452 # else
1453 # if !@HAVE_SYMLINKAT@
1454 _GL_FUNCDECL_SYS (symlinkat, int,
1455 (char const *contents, int fd, char const *file)
1456 _GL_ARG_NONNULL ((1, 3)));
1457 # endif
1458 _GL_CXXALIAS_SYS (symlinkat, int,
1459 (char const *contents, int fd, char const *file));
1460 # endif
1461 _GL_CXXALIASWARN (symlinkat);
1462 #elif defined GNULIB_POSIXCHECK
1463 # undef symlinkat
1464 # if HAVE_RAW_DECL_SYMLINKAT
1465 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1466 "use gnulib module symlinkat for portability");
1467 # endif
1468 #endif
1471 #if @GNULIB_TRUNCATE@
1472 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
1473 Return 0 if successful, otherwise -1 and errno set.
1474 See the POSIX:2008 specification
1475 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
1476 # if @REPLACE_TRUNCATE@
1477 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1478 # undef truncate
1479 # define truncate rpl_truncate
1480 # endif
1481 _GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
1482 _GL_ARG_NONNULL ((1)));
1483 _GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
1484 # else
1485 # if !@HAVE_TRUNCATE@
1486 _GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
1487 _GL_ARG_NONNULL ((1)));
1488 # endif
1489 _GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
1490 # endif
1491 _GL_CXXALIASWARN (truncate);
1492 #elif defined GNULIB_POSIXCHECK
1493 # undef truncate
1494 # if HAVE_RAW_DECL_TRUNCATE
1495 _GL_WARN_ON_USE (truncate, "truncate is unportable - "
1496 "use gnulib module truncate for portability");
1497 # endif
1498 #endif
1501 #if @GNULIB_TTYNAME_R@
1502 /* Store at most BUFLEN characters of the pathname of the terminal FD is
1503 open on in BUF. Return 0 on success, otherwise an error number. */
1504 # if @REPLACE_TTYNAME_R@
1505 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1506 # undef ttyname_r
1507 # define ttyname_r rpl_ttyname_r
1508 # endif
1509 _GL_FUNCDECL_RPL (ttyname_r, int,
1510 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1511 _GL_CXXALIAS_RPL (ttyname_r, int,
1512 (int fd, char *buf, size_t buflen));
1513 # else
1514 # if !@HAVE_DECL_TTYNAME_R@
1515 _GL_FUNCDECL_SYS (ttyname_r, int,
1516 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1517 # endif
1518 _GL_CXXALIAS_SYS (ttyname_r, int,
1519 (int fd, char *buf, size_t buflen));
1520 # endif
1521 _GL_CXXALIASWARN (ttyname_r);
1522 #elif defined GNULIB_POSIXCHECK
1523 # undef ttyname_r
1524 # if HAVE_RAW_DECL_TTYNAME_R
1525 _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1526 "use gnulib module ttyname_r for portability");
1527 # endif
1528 #endif
1531 #if @GNULIB_UNLINK@
1532 # if @REPLACE_UNLINK@
1533 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1534 # undef unlink
1535 # define unlink rpl_unlink
1536 # endif
1537 _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1538 _GL_CXXALIAS_RPL (unlink, int, (char const *file));
1539 # else
1540 _GL_CXXALIAS_SYS (unlink, int, (char const *file));
1541 # endif
1542 _GL_CXXALIASWARN (unlink);
1543 #elif defined GNULIB_POSIXCHECK
1544 # undef unlink
1545 # if HAVE_RAW_DECL_UNLINK
1546 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
1547 "use gnulib module unlink for portability");
1548 # endif
1549 #endif
1552 #if @GNULIB_UNLINKAT@
1553 # if @REPLACE_UNLINKAT@
1554 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1555 # undef unlinkat
1556 # define unlinkat rpl_unlinkat
1557 # endif
1558 _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1559 _GL_ARG_NONNULL ((2)));
1560 _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1561 # else
1562 # if !@HAVE_UNLINKAT@
1563 _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1564 _GL_ARG_NONNULL ((2)));
1565 # endif
1566 _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1567 # endif
1568 _GL_CXXALIASWARN (unlinkat);
1569 #elif defined GNULIB_POSIXCHECK
1570 # undef unlinkat
1571 # if HAVE_RAW_DECL_UNLINKAT
1572 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1573 "use gnulib module openat for portability");
1574 # endif
1575 #endif
1578 #if @GNULIB_USLEEP@
1579 /* Pause the execution of the current thread for N microseconds.
1580 Returns 0 on completion, or -1 on range error.
1581 See the POSIX:2001 specification
1582 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1583 # if @REPLACE_USLEEP@
1584 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1585 # undef usleep
1586 # define usleep rpl_usleep
1587 # endif
1588 _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1589 _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1590 # else
1591 # if !@HAVE_USLEEP@
1592 _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1593 # endif
1594 _GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1595 # endif
1596 _GL_CXXALIASWARN (usleep);
1597 #elif defined GNULIB_POSIXCHECK
1598 # undef usleep
1599 # if HAVE_RAW_DECL_USLEEP
1600 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1601 "use gnulib module usleep for portability");
1602 # endif
1603 #endif
1606 #if @GNULIB_WRITE@
1607 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
1608 See the POSIX:2008 specification
1609 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1610 # if @REPLACE_WRITE@
1611 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1612 # undef write
1613 # define write rpl_write
1614 # endif
1615 _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1616 _GL_ARG_NONNULL ((2)));
1617 _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1618 # else
1619 /* Need to cast, because on mingw, the third parameter is
1620 unsigned int count
1621 and the return type is 'int'. */
1622 _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1623 # endif
1624 _GL_CXXALIASWARN (write);
1625 #endif
1627 _GL_INLINE_HEADER_END
1629 #endif /* _@GUARD_PREFIX@_UNISTD_H */
1630 #endif /* _GL_INCLUDING_UNISTD_H */
1631 #endif /* _@GUARD_PREFIX@_UNISTD_H */