Commit 821339c9 authored by Paul Eggert's avatar Paul Eggert

Merge from gnulib.

This incorporates:
2014-10-18 readlinkat: port to AIX 7.1
2014-10-07 fcntl: fix error reporting by dupfd
* lib/fcntl.c, lib/readlinkat.c, lib/unistd.in.h, m4/readlinkat.m4:
* m4/unistd_h.m4: Update from gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
parent 26533185
2014-10-19 Paul Eggert <eggert@cs.ucla.edu>
Merge from gnulib, incorporating:
2014-10-18 readlinkat: port to AIX 7.1
2014-10-07 fcntl: fix error reporting by dupfd
* lib/fcntl.c, lib/readlinkat.c, lib/unistd.in.h, m4/readlinkat.m4:
* m4/unistd_h.m4: Update from gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
2014-10-17 Glenn Morris <rgm@gnu.org>
* configure.ac: Simplify OS X $canonical tests.
......
......@@ -89,8 +89,25 @@ dupfd (int oldfd, int newfd, int flags)
inherit, /* InheritHandle */
DUPLICATE_SAME_ACCESS)) /* Options */
{
/* TODO: Translate GetLastError () into errno. */
errno = EMFILE;
switch (GetLastError ())
{
case ERROR_TOO_MANY_OPEN_FILES:
errno = EMFILE;
break;
case ERROR_INVALID_HANDLE:
case ERROR_INVALID_TARGET_HANDLE:
case ERROR_DIRECT_ACCESS_HANDLE:
errno = EBADF;
break;
case ERROR_INVALID_PARAMETER:
case ERROR_INVALID_FUNCTION:
case ERROR_INVALID_ACCESS:
errno = EINVAL;
break;
default:
errno = EACCES;
break;
}
result = -1;
break;
}
......@@ -98,7 +115,6 @@ dupfd (int oldfd, int newfd, int flags)
if (duplicated_fd < 0)
{
CloseHandle (new_handle);
errno = EMFILE;
result = -1;
break;
}
......
......@@ -21,7 +21,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# 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=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=stdarg --avoid=stdbool --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv update-copyright utimens vla warnings
# 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=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=stdarg --avoid=stdbool --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdio strftime strtoimax strtoumax symlink sys_stat sys_time time time_r timer-time timespec-add timespec-sub unsetenv update-copyright utimens vla warnings
MOSTLYCLEANFILES += core *.stackdump
......@@ -1748,9 +1748,11 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
-e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \
-e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
-e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \
-e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
-e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
-e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
-e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \
-e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \
-e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
-e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
......
......@@ -20,6 +20,18 @@
#include <unistd.h>
#if HAVE_READLINKAT
# undef readlinkat
ssize_t
rpl_readlinkat (int fd, char const *file, char *buf, size_t len)
{
return readlinkat (fd, file, buf, len);
}
#else
/* Gnulib provides a readlink stub for mingw; use it for distinction
between EINVAL and ENOENT, rather than always failing with ENOSYS. */
......@@ -34,14 +46,16 @@
then readlink/restore_cwd. If either the save_cwd or the restore_cwd
fails, then give a diagnostic and exit nonzero. */
#define AT_FUNC_NAME readlinkat
#define AT_FUNC_F1 readlink
#define AT_FUNC_POST_FILE_PARAM_DECLS , char *buf, size_t len
#define AT_FUNC_POST_FILE_ARGS , buf, len
#define AT_FUNC_RESULT ssize_t
#include "at-func.c"
#undef AT_FUNC_NAME
#undef AT_FUNC_F1
#undef AT_FUNC_POST_FILE_PARAM_DECLS
#undef AT_FUNC_POST_FILE_ARGS
#undef AT_FUNC_RESULT
# define AT_FUNC_NAME readlinkat
# define AT_FUNC_F1 readlink
# define AT_FUNC_POST_FILE_PARAM_DECLS , char *buf, size_t len
# define AT_FUNC_POST_FILE_ARGS , buf, len
# define AT_FUNC_RESULT ssize_t
# include "at-func.c"
# undef AT_FUNC_NAME
# undef AT_FUNC_F1
# undef AT_FUNC_POST_FILE_PARAM_DECLS
# undef AT_FUNC_POST_FILE_ARGS
# undef AT_FUNC_RESULT
#endif
......@@ -1287,13 +1287,24 @@ _GL_WARN_ON_USE (readlink, "readlink is unportable - "
#if @GNULIB_READLINKAT@
# if !@HAVE_READLINKAT@
# if @REPLACE_READLINKAT@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define readlinkat rpl_readlinkat
# endif
_GL_FUNCDECL_RPL (readlinkat, ssize_t,
(int fd, char const *file, char *buf, size_t len)
_GL_ARG_NONNULL ((2, 3)));
_GL_CXXALIAS_RPL (readlinkat, ssize_t,
(int fd, char const *file, char *buf, size_t len));
# else
# if !@HAVE_READLINKAT@
_GL_FUNCDECL_SYS (readlinkat, ssize_t,
(int fd, char const *file, char *buf, size_t len)
_GL_ARG_NONNULL ((2, 3)));
# endif
# endif
_GL_CXXALIAS_SYS (readlinkat, ssize_t,
(int fd, char const *file, char *buf, size_t len));
# endif
_GL_CXXALIASWARN (readlinkat);
#elif defined GNULIB_POSIXCHECK
# undef readlinkat
......@@ -1407,13 +1418,25 @@ _GL_WARN_ON_USE (symlink, "symlink is not portable - "
#if @GNULIB_SYMLINKAT@
# if !@HAVE_SYMLINKAT@
# if @REPLACE_SYMLINKAT@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef symlinkat
# define symlinkat rpl_symlinkat
# endif
_GL_FUNCDECL_RPL (symlinkat, int,
(char const *contents, int fd, char const *file)
_GL_ARG_NONNULL ((1, 3)));
_GL_CXXALIAS_RPL (symlinkat, int,
(char const *contents, int fd, char const *file));
# else
# if !@HAVE_SYMLINKAT@
_GL_FUNCDECL_SYS (symlinkat, int,
(char const *contents, int fd, char const *file)
_GL_ARG_NONNULL ((1, 3)));
# endif
# endif
_GL_CXXALIAS_SYS (symlinkat, int,
(char const *contents, int fd, char const *file));
# endif
_GL_CXXALIASWARN (symlinkat);
#elif defined GNULIB_POSIXCHECK
# undef symlinkat
......
......@@ -322,7 +322,7 @@ AC_DEFUN([gl_INIT],
fi
gl_UNISTD_MODULE_INDICATOR([readlink])
gl_FUNC_READLINKAT
if test $HAVE_READLINKAT = 0; then
if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then
AC_LIBOBJ([readlinkat])
fi
gl_UNISTD_MODULE_INDICATOR([readlinkat])
......
# serial 3
# serial 4
# See if we need to provide readlinkat replacement.
dnl Copyright (C) 2009-2014 Free Software Foundation, Inc.
......@@ -15,5 +15,18 @@ AC_DEFUN([gl_FUNC_READLINKAT],
AC_CHECK_FUNCS_ONCE([readlinkat])
if test $ac_cv_func_readlinkat = no; then
HAVE_READLINKAT=0
else
AC_CACHE_CHECK([whether readlinkat signature is correct],
[gl_cv_decl_readlinkat_works],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <unistd.h>
/* Check whether original declaration has correct type. */
ssize_t readlinkat (int, char const *, char *, size_t);]])],
[gl_cv_decl_readlinkat_works=yes],
[gl_cv_decl_readlinkat_works=no])])
if test "$gl_cv_decl_readlink_works" != yes; then
REPLACE_READLINKAT=1
fi
fi
])
# unistd_h.m4 serial 67
# unistd_h.m4 serial 68
dnl Copyright (C) 2006-2014 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
......@@ -173,9 +173,11 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE])
REPLACE_READ=0; AC_SUBST([REPLACE_READ])
REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
REPLACE_READLINKAT=0; AC_SUBST([REPLACE_READLINKAT])
REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])
REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK])
REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT])
REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R])
REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK])
REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment