+2014-10-18 Paul Eggert <eggert@cs.ucla.edu>
+
+ readlinkat: port to AIX 7.1
+ * doc/posix-functions/readlink.texi (readlink):
+ * doc/posix-functions/readlinkat.texi (readlinkat):
+ Mention AIX porting problem.
+ * lib/readlinkat.c (rpl_readlinkat) [HAVE_READLINKAT]:
+ New function.
+ * lib/unistd.in.h (readlinkat): Add replacement machinery.
+ * m4/readlinkat.m4 (gl_FUNC_READLINKAT): Check readlinkat signature.
+ * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Add REPLACE_READLINKAT.
+ * modules/readlinkat (configure.ac): Also compile replacement
+ if REPLACE_READLINKAT.
+ * modules/unistd (unistd.h): Substitute REPLACE_READLINKAT.
+
2014-10-12 Karl Berry <karl@gnu.org>
* doc/posix-functions/dirname.texi: remove spurious {.
@item
On some platforms, @code{readlink} returns @code{int} instead of
@code{ssize_t}:
-glibc 2.4, FreeBSD 6.0, OpenBSD 3.8, Cygwin 1.5.x.
+glibc 2.4, FreeBSD 6.0, OpenBSD 3.8, Cygwin 1.5.x, AIX 7.1.
@item
This function is missing on some platforms:
mingw, MSVC 9.
glibc 2.3.6, Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8,
AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw, MSVC 9, Interix 3.5, BeOS.
But the replacement function is not safe to be used in libraries and is not multithread-safe.
+@item
+On some platforms, @code{readlinkat} returns @code{int} instead of
+@code{ssize_t}:
+AIX 7.1.
+@item
@end itemize
Portability problems not fixed by Gnulib:
#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. */
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
#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
-# serial 3
+# serial 4
# See if we need to provide readlinkat replacement.
dnl Copyright (C) 2009-2014 Free Software Foundation, Inc.
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,
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])
configure.ac:
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])
-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' \