]> Savannah Git Hosting - gnulib.git/commitdiff
readlinkat: port to AIX 7.1
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 Oct 2014 05:35:28 +0000 (22:35 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 Oct 2014 05:36:27 +0000 (22:36 -0700)
* 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.

ChangeLog
doc/posix-functions/readlink.texi
doc/posix-functions/readlinkat.texi
lib/readlinkat.c
lib/unistd.in.h
m4/readlinkat.m4
m4/unistd_h.m4
modules/readlinkat
modules/unistd

index 0fbd2e762b1bc6e8377566ce6d8d637bbce6c279..e012f3a0b743cfe366cf5c840cf2bb946486ae27 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+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 {.
index 2348a8469b0c9260f29a78f372e3b6777e44d5c5..60654b1ad25b21b22ae3466cd88ccb1ccc6e1580 100644 (file)
@@ -14,7 +14,7 @@ FreeBSD 7.2, Solaris 9.
 @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.
index a2988f23c827a6c4b3b2b88bf87134ea8ab7461d..51fbeba7a77f7a8137eca6990772a8c9d33da1cd 100644 (file)
@@ -13,6 +13,11 @@ This function is missing on some platforms:
 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:
index c8a60500f18b6a231cbe3348d6f56c4768bcad7e..83ea0af02e473d3dbc866893822541c6a52b8c74 100644 (file)
 
 #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
index 58ca1846470af16b85354490ab8b5ed9b7d5b562..cae779d26220fcbdad19832dee37f6483605895c 100644 (file)
@@ -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
index 65c0689c114b88d5d0f71435d3bfa22e7a3df083..f9ed9436af62b88a147804ebd9d05a99056e3ab6 100644 (file)
@@ -1,4 +1,4 @@
-# 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
 ])
index 1fa197e6943f8e9335c9c14d48ddb203f895f591..6d217d66b43a3c74cf657da53f8a239aa38b1f3d 100644 (file)
@@ -1,4 +1,4 @@
-# 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,6 +173,7 @@ 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])
index f31d3fed4e2c010da86262b60796ffa5d3de9e3d..a89c53fc1b8c6ad5898835b8143600b6aa213765 100644 (file)
@@ -21,7 +21,7 @@ readlink        [test $HAVE_READLINKAT = 0]
 
 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])
index c470ba6029a799b809f7cb04b61f5379d9595e2a..0bbeb847a5cfe1df5408054f1269c7bae179e150 100644 (file)
@@ -150,6 +150,7 @@ 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' \