diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/dup2.c | 71 | ||||
| -rw-r--r-- | lib/gnulib.mk | 40 | ||||
| -rw-r--r-- | lib/signal.in.h | 23 | ||||
| -rw-r--r-- | lib/sigprocmask.c | 27 | ||||
| -rw-r--r-- | lib/stat.c | 14 | ||||
| -rw-r--r-- | lib/stdio.in.h | 38 | ||||
| -rw-r--r-- | lib/sys_stat.in.h | 32 | ||||
| -rw-r--r-- | lib/unistd.in.h | 137 |
8 files changed, 295 insertions, 87 deletions
diff --git a/lib/dup2.c b/lib/dup2.c index e00dc7b2e3c..790c98a2e84 100644 --- a/lib/dup2.c +++ b/lib/dup2.c | |||
| @@ -25,21 +25,26 @@ | |||
| 25 | #include <errno.h> | 25 | #include <errno.h> |
| 26 | #include <fcntl.h> | 26 | #include <fcntl.h> |
| 27 | 27 | ||
| 28 | #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
| 29 | /* Get declarations of the Win32 API functions. */ | ||
| 30 | # define WIN32_LEAN_AND_MEAN | ||
| 31 | # include <windows.h> | ||
| 32 | #endif | ||
| 33 | |||
| 34 | #if HAVE_DUP2 | 28 | #if HAVE_DUP2 |
| 35 | 29 | ||
| 36 | # undef dup2 | 30 | # undef dup2 |
| 37 | 31 | ||
| 38 | int | 32 | # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ |
| 39 | rpl_dup2 (int fd, int desired_fd) | 33 | |
| 34 | /* Get declarations of the Win32 API functions. */ | ||
| 35 | # define WIN32_LEAN_AND_MEAN | ||
| 36 | # include <windows.h> | ||
| 37 | |||
| 38 | # include "msvc-inval.h" | ||
| 39 | |||
| 40 | /* Get _get_osfhandle. */ | ||
| 41 | # include "msvc-nothrow.h" | ||
| 42 | |||
| 43 | static int | ||
| 44 | ms_windows_dup2 (int fd, int desired_fd) | ||
| 40 | { | 45 | { |
| 41 | int result; | 46 | int result; |
| 42 | # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | 47 | |
| 43 | /* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open, | 48 | /* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open, |
| 44 | dup2 (fd, fd) returns 0, but all further attempts to use fd in | 49 | dup2 (fd, fd) returns 0, but all further attempts to use fd in |
| 45 | future dup2 calls will hang. */ | 50 | future dup2 calls will hang. */ |
| @@ -52,6 +57,7 @@ rpl_dup2 (int fd, int desired_fd) | |||
| 52 | } | 57 | } |
| 53 | return fd; | 58 | return fd; |
| 54 | } | 59 | } |
| 60 | |||
| 55 | /* Wine 1.0.1 return 0 when desired_fd is negative but not -1: | 61 | /* Wine 1.0.1 return 0 when desired_fd is negative but not -1: |
| 56 | http://bugs.winehq.org/show_bug.cgi?id=21289 */ | 62 | http://bugs.winehq.org/show_bug.cgi?id=21289 */ |
| 57 | if (desired_fd < 0) | 63 | if (desired_fd < 0) |
| @@ -59,26 +65,45 @@ rpl_dup2 (int fd, int desired_fd) | |||
| 59 | errno = EBADF; | 65 | errno = EBADF; |
| 60 | return -1; | 66 | return -1; |
| 61 | } | 67 | } |
| 62 | # elif !defined __linux__ | 68 | |
| 63 | /* On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */ | 69 | TRY_MSVC_INVAL |
| 64 | if (fd == desired_fd) | 70 | { |
| 65 | return fcntl (fd, F_GETFL) == -1 ? -1 : fd; | 71 | result = dup2 (fd, desired_fd); |
| 66 | # endif | 72 | } |
| 67 | result = dup2 (fd, desired_fd); | 73 | CATCH_MSVC_INVAL |
| 68 | # ifdef __linux__ | ||
| 69 | /* Correct a Linux return value. | ||
| 70 | <http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.30.y.git;a=commitdiff;h=2b79bc4f7ebbd5af3c8b867968f9f15602d5f802> | ||
| 71 | */ | ||
| 72 | if (fd == desired_fd && result == (unsigned int) -EBADF) | ||
| 73 | { | 74 | { |
| 74 | errno = EBADF; | 75 | errno = EBADF; |
| 75 | result = -1; | 76 | result = -1; |
| 76 | } | 77 | } |
| 77 | # endif | 78 | DONE_MSVC_INVAL; |
| 79 | |||
| 78 | if (result == 0) | 80 | if (result == 0) |
| 79 | result = desired_fd; | 81 | result = desired_fd; |
| 80 | /* Correct a cygwin 1.5.x errno value. */ | 82 | |
| 81 | else if (result == -1 && errno == EMFILE) | 83 | return result; |
| 84 | } | ||
| 85 | |||
| 86 | # define dup2 ms_windows_dup2 | ||
| 87 | |||
| 88 | # endif | ||
| 89 | |||
| 90 | int | ||
| 91 | rpl_dup2 (int fd, int desired_fd) | ||
| 92 | { | ||
| 93 | int result; | ||
| 94 | |||
| 95 | # ifdef F_GETFL | ||
| 96 | /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF. | ||
| 97 | On Cygwin 1.5.x, dup2 (1, 1) returns 0. | ||
| 98 | On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */ | ||
| 99 | if (fd == desired_fd) | ||
| 100 | return fcntl (fd, F_GETFL) == -1 ? -1 : fd; | ||
| 101 | # endif | ||
| 102 | |||
| 103 | result = dup2 (fd, desired_fd); | ||
| 104 | |||
| 105 | /* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x. */ | ||
| 106 | if (result == -1 && errno == EMFILE) | ||
| 82 | errno = EBADF; | 107 | errno = EBADF; |
| 83 | # if REPLACE_FCHDIR | 108 | # if REPLACE_FCHDIR |
| 84 | if (fd != desired_fd && result != -1) | 109 | if (fd != desired_fd && result != -1) |
diff --git a/lib/gnulib.mk b/lib/gnulib.mk index 5163269db41..14010feb04b 100644 --- a/lib/gnulib.mk +++ b/lib/gnulib.mk | |||
| @@ -2,14 +2,26 @@ | |||
| 2 | ## Process this file with automake to produce Makefile.in. | 2 | ## Process this file with automake to produce Makefile.in. |
| 3 | # Copyright (C) 2002-2011 Free Software Foundation, Inc. | 3 | # Copyright (C) 2002-2011 Free Software Foundation, Inc. |
| 4 | # | 4 | # |
| 5 | # This file is free software, distributed under the terms of the GNU | 5 | # This file is free software; you can redistribute it and/or modify |
| 6 | # General Public License. As a special exception to the GNU General | 6 | # it under the terms of the GNU General Public License as published by |
| 7 | # Public License, this file may be distributed as part of a program | 7 | # the Free Software Foundation; either version 3 of the License, or |
| 8 | # that contains a configuration script generated by Autoconf, under | 8 | # (at your option) any later version. |
| 9 | # | ||
| 10 | # This file is distributed in the hope that it will be useful, | ||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | # GNU General Public License for more details. | ||
| 14 | # | ||
| 15 | # You should have received a copy of the GNU General Public License | ||
| 16 | # along with this file. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | # | ||
| 18 | # As a special exception to the GNU General Public License, | ||
| 19 | # this file may be distributed as part of a program that | ||
| 20 | # contains a configuration script generated by Autoconf, under | ||
| 9 | # the same distribution terms as the rest of that program. | 21 | # the same distribution terms as the rest of that program. |
| 10 | # | 22 | # |
| 11 | # Generated by gnulib-tool. | 23 | # Generated by gnulib-tool. |
| 12 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dup2 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime pthread_sigmask readlink socklen stdarg stdio strftime strtoimax strtoumax symlink sys_stat | 24 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=msvc-inval --avoid=msvc-nothrow --avoid=pathmax --avoid=raise --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dup2 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime pthread_sigmask readlink socklen stdarg stdio strftime strtoimax strtoumax symlink sys_stat |
| 13 | 25 | ||
| 14 | 26 | ||
| 15 | MOSTLYCLEANFILES += core *.stackdump | 27 | MOSTLYCLEANFILES += core *.stackdump |
| @@ -264,7 +276,7 @@ EXTRA_libgnu_a_SOURCES += readlink.c | |||
| 264 | 276 | ||
| 265 | ## end gnulib module readlink | 277 | ## end gnulib module readlink |
| 266 | 278 | ||
| 267 | ## begin gnulib module signal | 279 | ## begin gnulib module signal-h |
| 268 | 280 | ||
| 269 | BUILT_SOURCES += signal.h | 281 | BUILT_SOURCES += signal.h |
| 270 | 282 | ||
| @@ -279,11 +291,13 @@ signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H | |||
| 279 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ | 291 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ |
| 280 | -e 's|@''NEXT_SIGNAL_H''@|$(NEXT_SIGNAL_H)|g' \ | 292 | -e 's|@''NEXT_SIGNAL_H''@|$(NEXT_SIGNAL_H)|g' \ |
| 281 | -e 's|@''GNULIB_PTHREAD_SIGMASK''@|$(GNULIB_PTHREAD_SIGMASK)|g' \ | 293 | -e 's|@''GNULIB_PTHREAD_SIGMASK''@|$(GNULIB_PTHREAD_SIGMASK)|g' \ |
| 294 | -e 's|@''GNULIB_RAISE''@|$(GNULIB_RAISE)|g' \ | ||
| 282 | -e 's/@''GNULIB_SIGNAL_H_SIGPIPE''@/$(GNULIB_SIGNAL_H_SIGPIPE)/g' \ | 295 | -e 's/@''GNULIB_SIGNAL_H_SIGPIPE''@/$(GNULIB_SIGNAL_H_SIGPIPE)/g' \ |
| 283 | -e 's/@''GNULIB_SIGPROCMASK''@/$(GNULIB_SIGPROCMASK)/g' \ | 296 | -e 's/@''GNULIB_SIGPROCMASK''@/$(GNULIB_SIGPROCMASK)/g' \ |
| 284 | -e 's/@''GNULIB_SIGACTION''@/$(GNULIB_SIGACTION)/g' \ | 297 | -e 's/@''GNULIB_SIGACTION''@/$(GNULIB_SIGACTION)/g' \ |
| 285 | -e 's|@''HAVE_POSIX_SIGNALBLOCKING''@|$(HAVE_POSIX_SIGNALBLOCKING)|g' \ | 298 | -e 's|@''HAVE_POSIX_SIGNALBLOCKING''@|$(HAVE_POSIX_SIGNALBLOCKING)|g' \ |
| 286 | -e 's|@''HAVE_PTHREAD_SIGMASK''@|$(HAVE_PTHREAD_SIGMASK)|g' \ | 299 | -e 's|@''HAVE_PTHREAD_SIGMASK''@|$(HAVE_PTHREAD_SIGMASK)|g' \ |
| 300 | -e 's|@''HAVE_RAISE''@|$(HAVE_RAISE)|g' \ | ||
| 287 | -e 's|@''HAVE_SIGSET_T''@|$(HAVE_SIGSET_T)|g' \ | 301 | -e 's|@''HAVE_SIGSET_T''@|$(HAVE_SIGSET_T)|g' \ |
| 288 | -e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \ | 302 | -e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \ |
| 289 | -e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \ | 303 | -e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \ |
| @@ -291,6 +305,7 @@ signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H | |||
| 291 | -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \ | 305 | -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \ |
| 292 | -e 's|@''HAVE_SIGHANDLER_T''@|$(HAVE_SIGHANDLER_T)|g' \ | 306 | -e 's|@''HAVE_SIGHANDLER_T''@|$(HAVE_SIGHANDLER_T)|g' \ |
| 293 | -e 's|@''REPLACE_PTHREAD_SIGMASK''@|$(REPLACE_PTHREAD_SIGMASK)|g' \ | 307 | -e 's|@''REPLACE_PTHREAD_SIGMASK''@|$(REPLACE_PTHREAD_SIGMASK)|g' \ |
| 308 | -e 's|@''REPLACE_RAISE''@|$(REPLACE_RAISE)|g' \ | ||
| 294 | -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ | 309 | -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ |
| 295 | -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ | 310 | -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ |
| 296 | -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ | 311 | -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ |
| @@ -301,7 +316,7 @@ MOSTLYCLEANFILES += signal.h signal.h-t | |||
| 301 | 316 | ||
| 302 | EXTRA_DIST += signal.in.h | 317 | EXTRA_DIST += signal.in.h |
| 303 | 318 | ||
| 304 | ## end gnulib module signal | 319 | ## end gnulib module signal-h |
| 305 | 320 | ||
| 306 | ## begin gnulib module sigprocmask | 321 | ## begin gnulib module sigprocmask |
| 307 | 322 | ||
| @@ -553,6 +568,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) | |||
| 553 | -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ | 568 | -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ |
| 554 | -e 's/@''GNULIB_DPRINTF''@/$(GNULIB_DPRINTF)/g' \ | 569 | -e 's/@''GNULIB_DPRINTF''@/$(GNULIB_DPRINTF)/g' \ |
| 555 | -e 's/@''GNULIB_FCLOSE''@/$(GNULIB_FCLOSE)/g' \ | 570 | -e 's/@''GNULIB_FCLOSE''@/$(GNULIB_FCLOSE)/g' \ |
| 571 | -e 's/@''GNULIB_FDOPEN''@/$(GNULIB_FDOPEN)/g' \ | ||
| 556 | -e 's/@''GNULIB_FFLUSH''@/$(GNULIB_FFLUSH)/g' \ | 572 | -e 's/@''GNULIB_FFLUSH''@/$(GNULIB_FFLUSH)/g' \ |
| 557 | -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \ | 573 | -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \ |
| 558 | -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \ | 574 | -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \ |
| @@ -577,6 +593,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) | |||
| 577 | -e 's/@''GNULIB_GETS''@/$(GNULIB_GETS)/g' \ | 593 | -e 's/@''GNULIB_GETS''@/$(GNULIB_GETS)/g' \ |
| 578 | -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GNULIB_OBSTACK_PRINTF)/g' \ | 594 | -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GNULIB_OBSTACK_PRINTF)/g' \ |
| 579 | -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GNULIB_OBSTACK_PRINTF_POSIX)/g' \ | 595 | -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GNULIB_OBSTACK_PRINTF_POSIX)/g' \ |
| 596 | -e 's/@''GNULIB_PCLOSE''@/$(GNULIB_PCLOSE)/g' \ | ||
| 580 | -e 's/@''GNULIB_PERROR''@/$(GNULIB_PERROR)/g' \ | 597 | -e 's/@''GNULIB_PERROR''@/$(GNULIB_PERROR)/g' \ |
| 581 | -e 's/@''GNULIB_POPEN''@/$(GNULIB_POPEN)/g' \ | 598 | -e 's/@''GNULIB_POPEN''@/$(GNULIB_POPEN)/g' \ |
| 582 | -e 's/@''GNULIB_PRINTF''@/$(GNULIB_PRINTF)/g' \ | 599 | -e 's/@''GNULIB_PRINTF''@/$(GNULIB_PRINTF)/g' \ |
| @@ -615,11 +632,14 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) | |||
| 615 | -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ | 632 | -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ |
| 616 | -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \ | 633 | -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \ |
| 617 | -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \ | 634 | -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \ |
| 635 | -e 's|@''HAVE_PCLOSE''@|$(HAVE_PCLOSE)|g' \ | ||
| 636 | -e 's|@''HAVE_POPEN''@|$(HAVE_POPEN)|g' \ | ||
| 618 | -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \ | 637 | -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \ |
| 619 | -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ | 638 | -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ |
| 620 | -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ | 639 | -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ |
| 621 | -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ | 640 | -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ |
| 622 | -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ | 641 | -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ |
| 642 | -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \ | ||
| 623 | -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ | 643 | -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ |
| 624 | -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ | 644 | -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ |
| 625 | -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ | 645 | -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ |
| @@ -826,6 +846,7 @@ sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU | |||
| 826 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ | 846 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ |
| 827 | -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ | 847 | -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ |
| 828 | -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \ | 848 | -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \ |
| 849 | -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \ | ||
| 829 | -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \ | 850 | -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \ |
| 830 | -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \ | 851 | -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \ |
| 831 | -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \ | 852 | -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \ |
| @@ -943,8 +964,10 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H | |||
| 943 | -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ | 964 | -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ |
| 944 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ | 965 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ |
| 945 | -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ | 966 | -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ |
| 967 | -e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \ | ||
| 946 | -e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \ | 968 | -e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \ |
| 947 | -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \ | 969 | -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \ |
| 970 | -e 's/@''GNULIB_DUP''@/$(GNULIB_DUP)/g' \ | ||
| 948 | -e 's/@''GNULIB_DUP2''@/$(GNULIB_DUP2)/g' \ | 971 | -e 's/@''GNULIB_DUP2''@/$(GNULIB_DUP2)/g' \ |
| 949 | -e 's/@''GNULIB_DUP3''@/$(GNULIB_DUP3)/g' \ | 972 | -e 's/@''GNULIB_DUP3''@/$(GNULIB_DUP3)/g' \ |
| 950 | -e 's/@''GNULIB_ENVIRON''@/$(GNULIB_ENVIRON)/g' \ | 973 | -e 's/@''GNULIB_ENVIRON''@/$(GNULIB_ENVIRON)/g' \ |
| @@ -952,6 +975,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H | |||
| 952 | -e 's/@''GNULIB_FACCESSAT''@/$(GNULIB_FACCESSAT)/g' \ | 975 | -e 's/@''GNULIB_FACCESSAT''@/$(GNULIB_FACCESSAT)/g' \ |
| 953 | -e 's/@''GNULIB_FCHDIR''@/$(GNULIB_FCHDIR)/g' \ | 976 | -e 's/@''GNULIB_FCHDIR''@/$(GNULIB_FCHDIR)/g' \ |
| 954 | -e 's/@''GNULIB_FCHOWNAT''@/$(GNULIB_FCHOWNAT)/g' \ | 977 | -e 's/@''GNULIB_FCHOWNAT''@/$(GNULIB_FCHOWNAT)/g' \ |
| 978 | -e 's/@''GNULIB_FDATASYNC''@/$(GNULIB_FDATASYNC)/g' \ | ||
| 955 | -e 's/@''GNULIB_FSYNC''@/$(GNULIB_FSYNC)/g' \ | 979 | -e 's/@''GNULIB_FSYNC''@/$(GNULIB_FSYNC)/g' \ |
| 956 | -e 's/@''GNULIB_FTRUNCATE''@/$(GNULIB_FTRUNCATE)/g' \ | 980 | -e 's/@''GNULIB_FTRUNCATE''@/$(GNULIB_FTRUNCATE)/g' \ |
| 957 | -e 's/@''GNULIB_GETCWD''@/$(GNULIB_GETCWD)/g' \ | 981 | -e 's/@''GNULIB_GETCWD''@/$(GNULIB_GETCWD)/g' \ |
| @@ -995,6 +1019,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H | |||
| 995 | -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ | 1019 | -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ |
| 996 | -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \ | 1020 | -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \ |
| 997 | -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ | 1021 | -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ |
| 1022 | -e 's|@''HAVE_FDATASYNC''@|$(HAVE_FDATASYNC)|g' \ | ||
| 998 | -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ | 1023 | -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ |
| 999 | -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ | 1024 | -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ |
| 1000 | -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ | 1025 | -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ |
| @@ -1019,6 +1044,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H | |||
| 1019 | -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ | 1044 | -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ |
| 1020 | -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ | 1045 | -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ |
| 1021 | -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \ | 1046 | -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \ |
| 1047 | -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \ | ||
| 1022 | -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \ | 1048 | -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \ |
| 1023 | -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ | 1049 | -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ |
| 1024 | -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ | 1050 | -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ |
diff --git a/lib/signal.in.h b/lib/signal.in.h index 93787f753fa..b0e192feeae 100644 --- a/lib/signal.in.h +++ b/lib/signal.in.h | |||
| @@ -152,6 +152,29 @@ _GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - " | |||
| 152 | #endif | 152 | #endif |
| 153 | 153 | ||
| 154 | 154 | ||
| 155 | #if @GNULIB_RAISE@ | ||
| 156 | # if @REPLACE_RAISE@ | ||
| 157 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 158 | # undef raise | ||
| 159 | # define raise rpl_raise | ||
| 160 | # endif | ||
| 161 | _GL_FUNCDECL_RPL (raise, int, (int sig)); | ||
| 162 | _GL_CXXALIAS_RPL (raise, int, (int sig)); | ||
| 163 | # else | ||
| 164 | # if !@HAVE_RAISE@ | ||
| 165 | _GL_FUNCDECL_SYS (raise, int, (int sig)); | ||
| 166 | # endif | ||
| 167 | _GL_CXXALIAS_SYS (raise, int, (int sig)); | ||
| 168 | # endif | ||
| 169 | _GL_CXXALIASWARN (raise); | ||
| 170 | #elif defined GNULIB_POSIXCHECK | ||
| 171 | # undef raise | ||
| 172 | /* Assume raise is always declared. */ | ||
| 173 | _GL_WARN_ON_USE (raise, "raise can crash on native Windows - " | ||
| 174 | "use gnulib module raise for portability"); | ||
| 175 | #endif | ||
| 176 | |||
| 177 | |||
| 155 | #if @GNULIB_SIGPROCMASK@ | 178 | #if @GNULIB_SIGPROCMASK@ |
| 156 | # if !@HAVE_POSIX_SIGNALBLOCKING@ | 179 | # if !@HAVE_POSIX_SIGNALBLOCKING@ |
| 157 | 180 | ||
diff --git a/lib/sigprocmask.c b/lib/sigprocmask.c index 6780a37b14f..6ccac5a8343 100644 --- a/lib/sigprocmask.c +++ b/lib/sigprocmask.c | |||
| @@ -24,6 +24,10 @@ | |||
| 24 | #include <stdint.h> | 24 | #include <stdint.h> |
| 25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
| 26 | 26 | ||
| 27 | #if HAVE_MSVC_INVALID_PARAMETER_HANDLER | ||
| 28 | # include "msvc-inval.h" | ||
| 29 | #endif | ||
| 30 | |||
| 27 | /* We assume that a platform without POSIX signal blocking functions | 31 | /* We assume that a platform without POSIX signal blocking functions |
| 28 | also does not have the POSIX sigaction() function, only the | 32 | also does not have the POSIX sigaction() function, only the |
| 29 | signal() function. We also assume signal() has SysV semantics, | 33 | signal() function. We also assume signal() has SysV semantics, |
| @@ -58,6 +62,28 @@ | |||
| 58 | 62 | ||
| 59 | typedef void (*handler_t) (int); | 63 | typedef void (*handler_t) (int); |
| 60 | 64 | ||
| 65 | #if HAVE_MSVC_INVALID_PARAMETER_HANDLER | ||
| 66 | static inline handler_t | ||
| 67 | signal_nothrow (int sig, handler_t handler) | ||
| 68 | { | ||
| 69 | handler_t result; | ||
| 70 | |||
| 71 | TRY_MSVC_INVAL | ||
| 72 | { | ||
| 73 | result = signal (sig, handler); | ||
| 74 | } | ||
| 75 | CATCH_MSVC_INVAL | ||
| 76 | { | ||
| 77 | result = SIG_ERR; | ||
| 78 | errno = EINVAL; | ||
| 79 | } | ||
| 80 | DONE_MSVC_INVAL; | ||
| 81 | |||
| 82 | return result; | ||
| 83 | } | ||
| 84 | # define signal signal_nothrow | ||
| 85 | #endif | ||
| 86 | |||
| 61 | /* Handling of gnulib defined signals. */ | 87 | /* Handling of gnulib defined signals. */ |
| 62 | 88 | ||
| 63 | #if GNULIB_defined_SIGPIPE | 89 | #if GNULIB_defined_SIGPIPE |
| @@ -80,6 +106,7 @@ ext_signal (int sig, handler_t handler) | |||
| 80 | return signal (sig, handler); | 106 | return signal (sig, handler); |
| 81 | } | 107 | } |
| 82 | } | 108 | } |
| 109 | # undef signal | ||
| 83 | # define signal ext_signal | 110 | # define signal ext_signal |
| 84 | #endif | 111 | #endif |
| 85 | 112 | ||
diff --git a/lib/stat.c b/lib/stat.c index 1002f161bfa..1397aa93290 100644 --- a/lib/stat.c +++ b/lib/stat.c | |||
| @@ -46,6 +46,15 @@ orig_stat (const char *filename, struct stat *buf) | |||
| 46 | #include "dosname.h" | 46 | #include "dosname.h" |
| 47 | #include "verify.h" | 47 | #include "verify.h" |
| 48 | 48 | ||
| 49 | #if REPLACE_FUNC_STAT_DIR | ||
| 50 | # include "pathmax.h" | ||
| 51 | /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also | ||
| 52 | have a constant PATH_MAX. */ | ||
| 53 | # ifndef PATH_MAX | ||
| 54 | # error "Please port this replacement to your platform" | ||
| 55 | # endif | ||
| 56 | #endif | ||
| 57 | |||
| 49 | /* Store information about NAME into ST. Work around bugs with | 58 | /* Store information about NAME into ST. Work around bugs with |
| 50 | trailing slashes. Mingw has other bugs (such as st_ino always | 59 | trailing slashes. Mingw has other bugs (such as st_ino always |
| 51 | being 0 on success) which this wrapper does not work around. But | 60 | being 0 on success) which this wrapper does not work around. But |
| @@ -70,11 +79,6 @@ rpl_stat (char const *name, struct stat *st) | |||
| 70 | } | 79 | } |
| 71 | #endif /* REPLACE_FUNC_STAT_FILE */ | 80 | #endif /* REPLACE_FUNC_STAT_FILE */ |
| 72 | #if REPLACE_FUNC_STAT_DIR | 81 | #if REPLACE_FUNC_STAT_DIR |
| 73 | /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also | ||
| 74 | have a constant PATH_MAX. */ | ||
| 75 | # ifndef PATH_MAX | ||
| 76 | # error "Please port this replacement to your platform" | ||
| 77 | # endif | ||
| 78 | 82 | ||
| 79 | if (result == -1 && errno == ENOENT) | 83 | if (result == -1 && errno == ENOENT) |
| 80 | { | 84 | { |
diff --git a/lib/stdio.in.h b/lib/stdio.in.h index 473c84ce3e4..ce00af574a8 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h | |||
| @@ -170,6 +170,26 @@ _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " | |||
| 170 | "use gnulib module fclose for portable POSIX compliance"); | 170 | "use gnulib module fclose for portable POSIX compliance"); |
| 171 | #endif | 171 | #endif |
| 172 | 172 | ||
| 173 | #if @GNULIB_FDOPEN@ | ||
| 174 | # if @REPLACE_FDOPEN@ | ||
| 175 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 176 | # undef fdopen | ||
| 177 | # define fdopen rpl_fdopen | ||
| 178 | # endif | ||
| 179 | _GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode) | ||
| 180 | _GL_ARG_NONNULL ((2))); | ||
| 181 | _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); | ||
| 182 | # else | ||
| 183 | _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); | ||
| 184 | # endif | ||
| 185 | _GL_CXXALIASWARN (fdopen); | ||
| 186 | #elif defined GNULIB_POSIXCHECK | ||
| 187 | # undef fdopen | ||
| 188 | /* Assume fdopen is always declared. */ | ||
| 189 | _GL_WARN_ON_USE (fdopen, "fdopen on Win32 platforms is not POSIX compatible - " | ||
| 190 | "use gnulib module fdopen for portability"); | ||
| 191 | #endif | ||
| 192 | |||
| 173 | #if @GNULIB_FFLUSH@ | 193 | #if @GNULIB_FFLUSH@ |
| 174 | /* Flush all pending data on STREAM according to POSIX rules. Both | 194 | /* Flush all pending data on STREAM according to POSIX rules. Both |
| 175 | output and seekable input streams are supported. | 195 | output and seekable input streams are supported. |
| @@ -750,6 +770,20 @@ _GL_CXXALIAS_SYS (obstack_vprintf, int, | |||
| 750 | _GL_CXXALIASWARN (obstack_vprintf); | 770 | _GL_CXXALIASWARN (obstack_vprintf); |
| 751 | #endif | 771 | #endif |
| 752 | 772 | ||
| 773 | #if @GNULIB_PCLOSE@ | ||
| 774 | # if !@HAVE_PCLOSE@ | ||
| 775 | _GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); | ||
| 776 | # endif | ||
| 777 | _GL_CXXALIAS_SYS (pclose, int, (FILE *stream)); | ||
| 778 | _GL_CXXALIASWARN (pclose); | ||
| 779 | #elif defined GNULIB_POSIXCHECK | ||
| 780 | # undef pclose | ||
| 781 | # if HAVE_RAW_DECL_PCLOSE | ||
| 782 | _GL_WARN_ON_USE (pclose, "popen is unportable - " | ||
| 783 | "use gnulib module pclose for more portability"); | ||
| 784 | # endif | ||
| 785 | #endif | ||
| 786 | |||
| 753 | #if @GNULIB_PERROR@ | 787 | #if @GNULIB_PERROR@ |
| 754 | /* Print a message to standard error, describing the value of ERRNO, | 788 | /* Print a message to standard error, describing the value of ERRNO, |
| 755 | (if STRING is not NULL and not empty) prefixed with STRING and ": ", | 789 | (if STRING is not NULL and not empty) prefixed with STRING and ": ", |
| @@ -781,6 +815,10 @@ _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode) | |||
| 781 | _GL_ARG_NONNULL ((1, 2))); | 815 | _GL_ARG_NONNULL ((1, 2))); |
| 782 | _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); | 816 | _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); |
| 783 | # else | 817 | # else |
| 818 | # if !@HAVE_POPEN@ | ||
| 819 | _GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode) | ||
| 820 | _GL_ARG_NONNULL ((1, 2))); | ||
| 821 | # endif | ||
| 784 | _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); | 822 | _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); |
| 785 | # endif | 823 | # endif |
| 786 | _GL_CXXALIASWARN (popen); | 824 | _GL_CXXALIASWARN (popen); |
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h index 5acee705f8a..77a7177ca64 100644 --- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h | |||
| @@ -55,10 +55,17 @@ | |||
| 55 | /* The definition of _GL_WARN_ON_USE is copied here. */ | 55 | /* The definition of _GL_WARN_ON_USE is copied here. */ |
| 56 | 56 | ||
| 57 | /* Before doing "#define mkdir rpl_mkdir" below, we need to include all | 57 | /* Before doing "#define mkdir rpl_mkdir" below, we need to include all |
| 58 | headers that may declare mkdir(). */ | 58 | headers that may declare mkdir(). Native Windows platforms declare mkdir |
| 59 | in <io.h> and/or <direct.h>, not in <unistd.h>. */ | ||
| 59 | #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | 60 | #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ |
| 60 | # include <io.h> /* mingw32, mingw64 */ | 61 | # include <io.h> /* mingw32, mingw64 */ |
| 61 | # include <direct.h> /* mingw64 */ | 62 | # include <direct.h> /* mingw64, MSVC 9 */ |
| 63 | #endif | ||
| 64 | |||
| 65 | #ifndef S_IFIFO | ||
| 66 | # ifdef _S_IFIFO | ||
| 67 | # define S_IFIFO _S_IFIFO | ||
| 68 | # endif | ||
| 62 | #endif | 69 | #endif |
| 63 | 70 | ||
| 64 | #ifndef S_IFMT | 71 | #ifndef S_IFMT |
| @@ -312,16 +319,25 @@ _GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - " | |||
| 312 | #endif | 319 | #endif |
| 313 | 320 | ||
| 314 | 321 | ||
| 315 | #if @REPLACE_FSTAT@ | 322 | #if @GNULIB_FSTAT@ |
| 316 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 323 | # if @REPLACE_FSTAT@ |
| 317 | # define fstat rpl_fstat | 324 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 318 | # endif | 325 | # undef fstat |
| 326 | # define fstat rpl_fstat | ||
| 327 | # endif | ||
| 319 | _GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2))); | 328 | _GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2))); |
| 320 | _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf)); | 329 | _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf)); |
| 321 | #else | 330 | # else |
| 322 | _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); | 331 | _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); |
| 323 | #endif | 332 | # endif |
| 324 | _GL_CXXALIASWARN (fstat); | 333 | _GL_CXXALIASWARN (fstat); |
| 334 | #elif defined GNULIB_POSIXCHECK | ||
| 335 | # undef fstat | ||
| 336 | # if HAVE_RAW_DECL_FSTAT | ||
| 337 | _GL_WARN_ON_USE (fstat, "fstat has portability problems - " | ||
| 338 | "use gnulib module fstat for portability"); | ||
| 339 | # endif | ||
| 340 | #endif | ||
| 325 | 341 | ||
| 326 | 342 | ||
| 327 | #if @GNULIB_FSTATAT@ | 343 | #if @GNULIB_FSTATAT@ |
diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 119cd142f43..77e5675aad2 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h | |||
| @@ -75,18 +75,21 @@ | |||
| 75 | #endif | 75 | #endif |
| 76 | 76 | ||
| 77 | /* mingw fails to declare _exit in <unistd.h>. */ | 77 | /* mingw fails to declare _exit in <unistd.h>. */ |
| 78 | /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */ | 78 | /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in |
| 79 | <unistd.h>. */ | ||
| 79 | /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */ | 80 | /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */ |
| 80 | /* But avoid namespace pollution on glibc systems. */ | 81 | /* But avoid namespace pollution on glibc systems. */ |
| 81 | #ifndef __GLIBC__ | 82 | #ifndef __GLIBC__ |
| 82 | # include <stdlib.h> | 83 | # include <stdlib.h> |
| 83 | #endif | 84 | #endif |
| 84 | 85 | ||
| 85 | /* mingw declares getcwd in <io.h>, not in <unistd.h>. */ | 86 | /* Native Windows platforms declare chdir, getcwd, rmdir in |
| 86 | #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \ | 87 | <io.h> and/or <direct.h>, not in <unistd.h>. */ |
| 88 | #if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \ | ||
| 89 | || defined GNULIB_POSIXCHECK) \ | ||
| 87 | && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) | 90 | && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) |
| 88 | # include <io.h> /* mingw32, mingw64 */ | 91 | # include <io.h> /* mingw32, mingw64 */ |
| 89 | # include <direct.h> /* mingw64 */ | 92 | # include <direct.h> /* mingw64, MSVC 9 */ |
| 90 | #endif | 93 | #endif |
| 91 | 94 | ||
| 92 | /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>. | 95 | /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>. |
| @@ -98,6 +101,12 @@ | |||
| 98 | # include <netdb.h> | 101 | # include <netdb.h> |
| 99 | #endif | 102 | #endif |
| 100 | 103 | ||
| 104 | /* MSVC defines off_t in <sys/types.h>. */ | ||
| 105 | #if !@HAVE_UNISTD_H@ | ||
| 106 | /* Get off_t. */ | ||
| 107 | # include <sys/types.h> | ||
| 108 | #endif | ||
| 109 | |||
| 101 | #if (@GNULIB_READ@ || @GNULIB_WRITE@ \ | 110 | #if (@GNULIB_READ@ || @GNULIB_WRITE@ \ |
| 102 | || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ | 111 | || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ |
| 103 | || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK) | 112 | || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK) |
| @@ -224,12 +233,24 @@ _GL_WARN_ON_USE (access, "the access function is a security risk - " | |||
| 224 | #endif | 233 | #endif |
| 225 | 234 | ||
| 226 | 235 | ||
| 236 | #if @GNULIB_CHDIR@ | ||
| 237 | _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1))); | ||
| 238 | _GL_CXXALIASWARN (chdir); | ||
| 239 | #elif defined GNULIB_POSIXCHECK | ||
| 240 | # undef chdir | ||
| 241 | # if HAVE_RAW_DECL_CHDIR | ||
| 242 | _GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - " | ||
| 243 | "use gnulib module chdir for portability"); | ||
| 244 | # endif | ||
| 245 | #endif | ||
| 246 | |||
| 247 | |||
| 227 | #if @GNULIB_CHOWN@ | 248 | #if @GNULIB_CHOWN@ |
| 228 | /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE | 249 | /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE |
| 229 | to GID (if GID is not -1). Follow symbolic links. | 250 | to GID (if GID is not -1). Follow symbolic links. |
| 230 | Return 0 if successful, otherwise -1 and errno set. | 251 | Return 0 if successful, otherwise -1 and errno set. |
| 231 | See the POSIX:2001 specification | 252 | See the POSIX:2008 specification |
| 232 | <http://www.opengroup.org/susv3xsh/chown.html>. */ | 253 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */ |
| 233 | # if @REPLACE_CHOWN@ | 254 | # if @REPLACE_CHOWN@ |
| 234 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 255 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 235 | # undef chown | 256 | # undef chown |
| @@ -280,24 +301,32 @@ _GL_WARN_ON_USE (close, "close does not portably work on sockets - " | |||
| 280 | #endif | 301 | #endif |
| 281 | 302 | ||
| 282 | 303 | ||
| 283 | #if @REPLACE_DUP@ | 304 | #if @GNULIB_DUP@ |
| 284 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 305 | # if @REPLACE_DUP@ |
| 285 | # define dup rpl_dup | 306 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 286 | # endif | 307 | # define dup rpl_dup |
| 308 | # endif | ||
| 287 | _GL_FUNCDECL_RPL (dup, int, (int oldfd)); | 309 | _GL_FUNCDECL_RPL (dup, int, (int oldfd)); |
| 288 | _GL_CXXALIAS_RPL (dup, int, (int oldfd)); | 310 | _GL_CXXALIAS_RPL (dup, int, (int oldfd)); |
| 289 | #else | 311 | # else |
| 290 | _GL_CXXALIAS_SYS (dup, int, (int oldfd)); | 312 | _GL_CXXALIAS_SYS (dup, int, (int oldfd)); |
| 291 | #endif | 313 | # endif |
| 292 | _GL_CXXALIASWARN (dup); | 314 | _GL_CXXALIASWARN (dup); |
| 315 | #elif defined GNULIB_POSIXCHECK | ||
| 316 | # undef dup | ||
| 317 | # if HAVE_RAW_DECL_DUP | ||
| 318 | _GL_WARN_ON_USE (dup, "dup is unportable - " | ||
| 319 | "use gnulib module dup for portability"); | ||
| 320 | # endif | ||
| 321 | #endif | ||
| 293 | 322 | ||
| 294 | 323 | ||
| 295 | #if @GNULIB_DUP2@ | 324 | #if @GNULIB_DUP2@ |
| 296 | /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if | 325 | /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if |
| 297 | NEWFD = OLDFD, otherwise close NEWFD first if it is open. | 326 | NEWFD = OLDFD, otherwise close NEWFD first if it is open. |
| 298 | Return newfd if successful, otherwise -1 and errno set. | 327 | Return newfd if successful, otherwise -1 and errno set. |
| 299 | See the POSIX:2001 specification | 328 | See the POSIX:2008 specification |
| 300 | <http://www.opengroup.org/susv3xsh/dup2.html>. */ | 329 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */ |
| 301 | # if @REPLACE_DUP2@ | 330 | # if @REPLACE_DUP2@ |
| 302 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 331 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 303 | # define dup2 rpl_dup2 | 332 | # define dup2 rpl_dup2 |
| @@ -426,8 +455,8 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - " | |||
| 426 | /* Change the process' current working directory to the directory on which | 455 | /* Change the process' current working directory to the directory on which |
| 427 | the given file descriptor is open. | 456 | the given file descriptor is open. |
| 428 | Return 0 if successful, otherwise -1 and errno set. | 457 | Return 0 if successful, otherwise -1 and errno set. |
| 429 | See the POSIX:2001 specification | 458 | See the POSIX:2008 specification |
| 430 | <http://www.opengroup.org/susv3xsh/fchdir.html>. */ | 459 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */ |
| 431 | # if ! @HAVE_FCHDIR@ | 460 | # if ! @HAVE_FCHDIR@ |
| 432 | _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); | 461 | _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); |
| 433 | 462 | ||
| @@ -484,11 +513,30 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - " | |||
| 484 | #endif | 513 | #endif |
| 485 | 514 | ||
| 486 | 515 | ||
| 487 | #if @GNULIB_FSYNC@ | 516 | #if @GNULIB_FDATASYNC@ |
| 488 | /* Synchronize changes to a file. | 517 | /* Synchronize changes to a file. |
| 489 | Return 0 if successful, otherwise -1 and errno set. | 518 | Return 0 if successful, otherwise -1 and errno set. |
| 490 | See POSIX:2001 specification | 519 | See POSIX:2008 specification |
| 491 | <http://www.opengroup.org/susv3xsh/fsync.html>. */ | 520 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */ |
| 521 | # if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@ | ||
| 522 | _GL_FUNCDECL_SYS (fdatasync, int, (int fd)); | ||
| 523 | # endif | ||
| 524 | _GL_CXXALIAS_SYS (fdatasync, int, (int fd)); | ||
| 525 | _GL_CXXALIASWARN (fdatasync); | ||
| 526 | #elif defined GNULIB_POSIXCHECK | ||
| 527 | # undef fdatasync | ||
| 528 | # if HAVE_RAW_DECL_FDATASYNC | ||
| 529 | _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - " | ||
| 530 | "use gnulib module fdatasync for portability"); | ||
| 531 | # endif | ||
| 532 | #endif | ||
| 533 | |||
| 534 | |||
| 535 | #if @GNULIB_FSYNC@ | ||
| 536 | /* Synchronize changes, including metadata, to a file. | ||
| 537 | Return 0 if successful, otherwise -1 and errno set. | ||
| 538 | See POSIX:2008 specification | ||
| 539 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */ | ||
| 492 | # if !@HAVE_FSYNC@ | 540 | # if !@HAVE_FSYNC@ |
| 493 | _GL_FUNCDECL_SYS (fsync, int, (int fd)); | 541 | _GL_FUNCDECL_SYS (fsync, int, (int fd)); |
| 494 | # endif | 542 | # endif |
| @@ -506,8 +554,8 @@ _GL_WARN_ON_USE (fsync, "fsync is unportable - " | |||
| 506 | #if @GNULIB_FTRUNCATE@ | 554 | #if @GNULIB_FTRUNCATE@ |
| 507 | /* Change the size of the file to which FD is opened to become equal to LENGTH. | 555 | /* Change the size of the file to which FD is opened to become equal to LENGTH. |
| 508 | Return 0 if successful, otherwise -1 and errno set. | 556 | Return 0 if successful, otherwise -1 and errno set. |
| 509 | See the POSIX:2001 specification | 557 | See the POSIX:2008 specification |
| 510 | <http://www.opengroup.org/susv3xsh/ftruncate.html>. */ | 558 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */ |
| 511 | # if !@HAVE_FTRUNCATE@ | 559 | # if !@HAVE_FTRUNCATE@ |
| 512 | _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length)); | 560 | _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length)); |
| 513 | # endif | 561 | # endif |
| @@ -527,8 +575,8 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - " | |||
| 527 | of BUF. | 575 | of BUF. |
| 528 | Return BUF if successful, or NULL if the directory couldn't be determined | 576 | Return BUF if successful, or NULL if the directory couldn't be determined |
| 529 | or SIZE was too small. | 577 | or SIZE was too small. |
| 530 | See the POSIX:2001 specification | 578 | See the POSIX:2008 specification |
| 531 | <http://www.opengroup.org/susv3xsh/getcwd.html>. | 579 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>. |
| 532 | Additionally, the gnulib module 'getcwd' guarantees the following GNU | 580 | Additionally, the gnulib module 'getcwd' guarantees the following GNU |
| 533 | extension: If BUF is NULL, an array is allocated with 'malloc'; the array | 581 | extension: If BUF is NULL, an array is allocated with 'malloc'; the array |
| 534 | is SIZE bytes long, unless SIZE == 0, in which case it is as big as | 582 | is SIZE bytes long, unless SIZE == 0, in which case it is as big as |
| @@ -891,8 +939,8 @@ _GL_WARN_ON_USE (group_member, "group_member is unportable - " | |||
| 891 | /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE | 939 | /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE |
| 892 | to GID (if GID is not -1). Do not follow symbolic links. | 940 | to GID (if GID is not -1). Do not follow symbolic links. |
| 893 | Return 0 if successful, otherwise -1 and errno set. | 941 | Return 0 if successful, otherwise -1 and errno set. |
| 894 | See the POSIX:2001 specification | 942 | See the POSIX:2008 specification |
| 895 | <http://www.opengroup.org/susv3xsh/lchown.html>. */ | 943 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */ |
| 896 | # if @REPLACE_LCHOWN@ | 944 | # if @REPLACE_LCHOWN@ |
| 897 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 945 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 898 | # undef lchown | 946 | # undef lchown |
| @@ -921,8 +969,8 @@ _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - " | |||
| 921 | #if @GNULIB_LINK@ | 969 | #if @GNULIB_LINK@ |
| 922 | /* Create a new hard link for an existing file. | 970 | /* Create a new hard link for an existing file. |
| 923 | Return 0 if successful, otherwise -1 and errno set. | 971 | Return 0 if successful, otherwise -1 and errno set. |
| 924 | See POSIX:2001 specification | 972 | See POSIX:2008 specification |
| 925 | <http://www.opengroup.org/susv3xsh/link.html>. */ | 973 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */ |
| 926 | # if @REPLACE_LINK@ | 974 | # if @REPLACE_LINK@ |
| 927 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 975 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 928 | # define link rpl_link | 976 | # define link rpl_link |
| @@ -987,8 +1035,8 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - " | |||
| 987 | #if @GNULIB_LSEEK@ | 1035 | #if @GNULIB_LSEEK@ |
| 988 | /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. | 1036 | /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. |
| 989 | Return the new offset if successful, otherwise -1 and errno set. | 1037 | Return the new offset if successful, otherwise -1 and errno set. |
| 990 | See the POSIX:2001 specification | 1038 | See the POSIX:2008 specification |
| 991 | <http://www.opengroup.org/susv3xsh/lseek.html>. */ | 1039 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */ |
| 992 | # if @REPLACE_LSEEK@ | 1040 | # if @REPLACE_LSEEK@ |
| 993 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1041 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 994 | # define lseek rpl_lseek | 1042 | # define lseek rpl_lseek |
| @@ -1058,8 +1106,9 @@ _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - " | |||
| 1058 | #if @GNULIB_PREAD@ | 1106 | #if @GNULIB_PREAD@ |
| 1059 | /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET. | 1107 | /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET. |
| 1060 | Return the number of bytes placed into BUF if successful, otherwise | 1108 | Return the number of bytes placed into BUF if successful, otherwise |
| 1061 | set errno and return -1. 0 indicates EOF. See the POSIX:2001 | 1109 | set errno and return -1. 0 indicates EOF. |
| 1062 | specification <http://www.opengroup.org/susv3xsh/pread.html>. */ | 1110 | See the POSIX:2008 specification |
| 1111 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */ | ||
| 1063 | # if @REPLACE_PREAD@ | 1112 | # if @REPLACE_PREAD@ |
| 1064 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1113 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1065 | # undef pread | 1114 | # undef pread |
| @@ -1093,8 +1142,8 @@ _GL_WARN_ON_USE (pread, "pread is unportable - " | |||
| 1093 | /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET. | 1142 | /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET. |
| 1094 | Return the number of bytes written if successful, otherwise | 1143 | Return the number of bytes written if successful, otherwise |
| 1095 | set errno and return -1. 0 indicates nothing written. See the | 1144 | set errno and return -1. 0 indicates nothing written. See the |
| 1096 | POSIX:2001 specification | 1145 | POSIX:2008 specification |
| 1097 | <http://www.opengroup.org/susv3xsh/pwrite.html>. */ | 1146 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */ |
| 1098 | # if @REPLACE_PWRITE@ | 1147 | # if @REPLACE_PWRITE@ |
| 1099 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1148 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1100 | # undef pwrite | 1149 | # undef pwrite |
| @@ -1126,9 +1175,9 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - " | |||
| 1126 | 1175 | ||
| 1127 | #if @GNULIB_READ@ | 1176 | #if @GNULIB_READ@ |
| 1128 | /* Read up to COUNT bytes from file descriptor FD into the buffer starting | 1177 | /* Read up to COUNT bytes from file descriptor FD into the buffer starting |
| 1129 | at BUF. See the POSIX:2001 specification | 1178 | at BUF. See the POSIX:2008 specification |
| 1130 | <http://www.opengroup.org/susv3xsh/read.html>. */ | 1179 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */ |
| 1131 | # if @REPLACE_READ@ && @GNULIB_UNISTD_H_NONBLOCKING@ | 1180 | # if @REPLACE_READ@ |
| 1132 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1181 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1133 | # undef read | 1182 | # undef read |
| 1134 | # define read rpl_read | 1183 | # define read rpl_read |
| @@ -1150,8 +1199,8 @@ _GL_CXXALIASWARN (read); | |||
| 1150 | /* Read the contents of the symbolic link FILE and place the first BUFSIZE | 1199 | /* Read the contents of the symbolic link FILE and place the first BUFSIZE |
| 1151 | bytes of it into BUF. Return the number of bytes placed into BUF if | 1200 | bytes of it into BUF. Return the number of bytes placed into BUF if |
| 1152 | successful, otherwise -1 and errno set. | 1201 | successful, otherwise -1 and errno set. |
| 1153 | See the POSIX:2001 specification | 1202 | See the POSIX:2008 specification |
| 1154 | <http://www.opengroup.org/susv3xsh/readlink.html>. */ | 1203 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */ |
| 1155 | # if @REPLACE_READLINK@ | 1204 | # if @REPLACE_READLINK@ |
| 1156 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1205 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1157 | # define readlink rpl_readlink | 1206 | # define readlink rpl_readlink |
| @@ -1222,8 +1271,8 @@ _GL_WARN_ON_USE (rmdir, "rmdir is unportable - " | |||
| 1222 | #if @GNULIB_SLEEP@ | 1271 | #if @GNULIB_SLEEP@ |
| 1223 | /* Pause the execution of the current thread for N seconds. | 1272 | /* Pause the execution of the current thread for N seconds. |
| 1224 | Returns the number of seconds left to sleep. | 1273 | Returns the number of seconds left to sleep. |
| 1225 | See the POSIX:2001 specification | 1274 | See the POSIX:2008 specification |
| 1226 | <http://www.opengroup.org/susv3xsh/sleep.html>. */ | 1275 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */ |
| 1227 | # if @REPLACE_SLEEP@ | 1276 | # if @REPLACE_SLEEP@ |
| 1228 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1277 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1229 | # undef sleep | 1278 | # undef sleep |
| @@ -1372,7 +1421,7 @@ _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " | |||
| 1372 | /* Pause the execution of the current thread for N microseconds. | 1421 | /* Pause the execution of the current thread for N microseconds. |
| 1373 | Returns 0 on completion, or -1 on range error. | 1422 | Returns 0 on completion, or -1 on range error. |
| 1374 | See the POSIX:2001 specification | 1423 | See the POSIX:2001 specification |
| 1375 | <http://www.opengroup.org/susv3xsh/sleep.html>. */ | 1424 | <http://www.opengroup.org/susv3xsh/usleep.html>. */ |
| 1376 | # if @REPLACE_USLEEP@ | 1425 | # if @REPLACE_USLEEP@ |
| 1377 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1426 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1378 | # undef usleep | 1427 | # undef usleep |
| @@ -1398,9 +1447,9 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - " | |||
| 1398 | 1447 | ||
| 1399 | #if @GNULIB_WRITE@ | 1448 | #if @GNULIB_WRITE@ |
| 1400 | /* Write up to COUNT bytes starting at BUF to file descriptor FD. | 1449 | /* Write up to COUNT bytes starting at BUF to file descriptor FD. |
| 1401 | See the POSIX:2001 specification | 1450 | See the POSIX:2008 specification |
| 1402 | <http://www.opengroup.org/susv3xsh/write.html>. */ | 1451 | <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */ |
| 1403 | # if @REPLACE_WRITE@ && (@GNULIB_UNISTD_H_NONBLOCKING@ || @GNULIB_UNISTD_H_SIGPIPE@) | 1452 | # if @REPLACE_WRITE@ |
| 1404 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1453 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1405 | # undef write | 1454 | # undef write |
| 1406 | # define write rpl_write | 1455 | # define write rpl_write |