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